@desmos-community/mathquill 2025.9.21-experimental → 2025.10.2-experimental

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,12 +19,12 @@ Add the following tags to your HTML:
19
19
 
20
20
  ```html
21
21
  <link rel="stylesheet"
22
- href="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2025.9.21-experimental/dist/style.css"
22
+ href="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2025.10.2-experimental/dist/style.css"
23
23
  integrity="sha384-EwTGPJ5T8P/KXJk/NW5ysp5Sp2u6Tv6HQZgViiSZBtUW4jGQW0JHIjLjAdD9qHMu"
24
24
  crossorigin="anonymous"
25
25
  referrerpolicy="no-referrer">
26
- <script src="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2025.9.21-experimental/dist/index.global.js"
27
- integrity="sha384-AmHoMjBOweUEi4tCjAPj4XaRhz6oKKl3+K4giwVla5MoRQrGJmLm6/LPksfUr97c"
26
+ <script src="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2025.10.2-experimental/dist/index.global.js"
27
+ integrity="sha384-68W2d5gR7HrZcqqPjfvHjXIWPS4VCsLhgPu0UzFnYIqxlrif0JkyGvBMvr3TeP3q"
28
28
  crossorigin="anonymous"
29
29
  referrerpolicy="no-referrer"></script>
30
30
  ```
@@ -7,8 +7,8 @@
7
7
  * was not distributed with this file, You can obtain
8
8
  * one at http://mozilla.org/MPL/2.0/.
9
9
  */
10
- var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){var e,n,r,i;for(n=1,r=arguments.length;n<r;n++){e=arguments[n];for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},__assign.apply(this,arguments)};!function(){function t(){}function e(t){for(;t;){if(!t.parent)return t;t=t.parent}}function n(t,n,r){var i,o,s,a,l,c;if(!n){if(i=new Error("prayer failed: "+t),r){o={},i.dcgExtraErrorMetaData=o;for(s in r)a=r[s],l=o[s]={},a?(l.localLatex=a.latex(),(c=e(a))&&(l.rootLatex=c.latex())):l.emptyNode=!0}throw i}}function r(t){n("a direction was passed",t===De||t===Ae)}function i(t){var e,n=document.implementation.createHTMLDocument("");if(n.body.innerHTML=t,1===n.body.children.length)return n.body.children[0];for(e=document.createDocumentFragment();n.body.firstChild;)e.appendChild(n.body.firstChild);return e}function o(t,e){var n,r,i,o;if("function"==typeof(null===t||void 0===t?void 0:t.closest))return t.closest(e);if(!(t instanceof HTMLElement))return null;i=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=t;do{if(i.call(o,e))return o;o=null!==(r=null!==(n=null===o||void 0===o?void 0:o.parentElement)&&void 0!==n?n:null===o||void 0===o?void 0:o.parentNode)&&void 0!==r?r:null}while(null!==o&&1===o.nodeType);return null}function s(t){return t.getClientRects().length?t.getBoundingClientRect():{top:0,left:0,height:0,width:0,x:0,y:0,bottom:0,right:0}}function a(){return void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft}function l(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}function c(t,e,n,r){e.insertBefore(n,t===De?r:r.nextSibling)}function u(t,e,n){t===De?n.insertBefore(e,n.firstChild):n.appendChild(e)}function p(t,e){var n,r=t[De];if(r&&(n=t[Ae]))for(n=n[Ae];r!==n&&!1!==e(r);r=r[Ae]);}function h(t,e,n){var r,i=t[De];if(!i)return e;if(!(r=t[Ae]))return e;for(r=r[Ae];i!==r;i=i[Ae])e=n(e,i);return e}function d(t,e,r){n("a parent is always present",t),n("leftward is properly set up",function(){return e?e[Ae]===r&&e.parent===t:t.getEnd(De)===r}(),{parent:t,leftward:e,leftwardL:e&&e[De],leftwardR:e&&e[Ae],rightwardL:r&&r[De],rightwardR:r&&r[Ae]}),n("rightward is properly set up",function(){return r?r[De]===e&&r.parent===t:t.getEnd(Ae)===e}(),{parent:t,rightward:r,leftwardL:e&&e[De],leftwardR:e&&e[Ae],rightwardL:r&&r[De],rightwardR:r&&r[Ae],rightwardParent:r&&r.parent})}function f(t){return t&&t.prototype instanceof xt}function m(t){return lt(),ct||(ct=g(1)),ct(t)}function g(t){function e(t,e){var n,r,o;for(n in e)if(e.hasOwnProperty(n)){if("substituteKeyboardEvents"===n&&i>=3)throw new Error(["As of interface version 3, the 'substituteKeyboardEvents'","option is no longer supported. Use 'overrideTypedText' and","'overrideKeystroke' instead."].join(" "));r=e[n],o=s[n],t[n]=o?o(r):r}}function r(t,e){function r(n,r){var o,s;return n&&n.nodeType?(o=d(n))instanceof e?o:(s=new qt(new e.RootBlock,n,new c(i)),s.KIND_OF_MQ=t,new e(s).__mathquillify(r||{},i)):null}return n(t+" is defined",e),r.prototype=e.prototype,r}var i,o,s,c,u,p,h,d;if(1!==t&&2!==t&&3!==t)throw"Only interface versions between "+ut+" and "+pt+" supported. You specified: "+t;if((i=t)<3){if(!(o=window.jQuery))throw"MathQuill interface version ".concat(i," requires jQuery 1.5.2+ to be loaded first");st.prototype.jQuery=o}return s=__assign(__assign({},ot),{handlers:function(t){return{fns:t||{},APIClasses:h}}}),c=i<3?st:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(st),u=function(t){function n(e){var n=t.call(this)||this;return n.__controller=e,n.__options=e.options,n.id=e.id,n.data=e.data,n}return __extends(n,t),n.prototype.mathquillify=function(t){var e,n=this.__controller,r=n.root,o=n.container;n.createTextarea(),e=$(o).addClass(t).children().detach(),r.setDOM($(Ne("span",{class:"mq-root-block","aria-hidden":!0})).appendTo(o).oneElement()),K.linkElementByBlockNode(r.domFrag().oneElement(),r),this.latex(e.text()),this.revert=function(){return n.removeMouseEventListener(),$(o).removeClass("mq-editable-field mq-math-mode mq-text-mode").empty().append(e),i<3?this.__options.assertJquery()(o):o}},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n.prototype.config=function(t){return e(this.__options,t),void 0!==t.tabindex&&this.__controller.setTabindex(t.tabindex),this},n.prototype.el=function(){return this.__controller.container},n.prototype.text=function(){return this.__controller.exportText()},n.prototype.mathspeak=function(){return this.__controller.exportMathSpeak()},n.prototype.latex=function(t){if(arguments.length>0){this.__controller.renderLatexMath(t);var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this}return this.__controller.exportLatex()},n.prototype.selection=function(t){return t?(this.__controller.restoreLatexSelection(t),this):this.__controller.exportLatexSelection().selection},n.prototype.html=function(){return this.__controller.root.domFrag().oneElement().innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},n.prototype.reflow=function(){return this.__controller.root.postOrder(function(t){t.reflow()}),this},n.prototype.focus=function(){return this.__controller.getTextarea().focus(),this.__controller.editable&&this.__controller.scrollHoriz(),this},n.prototype.select=function(){return this.__controller.selectAll(),this},n.prototype.blur=function(){return this.__controller.getTextarea().blur(),this},n}(at),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.mathquillify=function(e){return t.prototype.mathquillify.call(this,e),this.__controller.editable=!0,this.__controller.addMouseEventListener(),this.__controller.editablesTextareaEvents(),this},e.prototype.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.prototype.write=function(t){this.__controller.writeLatex(t),this.__controller.scrollHoriz();var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this},e.prototype.empty=function(){var t,e=this.__controller.root,n=this.__controller.cursor;return e.setEnds((t={},t[De]=0,t[Ae]=0,t)),e.domFrag().empty(),delete n.selection,n.insAtRightEnd(e),this},e.prototype.cmd=function(t){var e,n,r=this.__controller.notify(void 0),i=r.cursor;return/^\\[a-z]+$/i.test(t)&&!i.isTooDeep()?(t=t.slice(1),(e=Y[t])&&(n=e.constructor?new e(t):e(t),i.selection&&n.replaces(i.replaceSelection()),n.createLeftOf(i.show()))):i.parent.write(i,t),r.scrollHoriz(),r.blurred&&i.hide().parent.blur(i),this},e.prototype.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.prototype.moveToLeftEnd=function(){return this.moveToDirEnd(De)},e.prototype.moveToRightEnd=function(){return this.moveToDirEnd(Ae)},e.prototype.keystroke=function(t,e){var n,r=t.replace(/^\s+|\s+$/g,"").split(/\s+/);for(n=0;n<r.length;n+=1)this.__controller.keystroke(r[n],e);return this},e.prototype.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this},e.prototype.dropEmbedded=function(t,e,n){var r,i=t-a(),o=e-l(),s=document.elementFromPoint(i,o);this.__controller.seek(s,i,o),r=(new Te).setOptions(n),r.createLeftOf(this.__controller.cursor)},e.prototype.setAriaPostLabel=function(t,e){return this.__controller.setAriaPostLabel(t,e),this},e.prototype.getAriaPostLabel=function(){return this.__controller.getAriaPostLabel()},e.prototype.clickAt=function(t,e,n){var r,i,o;return n=n||document.elementFromPoint(t,e),r=this.__controller,i=r.root,o=i.domFrag().oneElement(),o.contains(n)||(n=o),r.seek(n,t,e),r.blurred&&this.focus(),this},e.prototype.ignoreNextMousedown=function(t){return this.__controller.cursor.options.ignoreNextMousedown=t,this},e.prototype.isUserSelecting=function(){return this.__controller.isMouseSelecting},e}(u),h={AbstractMathQuill:u,EditableField:p},n("API.StaticMath defined",rt.StaticMath),h.StaticMath=rt.StaticMath(h),n("API.MathField defined",rt.MathField),h.MathField=rt.MathField(h),n("API.InnerMathField defined",rt.InnerMathField),h.InnerMathField=rt.InnerMathField(h),rt.TextField&&(h.TextField=rt.TextField(h)),d=function(t){var e,n,r,i,o,s,a,l;if(!t||!t.nodeType)return null;for(n=$(t).children().toElementArray(),r=0,i=n;r<i.length;r++)if(o=i[r],o.classList.contains("mq-root-block")){e=o;break}return s=K.getNodeOfElement(e),a=s&&s.controller,l=a&&h[a.KIND_OF_MQ],a&&l?new l(a):null},d.L=De,d.R=Ae,d.config=function(t){return e(c.prototype,t),this},d.registerEmbed=function(t,e){if(!/^[a-z][a-z0-9]*$/i.test(t))throw"Embed name must start with letter and be only letters and digits";it[t]=e},d.StaticMath=r("StaticMath",h.StaticMath),d.MathField=r("MathField",h.MathField),d.InnerMathField=r("InnerMathField",h.InnerMathField),h.TextField&&(d.TextField=r("TextField",h.TextField)),d.prototype=u.prototype,d.EditableField=function(){throw"wtf don't call me, I'm 'abstract'"},d.EditableField.prototype=p.prototype,i<3&&(d.saneKeyboardEvents=E),d}function y(t){t.moveOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("moveOutOf",t)},t.deleteOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("deleteOutOf",t)},t.selectOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("selectOutOf",t)},t.upOutOf=function(){n("controller is defined",this.controller),this.controller.handle("upOutOf")},t.downOutOf=function(){n("controller is defined",this.controller),this.controller.handle("downOutOf")},t.reflow=function(){n("controller is defined",this.controller),this.controller.handle("reflow"),this.controller.handle("edited"),this.controller.handle("edit")}}function v(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}function x(t,e,n){var r,i,o=n.uncleanedStartIndex,s=n.uncleanedEndIndex;for(r=0,i=0;r<n.uncleanedEndIndex;r++)t[r]!==e[i]?(r<n.uncleanedStartIndex&&(o-=1),s-=1):i+=1;return{startIndex:o,endIndex:s}}function b(t,e,n){var r,i,o=n.startIndex,s=n.endIndex,a=o,l=s;for(r=0,i=0;r<e.length;r++)e[r]!==t[i]?(i<=o&&(a+=1),i<=s&&(l+=1)):i+=1;return{uncleanStartIndex:a,uncleanEndIndex:l}}function w(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function E(t,e){return mt(t[0],e)}function k(t,e,n){return function(){return new Dt(t,e?Ne.entityText(e):void 0,n)}}function L(t,e,n,r){return function(){return new At(t,e?Ne.entityText(e):void 0,n,r)}}function S(t,e,n){return function(){return new Pt(t,Ne.entityText(e))}}function _(t,e){for(var n="",r=0;t instanceof Ht&&t.ctrlSeq===t.letter&&r<e;)n=t.letter+n,t=t[De],r+=1;return n}function q(t){var e,n,r,i;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters';for(e=t.split(" "),n={},r=0;r<e.length;r+=1){if(i=e[r],i.length<2)throw'"'+i+'" not minimum length of 2';n[i]=!0}return n}function O(t){return S("\\"+t+" ","&"+t+";",t)}function C(t){return function(){return new Dt("\\"+t+" ",Ne.entityText("&"+t+";"))}}function T(t){return t instanceof At||t instanceof Ht&&"infix"==t.endsCategory}function F(t){if(!t)return!1;var e=t[De];return e?!(T(e)||e instanceof Ht&&"prefix"==e.endsCategory||!(e instanceof ke)&&/^(\\ )|[,;:\(\[]$/.test(e.ctrlSeq)):!!(t.parent&&t.parent.parent&&t.parent.parent.isStyleBlock())&&F(t.parent.parent)}function D(t){if(!t)return"";var e="";return t.eachChild(function(t){void 0!==t.ctrlSeq&&(e+=t.ctrlSeq)}),e}function A(t){var e=this.parent,n=t;do{if(n[Ae])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function M(t,e){var n;return"0"===e?"to the 0 power":"2"===e?"squared":"3"===e?"cubed":(n="",/^[+-]?\d{1,3}$/.test(e)&&(/(11|12|13|4|5|6|7|8|9|0)$/.test(e)?n="th":/1$/.test(e)?n="st":/2$/.test(e)?n="nd":/3$/.test(e)&&(n="rd")),"to the "+("object"==typeof t?t.mathspeak():e)+n+" power")}function I(t){var e=t.side,n=t.sides[e];return{ch:Le[n.ch],ctrlSeq:Le[n.ctrlSeq]}}function N(t,e,n){var r,i;e=e||t,r=Le[t],i=Le[e],Z[t]=function(){return new ke(De,t,r,e,i)},Z[r]=function(){return new ke(Ae,t,r,e,i)},Se[t]=Se[r]=n}var B,R,z,P,H,j,G,V,W,Q,$,U,K,X,Y,Z,J,tt,et,nt,rt,it,ot,st,at,lt,ct,ut,pt,ht,dt,ft,mt,gt,yt,vt,xt,bt,wt,Et,kt,Lt,St,_t,qt,Ot,Ct,Tt,Ft,Dt,At,Mt,It,Nt,Bt,Rt,zt,Pt,Ht,jt,Gt,Vt,Wt,Qt,$t,Ut,Kt,Xt,Yt,Zt,Jt,te,ee,ne,re,ie,oe,se,ae,le,ce,ue,pe,he,de,fe,me,ge,ye,ve,xe,be,we,Ee,ke,Le,Se,_e,qe,Oe,Ce,Te,Fe,De=-1,Ae=1,Me=Math.min,Ie=Math.max,Ne=function(t,e,n){var r,i,o,s;switch(t){case"svg":case"path":r=document.createElementNS("http://www.w3.org/2000/svg",t);break;default:r=document.createElement(t)}for(i in e)void 0!==(o=e[i])&&r.setAttribute(i,"string"==typeof o?o:String(o));if(n)for(s=0;s<n.length;s++)r.appendChild(n[s]);return r};Ne.text=function(t){return document.createTextNode(t)},Ne.block=function(t,e,n,r){var i,o=[n.html()];return(null===r||void 0===r?void 0:r.beforeChild)&&o.unshift(r.beforeChild),(null===r||void 0===r?void 0:r.afterChild)&&o.push(r.afterChild),i=Ne(t,e,o),n.setDOM(i),K.linkElementByBlockNode(i,n),i},Ne.entityText=function(t){var e=i(t);return n("entity parses to a single text node",e instanceof DocumentFragment&&1===e.childNodes.length&&e.childNodes[0]instanceof Text),e.childNodes[0]},B=" ",R="​",z="˙",P="∑",H="∏",j="∐",G="∫",V=function(){var t,e;return"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(t=requestAnimationFrame,e=cancelAnimationFrame):(t=function(t){return setTimeout(t,13)},e=clearTimeout),function(n,r){function i(){var t=(Date.now()-l)/n;t<=c?s():c=t,r(c,s,o)}function o(){void 0!==a&&e(a),a=void 0}function s(){o(),a=t(i)}var a,l=Date.now(),c=0;r(n<=0?1:0,s,o)}}(),W=function(){function t(t){this.span=Ne("span",{class:"mq-aria-alert","aria-live":"assertive","aria-atomic":"true"}),this.msg="",this.items=[],this.controller=t}return t.prototype.attach=function(){var t=this.controller.container;this.span.parentNode!==t&&$(t).prepend($(this.span))},t.prototype.queue=function(t,e){var n,r;return void 0===e&&(e=!1),n="",t instanceof xt?(r=t.mathspeak({ignoreShorthand:!0}),e&&(t.parent&&t.parent.ariaLabel&&"block"===t.ariaLabel?n=t.parent.ariaLabel+" "+r:t.ariaLabel&&(n=t.ariaLabel+" "+r)),""===n&&(n=r)):n=t||"",this.items.push(n),this},t.prototype.queueDirOf=function(t){return r(t),this.queue(t===De?"before":"after")},t.prototype.queueDirEndOf=function(t){return r(t),this.queue(t===De?"beginning of":"end of")},t.prototype.alert=function(t){return this.attach(),t&&this.queue(t),this.items.length&&(this.msg=this.items.join(" ").replace(/ +(?= )/g,"").trim(),this.controller.containerHasFocus()&&(this.controller.options.logAriaAlerts&&this.msg&&console.log(this.msg),this.span.textContent=this.msg)),this.clear()},t.prototype.clear=function(t){return this.items.length=0,(null===t||void 0===t?void 0:t.emptyContent)&&(this.span.textContent=""),this},t}(),Q=function(){function t(t,e){var n;1===arguments.length&&(e=t),t&&e&&(this.ends=(n={},n[De]=t,n[Ae]=e,n))}return t.create=function(e,r){1===arguments.length&&(r=e),n("No half-empty DOMFragments",!!e==!!r);var i=new t(e,r);return n("last is a forward sibling of first",i.isValid()),i},t.prototype.isEmpty=function(){return void 0===this.ends},t.prototype.isOneNode=function(){return!(!this.ends||this.ends[De]!==this.ends[Ae])},t.prototype.isValid=function(){if(!this.ends)return!0;if(this.ends[De]===this.ends[Ae])return!0;var t;return this.eachNode(function(e){return t=e}),t===this.ends[Ae]},t.prototype.firstNode=function(){return n("Fragment is not empty",this.ends),this.ends[De]},t.prototype.lastNode=function(){return n("Fragment is not empty",this.ends),this.ends[Ae]},t.prototype.children=function(){var e=this.oneNode(),n=e.firstChild,r=e.lastChild;return n&&r?new t(n,r):new t},t.prototype.join=function(e){var r,i;if(!this.ends)return e;if(!e.ends)return this;for(r=!1,i=this.ends[Ae].nextSibling;i;){if(i===e.ends[De]){r=!0;break}i=i.nextSibling}return n("sibling must be a forward DOM sibling of this fragment",r),new t(this.ends[De],e.ends[Ae])},t.prototype.oneNode=function(){return n("Fragment has a single node",this.ends&&this.ends[De]===this.ends[Ae]),this.ends[De]},t.prototype.oneElement=function(){var t=this.oneNode();return n("Node is an Element",t.nodeType===Node.ELEMENT_NODE),t},t.prototype.oneText=function(){var t=this.oneNode();return n("Node is Text",t.nodeType===Node.TEXT_NODE),t},t.prototype.eachNode=function(t){var e,n,r;if(!this.ends)return this;for(e=this.ends[Ae],n=this.ends[De],r=void 0;n&&(r=n.nextSibling,t(n),n!==e);n=r);return this},t.prototype.eachElement=function(t){return this.eachNode(function(e){e.nodeType===Node.ELEMENT_NODE&&t(e)}),this},t.prototype.text=function(){var t="";return this.eachNode(function(e){t+=e.textContent||""}),t},t.prototype.toNodeArray=function(){var t=[];return this.eachNode(function(e){return t.push(e)}),t},t.prototype.toElementArray=function(){var t=[];return this.eachElement(function(e){return t.push(e)}),t},t.prototype.toDocumentFragment=function(){var t=document.createDocumentFragment();return this.eachNode(function(e){return t.appendChild(e)}),t},t.prototype.insertBefore=function(t){return this.insDirOf(De,t)},t.prototype.insertAfter=function(t){return this.insDirOf(Ae,t)},t.prototype.append=function(t){return t.appendTo(this.oneElement()),this},t.prototype.prepend=function(t){return t.prependTo(this.oneElement()),this},t.prototype.appendTo=function(t){return this.insAtDirEnd(Ae,t)},t.prototype.prependTo=function(t){return this.insAtDirEnd(De,t)},t.prototype.parent=function(){if(!this.ends)return this;var e=this.ends[De].parentNode;return e?new t(e):new t},t.prototype.wrapAll=function(t){var e,n;return t.textContent="",this.ends?(e=this.ends[De].parentNode,n=this.ends[Ae].nextSibling,this.appendTo(t),e&&e.insertBefore(t,n),this):this},t.prototype.replaceWith=function(t){var e,n,r=null===(e=this.ends)||void 0===e?void 0:e[Ae],i=null===r||void 0===r?void 0:r.parentNode,o=null===r||void 0===r?void 0:r.nextSibling;return this.detach(),n=t.toDocumentFragment(),r&&i?(i.insertBefore(n,o||null),this):this},t.prototype.nthElement=function(t){if(this.ends&&!(t<0||t!==Math.floor(t)))for(var e=this.ends[De];e;){if(e.nodeType===Node.ELEMENT_NODE){if(t<=0)return e;t-=1}if(e===this.ends[Ae])return;e=e.nextSibling}},t.prototype.firstElement=function(){return this.nthElement(0)},t.prototype.lastElement=function(){if(this.ends)for(var t=this.ends[Ae];t;){if(t.nodeType===Node.ELEMENT_NODE)return t;if(t===this.ends[De])return;t=t.previousSibling}},t.prototype.first=function(){return new t(this.firstElement())},t.prototype.last=function(){return new t(this.lastElement())},t.prototype.eq=function(e){return new t(this.nthElement(e))},t.prototype.slice=function(e){if(!this.ends)return this;var n=this.nthElement(e);return n?new t(n,this.ends[Ae]):new t},t.prototype.next=function(){for(var e=this.oneNode();e;)if((e=e.nextSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.prev=function(){for(var e=this.oneNode();e;)if((e=e.previousSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.empty=function(){return this.eachElement(function(t){t.textContent=""}),this},t.prototype.remove=function(){return this.toDocumentFragment(),this},t.prototype.detach=function(){return this.remove()},t.prototype.insDirOf=function(t,e){var n,r;return this.ends?(r=null===(n=e.ends)||void 0===n?void 0:n[t])&&r.parentNode?(c(t,r.parentNode,this.toDocumentFragment(),r),this):this.detach():this},t.prototype.insAtDirEnd=function(t,e){return this.ends?(u(t,this.toDocumentFragment(),e),this):this},t.prototype.hasClass=function(t){var e=!1;return this.eachElement(function(n){n.classList.contains(t)&&(e=!0)}),e},t.prototype.addClass=function(t){var e,n,r,i=function(t){if(!t)return"continue";o.eachElement(function(e){e.classList.add(t)})},o=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],i(r);return this},t.prototype.removeClass=function(t){var e,n,r,i=function(t){if(!t)return"continue";o.eachElement(function(e){e.classList.remove(t)})},o=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],i(r);return this},t.prototype.toggleClass=function(t,e){var n,r,i,o,s;if(!0===e)return this.addClass(t);if(!1===e)return this.removeClass(t);for(n=function(t){if(!t)return"continue";r.eachElement(function(e){e.classList.toggle(t)})},r=this,i=0,o=t.split(/\s+/);i<o.length;i++)s=o[i],n(s);return this},t}(),$=Q.create,U=function(){function t(t,e,n){this.init(t,e,n)}return t.prototype.init=function(t,e,n){this.parent=t,this[De]=e,this[Ae]=n},t.copy=function(e){return new t(e.parent,e[De],e[Ae])},t}(),K=function(){function t(){var n;this[e]=0,this[i]=0,this.parent=0,this.ends=(n={},n[De]=0,n[Ae]=0,n),this.id=t.uniqueNodeId()}t.uniqueNodeId=function(){return t.idCounter+=1},t.getNodeOfElement=function(t){if(t){if(!t.nodeType)throw new Error("must pass an Element to NodeBase.getNodeOfElement");var e=t;return e.mqBlockNode||e.mqCmdNode}},t.linkElementByBlockNode=function(t,e){t.mqBlockNode=e},t.linkElementByCmdNode=function(t,e){t.mqCmdNode=e},t.prototype.setEnds=function(t){this.ends=t,n("No half-empty node ends",!!this.ends[De]==!!this.ends[Ae])},t.prototype.getEnd=function(t){return this.ends[t]},t.prototype.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.prototype.setDOM=function(t){return t&&n("DOM is an element or a text node",t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE),this._el=t,this},t.prototype.domFrag=function(){return $(this._el)},t.prototype.createDir=function(t,e){r(t);var n=this;return n.html(),n.domFrag().insDirOf(t,e.domFrag()),e[t]=n.adopt(e.parent,e[De],e[Ae]),n},t.prototype.createLeftOf=function(t){this.createDir(De,t)},t.prototype.selectChildren=function(t,e){return new et(t,e)},t.prototype.bubble=function(t){var e,n=this.getSelfNode();for(e=n;e&&!1!==t(e);e=e.parent);return this},t.prototype.postOrder=function(t){var e=this.getSelfNode();return function e(n){return!!n&&(n.eachChild(e),t(n),!0)}(e),e},t.prototype.isEmpty=function(){return 0===this.ends[De]&&0===this.ends[Ae]},t.prototype.isQuietEmptyDelimiter=function(t){if(!this.isEmpty())return!1;if(!t)return!1;if(!this.parent||void 0===this.parent.ctrlSeq)return!1;var e=this.parent.ctrlSeq.replace(/^\\(left|right)?/,"");return t.hasOwnProperty(e)},t.prototype.isStyleBlock=function(){return!1},t.prototype.isTextBlock=function(){return!1},t.prototype.children=function(){return new X(this.getEnd(De),this.getEnd(Ae))},t.prototype.eachChild=function(t){return p(this.ends,t),this},t.prototype.foldChildren=function(t,e){return h(this.ends,t,e)},t.prototype.withDirAdopt=function(t,e,n,r){var i=this.getSelfNode();return new X(i,i).withDirAdopt(t,e,n,r),this},t.prototype.adopt=function(t,e,n){var r=this.getSelfNode();return new X(r,r).adopt(t,e,n),this.getSelfNode()},t.prototype.disown=function(){var t=this.getSelfNode();return new X(t,t).disown(),this},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.shouldIgnoreSubstitutionInSimpleSubscript=function(t){var e,n=t.disableAutoSubstitutionInSubscripts;return!!n&&(!!this.parent&&(this.parent.parent instanceof ce&&(e=this.parent.parent[De],!("object"==typeof n&&e instanceof Ht&&e.endsWord&&n.except[e.endsWord])&&!!this.parent.domFrag().hasClass("mq-sub"))))},t.prototype.getSelfNode=function(){return this},t.prototype.parser=function(){n("Abstract parser() method is never called",!1)},t.prototype.html=function(){throw new Error("html() unimplemented in NodeBase")},t.prototype.text=function(){return""},t.prototype.latex=function(){var t={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return this.latexRecursive(t),t.uncleanedLatex},t.prototype.latexRecursive=function(t){},t.prototype.checkCursorContextOpen=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionBefore===this&&(t.uncleanedStartIndex=n),t.endSelectionBefore===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedStartIndex&&(e.uncleanedEndIndex===e.uncleanedStartIndex?n===e.uncleanedStartIndex&&(e.cursorParent=this.parent):e.selectionL=this)},t.prototype.checkCursorContextClose=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionAfter===this&&(t.uncleanedStartIndex=n),t.endSelectionAfter===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedEndIndex&&(e.uncleanedStartIndex===e.uncleanedEndIndex?(e.cursorL||(e.cursorL=this),e.cursorParent?e.cursorParent===this.parent&&(e.cursorParent=this,e.cursorL=0):e.cursorParent=this.parent):e.selectionR||(e.selectionR=this))},t.prototype.finalizeTree=function(t,e){},t.prototype.contactWeld=function(t,e){},t.prototype.blur=function(t){},t.prototype.focus=function(){},t.prototype.intentionalBlur=function(){},t.prototype.reflow=function(){},t.prototype.registerInnerField=function(t,e){},t.prototype.chToCmd=function(t,e){n("Abstract chToCmd() method is never called",!1)},t.prototype.mathspeak=function(t){return""},t.prototype.seek=function(t,e){},t.prototype.siblingDeleted=function(t,e){},t.prototype.siblingCreated=function(t,e){},t.prototype.finalizeInsert=function(t,e){},t.prototype.fixDigitGrouping=function(t){},t.prototype.writeLatex=function(t,e){},t.prototype.write=function(t,e){};var e,i;return e=De,i=Ae,t.idCounter=0,t}(),X=function(){function t(t,e,i){var o,s,a,l;if(this.disowned=!1,void 0===i&&(i=De),r(i),n("no half-empty fragments",!t==!e,{withDir:t,oppDir:e}),!t||!e)return void this.setEnds((o={},o[De]=0,o[Ae]=0,o));n("withDir is passed to Fragment",t instanceof xt),n("oppDir is passed to Fragment",e instanceof xt),n("withDir and oppDir have the same parent",t.parent===e.parent),s={},s[i]=t,s[-i]=e,a=s,this.setEnds(a),l=0,this.each(function(t){l=t}),n("following direction siblings from start reaches end",l===a[Ae])}return t.prototype.getDOMFragFromEnds=function(){var t=this.ends[De],e=this.ends[Ae];return 0===t||0===e?$():t===e?t.domFrag():t.domFrag().join(e.domFrag())},t.prototype.setEnds=function(t){this.ends=t},t.prototype.getEnd=function(t){return this.ends?this.ends[t]:0},t.prototype.domFrag=function(){return this.getDOMFragFromEnds()},t.prototype.withDirAdopt=function(t,e,n,r){return t===De?this.adopt(e,n,r):this.adopt(e,r,n)},t.prototype.adopt=function(t,e,n){var r,i,o,s,a;return d(t,e,n),i=this,this.disowned=!1,(o=i.ends[De])&&(s=i.ends[Ae])?(r={},r[De]=t.getEnd(De),r[Ae]=t.getEnd(Ae),a=r,e||(a[De]=o),n?n[De]=s:a[Ae]=s,t.setEnds(a),s[Ae]=n,i.each(function(n){return n[De]=e,n.parent=t,e&&(e[Ae]=n),e=n,!0}),i):this},t.prototype.disown=function(){var t,e,n,r,i,o,s=this,a=s.ends[De];return!a||s.disowned?s:(this.disowned=!0,(e=s.ends[Ae])?(n=a.parent,d(n,a[De],a),d(n,e,e[Ae]),t={},t[De]=n.getEnd(De),t[Ae]=n.getEnd(Ae),r=t,a[De]?(i=a[De],i[Ae]=e[Ae]):r[De]=e[Ae],e[Ae]?(o=e[Ae],o[De]=a[De]):r[Ae]=a[De],r[De]&&r[Ae]?n.setEnds(r):n.ends=r,s):s)},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.each=function(t){return p(this.ends,t),this},t.prototype.fold=function(t,e){return h(this.ends,t,e)},t}(),Y={},Z={},J=function(t){function e(e,n,r){var i=t.call(this,e,n,r)||this;return i.ancestors={},i}return __extends(e,t),e.fromCursor=function(t){return new e(t.parent,t[De],t[Ae])},e}(U),tt=function(t){function e(e,n,r){var i=t.call(this,e,0,0)||this;return i.upDownCache={},i.cursorElement=Ne("span",{class:"mq-cursor"},[Ne.text(R)]),i._domFrag=$(),i.controller=r,i.options=n,i.setDOMFrag($(i.cursorElement)),i.blink=function(){$(i.cursorElement).toggleClass("mq-blink")},i}return __extends(e,t),e.prototype.setDOMFrag=function(t){return this._domFrag=t,this},e.prototype.domFrag=function(){return this._domFrag},e.prototype.show=function(){var t,e;return $(this.cursorElement).removeClass("mq-blink"),this.setDOMFrag($(this.cursorElement)),this.intervalId?clearInterval(this.intervalId):(t=this[Ae],t?(e=this.selection,e&&e.getEnd(De)[De]===this[De]?this.domFrag().insertBefore(e.domFrag()):this.domFrag().insertBefore(t.domFrag())):this.domFrag().appendTo(this.parent.domFrag().oneElement()),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},e.prototype.hide=function(){return this.intervalId&&clearInterval(this.intervalId),this.intervalId=0,this.domFrag().detach(),this.setDOMFrag($()),this},e.prototype.withDirInsertAt=function(t,e,n,r){var i=this.parent;this.parent=e,this[t]=n,this[-t]=r,i!==e&&i.blur&&i.blur(this)},e.prototype.insDirOf=function(t,e){return r(t),this.domFrag().insDirOf(t,e.domFrag()),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.domFrag().addClass("mq-hasCursor"),this},e.prototype.insLeftOf=function(t){return this.insDirOf(De,t)},e.prototype.insRightOf=function(t){return this.insDirOf(Ae,t)},e.prototype.insAtDirEnd=function(t,e){return r(t),this.domFrag().insAtDirEnd(t,e.domFrag().oneElement()),this.withDirInsertAt(t,e,0,e.getEnd(t)),e.focus(),this},e.prototype.insAtLeftEnd=function(t){return this.insAtDirEnd(De,t)},e.prototype.insAtRightEnd=function(t){return this.insAtDirEnd(Ae,t)},e.prototype.jumpUpDown=function(t,e){var n,r,i,o=this;o.upDownCache[t.id]=U.copy(o),n=o.upDownCache[e.id],n?(r=n[Ae],r?o.insLeftOf(r):o.insAtRightEnd(n.parent)):(i=o.getBoundingClientRectWithoutMargin().left,e.seek(i,o)),o.controller.aria.queue(e,!0)},e.prototype.getBoundingClientRectWithoutMargin=function(){var t,e,n,r=this.domFrag();return r.removeClass("mq-cursor"),t=s(r.oneElement()),e=t.left,n=t.right,r.addClass("mq-cursor"),{left:e,right:n}},e.prototype.unwrapGramp=function(){var t,e,n,r,i,o=this.parent.parent,s=o.parent,a=o[Ae],l=this,c=o[De];if(o.disown().eachChild(function(t){return!!t.isEmpty()||(t.children().adopt(s,c,a).each(function(t){return t.domFrag().insertBefore(o.domFrag()),!0}),c=t.getEnd(Ae),!0)}),!this[Ae])if(t=this[De])this[Ae]=t[Ae];else for(;!this[Ae];){if(!(e=this.parent[Ae])){this[Ae]=o[Ae],this.parent=s;break}this.parent=e,this[Ae]=e.getEnd(De)}n=this[Ae],n?this.insLeftOf(n):this.insAtRightEnd(s),o.domFrag().remove(),r=o[De],i=o[Ae],r&&r.siblingDeleted(l.options,Ae),i&&i.siblingDeleted(l.options,De)},e.prototype.startSelection=function(){var t,e=this.anticursor=J.fromCursor(this),n=e.ancestors;for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},e.prototype.endSelection=function(){delete this.anticursor},e.prototype.select=function(){var t,e,r,i,o,s,a,l,c,u=this.anticursor;if(this[De]===u[De]&&this.parent===u.parent)return!1;for(e=this;e.parent;e=e.parent)if(e.parent.id in u.ancestors){t=e.parent;break}if(n("cursor and anticursor in the same tree",t),r=t,i=u.ancestors[r.id],a=Ae,e[De]!==i)for(l=e;l;l=l[Ae])if(l[Ae]===i[Ae]){a=De,o=e,s=i;break}return a===Ae&&(o=i,s=e),o instanceof U&&(o=o[Ae]),s instanceof U&&(s=s[De]),this.hide().selection=r.selectChildren(o,s),c=this.selection.getEnd(a),this.insDirOf(a,c),this.selectionChanged(),!0},e.prototype.resetToEnd=function(t){this.clearSelection();var e=t.root;this[Ae]=0,this[De]=e.getEnd(Ae),this.parent=e},e.prototype.clearSelection=function(){
11
- return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},e.prototype.deleteSelection=function(){var t=this.selection;t&&(this[De]=t.getEnd(De)[De],this[Ae]=t.getEnd(Ae)[Ae],t.remove(),this.selectionChanged(),delete this.selection)},e.prototype.replaceSelection=function(){var t=this.selection;return t&&(this[De]=t.getEnd(De)[De],this[Ae]=t.getEnd(Ae)[Ae],delete this.selection),t},e.prototype.depth=function(){for(var t=this,e=0;t=t.parent;)e+=t instanceof Mt?1:0;return e},e.prototype.isTooDeep=function(t){return void 0!==this.options.maxDepth&&this.depth()+(t||0)>this.options.maxDepth},e.prototype.selectionChanged=function(){},e}(U),et=function(t){function e(e,n,r){var i=t.call(this,e,n,r)||this;return i._el=Ne("span",{class:"mq-selection"}),i.getDOMFragFromEnds().wrapAll(i._el),i}return __extends(e,t),e.prototype.isCleared=function(){return void 0===this._el},e.prototype.domFrag=function(){return this.isCleared()?this.getDOMFragFromEnds():$(this._el)},e.prototype.setEnds=function(t){n("Selection ends are never empty",t[De]&&t[Ae]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.adopt=function(e,n,r){return this.clear(),t.prototype.adopt.call(this,e,n,r)},e.prototype.clear=function(){var t=this.getDOMFragFromEnds();return this.domFrag().replaceWith(t),this._el=void 0,this},e.prototype.join=function(t,e){return void 0===e&&(e=""),this.fold("",function(n,r){return n+e+r[t]()})},e}(X),nt=function(){function t(t,e,n){this.isMouseSelecting=!1,this.textareaEventListeners={},this.id=t.id,this.data={},this.root=t,this.container=e,this.options=n,this.aria=new W(this.getControllerSelf()),this.ariaLabel="Math Input",this.ariaPostLabel="",t.controller=this.getControllerSelf(),this.cursor=t.cursor=new tt(t,n,this.getControllerSelf())}return t.prototype.getControllerSelf=function(){return this},t.prototype.handle=function(t,e){var r,i,o,s=this.options.handlers,a=null===(r=this.options.handlers)||void 0===r?void 0:r.fns[t];a&&(i=null===s||void 0===s?void 0:s.APIClasses[this.KIND_OF_MQ],n("APIClass is defined",i),o=new i(this),e===De||e===Ae?a(e,o):a(o))},t.onNotify=function(e){t.notifyees.push(e)},t.prototype.notify=function(e){for(var n=0;n<t.notifyees.length;n+=1)t.notifyees[n](this.cursor,e);return this},t.prototype.setAriaLabel=function(t){var e=this.getAriaLabel();return!t&&this.editable?this.ariaLabel="Math Input":this.ariaLabel=t,t===e||this.containerHasFocus()||this.updateMathspeak(),this},t.prototype.getAriaLabel=function(){return"Math Input"!==this.ariaLabel?this.ariaLabel:this.editable?"Math Input":""},t.prototype.setAriaPostLabel=function(t,e){var n=this;return t&&"string"==typeof t&&""!==t?(t!==this.ariaPostLabel&&"number"==typeof e&&(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this._ariaAlertTimeout=setTimeout(function(){n.containerHasFocus()?n.aria.alert(n.root.mathspeak().trim()+" "+t.trim()):n.updateMathspeak()},e)),this.ariaPostLabel=t):(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this.ariaPostLabel=""),this},t.prototype.getAriaPostLabel=function(){return this.ariaPostLabel||""},t.prototype.containerHasFocus=function(){return document.activeElement&&this.container.contains(document.activeElement)},t.prototype.getTextarea=function(){var t=this.textarea;return n("textarea initialized",t),t},t.prototype.getTextareaSpan=function(){var t=this.textareaSpan;return n("textareaSpan initialized",t),t},t.prototype.addTextareaEventListeners=function(t){var e,n;if(this.textarea)for(e in t)n=e,this.removeTextareaEventListener(n),this.textarea.addEventListener(n,t[n])},t.prototype.removeTextareaEventListener=function(t){if(this.textarea){var e=this.textareaEventListeners[t];e&&this.textarea.removeEventListener(t,e)}},t.prototype.exportMathSpeak=function(){return this.root.mathspeak()},t.prototype.updateMathspeak=function(t){},t.prototype.scrollHoriz=function(){},t.prototype.selectionChanged=function(){},t.prototype.setOverflowClasses=function(){},t.notifyees=[],t}(),rt={},it={},ot={},st=function(){function t(t){this.version=t}return t.prototype.assertJquery=function(){return n("Interface versions > 2 do not depend on JQuery",this.version<=2),n("JQuery is set for interface v < 3",this.jQuery),this.jQuery},t}(),at=function(){function t(){}return t}(),lt=function(){window.console&&console.warn('You are using the MathQuill API without specifying an interface version, which will fail in v1.0.0. Easiest fix is to do the following before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},m.prototype=at.prototype,m.VERSION="v0.10.1",m.interfaceVersion=function(t){if(1!==t)throw"Only interface version 1 supported. You specified: "+t;return lt=function(){window.console&&console.warn('You called MathQuill.interfaceVersion(1); to specify the interface version, which will fail in v1.0.0. You can fix this easily by doing this before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},lt(),m},m.getInterface=g,ut=g.MIN=1,pt=g.MAX=3,m.noConflict=function(){return window.MathQuill=ht,m},ht=window.MathQuill,window.MathQuill=m,dt=function(){function t(t){this._=t}return t.prototype.parse=function(e){function n(t,e){return e}return this.skip(t.eof)._(""+e,n,v)},t.prototype.or=function(e){n("or is passed a parser",e instanceof t);var r=this;return new t(function(t,n,i){function o(r){return e._(t,n,i)}return r._(t,n,o)})},t.prototype.then=function(e){var r=this;return new t(function(i,o,s){function a(r,i){var a=e instanceof t?e:e(i);return n("a parser is returned",a instanceof t),a._(r,o,s)}return r._(i,a,s)})},t.prototype.many=function(){var e=this;return new t(function(t,n,r){function i(e,n){return t=e,s.push(n),!0}function o(){return!1}for(var s=[];e._(t,i,o););return n(t,s)})},t.prototype.times=function(e,n){arguments.length<2&&(n=e);var r=this;return new t(function(t,i,o){function s(e,n){return p.push(n),t=e,!0}function a(e,n){return c=n,t=e,!1}function l(t,e){return!1}var c,u,p=[],h=!0;for(u=0;u<e;u+=1)if(!(h=!!r._(t,s,a)))return o(t,c);for(;u<n&&h;u+=1)r._(t,s,l);return i(t,p)})},t.prototype.result=function(e){return this.then(t.succeed(e))},t.prototype.atMost=function(t){return this.times(0,t)},t.prototype.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.prototype.map=function(e){return this.then(function(n){return t.succeed(e(n))})},t.prototype.skip=function(t){return this.then(function(e){return t.result(e)})},t.string=function(e){var n=e.length,r="expected '"+e+"'";return new t(function(t,i,o){var s=t.slice(0,n);return s===e?i(t.slice(n),s):o(t,r)})},t.regex=function(e){n("regexp parser is anchored","^"===e.toString().charAt(1));var r="expected "+e;return new t(function(t,n,i){var o,s=e.exec(t);return s?(o=s[0],n(t.slice(o.length),o)):i(t,r)})},t.succeed=function(e){return new t(function(t,n){return n(t,e)})},t.fail=function(e){return new t(function(t,n,r){return r(t,e)})},t.letter=t.regex(/^[a-z]/i),t.letters=t.regex(/^[a-z]*/i),t.digit=t.regex(/^[0-9]/),t.digits=t.regex(/^[0-9]*/),t.whitespace=t.regex(/^\s+/),t.optWhitespace=t.regex(/^\s*/),t.any=new t(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),t.all=new t(function(t,e,n){return e("",t)}),t.eof=new t(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)}),t}(),ft=function(){function e(){this.fn=t}return e.prototype.listen=function(t){this.fn=t,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(this.fn)},e.prototype.listenOnce=function(t){var e=this;this.listen(function(){var n,r=[];for(n=0;n<arguments.length;n++)r[n]=arguments[n];e.clearListener(),t.apply(void 0,r)})},e.prototype.clearListener=function(){this.fn=t,clearTimeout(this.timeoutId)},e.prototype.trigger=function(){var t,e=[];for(t=0;t<arguments.length;t++)e[t]=arguments[t];this.fn.apply(this,e)},e}(),mt=function(){function t(t){switch(n(t)){case"Right":case"Left":case"Down":case"Up":return!0}return!1}function e(t){return 1===t.length&&t>="a"&&t<="z"}function n(t){var n,r;return void 0===t.key?(r=t.which||t.keyCode,i[r]||String.fromCharCode(r)):e(t.key)?t.key.toUpperCase():null!==(n=o[t.key])&&void 0!==n?n:t.key}function r(t){var e=n(t),r=[];return t.ctrlKey&&r.push("Ctrl"),t.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),r.length?("Alt"!==e&&"Control"!==e&&"Meta"!==e&&"Shift"!==e&&r.push(e),r.join("-")):e}var i={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"},o={ArrowRight:"Right",ArrowLeft:"Left",ArrowDown:"Down",ArrowUp:"Up",Delete:"Del",Escape:"Esc"," ":"Spacebar"};return function(e,n){function i(){try{e instanceof HTMLTextAreaElement&&e.select()}catch(t){}}function o(t){v.trigger(),v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value=t),t&&i(),x=!!t}function s(){return"selectionStart"in e&&(e instanceof HTMLTextAreaElement&&e.selectionStart!==e.selectionEnd)}function a(){n.options&&n.options.overrideKeystroke?n.options.overrideKeystroke(r(g),g):n.keystroke(r(g),g)}function l(t){v.trigger(t),t.target===e&&(g=t,y=null,x&&v.listenOnce(function(t){t&&"focusout"===t.type||i()}),a())}function c(n){v.trigger(n),n.target===e&&(g&&y&&a(),y=n,t(n)?v.listenOnce(h):v.listen(p))}function u(n){v.trigger(n),n.target===e&&g&&!y&&(t(n)?v.listenOnce(h):v.listen(p))}function p(){if(!s()&&e instanceof HTMLTextAreaElement){var t=e.value;(!g||"Unidentified"!==g.key&&(g.altKey||!g.ctrlKey||g.metaKey||!g.shiftKey||"U"!==g.key&&"Process"!==g.key))&&(1===t.length?(e.value="",n.options&&n.options.overrideTypedText?n.options.overrideTypedText(t):n.typedText(t)):h())}}function h(){e instanceof HTMLTextAreaElement&&e.value.length>1&&i()}function d(){g=null,y=null,v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value="")}function f(t){v.trigger(),t.target===e&&(document.activeElement!==e&&e.focus(),v.listen(function(){if(e instanceof HTMLTextAreaElement){var t=e.value;e.value="",t&&n.paste(t)}}))}function m(t){v.trigger(t)}var g=null,y=null,v=new ft,x=!1;return"StaticMath"===n.KIND_OF_MQ?(n.addTextareaEventListeners({keydown:function(t){var e,i;null===(i=(e=n.options).overrideKeystroke)||void 0===i||i.call(e,r(t),t)}}),{select:o}):(n.options&&n.options.disableCopyPaste?n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,copy:function(t){t.preventDefault()},cut:function(t){t.preventDefault()},paste:function(t){v.trigger(),t.preventDefault()},input:m}):n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,cut:function(){v.listenOnce(function(){n.cut()})},copy:function(){v.listenOnce(function(){n.copy()})},paste:f,input:m}),{select:o})}}(),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.exportText=function(){return this.root.foldChildren("",function(t,e){return t+e.text()})},e}(nt),nt.onNotify(function(t,e){if("edit"===e||"replace"===e||void 0===e){var n=t.controller;if(!n)return;if(!n.options.enableDigitGrouping)return;if(!1!==n.blurred)return;n.disableGroupingForSeconds(1)}}),yt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.handleTextareaFocusEditable=function(){var t=e.cursor;e.updateMathspeak(),e.blurred=!1,clearTimeout(e.blurTimeout),$(e.container).addClass("mq-focused"),t.parent||t.insAtRightEnd(e.root),t.selection?(t.selection.domFrag().removeClass("mq-blur"),e.selectionChanged()):t.show(),e.setOverflowClasses()},e.handleTextareaBlurEditable=function(){e.textareaSelectionTimeout&&(clearTimeout(e.textareaSelectionTimeout),e.textareaSelectionTimeout=0),e.disableGroupingForSeconds(0),e.blurred=!0,e.blurTimeout=setTimeout(function(){e.root.postOrder(function(t){t.intentionalBlur()}),e.cursor.clearSelection().endSelection(),e.blur(),e.updateMathspeak({emptyContent:!0}),e.scrollHoriz()}),window.addEventListener("blur",e.handleWindowBlur)},e.handleTextareaFocusStatic=function(){e.cursor.selection||e.cursor.controller.selectAll(),e.blurred=!1},e.handleTextareaBlurStatic=function(){e.cursor.clearSelection(),e.updateMathspeak({emptyContent:!0})},e.handleWindowBlur=function(){clearTimeout(e.blurTimeout),e.cursor.selection&&e.cursor.selection.domFrag().addClass("mq-blur"),e.blurWithoutResettingCursor(),e.updateMathspeak({emptyContent:!0})},e}return __extends(e,t),e.prototype.disableGroupingForSeconds=function(t){var e=this;clearTimeout(this.__disableGroupingTimeout),0===t?this.root.domFrag().removeClass("mq-suppress-grouping"):(this.root.domFrag().addClass("mq-suppress-grouping"),this.__disableGroupingTimeout=setTimeout(function(){e.root.domFrag().removeClass("mq-suppress-grouping")},1e3*t))},e.prototype.blur=function(){this.blurWithoutResettingCursor(),this.options&&this.options.resetCursorOnBlur&&this.cursor.resetToEnd(this)},e.prototype.blurWithoutResettingCursor=function(){this.cursor.hide().parent.blur(this.cursor),$(this.container).removeClass("mq-focused"),window.removeEventListener("blur",this.handleWindowBlur)},e.prototype.addEditableFocusBlurListeners=function(){var t=this,e=t.cursor;this.addTextareaEventListeners({focus:this.handleTextareaFocusEditable,blur:this.handleTextareaBlurEditable}),t.blurred=!0,e.hide().parent.blur(e)},e.prototype.addStaticFocusBlurListeners=function(){this.addTextareaEventListeners({focus:this.handleTextareaFocusStatic,blur:this.handleTextareaBlurStatic})},e}(gt),vt=!1,xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,n,r){var i=r.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":r.ctrlDeleteDir(De);break;case"Shift-Backspace":case"Backspace":r.backspace();break;case"Esc":case"Tab":return void r.escapeDir(Ae,t,n);case"Shift-Tab":case"Shift-Esc":return void r.escapeDir(De,t,n);case"End":r.notify("move").cursor.insAtRightEnd(i.parent),r.aria.queue("end of").queue(i.parent,!0);break;case"Ctrl-End":r.notify("move").cursor.insAtRightEnd(r.root),r.aria.queue("end of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-End":r.selectToBlockEndInDir(Ae);break;case"Ctrl-Shift-End":r.selectToRootEndInDir(Ae);break;case"Home":r.notify("move").cursor.insAtLeftEnd(i.parent),r.aria.queue("beginning of").queue(i.parent,!0);break;case"Ctrl-Home":r.notify("move").cursor.insAtLeftEnd(r.root),r.aria.queue("beginning of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-Home":r.selectToBlockEndInDir(De);break;case"Ctrl-Shift-Home":r.selectToRootEndInDir(De);break;case"Left":r.moveLeft();break;case"Shift-Left":r.selectLeft();break;case"Ctrl-Left":break;case"Right":r.moveRight();break;case"Shift-Right":r.selectRight();break;case"Ctrl-Right":break;case"Up":r.moveUp();break;case"Down":r.moveDown();break;case"Shift-Up":r.withIncrementalSelection(function(t){if(i[De])for(;i[De];)t(De);else t(De)});break;case"Shift-Down":r.withIncrementalSelection(function(t){if(i[Ae])for(;i[Ae];)t(Ae);else t(Ae)});break;case"Ctrl-Up":case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":r.ctrlDeleteDir(Ae);break;case"Shift-Del":case"Del":r.deleteForward();break;case"Meta-A":case"Ctrl-A":r.selectAll();break;case"Ctrl-Alt-Up":i.parent.parent&&i.parent.parent instanceof e?r.aria.queue(i.parent.parent):r.aria.queue("nothing above");break;case"Ctrl-Alt-Down":i.parent&&i.parent instanceof e?r.aria.queue(i.parent):r.aria.queue("block is empty");break;case"Ctrl-Alt-Left":i.parent.parent&&i.parent.parent.getEnd(De)?r.aria.queue(i.parent.parent.getEnd(De)):r.aria.queue("nothing to the left");break;case"Ctrl-Alt-Right":i.parent.parent&&i.parent.parent.getEnd(Ae)?r.aria.queue(i.parent.parent.getEnd(Ae)):r.aria.queue("nothing to the right");break;case"Ctrl-Alt-Shift-Down":i.selection?r.aria.queue(i.selection.join("mathspeak"," ").trim()+" selected"):r.aria.queue("nothing selected");break;case"Ctrl-Alt-=":case"Ctrl-Alt-Shift-Right":r.ariaPostLabel.length?r.aria.queue(r.ariaPostLabel):r.aria.queue("no answer");break;default:return}r.aria.alert(),null===n||void 0===n||n.preventDefault(),r.scrollHoriz()},e.prototype.moveOutOf=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.moveTowards=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.deleteOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.deleteTowards=function(t,e){n("overridden or never called on this node",!1)},e.prototype.unselectInto=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectTowards=function(t,e){n("overridden or never called on this node",!1)},e}(K),nt.onNotify(function(t,e){"move"!==e&&"upDown"!==e||t.show().clearSelection()}),ot.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},nt.onNotify(function(t,e){"upDown"!==e&&(t.upDownCache={})}),nt.onNotify(function(t,e){"edit"===e&&t.show().deleteSelection()}),nt.onNotify(function(t,e){"select"!==e&&t.endSelection()}),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this.getControllerSelf())},e.prototype.escapeDir=function(t,e,n){r(t);var i=this.cursor;if(i.parent!==this.root&&(null===n||void 0===n||n.preventDefault()),i.parent!==this.root)return i.clearSelection(),i.parent.moveOutOf(t,i),i.controller.aria.alert(),this.notify("move")},e.prototype.moveDir=function(t){var e,n,i;return r(t),e=this.cursor,n=e.options.leftRightIntoCmdGoes,i=e[t],e.selection?e.insDirOf(t,e.selection.getEnd(t)):i?i.moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.notify("move")},e.prototype.moveLeft=function(){return this.moveDir(De)},e.prototype.moveRight=function(){return this.moveDir(Ae)},e.prototype.moveUp=function(){return this.moveUpDown("up")},e.prototype.moveDown=function(){return this.moveUpDown("down")},e.prototype.moveUpDown=function(t){var e,n,r,i,o,s,a=this,l=a.notify("upDown").cursor;return"up"===t?(e="upInto",n="upOutOf"):(e="downInto",n="downOutOf"),r=l[De],i=l[Ae],o=i&&i[e],s=r&&r[e],o?l.insAtLeftEnd(o):s?l.insAtRightEnd(s):l.parent.bubble(function(t){var e=t[n];if(e&&("function"==typeof e&&(e=e.call(t,l)),e instanceof xt&&l.jumpUpDown(t,e),!0!==e))return!1}),a},e.prototype.deleteDir=function(t){var e,n,i,o,s,a,l,c,u,p;return r(t),e=this.cursor,n=e[t],i=e.parent.parent,o=e.controller,n&&n instanceof xt?n.sides?o.aria.queue(n.parent.chToCmd(n.sides[-t].ch).mathspeak({createdLeftOf:e})):n.blocks||"\\text"===n.parent.ctrlSeq||o.aria.queue(n):i&&i instanceof xt&&(i.sides?o.aria.queue(i.parent.chToCmd(i.sides[t].ch).mathspeak({createdLeftOf:e})):i.blocks&&i.mathspeakTemplate?i.upInto&&i.downInto?o.aria.queue(i.mathspeakTemplate[1]):(s=i.mathspeakTemplate,a=t===De?s[0]:s[s.length-1],o.aria.queue(a)):o.aria.queue(i)),l=e.selection,this.notify("edit"),l||(c=e[t],c?c.deleteTowards(t,e):e.parent.deleteOutOf(t,e)),u=e[De],p=e[Ae],u.siblingDeleted&&u.siblingDeleted(e.options,Ae),p.siblingDeleted&&p.siblingDeleted(e.options,De),e.parent.bubble(function(t){t.reflow()}),this},e.prototype.ctrlDeleteDir=function(t){var e,n,i,o;return r(t),e=this.cursor,!e[t]||e.selection?this.deleteDir(t):(this.notify("edit"),n=t===De?new X(e.parent.getEnd(De),e[De]):new X(e[Ae],e.parent.getEnd(Ae)),e.controller.aria.queue(n),n.remove(),e.insAtDirEnd(t,e.parent),i=e[De],o=e[Ae],i&&i.siblingDeleted(e.options,Ae),o&&o.siblingDeleted(e.options,De),e.parent.bubble(function(t){t.reflow()}),this)},e.prototype.backspace=function(){return this.deleteDir(De)},e.prototype.deleteForward=function(){return this.deleteDir(Ae)},e.prototype.startIncrementalSelection=function(){n("Multiple selections can't be simultaneously open",!vt),vt=!0,this.notify("select");var t=this.cursor;t.anticursor||t.startSelection()},e.prototype.selectDirIncremental=function(t){var e,i,o;n("A selection is open",vt),vt=!0,e=this.cursor,i=e.selection,r(t),o=e[t],o?i&&i.getEnd(t)===o&&e.anticursor[-t]!==o?o.unselectInto(t,e):o.selectTowards(t,e):e.parent.selectOutOf(t,e)},e.prototype.finishIncrementalSelection=function(){var t,e;n("A selection is open",vt),t=this.cursor,t.clearSelection(),t.select()||t.show(),e=t.selection,e&&t.controller.aria.clear().queue(e.join("mathspeak"," ").trim()+" selected"),vt=!1},e.prototype.withIncrementalSelection=function(t){var e=this;try{this.startIncrementalSelection();try{t(function(t){return e.selectDirIncremental(t)})}finally{this.finishIncrementalSelection()}}finally{vt=!1}},e.prototype.selectDir=function(t){this.withIncrementalSelection(function(e){return e(t)})},e.prototype.selectLeft=function(){return this.selectDir(De)},e.prototype.selectRight=function(){return this.selectDir(Ae)},e.prototype.selectAll=function(){this.notify("move");var t=this.cursor;t.insAtRightEnd(this.root),this.withIncrementalSelection(function(e){for(;t[De];)e(De)})},e.prototype.selectToBlockEndInDir=function(t){var e=this.cursor;this.withIncrementalSelection(function(n){for(;e[t];)n(t)})},e.prototype.selectToRootEndInDir=function(t){var e=this,n=this.cursor;this.withIncrementalSelection(function(r){for(;n[t]||n.parent!==e.root;)r(t)})},e}(yt),function(t){function e(e){return t.call(this)||this}__extends(e,t)}(xt),wt=function(){function t(t){var e=new Mt;return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||new Mt;for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.getEnd(Ae),0);return n}var n=dt.string,r=dt.regex,i=dt.letter,o=dt.digit,s=dt.any,a=dt.optWhitespace,l=dt.succeed,c=dt.fail,u=i.map(function(t){return new Ht(t)}),p=o.map(function(t){return new zt(t)}),h=r(/^[^${}\\_^]/).map(function(t){return new Dt(t)}),d=r(/^[^\\a-eg-zA-Z]/).or(n("\\").then(r(/^[a-z]+/i).or(r(/^\s+/).result(" ")).or(s))).then(function(t){var e,n,r=Y[t];return r?r.constructor?(e=r,new e(t).parser()):(n=r,n(t).parser()):c("unknown command: \\"+t)}),f=d.or(u).or(p).or(h),m=n("{").then(function(){return y}).skip(n("}")),g=a.then(m.or(f.map(t))),y=g.many().map(e).skip(a),v=n("[").then(g.then(function(t){return"]"!==t.join("latex")?l(t):c("")}).many().map(e).skip(a)).skip(n("]")),x=y;return x.block=g,x.optBlock=v,x}(),ot.maxDepth=function(t){return"number"==typeof t?t:void 0},Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.cleanLatex=function(t){return t.replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},e.prototype.exportLatex=function(){return this.cleanLatex(this.root.latex())},e.prototype.writeLatex=function(t){var e=this.notify("edit").cursor;return e.parent.writeLatex(e,t),this},e.prototype.prepareCursorForRestoration=function(){return this.cursor.clearSelection().endSelection(),this.notify("move").cursor},e.prototype.restoreLatexSelection=function(t){var e,n,r,i=this,o=this.exportLatexSelection(),s=o.selection,a=s.latex,l=t.latex;l===a&&(t.startIndex===s.startIndex&&t.endIndex===s.endIndex||(0===t.endIndex?this.prepareCursorForRestoration().insAtDirEnd(De,this.root):t.startIndex===l.length?this.prepareCursorForRestoration().insAtDirEnd(Ae,this.root):(e=b(a,o.ctx.uncleanedLatex,t),n=this.exportLatexSelection(e).ctx.restoreInfo,t.startIndex===t.endIndex?(null===n||void 0===n?void 0:n.cursorL)?this.prepareCursorForRestoration().insRightOf(n.cursorL):(null===n||void 0===n?void 0:n.cursorParent)&&this.prepareCursorForRestoration().insAtLeftEnd(n.cursorParent):(null===n||void 0===n?void 0:n.selectionL)&&n.selectionR&&(this.prepareCursorForRestoration().insRightOf(n.selectionR),r=this.cursor.controller.root,this.withIncrementalSelection(function(t){do{if(t(De),!i.cursor[De]&&i.cursor.parent===r)break}while(i.cursor[Ae]!==n.selectionL)})))))},e.prototype.exportLatexSelection=function(t){var e,n,r,i,o,s,a,l,c={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return t&&(c.restoreInfo={uncleanedStartIndex:t.uncleanStartIndex,uncleanedEndIndex:t.uncleanEndIndex}),e=this.cursor.selection,e&&this.cursor.anticursor?(c.startSelectionBefore=e.getEnd(De),c.endSelectionAfter=e.getEnd(Ae)):(n=this.cursor[De],n?c.startSelectionAfter=n:c.startSelectionBefore=this.cursor.parent,r=this.cursor[Ae],r?c.endSelectionBefore=r:c.endSelectionAfter=this.cursor.parent),this.root.latexRecursive(c),i=c.uncleanedLatex,o=this.cleanLatex(i),s=x(i,o,c),a=s.startIndex,l=s.endIndex,{selection:{latex:o,startIndex:a,endIndex:l},ctx:c}},e.prototype.classifyLatexForEfficientUpdate=function(t){if("string"==typeof t){var e=t.match(/-?[0-9.]+$/g);return e&&1===e.length?{latex:t,prefix:t.substr(0,t.length-e[0].length),digits:e[0]}:void 0}},e.prototype.updateLatexMathEfficiently=function(t,e){var n,r,i,o,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b,w,E,k,L,S,_,q=this.root,O=this.classifyLatexForEfficientUpdate(t);if(!O)return!1;if(!(s=this.classifyLatexForEfficientUpdate(e))||s.prefix!==O.prefix)return!1;for(a=s.digits,l=O.digits,c=!1,u=!1,"-"===a[0]&&(c=!0,a=a.substr(1)),"-"===l[0]&&(u=!0,l=l.substr(1)),p=this.root.getEnd(Ae),h=[],d=a.length-1;d>=0;d--){if(!p||p.ctrlSeq!==a[d])return!1;if(p.parent!==q)return!1;h.unshift(p),p=p[De]}if(c&&!u){if(!(f=p))return!1;if("-"!==f.ctrlSeq)return!1;if(f[Ae]!==h[0])return!1;if(f.parent!==q)return!1;if((m=f[De])&&m.parent!==q)return!1;h[0][De]=f[De],q.getEnd(De)===f&&q.setEnds((n={},n[De]=h[0],n[Ae]=q.getEnd(Ae),n)),m&&(m[Ae]=h[0]),f.domFrag().remove()}for(!c&&u&&(g=new Kt("-"),y=document.createElement("span"),y.textContent="-",g.setDOM(y),v=h[0][De],v&&(v[Ae]=g),q.getEnd(De)===h[0]&&q.setEnds((r={},r[De]=g,r[Ae]=q.getEnd(Ae),r)),g.parent=q,g[De]=h[0][De],g[Ae]=h[0],h[0][De]=g,g.contactWeld(this.cursor),g.domFrag().insertBefore(h[0].domFrag())),x=Math.min(a.length,l.length),d=0;d<x;d++)b=l[d],p=h[d],p.ctrlSeq!==b&&(p.ctrlSeq=b,p.domFrag().oneElement().textContent=b,p.mathspeakName=b);if(a.length>l.length)for(p=h[l.length-1],q.setEnds((i={},i[De]=q.getEnd(De),i[Ae]=p,i)),p[Ae]=0,d=a.length-1;d>=x;d--)h[d].domFrag().remove();if(l.length>a.length){for(w=document.createDocumentFragment(),d=x;d<l.length;d++)E=document.createElement("span"),E.className="mq-digit",E.textContent=l[d],k=new zt(l[d]),k.parent=q,k.setDOM(E),w.appendChild(E),k[De]=q.getEnd(Ae),k[Ae]=0,L=k[De],L[Ae]=k,q.setEnds((o={},o[De]=q.getEnd(De),o[Ae]=k,o));q.domFrag().oneElement().appendChild(w)}return(S=this.exportLatex())!==t?(console.warn("tried updating latex efficiently but did not work. Attempted: "+t+" but wrote: "+S),!1):(_=q.getEnd(Ae),_&&_.fixDigitGrouping(this.cursor.options),!0)},e.prototype.renderLatexMathFromScratch=function(t){var e,n,r=this.root,i=this.cursor,o=dt.all,s=dt.eof,a=wt.skip(s).or(o.result(!1)).parse(t);r.setEnds((e={},e[De]=0,e[Ae]=0,e)),a&&a.children().adopt(r,0,0),a?(n=r.domFrag(),n.children().remove(),n.oneElement().appendChild(a.html()),r.finalizeInsert(i.options,i)):r.domFrag().empty()},e.prototype.renderLatexMath=function(t){var e,n=this.cursor,r=this.root;this.notify("replace"),n.clearSelection(),e=this.exportLatex(),r.getEnd(De)&&r.getEnd(Ae)&&e===t||(this.updateLatexMathEfficiently(t,e)||this.renderLatexMathFromScratch(t),this.updateMathspeak()),n.insAtRightEnd(r)},e.prototype.renderLatexText=function(t){var e,n,r,i,o,s,a,l,c,u,p,h=this.root,d=this.cursor;if(h.domFrag().children().slice(1).remove(),h.setEnds((e={},e[De]=0,e[Ae]=0,e)),delete d.selection,d.show().insAtRightEnd(h),n=dt.regex,r=dt.string,i=dt.eof,o=dt.all,s=r("$").then(wt).skip(r("$").or(i)).map(function(t){var e,n=new RootMathCommand(d);return n.createBlocks(),e=n.getEnd(De),t.children().adopt(e,0,0),n}),a=r("\\$").result("$"),l=a.or(n(/^[^$]/)).map(function(t){return new Dt(t)}),c=s.or(l).many(),u=c.skip(i).or(o.result(!1)).parse(t)){for(p=0;p<u.length;p+=1)u[p].adopt(h,h.getEnd(Ae),0);$(h.html()).appendTo(h.domFrag().oneElement()),h.finalizeInsert(d.options,d)}},e}(bt),kt=function(t){return!1},st.prototype.ignoreNextMousedown=kt,function(){nt.onNotify(function(t,e){"edit"!==e&&"replace"!==e||Lt&&Lt.cursor===t&&Lt.cb()})}(),St=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.handleMouseDown=function(e){function r(t){c=t.target}function i(t){m.anticursor||m.startSelection(),f.seek(c,t.clientX,t.clientY).cursor.select(),m.selection&&m.controller.aria.clear().queue(m.selection.join("mathspeak")+" selected").alert(),c=null}function s(){null===p||void 0===p||p.removeEventListener("mousemove",r),null===d||void 0===d||d.removeEventListener("mousemove",i),null===d||void 0===d||d.removeEventListener("mouseup",l),Lt=void 0,f.isMouseSelecting=!1}function a(){f.editable&&(m.show(),m.controller.aria.queue(m.parent).alert())}function l(){m.blink=g,m.selection||a(),s()}var c,u,p=o(e.target,".mq-root-block"),h=p&&K.getNodeOfElement(p)||K.getNodeOfElement(n.root.domFrag().oneElement()),d=h.domFrag().firstNode().ownerDocument,f=h.controller,m=f.cursor,g=m.blink,y=f.getTextarea();e.preventDefault(),e.target.unselectable=!0,m.options.ignoreNextMousedown(e)||o(e.target,".mq-ignore-mousedown")||(c=null,Lt={cursor:m,cb:function(){u=!0,m.blink=g,m.clearSelection(),a(),s()}},f.blurred&&(n.editable&&y.focus(),u)||(m.blink=t,f.isMouseSelecting=!0,f.seek(e.target,e.clientX,e.clientY).cursor.startSelection(),null===p||void 0===p||p.addEventListener("mousemove",r),null===d||void 0===d||d.addEventListener("mousemove",i),null===d||void 0===d||d.addEventListener("mouseup",l)))},n}return __extends(n,e),n.prototype.addMouseEventListener=function(){this.container.addEventListener("mousedown",this.handleMouseDown)},n.prototype.removeMouseEventListener=function(){this.container.removeEventListener("mousedown",this.handleMouseDown)},n.prototype.seek=function(t,e,n){for(var r,i=this.notify("select").cursor;t&&!(r=K.getNodeOfElement(t));)t=t.parentElement;return r||(r=this.root),i.clearSelection().show(),r.seek(e,i),this.scrollHoriz(),this},n}(Et),_t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOverflowClasses=function(){var t,e,n,r=this.root.domFrag().oneElement(),i=!1,o=!1;this.blurred||(t=s(r).width,e=r.scrollWidth,n=r.scrollLeft,i=e>t+n,o=n>0),r.classList.contains("mq-editing-overflow-right")!==i&&r.classList.toggle("mq-editing-overflow-right"),r.classList.contains("mq-editing-overflow-left")!==o&&r.classList.toggle("mq-editing-overflow-left")},e.prototype.scrollHoriz=function(){var t,e,n,r,i,o,a,l,c,u,p=this,h=this.cursor,d=h.selection,f=s(this.root.domFrag().oneElement());if(h.domFrag().isEmpty()&&!d)return this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),t=this.root.domFrag().oneElement(),e=t.scrollLeft,void V(this.getScrollAnimationDuration(),function(n,r,i){n>=1?(p.cancelScrollHoriz=void 0,t.scrollLeft=0,p.setOverflowClasses()):(p.cancelScrollHoriz=i,r(),t.scrollLeft=Math.round((1-n)*e))});if(d)if(i=s(d.domFrag().oneElement()),o=i.left-(f.left+20),a=i.right-(f.right-20),d.getEnd(De)===h[Ae])if(o<0)r=o;else{if(!(a>0))return;r=i.left-a<f.left+20?o:a}else if(a>0)r=a;else{if(!(o<0))return;r=i.right-o>f.right-20?a:o}else if((n=s(h.domFrag().oneElement()).left)>f.right-20)r=n-(f.right-20);else{if(!(n<f.left+20))return;r=n-(f.left+20)}l=this.root.domFrag().oneElement(),r<0&&0===l.scrollLeft||r>0&&l.scrollWidth<=l.scrollLeft+f.width||(this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),c=this.root.domFrag().oneElement(),u=c.scrollLeft,
12
- V(this.getScrollAnimationDuration(),function(t,e,n){t>=1?(p.cancelScrollHoriz=void 0,c.scrollLeft=Math.round(u+r),p.setOverflowClasses()):(p.cancelScrollHoriz=n,e(),c.scrollLeft=Math.round(u+t*r))}))},e.prototype.getScrollAnimationDuration=function(){var t;return null!==(t=this.options.scrollAnimationDuration)&&void 0!==t?t:100},e}(St),st.prototype.substituteTextarea=function(){return Ne("textarea",{autocapitalize:"off",autocomplete:"off",autocorrect:"off",spellcheck:!1,"x-palm-disable-ste-all":!0})},st.prototype.substituteKeyboardEvents=E,qt=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.selectFn=t,n}return __extends(n,e),n.prototype.createTextarea=function(){var t,e,n;if(this.textareaSpan=Ne("span",{class:"mq-textarea"}),t=this.options.substituteTextarea(),!t.nodeType)throw"substituteTextarea() must return a DOM element, got "+t;this.textarea=$(t).appendTo(this.textareaSpan).oneElement(),this.mathspeakSpan||(this.mathspeakId=w(),this.mathspeakSpan=Ne("span",{class:"mq-mathspeak",id:this.mathspeakId}),$(this.textareaSpan).prepend($(this.mathspeakSpan))),this.mathspeakId&&(null===t||void 0===t||t.setAttribute("aria-labelledby",this.mathspeakId)),e=this,e.cursor.selectionChanged=function(){e.selectionChanged()},n=void 0!==this.options.tabindex?this.options.tabindex:"StaticMath"===this.KIND_OF_MQ?-1:0,this.setTabindex(n)},n.prototype.setTabindex=function(t){var e,n,r,i,o;t!==this.previousTabindex&&this.textarea&&(this.previousTabindex=t,null===(e=this.textarea)||void 0===e||e.setAttribute("tabindex",""+t),t<0&&"StaticMath"===this.KIND_OF_MQ?null===(n=this.textarea)||void 0===n||n.setAttribute("aria-hidden","true"):null===(r=this.textarea)||void 0===r||r.removeAttribute("aria-hidden"),t>=0?null===(i=this.mathspeakSpan)||void 0===i||i.setAttribute("aria-hidden","true"):null===(o=this.mathspeakSpan)||void 0===o||o.removeAttribute("aria-hidden"))},n.prototype.selectionChanged=function(){var t=this;t.textareaSelectionTimeout||(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},n.prototype.setTextareaSelection=function(){this.textareaSelectionTimeout=0;var t="";this.cursor.selection&&(t=this.cleanLatex(this.cursor.selection.join("latex")),this.options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},n.prototype.staticMathTextareaEvents=function(){var t,e,n,r=this;this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste"),r.options.disableCopyPaste?this.removeTextareaEventListener("copy"):this.addTextareaEventListeners({copy:function(){r.setTextareaSelection()}}),this.addStaticFocusBlurListeners(),t=this.getTextarea(),e=mt(t,this).select,this.selectFn=e,n=this.getTextareaSpan(),$(this.container).prepend($(n))},n.prototype.editablesTextareaEvents=function(){var t,e,n,r=this,i=r.getTextarea(),o=r.getTextareaSpan();this.options.version<3?(t=this.options.assertJquery(),e=this.options.substituteKeyboardEvents(t(i),this),this.selectFn=function(t){e.select(t)}):(n=mt(i,this).select,this.selectFn=n),$(this.container).prepend($(o)),this.addEditableFocusBlurListeners(),this.updateMathspeak()},n.prototype.unbindEditablesEvents=function(){var t=this,e=t.getTextarea(),n=t.getTextareaSpan();this.selectFn=function(t){e instanceof HTMLTextAreaElement&&(e.value=t,t&&e.select())},$(n).remove(),this.removeTextareaEventListener("focus"),this.removeTextareaEventListener("blur"),t.blurred=!0,this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste")},n.prototype.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify(void 0).cursor;e.parent.write(e,t),this.scrollHoriz()},n.prototype.cut=function(){var t=this,e=t.cursor;e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble(function(t){t.reflow()}),t.options&&t.options.onCut&&t.options.onCut()})},n.prototype.copy=function(){this.setTextareaSelection()},n.prototype.paste=function(t){this.options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show(),this.scrollHoriz(),this.options&&this.options.onPaste&&this.options.onPaste()},n.prototype.setupStaticField=function(){this.updateMathspeak(),this.blurred=!0,this.cursor.hide().parent.blur(this.cursor)},n.prototype.updateMathspeak=function(t){var e=this,n=e.getAriaLabel(),r=/[A-Za-z0-9]$/.test(n)?n+":":n,i=e.root.mathspeak().trim(),o=!!(null===t||void 0===t?void 0:t.emptyContent);this.aria.clear({emptyContent:o}),e.mathspeakSpan&&(e.mathspeakSpan.textContent=(r+" "+i+" "+e.ariaPostLabel).trim())},n}(_t),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeInsert=function(t,e){var n,r,i=this;i.postOrder(function(e){e.finalizeTree(t)}),i.postOrder(function(t){t.contactWeld(e)}),i.postOrder(function(t){t.blur(e)}),i.postOrder(function(t){t.reflow()}),n=i[Ae],r=i[De],n&&n.siblingCreated(t,De),r&&r.siblingCreated(t,Ae),i.bubble(function(t){t.reflow()})},e.prototype.prepareInsertionAt=function(t){var e,n=t.options.maxDepth;if(void 0!==n){if((e=t.depth())>n)return!1;this.removeNodesDeeperThan(n-e)}return!0},e.prototype.removeNodesDeeperThan=function(t){for(var e,n,r=0,i=[[this,r]];e=i.shift();)n=e,n[0].children().each(function(e){var o=e instanceof Mt?1:0;r=n[1]+o,r<=t?i.push([e,r]):(o?e.children():e).remove()})},e}(xt),Ct=function(){function t(t,e){this.childCount=t,this.render=e}return t}(),Tt=function(t){function e(e,n,r){var i=t.call(this)||this;return i.textTemplate=[""],i.mathspeakTemplate=[""],i.setCtrlSeqHtmlAndText(e,n,r),i}return __extends(e,t),e.prototype.setEnds=function(t){n("MathCommand ends are never empty",t[De]&&t[Ae]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.setCtrlSeqHtmlAndText=function(t,e,n){this.ctrlSeq||(this.ctrlSeq=t),e&&(this.domView=e),n&&(this.textTemplate=n)},e.prototype.replaces=function(t){t.disown(),this.replacedFragment=t},e.prototype.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},e.prototype.parser=function(){var t=this;return wt.block.times(this.numBlocks()).map(function(e){t.blocks=e;for(var n=0;n<e.length;n+=1)e[n].adopt(t,t.getEnd(Ae),0);return t})},e.prototype.createLeftOf=function(e){var n,r=this,i=r.replacedFragment;r.createBlocks(),t.prototype.createLeftOf.call(this,e),i&&(n=r.getEnd(De),i.adopt(n,0,0),i.domFrag().appendTo(n.domFrag().oneElement()),r.placeCursor(e),r.prepareInsertionAt(e)),r.finalizeInsert(e.options,e),r.placeCursor(e)},e.prototype.createBlocks=function(){var t,e,n=this,r=n.numBlocks(),i=n.blocks=Array(r);for(t=0;t<r;t+=1)e=i[t]=new Mt,e.adopt(n,n.getEnd(Ae),0)},e.prototype.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.getEnd(De),function(t,e){return t.isEmpty()?t:e}))},e.prototype.moveTowards=function(t,e,n){var r,i;"up"===n?r=this.upInto:"down"===n&&(r=this.downInto),i=r||this.getEnd(-t),e.insAtDirEnd(-t,i),e.controller.aria.queueDirEndOf(-t).queue(e.parent,!0)},e.prototype.deleteTowards=function(t,e){this.isEmpty()?e[t]=this.remove()[t]:this.moveTowards(t,e)},e.prototype.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},e.prototype.selectChildren=function(){return new et(this,this)},e.prototype.unselectInto=function(t,e){var n=e.anticursor,r=n.ancestors[this.id];e.insAtDirEnd(-t,r)},e.prototype.seek=function(t,e){function n(t){var e,n=t.domFrag().oneElement(),r=s(n).left,i=r+n.offsetWidth;return e={},e[De]=r,e[Ae]=i,e}var r,i=this,o=n(i);return t<o[De]?e.insLeftOf(i):t>o[Ae]?e.insRightOf(i):(r=o[De],void i.eachChild(function(s){var a=n(s);return t<a[De]?(t-r<a[De]-t?s[De]?e.insAtRightEnd(s[De]):e.insLeftOf(i):e.insAtLeftEnd(s),!1):t>a[Ae]?void(s[Ae]?r=a[Ae]:o[Ae]-t<t-a[Ae]?e.insRightOf(i):e.insAtRightEnd(s)):(s.seek(t,e),!1)}))},e.prototype.numBlocks=function(){return this.domView.childCount},e.prototype.html=function(){var t,e,r=this.blocks;return n("domView is defined",this.domView),t=this.domView,e=t.render(r||[]),this.setDOM(e),K.linkElementByCmdNode(e,this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.eachChild(function(e){var n,r;t.uncleanedLatex+="{",n=t.uncleanedLatex.length,e.latexRecursive(t),r=t.uncleanedLatex.length,n===r&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this,e=0;return t.foldChildren(t.textTemplate[e],function(n,r){e+=1;var i=r.text();return n&&"("===t.textTemplate[e]&&"("===i[0]&&")"===i.slice(-1)?n+i.slice(1,-1)+t.textTemplate[e]:n+i+(t.textTemplate[e]||"")})},e.prototype.mathspeak=function(){var t=this,e=0;return t.foldChildren(t.mathspeakTemplate[e]||"Start"+t.ctrlSeq+" ",function(n,r){return e+=1,n+" "+r.mathspeak()+" "+(t.mathspeakTemplate[e]+" "||"End"+t.ctrlSeq+" ")})},e}(Ot),Ft=function(t){function e(e,n,r,i){var o=t.call(this)||this;return o.setCtrlSeqHtmlTextAndMathspeak(e,n?new Ct(0,function(){return n.cloneNode(!0)}):void 0,r,i),o}return __extends(e,t),e.prototype.setCtrlSeqHtmlTextAndMathspeak=function(e,n,r,i){!r&&e&&(r=e.replace(/^\\/,"")),this.mathspeakName=i||r,t.prototype.setCtrlSeqHtmlAndText.call(this,e,n,[r||""])},e.prototype.parser=function(){return dt.succeed(this)},e.prototype.numBlocks=function(){return 0},e.prototype.replaces=function(t){t.remove()},e.prototype.createBlocks=function(){},e.prototype.moveTowards=function(t,e){e.domFrag().insDirOf(t,this.domFrag()),e[-t]=this,e[t]=this[t],e.controller.aria.queue(this)},e.prototype.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.prototype.seek=function(t,e){var n=this.domFrag().oneElement();return t-s(n).left<n.offsetWidth/2?e.insLeftOf(this):e.insRightOf(this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.checkCursorContextClose(t)},e.prototype.text=function(){return this.textTemplate.join("")},e.prototype.mathspeak=function(t){return this.mathspeakName||""},e.prototype.placeCursor=function(){},e.prototype.isEmpty=function(){return!0},e}(Tt),Dt=function(t){function e(e,n,r){return t.call(this,e,Ne("span",{},[n||Ne.text(e)]),void 0,r)||this}return __extends(e,t),e}(Ft),At=function(t){function e(e,n,r,i,o){return o?t.call(this,e,Ne("span",{},[n||Ne.text(e||"")]),void 0,i)||this:t.call(this,e,Ne("span",{class:"mq-binary-operator"},n?[n]:[]),r,i)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return!0},e}(Ft),Mt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ariaLabel="block",e}return __extends(e,t),e.prototype.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},e.prototype.html=function(){var t=document.createDocumentFragment();return this.eachChild(function(e){var n=e.html();t.appendChild(n)}),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.eachChild(function(e){return e.latexRecursive(t)}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this.getEnd(De);return t===this.getEnd(Ae)&&0!==t?t.text():this.join("text")},e.prototype.mathspeak=function(){var t="",e={};return this.controller&&(e=this.controller.options.autoOperatorNames),this.foldChildren([],function(n,r){var i,o,s;return r.isPartOfOperator?t+=r.mathspeak():(""!==t&&(e._maxLength>0&&"string"==typeof(i=e[t.toLowerCase()])&&(t=i),n.push(t+" "),t=""),o=r.mathspeak(),s=r.ctrlSeq,!isNaN(s)||"."===s||r.parent&&r.parent.parent&&r.parent.parent.isTextBlock()||(o=" "+o+" "),n.push(o)),n}).join("").replace(/ +(?= )/g,"").replace(/(\.)([0-9]+)/g,function(t,e,n){return e+n.split("").join(" ").trim()})},e.prototype.keystroke=function(e,n,r){return!r.options.spaceBehavesLikeTab||"Spacebar"!==e&&"Shift-Spacebar"!==e?t.prototype.keystroke.call(this,e,n,r):(null===n||void 0===n||n.preventDefault(),void r.escapeDir("Shift-Spacebar"===e?De:Ae,e,n))},e.prototype.moveOutOf=function(t,e,n){var r,i;"up"===n?r=this.parent.upInto:"down"===n&&(r=this.parent.downInto),!r&&this[t]?(i=-t,e.insAtDirEnd(i,this[t]),e.controller.aria.queueDirEndOf(i).queue(e.parent,!0)):(e.insDirOf(t,this.parent),e.controller.aria.queueDirOf(t).queue(this.parent))},e.prototype.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},e.prototype.deleteOutOf=function(t,e){e.unwrapGramp()},e.prototype.seek=function(t,e){var n,r,i=this.getEnd(Ae);if(!i)return e.insAtRightEnd(this);if(n=i.domFrag().oneElement(),s(n).left+n.offsetWidth<t)return e.insAtRightEnd(this);if(r=this.getEnd(De),t<s(r.domFrag().oneElement()).left)return e.insAtLeftEnd(this);for(;t<s(i.domFrag().oneElement()).left;)i=i[De];return i.seek(t,e)},e.prototype.chToCmd=function(t,e){var n;return t.match(/^[a-eg-zA-Z]$/)?new Ht(t):/^\d$/.test(t)?new zt(t):e&&e.typingSlashWritesDivisionSymbol&&"/"===t?Y["÷"](t):e&&e.typingAsteriskWritesTimesSymbol&&"*"===t?Y["×"](t):e&&e.typingPercentWritesPercentOf&&"%"===t?Y.percentof(t):(n=Z[t]||Y[t])?n.constructor?new n(t):n(t):new Dt(t)},e.prototype.write=function(t,e){var n=this.chToCmd(e,t.options);t.selection&&n.replaces(t.replaceSelection()),t.isTooDeep()||(n.createLeftOf(t.show()),"/"===e?t.controller.aria.alert("over"):t.controller.aria.alert(n.mathspeak({createdLeftOf:t})))},e.prototype.writeLatex=function(t,e){var n,r,i,o,s=dt.all,a=dt.eof,l=wt.skip(a).or(s.result(!1)).parse(e);l&&!l.isEmpty()&&l.prepareInsertionAt(t)&&(l.children().adopt(t.parent,t[De],t[Ae]),$(l.html()).insertBefore(t.domFrag()),t[De]=l.getEnd(Ae),l.finalizeInsert(t.options,t),n=l.getEnd(Ae),r=l.getEnd(De),i=n[Ae],o=r[De],i&&i.siblingCreated(t.options,De),o&&o.siblingCreated(t.options,Ae),t.parent.bubble(function(t){t.reflow()}))},e.prototype.focus=function(){return this.domFrag().addClass("mq-hasCursor"),this.domFrag().removeClass("mq-empty"),this},e.prototype.blur=function(t){return this.domFrag().removeClass("mq-hasCursor"),this.isEmpty()&&(this.domFrag().addClass("mq-empty"),t&&this.isQuietEmptyDelimiter(t.options.quietEmptyDelimiters)&&this.domFrag().addClass("mq-quiet-delimiter")),this},e}(Ot),st.prototype.mouseEvents=!0,rt.StaticMath=function(t){var e;return e=function(e){function n(n){var r=e.call(this,n)||this,i=r.innerFields=[];return r.__controller.root.postOrder(function(e){e.registerInnerField(i,t.InnerMathField)}),r}return __extends(n,e),n.prototype.__mathquillify=function(t,n){return this.config(t),e.prototype.mathquillify.call(this,"mq-math-mode"),this.__controller.setupStaticField(),this.__options.mouseEvents&&this.__controller.addMouseEventListener(),this.__controller.staticMathTextareaEvents(),this},n.prototype.latex=function(n){var r,i=e.prototype.latex.apply(this,arguments);return arguments.length>0&&(r=this.innerFields=[],this.__controller.root.postOrder(function(e){e.registerInnerField(r,t.InnerMathField)}),this.__controller.updateMathspeak()),i},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n}(t.AbstractMathQuill),e.RootBlock=Mt,e},It=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(Mt),y(It.prototype),rt.MathField=function(e){var n;return n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.__mathquillify=function(n,r){return this.config(n),r>1&&(this.__controller.root.reflow=t),e.prototype.mathquillify.call(this,"mq-editable-field mq-math-mode"),delete this.__controller.root.reflow,this},n}(e.EditableField),n.RootBlock=It,n},rt.InnerMathField=function(t){return n("MathField class is defined",t.MathField),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.makeStatic=function(){this.__controller.editable=!1,this.__controller.root.blur(),this.__controller.unbindEditablesEvents(),$(this.__controller.container).removeClass("mq-editable-field")},e.prototype.makeEditable=function(){this.__controller.editable=!0,this.__controller.editablesTextareaEvents(),this.__controller.cursor.insAtRightEnd(this.__controller.root),$(this.__controller.container).addClass("mq-editable-field")},e}(t.MathField)},Nt="\\ ",Bt=".",Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==De&&this[Ae]instanceof e||this.fixDigitGrouping(t)},e.prototype.fixDigitGrouping=function(t){var n,r;if(t.enableDigitGrouping){n=this,r=n;do{if(/^[0-9]$/.test(r.ctrlSeq))n=r;else if(r.ctrlSeq===Nt)n=r;else{if(r.ctrlSeq!==Bt)break;n=r}}while(r=n[De]);e.fixDigitGroupingFromLeft(t,n)}},e.fixDigitGroupingFromLeft=function(t,r){for(var i,o,s,a,l,c,u,p,h;r&&r.ctrlSeq===Nt;){if(!r[Ae])return;r=r[Ae]}if(r instanceof e){i=r,n("node",i),o=r,s=0,a=0,l=[];do{if(/^[0-9]$/.test(i.ctrlSeq))o=i,a=0;else if(i.ctrlSeq===Nt)o=i,s+=1,a=0;else{if(!(i.ctrlSeq===Bt&&i instanceof e))break;o=i,l.push(i),t.tripleDotsAreEllipsis&&(a+=1)}if(3==a)break}while(i=o[Ae]);if(3!==a||(c=l.pop(),u=l.pop(),p=l.pop(),c[Ae]instanceof e&&e.fixDigitGroupingFromLeft(t,c[Ae]),c.setGroupingClass("mq-ellipsis-end"),u.setGroupingClass("mq-ellipsis-middle"),p.setGroupingClass("mq-ellipsis-start"),o=p[De],r!==p)){for(;o!==r&&o&&o.ctrlSeq===Nt;)o=o[De],s-=1;r===o&&r&&r.ctrlSeq===Nt||(h=s>0||l.length>1,h?e.removeGroupingBetween(r,o):l[0]?(l[0]!==r&&e.addGroupingBetween(l[0][De],r),l[0]!==o&&e.removeGroupingBetween(l[0],o)):e.addGroupingBetween(o,r))}}},e.removeGroupingBetween=function(t,n){var r=t;do{if(r instanceof e&&r.setGroupingClass(void 0),!r||r===n)break}while(r=r[Ae])},e.addGroupingBetween=function(t,r){for(var i,o,s=t,a=0,l=0;s&&(l+=1,n("digit",s instanceof e),s!==r);)s=s[De];for(i=l%3,0===i&&(i=3),s=t;s&&(a+=1,o=void 0,l>=4&&(a===l?o="mq-group-leading-"+i:a%3==0&&a!==l&&(o="mq-group-start"),o||(o="mq-group-other")),s instanceof e&&s.setGroupingClass(o),s!==r);)s=s[De]},e.prototype.setGroupingClass=function(t){this._groupingClass!==t&&(this._groupingClass&&this.domFrag().removeClass(this._groupingClass),t&&this.domFrag().addClass(t),this._groupingClass=t)},e}(Ft),zt=function(t){function e(e,n){return t.call(this,e,Ne("span",{class:"mq-digit"},[Ne.text(e)]),void 0,n)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[De],r=n&&n[De],i=e.parent.parent instanceof ce?e.parent.parent.sub:void 0;e.options.autoSubscriptNumerals&&e.parent!==i&&(n instanceof Pt&&!1!==n.isItalic||n instanceof ce&&r instanceof Pt&&!1!==r.isItalic)?(new ce("sub").createLeftOf(e),t.prototype.createLeftOf.call(this,e),e.insRightOf(e.parent.parent)):t.prototype.createLeftOf.call(this,e)},e.prototype.mathspeak=function(e){var n,r,i,o;return e&&e.createdLeftOf&&(n=e.createdLeftOf,r=n[De],i=r&&r[De],o=n.parent.parent instanceof ce?n.parent.parent.sub:void 0,n.options.autoSubscriptNumerals&&n.parent!==o&&(r instanceof Pt&&!1!==r.isItalic||n[De]instanceof ce&&i instanceof Pt&&!1!==i.isItalic))?"Subscript "+t.prototype.mathspeak.call(this)+" Baseline":t.prototype.mathspeak.call(this)},e}(Rt),Pt=function(t){function e(e,n){return t.call(this,e,Ne("var",{},[n||Ne.text(e)]))||this}return __extends(e,t),e.prototype.text=function(){var t=this.ctrlSeq||"";return this.isPartOfOperator?"\\"==t[0]?t=t.slice(1,t.length):" "==t[t.length-1]&&(t=t.slice(0,-1)):(!this[De]||this[De]instanceof e||this[De]instanceof At||"\\ "===this[De].ctrlSeq||(t="*"+t),!this[Ae]||this[Ae]instanceof At||this[Ae]instanceof ce||(t+="*")),t},e.prototype.mathspeak=function(){var e=this.ctrlSeq||"";return this.isPartOfOperator||e.length>1||this.parent&&this.parent.parent&&this.parent.parent.isTextBlock()?t.prototype.mathspeak.call(this):'"'+e+'"'},e}(Ft),st.prototype.autoCommands={_maxLength:0},ot.autoCommands=function(t){var e,n,r,i,o;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,i=0;i<e.length;i+=1){if(o=e[i],o.length<2)throw'autocommand "'+o+'" not minimum length of 2';if(Y[o]===Vt)throw'"'+o+'" is a built-in operator name';n[o]=1,r=Ie(r,o.length)}return n._maxLength=r,n},st.prototype.quietEmptyDelimiters={},ot.quietEmptyDelimiters=function(t){var e,n,r,i;for(void 0===t&&(t=""),e=t.split(" "),n={},r=0;r<e.length;r+=1)i=e[r],n[i]=1;return n},st.prototype.autoParenthesizedFunctions={_maxLength:0},ot.autoParenthesizedFunctions=function(t){var e,n,r,i,o;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,i=0;i<e.length;i+=1){if(o=e[i],o.length<2)throw'autocommand "'+o+'" not minimum length of 2';n[o]=1,r=Ie(r,o.length)}return n._maxLength=r,n},Ht=function(t){function e(e){var n=t.call(this,e)||this;return n.letter=e,n}return __extends(e,t),e.prototype.checkAutoCmds=function(t){var e,n,r,i,o,s,a,l;if(!this.shouldIgnoreSubstitutionInSimpleSubscript(t.options)&&(n=t.options.autoCommands,(r=n._maxLength||0)>0))for(i=null!==(e=_(this,r))&&void 0!==e?e:"";i.length;){if(n.hasOwnProperty(i)){for(o=this,s=1;o&&s<i.length;s+=1,o=o[De]);return new X(o,this).remove(),t[De]=o[De],a=Y[i],l=f(a)?new a(i):a(i),l.createLeftOf(t)}i=i.slice(1)}},e.prototype.autoParenthesize=function(t){var n,r,i,o,s,a,l=t.parent.getEnd(Ae);if(!(l&&l instanceof ke&&"\\left("===l.ctrlSeq||this.shouldIgnoreSubstitutionInSimpleSubscript(t.options))){for(n="",r=this,i=0,o=t.options.autoParenthesizedFunctions,s=o._maxLength||0,a=t.options.autoOperatorNames;r instanceof e&&i<s;)n=r.letter+n,r=r[De],i+=1;for(;n.length;){if(o.hasOwnProperty(n)&&a.hasOwnProperty(n))return t.parent.write(t,"(");n=n.slice(1)}}},e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),this.checkAutoCmds(e),this.autoParenthesize(e)},e.prototype.italicize=function(t){return this.isItalic=t,this.isPartOfOperator=!t,t&&(delete this.endsCategory,delete this.endsWord),this.domFrag().toggleClass("mq-operator-name",!t),this},e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==De&&this[Ae]instanceof e||this.autoUnItalicize(t)},e.prototype.autoUnItalicize=function(t){var n,r,i,o,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b=t.autoOperatorNames;if(0!==b._maxLength&&!this.shouldIgnoreSubstitutionInSimpleSubscript(t)){for(n=this.letter,r=this[De];r instanceof e;r=r[De])n=r.letter+n;for(i=this[Ae];i instanceof e;i=i[Ae])n+=i.letter;o=r&&r[Ae],s=i&&i[De],new X(o||this.parent.getEnd(De),s||this.parent.getEnd(Ae)).each(function(t){t instanceof e&&(t.italicize(!0).domFrag().removeClass("mq-first mq-last mq-followed-by-supsub"),t.ctrlSeq=t.letter)}),a=b._maxLength||0;t:for(l=0,c=r[Ae]||this.parent.getEnd(De);c&&l<n.length;l+=1,c=c[Ae])for(u=Me(a,n.length-l);u>0;u-=1)if(p=n.slice(l,l+u),h=void 0,b.hasOwnProperty(p)){for(d=0,f=c;d<u;d+=1,f=f[Ae])f instanceof e&&(f.italicize(!1),h=f);m=jt.hasOwnProperty(p),c.ctrlSeq=(m?"\\":"\\operatorname{")+c.ctrlSeq,h.ctrlSeq+=m?" ":"}",h.endsWord=p,t.infixOperatorNames[p]?h.endsCategory="infix":t.prefixOperatorNames[p]&&(h.endsCategory="prefix"),Gt.hasOwnProperty(p)&&(g=h[De],y=g&&g[De],v=y&&y[De],v.domFrag().addClass("mq-last")),this.shouldOmitPadding(c[De])||c.domFrag().addClass("mq-first"),this.shouldOmitPadding(h[Ae])||(h[Ae]instanceof ce?(x=h[Ae],(x.siblingCreated=x.siblingDeleted=function(){x.domFrag().toggleClass("mq-after-operator-name",!(x[Ae]instanceof ke))})()):h.domFrag().toggleClass("mq-last",!(h[Ae]instanceof ke))),l+=u-1,c=h;continue t}}},e.prototype.shouldOmitPadding=function(t){return!t||("."===t.ctrlSeq||(!!(t instanceof At&&t.isBinaryOperator())||t instanceof de))},e}(Pt),jt={},st.prototype.autoOperatorNames=function(){var t,e,n,r,i={_maxLength:9},o="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<o.length;t+=1)jt[o[t]]=i[o[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)jt[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)i[n[t]]=i["arc"+n[t]]=i[n[t]+"h"]=i["ar"+n[t]+"h"]=i["arc"+n[t]+"h"]=1;for(r="gcf hcf lcm proj span".split(" "),t=0;t<r.length;t+=1)i[r[t]]=1;return i}(),Gt={limsup:1,liminf:1,projlim:1,injlim:1},ot.autoOperatorNames=function(t){var e,n,r,i,o,s;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z\|\-]+(?: [a-z\|\-]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters or "|"';for(e=t.split(" "),n={},r=0,i=0;i<e.length;i+=1){if(o=e[i],o.length<2)throw'"'+o+'" not minimum length of 2';if(o.indexOf("|")<0)n[o]=o,r=Ie(r,o.length);else{if(s=o.split("|"),s.length>2)throw'"'+o+'" has more than 1 mathspeak delimiter';if(s[0].length<2)throw'"'+o[0]+'" not minimum length of 2';n[s[0]]=s[1].replace(/-/g," "),r=Ie(r,s[0].length)}}return n._maxLength=r,n},st.prototype.infixOperatorNames={},ot.infixOperatorNames=q,st.prototype.prefixOperatorNames={},ot.prefixOperatorNames=q,st.prototype.disableAutoSubstitutionInSubscripts=!1,ot.disableAutoSubstitutionInSubscripts=function(t){if("boolean"==typeof t)return t;if("object"!=typeof t||null===t||!("except"in t))throw'"'+t+'" not an object with property "except"';return{except:q(t.except)}},Vt=function(t){function e(e){return t.call(this,e||"")||this}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n=this.ctrlSeq;for(e=0;e<n.length;e+=1)new Ht(n.charAt(e)).createLeftOf(t)},e.prototype.parser=function(){var t,e=this.ctrlSeq,n=new Mt;for(t=0;t<e.length;t+=1)new Ht(e.charAt(t)).adopt(n,n.getEnd(Ae),0);return dt.succeed(n.children())},e}(Ft);for(Wt in st.prototype.autoOperatorNames)st.prototype.autoOperatorNames.hasOwnProperty(Wt)&&(Y[Wt]=Vt);if(Y.operatorname=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(){},e.prototype.numBlocks=function(){return 1},e.prototype.parser=function(){return wt.block.map(function(t){var e=!0,n="",r=t.children();return r.each(function(t){t instanceof Ht?n+=t.letter:e=!1}),e&&"ans"===n?ge():r})},e}(Tt),Y.f=function(t){function e(){var e=this,n="f";return e=t.call(this,n)||this,e.letter=n,e.domView=new Ct(0,function(){return Ne("var",{class:"mq-f"},[Ne.text("f")])}),e}return __extends(e,t),e.prototype.italicize=function(e){return this.domFrag().eachElement(function(t){return t.textContent="f"}),this.domFrag().toggleClass("mq-f",e),t.prototype.italicize.call(this,e)},e}(Ht),Y[" "]=Y.space=function(){return new Rt("\\ ",Ne("span",{},[Ne.text(B)])," ")},Y["."]=function(){return new Rt(".",Ne("span",{class:"mq-digit"},[Ne.text(".")]),".")},Y["'"]=Y.prime=k("'","&prime;","prime"),Y["″"]=Y.dprime=k("″","&Prime;","double prime"),Y.backslash=k("\\backslash ","\\","backslash"),Z["\\"]||(Z["\\"]=Y.backslash),Y.$=k("\\$","$","dollar"),Y["?"]=k("?","?","question mark"),Y["□"]=Y.square=k("\\square ","□","square"),Y.mid=k("\\mid ","∣","mid"),Qt=function(t){function e(e,n){return t.call(this,e,Ne("span",{class:n},[Ne.text(e)]))||this}return __extends(e,t),e}(Ft),Y[","]=function(){return new Qt(",","mq-comma")},$t=function(t){function e(e,n,r){return t.call(this,e,Ne("span",{class:"mq-nonSymbola"},[n||Ne.text(e)]))||this}return __extends(e,t),e}(Ft),Y["@"]=function(){return new $t("@")},Y["&"]=function(){return new $t("\\&",Ne.entityText("&amp;"),"and")},Y["%"]=function(t){function e(){return t.call(this,"\\%",Ne.text("%"),"percent")||this}return __extends(e,t),e.prototype.parser=function(){var e=dt.optWhitespace,n=dt.string;return e.then(n("\\operatorname{of}").map(function(){return ye()})).or(t.prototype.parser.call(this))},e}($t),Y["∥"]=Y.parallel=k("\\parallel ","&#x2225;","parallel"),Y["∦"]=Y.nparallel=k("\\nparallel ","&#x2226;","not parallel"),Y["⟂"]=Y.perp=k("\\perp ","&#x27C2;","perpendicular"),Y["α"]=Y.alpha=O("alpha"),Y["β"]=Y.beta=O("beta"),Y["γ"]=Y.gamma=O("gamma"),Y["δ"]=Y.delta=O("delta"),Y["ζ"]=Y.zeta=O("zeta"),Y["η"]=Y.eta=O("eta"),Y["θ"]=Y.theta=O("theta"),Y["ι"]=Y.iota=O("iota"),Y["κ"]=Y.kappa=O("kappa"),Y["μ"]=Y.mu=O("mu"),Y["ν"]=Y.nu=O("nu"),Y["ξ"]=Y.xi=O("xi"),Y["ρ"]=Y.rho=O("rho"),Y["σ"]=Y.sigma=O("sigma"),Y["τ"]=Y.tau=O("tau"),Y["χ"]=Y.chi=O("chi"),Y["ψ"]=Y.psi=O("psi"),Y["ω"]=Y.omega=O("omega"),Y["ϕ"]=Y.phi=S("\\phi ","&#981;","phi"),Y["φ"]=Y.phiv=Y.varphi=S("\\varphi ","&phi;","phi"),Y["ϵ"]=Y.epsilon=S("\\epsilon ","&#1013;","epsilon"),Y["ε"]=Y.epsiv=Y.varepsilon=S("\\varepsilon ","&epsilon;","epsilon"),Y["ϖ"]=Y.piv=Y.varpi=S("\\varpi ","&piv;","piv"),Y["ς"]=Y.sigmaf=Y.sigmav=Y.varsigma=S("\\varsigma ","&sigmaf;","sigma"),Y["ϑ"]=Y.thetav=Y.vartheta=Y.thetasym=S("\\vartheta ","&thetasym;","theta"),Y["υ"]=Y.upsilon=Y.upsi=S("\\upsilon ","&upsilon;","upsilon"),Y["Ϝ"]=Y.gammad=Y.Gammad=Y.digamma=S("\\digamma ","&#989;","gamma"),Y["ϰ"]=Y.kappav=Y.varkappa=S("\\varkappa ","&#1008;","kappa"),Y["ϱ"]=Y.rhov=Y.varrho=S("\\varrho ","&#1009;","rho"),Y.pi=Y["π"]=function(){return new $t("\\pi ",Ne.entityText("&pi;"),"pi")},Y["λ"]=Y.lambda=function(){return new $t("\\lambda ",Ne.entityText("&lambda;"),"lambda")},Y["Υ"]=Y.Upsilon=Y.Upsi=Y.upsih=Y.Upsih=function(){return new Ft("\\Upsilon ",Ne("var",{style:"font-family: serif"},[Ne.entityText("&upsih;")]),"capital upsilon")},Y["Γ"]=Y.Gamma=C("Gamma"),Y["Δ"]=Y.Delta=C("Delta"),Y["Θ"]=Y.Theta=C("Theta"),Y["Λ"]=Y.Lambda=C("Lambda"),Y["Ξ"]=Y.Xi=C("Xi"),Y["Π"]=Y.Pi=C("Pi"),Y["Σ"]=Y.Sigma=C("Sigma"),Y["Φ"]=Y.Phi=C("Phi"),Y["Ψ"]=Y.Psi=C("Psi"),Y["Ω"]=Y.Omega=C("Omega"),Y["∀"]=Y.forall=C("forall"),Ut=function(t){function e(e){var n=t.call(this)||this;return n.latexStr=e,n}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n,r,i,o=wt.parse(this.latexStr);o.children().adopt(t.parent,t[De],t[Ae]),t[De]=o.getEnd(Ae),$(o.html()).insertBefore(t.domFrag()),o.finalizeInsert(t.options,t),e=o.getEnd(Ae),n=e&&e[Ae],n&&n.siblingCreated(t.options,De),r=o.getEnd(De),i=r&&r[De],i&&i.siblingCreated(t.options,Ae),t.parent.bubble(function(t){t.reflow()})},e.prototype.mathspeak=function(){return wt.parse(this.latexStr).mathspeak()},e.prototype.parser=function(){var t=wt.parse(this.latexStr).children();return dt.succeed(t)},e}(Tt),Y["⁰"]=function(){return new Ut("^0")},Y["¹"]=function(){return new Ut("^1")},Y["²"]=function(){return new Ut("^2")},Y["³"]=function(){return new Ut("^3")},Y["⁴"]=function(){return new Ut("^4")},Y["⁵"]=function(){return new Ut("^5")},Y["⁶"]=function(){return new Ut("^6")},Y["⁷"]=function(){return new Ut("^7")},Y["⁸"]=function(){return new Ut("^8")},Y["⁹"]=function(){return new Ut("^9")},Y["¼"]=function(){return new Ut("\\frac14")},Y["½"]=function(){return new Ut("\\frac12")},Y["¾"]=function(){return new Ut("\\frac34")},Y["√"]=function(){return new Ut("\\sqrt{}")},Kt=function(t){function e(e,n,r){return t.call(this,e,n,void 0,r,!0)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return F(this)},e.prototype.contactWeld=function(t,e){this.sharedSiblingMethod(t.options,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,e){if(e!==Ae)return this.domFrag().oneElement().className=F(this)?"mq-binary-operator":"",this},e}(At),Y["+"]=function(t){function e(){return t.call(this,"+",Ne.text("+"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return F(this)?"plus":"positive"},e}(Kt),Xt=function(t){function e(){return t.call(this,"-",Ne.entityText("&minus;"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return F(this)?"minus":"negative"},e}(Kt),Y["−"]=Y["—"]=Y["–"]=Y["-"]=Xt,Y["±"]=Y.pm=Y.plusmn=Y.plusminus=function(){return new Kt("\\pm ",Ne.entityText("&plusmn;"),"plus-or-minus")},Y.mp=Y.mnplus=Y.minusplus=function(){
13
- return new Kt("\\mp ",Ne.entityText("&#8723;"),"minus-or-plus")},Z["*"]=Y.sdot=Y.cdot=L("\\cdot ","&middot;","*","times"),Yt=function(t){function e(){return t.call(this,"\\to ",Ne.entityText("&rarr;"),"to")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===De){var r=n[De];return new X(r,this).remove(),n[De]=r[De],(new Xt).createLeftOf(n),void n[De].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(At),Y["→"]=Y.to=Yt,Zt=function(t){function e(e,n){var r=this,i=n?"Strict":"";return r=t.call(this,e["ctrlSeq".concat(i)],Ne.entityText(e["htmlEntity".concat(i)]),e["text".concat(i)],e["mathspeak".concat(i)])||this,r.data=e,r.strict=n,r}return __extends(e,t),e.prototype.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq".concat(e)],this.domFrag().children().replaceWith($(Ne.entityText(this.data["htmlEntity".concat(e)]))),this.textTemplate=[this.data["text".concat(e)]],this.mathspeakName=this.data["mathspeak".concat(e)]},e.prototype.deleteTowards=function(e,n){if(e===De&&!this.strict)return this.swap(!0),void this.bubble(function(t){t.reflow()});t.prototype.deleteTowards.call(this,e,n)},e}(At),Jt={ctrlSeq:"\\le ",htmlEntity:"&le;",text:"≤",mathspeak:"less than or equal to",ctrlSeqStrict:"<",htmlEntityStrict:"&lt;",textStrict:"<",mathspeakStrict:"less than"},te={ctrlSeq:"\\ge ",htmlEntity:"&ge;",text:"≥",mathspeak:"greater than or equal to",ctrlSeqStrict:">",htmlEntityStrict:"&gt;",textStrict:">",mathspeakStrict:"greater than"},ee=function(t){function e(){return t.call(this,te,!0)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r=e[De];if(r instanceof At&&"-"===r.ctrlSeq)return n=r,e[De]=n[De],n.remove(),(new Yt).createLeftOf(e),void e[De].bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Zt),Y["<"]=Y.lt=function(){return new Zt(Jt,!0)},Y[">"]=Y.gt=ee,Y["≤"]=Y.le=Y.leq=function(){return new Zt(Jt,!1)},Y["≥"]=Y.ge=Y.geq=function(){return new Zt(te,!1)},Y["∞"]=Y.infty=Y.infin=Y.infinity=k("\\infty ","&infin;","infinity"),Y["≠"]=Y.ne=Y.neq=L("\\ne ","&ne;","not equal"),ne=function(t){function e(){return t.call(this,"=",Ne.text("="),"=","equals")||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[De];if(n instanceof Zt&&n.strict)return n.swap(!1),void n.bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(At),Y["="]=ne,Y["×"]=Y.times=Y.cross=L("\\times ","&times;","[x]","times"),Y["÷"]=Y.div=Y.divide=Y.divides=L("\\div ","&divide;","[/]","divided by"),re=function(t){function e(){return t.call(this,"\\sim ",Ne.text("~"),"~","tilde")||this}return __extends(e,t),e.prototype.createLeftOf=function(n){if(n[De]instanceof e){var r=n[De];return n[De]=r[De],r.remove(),(new ie).createLeftOf(n),void n[De].bubble(function(t){t.reflow()})}t.prototype.createLeftOf.call(this,n)},e}(At),ie=function(t){function e(){return t.call(this,"\\approx ",Ne.entityText("&approx;"),"≈","approximately equal")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===De){var r=n[De];return new X(r,this).remove(),n[De]=r[De],(new re).createLeftOf(n),void n[De].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(At),Y.tildeNbsp=k("~",B," "),Y.sim=re,Y["≈"]=Y.approx=ie,Z["~"]=Y.sim,Y["~"]=Y.tildeNbsp,ot.interpretTildeAsSim=function(t){var e=!!t;return Y["~"]=e?Y.sim:Y.tildeNbsp,e},Y["◯"]=Y.bigcirc=k("\\bigcirc ","&#9711;","circle"),Y["∠"]=Y.ang=Y.angle=k("\\angle ","&ang;","angle"),Y["°"]=Y.degree=k("\\degree ","&deg;","degrees"),Y["△"]=Y.triangle=k("\\triangle ","&#9651;","triangle"),Y["≅"]=Y.cong=L("\\cong ","&cong;","cong","congruent"),Y["∡"]=Y.measuredangle=k("\\measuredangle ","&#8737;","measured angle"),Y["▱"]=Y.parallelogram=k("\\parallelogram ","&#9649;","parallelogram"),Y["≇"]=Y.ncong=L("\\ncong ","&ncong;","ncong","not congruent"),Y["≁"]=Y.nsim=L("\\nsim ","&nsim;","nsim","not similar"),oe={sqrt:{width:"",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 32 54"},[Ne("path",{d:"M0 33 L7 27 L12.5 47 L13 47 L30 0 L32 0 L13 54 L11 54 L4.5 31 L0 33"})])}},"|":{width:".4em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Ne("path",{d:"M4.4 0 L4.4 54 L5.6 54 L5.6 0"})])}},"[":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Ne("path",{d:"M8 0 L3 0 L3 24 L8 24 L8 23 L4 23 L4 1 L8 1"})])}},"]":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Ne("path",{d:"M3 0 L8 0 L8 24 L3 24 L3 23 L7 23 L7 1 L3 1"})])}},"(":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Ne("path",{d:"M85 0 A61 101 0 0 0 85 186 L75 186 A75 101 0 0 1 75 0"})])}},")":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Ne("path",{d:"M24 0 A61 101 0 0 1 24 186 L34 186 A75 101 0 0 0 34 0"})])}},"{":{width:".7em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Ne("path",{d:"M170 0 L170 6 A47 52 0 0 0 123 60 L123 127 A35 48 0 0 1 88 175 A35 48 0 0 1 123 223 L123 290 A47 52 0 0 0 170 344 L170 350 L160 350 A58 49 0 0 1 102 301 L103 220 A45 40 0 0 0 58 180 L58 170 A45 40 0 0 0 103 130 L103 49 A58 49 0 0 1 161 0"})])}},"}":{width:".7em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Ne("path",{d:"M60 0 L60 6 A47 52 0 0 1 107 60 L107 127 A35 48 0 0 0 142 175 A35 48 0 0 0 107 223 L107 290 A47 52 0 0 1 60 344 L60 350 L70 350 A58 49 0 0 0 128 301 L127 220 A45 40 0 0 1 172 180 L172 170 A45 40 0 0 1 127 130 L127 49 A58 49 0 0 0 70 0"})])}},"&#8741;":{width:".7em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Ne("path",{d:"M3.2 0 L3.2 54 L4 54 L4 0 M6.8 0 L6.8 54 L6 54 L6 0"})])}},"&lang;":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Ne("path",{d:"M6.8 0 L3.2 27 L6.8 54 L7.8 54 L4.2 27 L7.8 0"})])}},"&rang;":{width:".55em",html:function(){return Ne("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Ne("path",{d:"M3.2 0 L6.8 27 L3.2 54 L2.2 54 L5.8 27 L2.2 0"})])}}},se="➤",ae=function(t){function e(e,n,r,i,o){var s=t.call(this,e,new Ct(1,function(t){var e,i;return Ne.block(n,r,t[0],{beforeChild:null===(e=null===o||void 0===o?void 0:o.beforeChild)||void 0===e?void 0:e.call(o),afterChild:null===(i=null===o||void 0===o?void 0:o.afterChild)||void 0===i?void 0:i.call(o)})}))||this;return s.ariaLabel=i||e.replace(/^\\/,""),s.mathspeakTemplate=["Start"+s.ariaLabel+",","End"+s.ariaLabel],s.shouldNotSpeakDelimiters=o&&o.shouldNotSpeakDelimiters,s}return __extends(e,t),e.prototype.mathspeak=function(e){return!this.shouldNotSpeakDelimiters||e&&e.ignoreShorthand?t.prototype.mathspeak.call(this):this.foldChildren("",function(t,n){return t+" "+n.mathspeak(e)}).trim()},e}(Tt),Y.mathrm=function(t){function e(){return t.call(this,"\\mathrm","span",{class:"mq-roman mq-font"},"Roman Font",{shouldNotSpeakDelimiters:!0})||this}return __extends(e,t),e.prototype.isTextBlock=function(){return!0},e}(ae),Y.mathit=function(){return new ae("\\mathit","i",{class:"mq-font"},"Italic Font")},Y.mathbf=function(){return new ae("\\mathbf","b",{class:"mq-font"},"Bold Font")},Y.mathsf=function(){return new ae("\\mathsf","span",{class:"mq-sans-serif mq-font"},"Serif Font")},Y.mathtt=function(){return new ae("\\mathtt","span",{class:"mq-monospace mq-font"},"Math Text")},Y.underline=function(){return new ae("\\underline","span",{class:"mq-non-leaf mq-underline"},"Underline")},Y.overline=Y.bar=function(){return new ae("\\overline","span",{class:"mq-non-leaf mq-overline"},"Overline")},Y.overrightarrow=function(){return new ae("\\overrightarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Right Arrow",{afterChild:function(){return Ne("span",{class:"mq-arrow-right-content"},[Ne.text(se)])}})},Y.overleftarrow=function(){return new ae("\\overleftarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Left Arrow",{beforeChild:function(){return Ne("span",{class:"mq-arrow-left-content"},[Ne.text(se)])}})},Y.overleftrightarrow=function(){return new ae("\\overleftrightarrow ","span",{class:"mq-non-leaf mq-overarrow"},"Over Left and Right Arrow",{beforeChild:function(){return Ne("span",{class:"mq-arrow-left-content"},[Ne.text(se)])},afterChild:function(){return Ne("span",{class:"mq-arrow-right-content"},[Ne.text(se)])}})},Y.overarc=function(){return new ae("\\overarc","span",{class:"mq-non-leaf mq-overarc"},"Over Arc")},Y.dot=function(){return new Tt("\\dot",new Ct(1,function(t){return Ne("span",{class:"mq-non-leaf"},[Ne("span",{class:"mq-dot-recurring-inner"},[Ne("span",{class:"mq-dot-recurring"},[Ne.text(z)]),Ne.block("span",{class:"mq-empty-box"},t[0])])])}))},Y.textcolor=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setColor=function(t){this.color=t,this.domView=new Ct(1,function(e){return Ne.block("span",{class:"mq-textcolor",style:"color:"+t},e[0])}),this.ariaLabel=t.replace(/^\\/,""),this.mathspeakTemplate=["Start "+this.ariaLabel+",","End "+this.ariaLabel]},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\textcolor{"+this.color+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.parser=function(){var e=this,n=dt.optWhitespace,r=dt.string,i=dt.regex;return n.then(r("{")).then(i(/^[#\w\s.,()%-]*/)).skip(r("}")).then(function(n){return e.setColor(n),t.prototype.parser.call(e)})},e.prototype.isStyleBlock=function(){return!0},e}(Tt),Y.class=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var e=this,n=dt.string,r=dt.regex;return dt.optWhitespace.then(n("{")).then(r(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return e.cls=n||"",e.domView=new Ct(1,function(t){return Ne.block("span",{class:"mq-class ".concat(n)},t[0])}),e.ariaLabel=n+" class",e.mathspeakTemplate=["Start "+e.ariaLabel+",","End "+e.ariaLabel],t.prototype.parser.call(e)})},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\class{"+this.cls+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.isStyleBlock=function(){return!0},e}(Tt),le=/^[\+\-]?[\d]+$/,st.prototype.charsThatBreakOutOfSupSub="",ce=function(t){function e(e){var n,r=this;return n="sub"===e?new Ct(1,function(t){return Ne("span",{class:"mq-supsub mq-non-leaf"},[Ne.block("span",{class:"mq-sub"},t[0]),Ne("span",{style:"display:inline-block;width:0"},[Ne.text(R)])])}):new Ct(1,function(t){return Ne("span",{class:"mq-supsub mq-non-leaf mq-sup-only"},[Ne.block("span",{class:"mq-sup"},t[0])])}),r=t.call(this,"_{...}^{...}",n)||this,r.ariaLabel="sub"===e?"subscript":"superscript",r.supsub=e,r}return __extends(e,t),e.prototype.setEnds=function(t){n("SupSub ends must be MathBlocks",t[De]instanceof Mt&&t[Ae]instanceof Mt),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.createLeftOf=function(e){if(this.replacedFragment||e[De]||!e.options.supSubsRequireOperand)return t.prototype.createLeftOf.call(this,e)},e.prototype.contactWeld=function(t){var n,r,i,o,s,a,l;for(n=De;n;n=n===De&&Ae)if(r=this[n],i=void 0,r instanceof e){for(o="sub";o;o="sub"===o&&"sup")s=this[o],a=r[o],s&&(a?s.isEmpty()?i=new U(a,0,a.getEnd(De)):(s.domFrag().children().insAtDirEnd(-n,a.domFrag().oneElement()),l=s.children().disown(),i=new U(a,l.getEnd(Ae),a.getEnd(De)),n===De?l.adopt(a,a.getEnd(Ae),0):l.adopt(a,0,a.getEnd(De))):r.addBlock(s.disown()),this.placeCursor=function(t,e){return function(r){r.insAtDirEnd(-n,t||e)}}(a,s));this.remove(),t&&t[De]===this&&(n===Ae&&i?i[De]?t.insRightOf(i[De]):t.insAtLeftEnd(i.parent):t.insRightOf(r));break}},e.prototype.finalizeTree=function(){"sub"===this.supsub?(this.downInto=this.sub=this.getEnd(De),this.sub.upOutOf=A):"sup"===this.supsub&&(this.upInto=this.sup=this.getEnd(Ae),this.sup.downOutOf=A),this.getEnd(De).write=function(t,e){if(t.options.autoSubscriptNumerals&&this===this.parent.sub&&"0123456789".indexOf(e)>=0){var n=this.chToCmd(e,t.options);return n instanceof Ft?t.deleteSelection():t.clearSelection().insRightOf(this.parent),n.createLeftOf(t.show()),void t.controller.aria.queue("Baseline").alert(n.mathspeak({createdLeftOf:t}))}t[De]&&!t[Ae]&&!t.selection&&t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&(t.insRightOf(this.parent),t.controller.aria.queue("Baseline")),Mt.prototype.write.call(this,t,e)}},e.prototype.moveTowards=function(e,n,r){n.options.autoSubscriptNumerals&&!this.sup?n.insDirOf(e,this):t.prototype.moveTowards.call(this,e,n,r)},e.prototype.deleteTowards=function(e,n){if(n.options.autoSubscriptNumerals&&this.sub){var r=this.sub.getEnd(-e);r instanceof Ft?r.remove():r&&r.deleteTowards(e,n.insAtDirEnd(-e,this.sub)),this.sub.isEmpty()&&(this.sub.deleteOutOf(De,n.insAtLeftEnd(this.sub)),this.sup&&n.insDirOf(-e,this))}else t.prototype.deleteTowards.call(this,e,n)},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),this.sub&&(t.uncleanedLatex+="_{",e=t.uncleanedLatex.length,this.sub.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.sup&&(t.uncleanedLatex+="^{",e=t.uncleanedLatex.length,this.sup.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r;return void 0===this.sup||(n=D(this.sup),e&&e.ignoreShorthand||!le.test(n))?(this.mathspeakTemplate=this.getMathspeakTemplate(),t.prototype.mathspeak.call(this)):(r="",this.sub&&(r=ue[0]+" "+this.sub.mathspeak()+" "+ue[1]+" "),r+M(this.sup,n))},e.prototype.getMathspeakTemplate=function(){return this.sub&&this.sup?he:this.sup?pe:ue},e.prototype.text=function(){function t(t,e){var n=e&&e.text()||"";return e?t+(1===n.length?n:"("+(n||" ")+")"):""}return t("_",this.sub)+t("^",this.sup)},e.prototype.addBlock=function(t){var e,n,r;for("sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.setDOM($(Ne("span",{class:"mq-sup"})).append(t.domFrag().children()).prependTo(this.domFrag().oneElement()).oneElement()),K.linkElementByBlockNode(t.domFrag().oneElement(),t)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,this.domFrag().removeClass("mq-sup-only"),t.setDOM($(Ne("span",{class:"mq-sub"})).append(t.domFrag().children()).appendTo(this.domFrag().oneElement()).oneElement()),K.linkElementByBlockNode(t.domFrag().oneElement(),t),this.domFrag().append($(Ne("span",{style:"display:inline-block;width:0"},[Ne.text(R)])))),e=function(t){var e=n,r=["sub","sup"][t],i=["sup","sub"][t],o=["down","up"][t];e[r].deleteOutOf=function(t,n){var s,a;n.insDirOf(this[t]?-t:t,this.parent),this.isEmpty()||(s=this.getEnd(t),this.children().disown().withDirAdopt(t,n.parent,n[t],n[-t]).domFrag().insDirOf(-t,n.domFrag()),n[-t]=s),e.supsub=i,delete e[r],delete e["".concat(o,"Into")],a=e[i],a["".concat(o,"OutOf")]=A,delete a.deleteOutOf,"sub"===r&&e.domFrag().addClass("mq-sup-only").children().last().remove(),this.remove()}},n=this,r=0;r<2;r+=1)e(r)},e}(Tt),ue=["Subscript,",", Baseline"],pe=["Superscript,",", Baseline"],he=["Subscript,",", Baseline Superscript,",", Baseline"],Y.subscript=Y._=function(){return new ce("sub")},Y.superscript=Y.supscript=Y["^"]=function(){return new ce("sup")},de=function(t){function e(e,n,r){var i,o=t.call(this)||this;return o.ariaLabel=r||e.replace(/^\\/,""),i=new Ct(2,function(t){return Ne("span",{class:"mq-large-operator mq-non-leaf"},[Ne("span",{class:"mq-to"},[Ne.block("span",{},t[1])]),Ne("big",{},[Ne.text(n)]),Ne("span",{class:"mq-from"},[Ne.block("span",{},t[0])])])}),Ft.prototype.setCtrlSeqHtmlTextAndMathspeak.call(o,e,i),o}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),e.options.sumStartsWithNEquals&&(new Ht("n").createLeftOf(e),(new ne).createLeftOf(e))},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq+"_{",e=t.uncleanedLatex.length,this.getEnd(De).latexRecursive(t),n=t.uncleanedLatex.length,n===e&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}^{",e=t.uncleanedLatex.length,this.getEnd(Ae).latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){return"Start "+this.ariaLabel+" from "+this.getEnd(De).mathspeak()+" to "+this.getEnd(Ae).mathspeak()+", end "+this.ariaLabel+", "},e.prototype.parser=function(){var t,e=dt.string,n=dt.optWhitespace,r=dt.succeed,i=wt.block,o=this,s=o.blocks=[new Mt,new Mt];for(t=0;t<s.length;t+=1)s[t].adopt(o,o.getEnd(Ae),0);return n.then(e("_").or(e("^"))).then(function(t){var e=s["_"===t?0:1];return i.then(function(t){return t.children().adopt(e,e.getEnd(Ae),0),r(o)})}).many().result(o)},e.prototype.finalizeTree=function(){var t=this.getEnd(De),e=this.getEnd(Ae);t.ariaLabel="lower bound",e.ariaLabel="upper bound",this.downInto=t,this.upInto=e,t.upOutOf=e,e.downOutOf=t},e}(Tt),Y["∑"]=Y.sum=Y.summation=function(){return new de("\\sum ",P,"sum")},Y["∏"]=Y.prod=Y.product=function(){return new de("\\prod ",H,"product")},Y.coprod=Y.coproduct=function(){return new de("\\coprod ",j,"co product")},Y["∫"]=Y.int=Y.integral=function(t){function e(){var e=t.call(this,"\\int ","","integral")||this;return e.ariaLabel="integral",e.domView=new Ct(2,function(t){return Ne("span",{class:"mq-int mq-non-leaf"},[Ne("big",{},[Ne.text(G)]),Ne("span",{class:"mq-supsub mq-non-leaf"},[Ne("span",{class:"mq-sup"},[Ne.block("span",{class:"mq-sup-inner"},t[1])]),Ne.block("span",{class:"mq-sub"},t[0]),Ne("span",{style:"display:inline-block;width:0"},[Ne.text(R)])])])}),e}return __extends(e,t),e.prototype.createLeftOf=function(t){Tt.prototype.createLeftOf.call(this,t)},e}(de),fe=Y.frac=Y.dfrac=Y.cfrac=Y.fraction=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\frac",e.domView=new Ct(2,function(t){return Ne("span",{class:"mq-fraction mq-non-leaf"},[Ne.block("span",{class:"mq-numerator"},t[0]),Ne.block("span",{class:"mq-denominator"},t[1]),Ne("span",{style:"display:inline-block;width:0"},[Ne.text(R)])])}),e.textTemplate=["(",")/(",")"],e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(De),e=this.getEnd(Ae);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="numerator",e.ariaLabel="denominator",this.getFracDepth()>1?this.mathspeakTemplate=["StartNestedFraction,","NestedOver",", EndNestedFraction"]:this.mathspeakTemplate=["StartFraction,","Over",", EndFraction"]},e.prototype.mathspeak=function(e){var n,r,i,o,s,a,l,c;if(e&&e.createdLeftOf)return n=e.createdLeftOf,n.parent.mathspeak();if(r=D(this.getEnd(De)),i=D(this.getEnd(Ae)),(!e||!e.ignoreShorthand)&&le.test(r)&&le.test(i)&&(o="1"===r||"-1"===r,s="","2"===i?s=o?"half":"halves":"3"===i?s=o?"third":"thirds":"4"===i?s=o?"fourth":"fourths":"5"===i?s=o?"fifth":"fifths":"6"===i?s=o?"sixth":"sixths":"7"===i?s=o?"seventh":"sevenths":"8"===i?s=o?"eighth":"eighths":"9"===i?s=o?"ninth":"ninths":"10"===i?s=o?"tenth":"tenths":"11"===i?s=o?"eleventh":"elevenths":"12"===i?s=o?"twelfth":"twelfths":"100"===i&&(s=o?"hundredth":"hundredths"),""!==s)){for(a="",l=!1,c=this[De];c&&void 0!==c[De];c=c[De])if("\\ "!==c.ctrlSeq){if(!le.test(c.ctrlSeq||"")){l=!1;break}l=!0}return l&&(a+="and "),a+=this.getEnd(De).mathspeak()+" "+s}return t.prototype.mathspeak.call(this)},e.prototype.getFracDepth=function(){var t=function(e,n){return e instanceof xt&&e.ctrlSeq&&e.ctrlSeq.toLowerCase().search("frac")>=0&&(n+=1),e&&e.parent?t(e.parent,n):n};return t(this,0)},e}(Tt),me=Y.over=Z["/"]=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.createLeftOf=function(n){var r,i,o;if(!this.replacedFragment){if(r=n[De],!(n.options.typingSlashCreatesNewFraction&&this instanceof fe))for(;r&&!(T(r)||r instanceof Rt&&"mq-ellipsis-end"===r._groupingClass||r instanceof(Y.text||t)||r instanceof de||"\\ "===r.ctrlSeq||/^[,;:]$/.test(r.ctrlSeq));)r=r[De];r instanceof de&&r[Ae]instanceof ce&&(r=r[Ae],(i=r[Ae])instanceof ce&&i.ctrlSeq!=r.ctrlSeq&&(r=r[Ae])),r===n[De]||n.isTooDeep(1)||(i=r[Ae],o=n[De],this.replaces(new X(i||n.parent.getEnd(De),o)),n[De]=r)}e.prototype.createLeftOf.call(this,n)},n}(fe),ge=function(){return new Ft("\\operatorname{ans}",Ne("span",{class:"mq-ans"},[Ne.text("ans")]),"ans")},Y.ans=ge,ye=function(){return new Ft("\\%\\operatorname{of}",Ne("span",{class:"mq-nonSymbola mq-operator-name"},[Ne.text("% of ")]),"percent of")},Y.percent=Y.percentof=ye,ve=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tokenId="",e.ctrlSeq="\\token",e.textTemplate=["token(",")"],e.mathspeakTemplate=["StartToken,",", EndToken"],e.ariaLabel="token",e}return __extends(e,t),e.prototype.html=function(){var t=Ne("span",{class:"mq-token mq-ignore-mousedown","data-mq-token":this.tokenId});return this.setDOM(t),K.linkElementByCmdNode(t,this),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\token{"+this.tokenId+"}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=[];return this.domFrag().children().eachElement(function(e){var n=e.getAttribute("aria-label");"string"==typeof n&&""!==n&&t.push(n)}),t.length>0?t.join(" ").trim():"token "+this.tokenId},e.prototype.parser=function(){var t=this;return wt.block.map(function(e){var n=e.getEnd(De);if(n)for(t.tokenId+=n.ctrlSeq;n=n[Ae];)t.tokenId+=n.ctrlSeq;return t})},e}(Ft),Y.token=ve,xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\sqrt",e.domView=new Ct(1,function(t){return Ne("span",{class:"mq-non-leaf mq-sqrt-container"},[Ne("span",{class:"mq-scaled mq-sqrt-prefix"},[oe.sqrt.html()]),Ne.block("span",{class:"mq-non-leaf mq-sqrt-stem"},t[0])])}),e.textTemplate=["sqrt(",")"],e.mathspeakTemplate=["StartRoot,",", EndRoot"],e.ariaLabel="root",e}return __extends(e,t),e.prototype.parser=function(){return wt.optBlock.then(function(t){return wt.block.map(function(e){var n=new be;return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(t.prototype.parser.call(this))},e.prototype.deleteTowards=function(e,n){if(!this.isEmpty()&&1===e)return this.moveTowards(Ae,n),void n.parent.deleteOutOf(De,n);t.prototype.deleteTowards.call(this,e,n)},e}(Tt),Y.sqrt=xe,Y.hat=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\hat",e.domView=new Ct(1,function(t){return Ne("span",{class:"mq-non-leaf"},[Ne("span",{class:"mq-hat-prefix"},[Ne.text("^")]),Ne.block("span",{class:"mq-hat-stem"},t[0])])}),e.textTemplate=["hat(",")"],e}return __extends(e,t),e}(Tt),be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.domView=new Ct(2,function(t){return Ne("span",{class:"mq-nthroot-container mq-non-leaf"},[Ne.block("sup",{class:"mq-nthroot mq-non-leaf"},t[0]),Ne("span",{class:"mq-scaled mq-sqrt-container"},[Ne("span",{class:"mq-sqrt-prefix mq-scaled"},[oe.sqrt.html()]),Ne.block("span",{class:"mq-sqrt-stem mq-non-leaf"},t[1])])])}),e.textTemplate=["sqrt[","](",")"],e}return __extends(e,t),e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\sqrt[",this.getEnd(De).latexRecursive(t),t.uncleanedLatex+="]{",this.getEnd(Ae).latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=this.getEnd(De).mathspeak(),e=this.getEnd(Ae).mathspeak();return this.getEnd(De).ariaLabel="Index",this.getEnd(Ae).ariaLabel="Radicand","3"===t?"Start Cube Root, "+e+", End Cube Root":"Root Index "+t+", Start Root, "+e+", End Root"},e.prototype.deleteTowards=function(t,e){Tt.prototype.deleteTowards.call(this,t,e)},e}(xe),Y.nthroot=be,Y.cbrt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),new zt("3").createLeftOf(e),e.controller.moveRight()},e}(be),we=function(t){function e(e,n,r){var i=new Ct(1,function(t){return Ne("span",{class:"mq-non-leaf"},[Ne("span",{class:"mq-diacritic-above"},[n]),Ne.block("span",{class:"mq-diacritic-stem"},t[0])])});return t.call(this,e,i,r)||this}return __extends(e,t),e}(Tt),Y.vec=function(){return new we("\\vec",Ne.entityText("&rarr;"),["vec(",")"])},Y.tilde=function(){return new we("\\tilde",Ne.text("~"),["tilde(",")"])},Ee=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setDOM=function(e){var n,r;return t.prototype.setDOM.call(this,e),r=this.domFrag().children(),r.isEmpty()||(this.delimFrags=(n={},n[De]=r.first(),n[Ae]=r.last(),n)),this},e}(Tt),ke=function(t){function e(e,n,r,i,o){var s,a=t.call(this,"\\left"+i,void 0,[n,r])||this;return a.side=e,a.sides=(s={},s[De]={ch:n,ctrlSeq:i},s[Ae]={ch:r,ctrlSeq:o},s),a}return __extends(e,t),e.prototype.numBlocks=function(){return 1},e.prototype.html=function(){var e=this,n=this.getSymbol(De),r=this.getSymbol(Ae);return this.domView=new Ct(1,function(t){return Ne("span",{class:"mq-non-leaf mq-bracket-container"},[Ne("span",{style:"width:"+n.width,class:"mq-scaled mq-bracket-l mq-paren"+(e.side===Ae?" mq-ghost":"")},[n.html()]),Ne.block("span",{style:"margin-left:"+n.width+";margin-right:"+r.width,class:"mq-bracket-middle mq-non-leaf"},t[0]),Ne("span",{style:"width:"+r.width,class:"mq-scaled mq-bracket-r mq-paren"+(e.side===De?" mq-ghost":"")},[r.html()])])}),t.prototype.html.call(this)},e.prototype.getSymbol=function(t){var e=this.sides[t||Ae].ch;return oe[e]||{width:"0",html:""}},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\left"+this.sides[De].ctrlSeq,this.getEnd(De).latexRecursive(t),t.uncleanedLatex+="\\right"+this.sides[Ae].ctrlSeq,this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r=this.sides[De].ch,i=this.sides[Ae].ch;if("|"===r&&"|"===i)this.mathspeakTemplate=["StartAbsoluteValue,",", EndAbsoluteValue"],this.ariaLabel="absolute value";else{if(e&&e.createdLeftOf&&this.side)return n="",this.side===De?n=this.textTemplate[0]:this.side===Ae&&(n=this.textTemplate[1]),(this.side===De?"left ":"right ")+Se[n];this.mathspeakTemplate=["left "+Se[r]+",",", right "+Se[i]],this.ariaLabel=Se[r]+" block"}return t.prototype.mathspeak.call(this)},e.prototype.matchBrack=function(t,n,r){return r instanceof e&&r.side&&r.side!==-n&&(!t.restrictMismatchedBrackets||Le[this.sides[this.side].ch]===r.sides[r.side].ch||"none"!==t.restrictMismatchedBrackets&&{"(":"]","[":")"}[this.sides[De].ch]===r.sides[Ae].ch)&&r},e.prototype.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side];var e=t.delimFrags[this.side===De?De:Ae].removeClass("mq-ghost");this.replaceBracket(e,this.side)},e.prototype.createLeftOf=function(e){var n,r,i;this.replacedFragment||(r=e.options,n="|"===this.sides[De].ch?this.matchBrack(r,Ae,e[Ae])||this.matchBrack(r,De,e[De])||this.matchBrack(r,0,e.parent.parent):this.matchBrack(r,-this.side,e[-this.side])||this.matchBrack(r,-this.side,e.parent.parent)),n?(i=this.side=-n.side,this.closeOpposing(n),n===e.parent.parent&&e[i]&&new X(e[i],e.parent.getEnd(i),-i).disown().withDirAdopt(-i,n.parent,n,n[i]).domFrag().insDirOf(i,n.domFrag()),n.bubble(function(t){t.reflow()})):(n=this,i=n.side,n.replacedFragment?n.side=0:e[-i]&&(n.replaces(new X(e[-i],e.parent.getEnd(-i),i)),e[-i]=0),t.prototype.createLeftOf.call(this,e)),i===De?e.insAtLeftEnd(n.getEnd(De)):e.insRightOf(n)},e.prototype.placeCursor=function(){},e.prototype.unwrap=function(){this.getEnd(De).children().disown().adopt(this.parent,this,this[Ae]).domFrag().insertAfter(this.domFrag()),this.remove()},e.prototype.deleteSide=function(t,e,n){var r,i,o,s,a,l=this.parent,c=this[t],u=l.getEnd(t);if(t===this.side)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));if(r=n.options,i=!this.side,this.side=-t,this.matchBrack(r,t,this.getEnd(De).getEnd(this.side)))this.closeOpposing(this.getEnd(De).getEnd(this.side)),o=this.getEnd(De).getEnd(t),this.unwrap(),o&&o.siblingCreated(n.options,t),c?n.insDirOf(-t,c):n.insAtDirEnd(t,l);else{if(this.matchBrack(r,t,this.parent.parent))this.parent.parent.closeOpposing(this),this.parent.parent.unwrap();else{if(e&&i)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));this.sides[t]=I(this),this.delimFrags[De].removeClass("mq-ghost"),this.delimFrags[Ae].removeClass("mq-ghost"),s=this.delimFrags[t].addClass("mq-ghost"),this.replaceBracket(s,t)}c?(a=this.getEnd(De),o=a.getEnd(t),a.domFrag().removeClass("mq-empty"),new X(c,u,-t).disown().withDirAdopt(-t,a,o,0).domFrag().insAtDirEnd(t,a.domFrag().oneElement()),o&&o.siblingCreated(n.options,t),n.insDirOf(-t,c)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.getEnd(De))}},e.prototype.replaceBracket=function(t,e){var n,r,i=this.getSymbol(e);t.children().replaceWith($(i.html())),t.oneElement().style.width=i.width,e===De?(n=t.next(),n.isEmpty()||(n.oneElement().style.marginLeft=i.width)):(r=t.prev(),r.isEmpty()||(r.oneElement().style.marginRight=i.width))},e.prototype.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.prototype.finalizeTree=function(){this.getEnd(De).deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimFrags[this.side===De?Ae:De].removeClass("mq-ghost"),this.side=0}},e.prototype.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()},e}(Ee),Le={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|","\\lVert ":"\\rVert ","\\rVert ":"\\lVert "},Se={"&lang;":"angle-bracket","&rang;":"angle-bracket","|":"pipe"},N("(","","parenthesis"),N("[","","bracket"),N("{","\\{","brace"),Y.langle=function(){return new ke(De,"&lang;","&rang;","\\langle ","\\rangle ")},Y.rangle=function(){return new ke(Ae,"&lang;","&rang;","\\langle ","\\rangle ")},Z["|"]=function(){return new ke(De,"|","|","|","|")},Y.lVert=function(){return new ke(De,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Y.rVert=function(){return new ke(Ae,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Y.left=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var t=dt.regex,e=dt.string,n=dt.optWhitespace;return n.then(t(/^(?:[([|]|\\\{|\\langle(?![a-zA-Z])|\\lVert(?![a-zA-Z]))/)).then(function(r){var i=r.replace(/^\\/,"");return"\\langle"==r&&(i="&lang;",r+=" "),"\\lVert"==r&&(i="&#8741;",r+=" "),wt.then(function(o){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\}|\\rangle(?![a-zA-Z])|\\rVert(?![a-zA-Z]))/)).map(function(t){var e,n=t.replace(/^\\/,"");return"\\rangle"==t&&(n="&rang;",t+=" "),"\\rVert"==t&&(n="&#8741;",t+=" "),e=new ke(0,i,n,r,t),e.blocks=[o],o.adopt(e,0,0),e})})})},e}(Tt),Y.right=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){return dt.fail("unmatched \\right")},e}(Tt),_e=oe["("],qe=oe[")"],Oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\binom",e.domView=new Ct(2,function(t){return Ne("span",{class:"mq-non-leaf mq-bracket-container"},[Ne("span",{style:"width:"+_e.width,class:"mq-paren mq-bracket-l mq-scaled"},[_e.html()]),Ne("span",{style:"margin-left:"+_e.width+"; margin-right:"+qe.width,class:"mq-non-leaf mq-bracket-middle"},[Ne("span",{class:"mq-array mq-non-leaf"},[Ne.block("span",{},t[0]),Ne.block("span",{},t[1])])]),Ne("span",{style:"width:"+qe.width,class:"mq-paren mq-bracket-r mq-scaled"},[qe.html()])])}),e.textTemplate=["choose(",",",")"],e.mathspeakTemplate=["StartBinomial,","Choose",", EndBinomial"],e.ariaLabel="binomial",e}
14
- return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(De),e=this.getEnd(Ae);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="upper index",e.ariaLabel="lower index"},e}(Ee),Y.binom=Y.binomial=Oe,Y.choose=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){me.prototype.createLeftOf.call(this,t)},e}(Oe),Ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\MathQuillMathField",e.domView=new Ct(1,function(t){return Ne("span",{class:"mq-editable-field"},[Ne.block("span",{class:"mq-root-block","aria-hidden":"true"},t[0])])}),e}return __extends(e,t),e.prototype.parser=function(){var e=this,n=dt.string,r=dt.regex,i=dt.succeed;return n("[").then(r(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(t){e.name=t}).or(i(void 0)).then(t.prototype.parser.call(this))},e.prototype.finalizeTree=function(t){function e(t){if(t.parentNode&&!$(t).hasClass("mq-root-block")&&e(t.parentNode),t.nodeType===Node.ELEMENT_NODE){var n=t;"true"===n.getAttribute("aria-hidden")&&(n.removeAttribute("aria-hidden"),$(t).children().eachElement(function(t){t.setAttribute("aria-hidden","true")}))}}var n=new qt(this.getEnd(De),this.domFrag().oneElement(),t);n.KIND_OF_MQ="MathField",n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(n.root),y(n.root),e(this.domFrag().parent().oneElement()),this.domFrag().oneElement().removeAttribute("aria-hidden")},e.prototype.registerInnerField=function(t,e){var n=this.getEnd(De).controller,r=new e(n);t[this.name]=r,t.push(r)},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.getEnd(De).latexRecursive(t),this.checkCursorContextClose(t)},e.prototype.text=function(){return this.getEnd(De).text()},e}(Tt),Y.editable=Y.MathQuillMathField=Ce,Te=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOptions=function(t){function e(){return""}return this.text=t.text||e,this.domView=new Ct(0,function(){return Ne("span",{},[i(t.htmlString||"")])}),this.latex=t.latex||e,this},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.latex(),this.checkCursorContextClose(t)},e.prototype.parser=function(){var t=this,e=dt.string,n=dt.regex,r=dt.succeed;return e("{").then(n(/^[a-z][a-z0-9]*/i)).skip(e("}")).then(function(i){return e("[").then(n(/^[-\w\s]*/)).skip(e("]")).or(r(void 0)).map(function(e){return t.setOptions(it[i](e))})})},e}(Ft),Y.embed=Te,window.jQuery){ct=g(1);for(Fe in ct)!function(t,e){"function"==typeof e?(m[t]=function(){return lt(),e.apply(this,arguments)},m[t].prototype=e.prototype):m[t]=e}(Fe,ct[Fe])}}();
10
+ var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){var e,n,r,o;for(n=1,r=arguments.length;n<r;n++){e=arguments[n];for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},__assign.apply(this,arguments)};!function(){function t(){}function e(t){for(;t;){if(!t.parent)return t;t=t.parent}}function n(t,n,r){var o,i,s,a,l,c;if(!n){if(o=new Error("prayer failed: "+t),r){i={},o.dcgExtraErrorMetaData=i;for(s in r)a=r[s],l=i[s]={},a?(l.localLatex=a.latex(),(c=e(a))&&(l.rootLatex=c.latex())):l.emptyNode=!0}throw o}}function r(t){n("a direction was passed",t===Ae||t===Me)}function o(t){var e,n=document.implementation.createHTMLDocument("");if(n.body.innerHTML=t,1===n.body.children.length)return n.body.children[0];for(e=document.createDocumentFragment();n.body.firstChild;)e.appendChild(n.body.firstChild);return e}function i(t,e){var n,r,o,i;if("function"==typeof(null===t||void 0===t?void 0:t.closest))return t.closest(e);if(!(t instanceof HTMLElement))return null;o=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=t;do{if(o.call(i,e))return i;i=null!==(r=null!==(n=null===i||void 0===i?void 0:i.parentElement)&&void 0!==n?n:null===i||void 0===i?void 0:i.parentNode)&&void 0!==r?r:null}while(null!==i&&1===i.nodeType);return null}function s(t){return t.getClientRects().length?t.getBoundingClientRect():{top:0,left:0,height:0,width:0,x:0,y:0,bottom:0,right:0}}function a(){return void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft}function l(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}function c(t,e,n,r){e.insertBefore(n,t===Ae?r:r.nextSibling)}function u(t,e,n){t===Ae?n.insertBefore(e,n.firstChild):n.appendChild(e)}function p(t,e){var n,r=t[Ae];if(r&&(n=t[Me]))for(n=n[Me];r!==n&&!1!==e(r);r=r[Me]);}function h(t,e,n){var r,o=t[Ae];if(!o)return e;if(!(r=t[Me]))return e;for(r=r[Me];o!==r;o=o[Me])e=n(e,o);return e}function d(t,e,r){n("a parent is always present",t),n("leftward is properly set up",function(){return e?e[Me]===r&&e.parent===t:t.getEnd(Ae)===r}(),{parent:t,leftward:e,leftwardL:e&&e[Ae],leftwardR:e&&e[Me],rightwardL:r&&r[Ae],rightwardR:r&&r[Me]}),n("rightward is properly set up",function(){return r?r[Ae]===e&&r.parent===t:t.getEnd(Me)===e}(),{parent:t,rightward:r,leftwardL:e&&e[Ae],leftwardR:e&&e[Me],rightwardL:r&&r[Ae],rightwardR:r&&r[Me],rightwardParent:r&&r.parent})}function f(t){return t&&t.prototype instanceof bt}function m(t){return ct(),ut||(ut=g(1)),ut(t)}function g(t){function e(t,e){var n,r,i;for(n in e)if(e.hasOwnProperty(n)){if("substituteKeyboardEvents"===n&&o>=3)throw new Error(["As of interface version 3, the 'substituteKeyboardEvents'","option is no longer supported. Use 'overrideTypedText' and","'overrideKeystroke' instead."].join(" "));r=e[n],i=s[n],t[n]=i?i(r):r}}function r(t,e){function r(n,r){var i,s;return n&&n.nodeType?(i=d(n))instanceof e?i:(s=new Ot(new e.RootBlock,n,new c(o)),s.KIND_OF_MQ=t,new e(s).__mathquillify(r||{},o)):null}return n(t+" is defined",e),r.prototype=e.prototype,r}var o,i,s,c,u,p,h,d;if(1!==t&&2!==t&&3!==t)throw"Only interface versions between "+pt+" and "+ht+" supported. You specified: "+t;if((o=t)<3){if(!(i=window.jQuery))throw"MathQuill interface version ".concat(o," requires jQuery 1.5.2+ to be loaded first");at.prototype.jQuery=i}return s=__assign(__assign({},st),{handlers:function(t){return{fns:t||{},APIClasses:h}}}),c=o<3?at:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(at),u=function(t){function n(e){var n=t.call(this)||this;return n.__controller=e,n.__options=e.options,n.id=e.id,n.data=e.data,n}return __extends(n,t),n.prototype.mathquillify=function(t){var e,n=this.__controller,r=n.root,i=n.container;n.createTextarea(),e=U(i).addClass(t).children().detach(),r.setDOM(U(Re("span",{class:"mq-root-block","aria-hidden":!0})).appendTo(i).oneElement()),X.linkElementByBlockNode(r.domFrag().oneElement(),r),this.latex(e.text()),this.revert=function(){return n.removeMouseEventListener(),U(i).removeClass("mq-editable-field mq-math-mode mq-text-mode").empty().append(e),o<3?this.__options.assertJquery()(i):i}},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n.prototype.config=function(t){return e(this.__options,t),void 0!==t.tabindex&&this.__controller.setTabindex(t.tabindex),this},n.prototype.el=function(){return this.__controller.container},n.prototype.text=function(){return this.__controller.exportText()},n.prototype.mathspeak=function(){return this.__controller.exportMathSpeak()},n.prototype.latex=function(t){if(arguments.length>0){this.__controller.renderLatexMath(t);var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this}return this.__controller.exportLatex()},n.prototype.selection=function(t){return t?(this.__controller.restoreLatexSelection(t),this):this.__controller.exportLatexSelection().selection},n.prototype.html=function(){return this.__controller.root.domFrag().oneElement().innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},n.prototype.reflow=function(){return this.__controller.root.postOrder(function(t){t.reflow()}),this},n.prototype.focus=function(){return this.__controller.getTextarea().focus(),this.__controller.editable&&this.__controller.scrollHoriz(),this},n.prototype.select=function(){return this.__controller.selectAll(),this},n.prototype.blur=function(){return this.__controller.getTextarea().blur(),this},n}(lt),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.mathquillify=function(e){return t.prototype.mathquillify.call(this,e),this.__controller.editable=!0,this.__controller.addMouseEventListener(),this.__controller.editablesTextareaEvents(),this},e.prototype.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.prototype.write=function(t){this.__controller.writeLatex(t),this.__controller.scrollHoriz();var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this},e.prototype.empty=function(){var t,e=this.__controller.root,n=this.__controller.cursor;return e.setEnds((t={},t[Ae]=0,t[Me]=0,t)),e.domFrag().empty(),delete n.selection,n.insAtRightEnd(e),this},e.prototype.cmd=function(t){var e,n,r=this.__controller.notify(void 0),o=r.cursor;return/^\\[a-z]+$/i.test(t)&&!o.isTooDeep()?(t=t.slice(1),(e=Z[t])&&(n=e.constructor?new e(t):e(t),o.selection&&n.replaces(o.replaceSelection()),n.createLeftOf(o.show()))):o.parent.write(o,t),r.scrollHoriz(),r.blurred&&o.hide().parent.blur(o),this},e.prototype.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.prototype.moveToLeftEnd=function(){return this.moveToDirEnd(Ae)},e.prototype.moveToRightEnd=function(){return this.moveToDirEnd(Me)},e.prototype.keystroke=function(t,e){var n,r=t.replace(/^\s+|\s+$/g,"").split(/\s+/);for(n=0;n<r.length;n+=1)this.__controller.keystroke(r[n],e);return this},e.prototype.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this},e.prototype.dropEmbedded=function(t,e,n){var r,o=t-a(),i=e-l(),s=document.elementFromPoint(o,i);this.__controller.seek(s,o,i),r=(new Fe).setOptions(n),r.createLeftOf(this.__controller.cursor)},e.prototype.setAriaPostLabel=function(t,e){return this.__controller.setAriaPostLabel(t,e),this},e.prototype.getAriaPostLabel=function(){return this.__controller.getAriaPostLabel()},e.prototype.clickAt=function(t,e,n){var r,o,i;return n=n||document.elementFromPoint(t,e),r=this.__controller,o=r.root,i=o.domFrag().oneElement(),i.contains(n)||(n=i),r.seek(n,t,e),r.blurred&&this.focus(),this},e.prototype.ignoreNextMousedown=function(t){return this.__controller.cursor.options.ignoreNextMousedown=t,this},e.prototype.isUserSelecting=function(){return this.__controller.isMouseSelecting},e}(u),h={AbstractMathQuill:u,EditableField:p},n("API.StaticMath defined",ot.StaticMath),h.StaticMath=ot.StaticMath(h),n("API.MathField defined",ot.MathField),h.MathField=ot.MathField(h),n("API.InnerMathField defined",ot.InnerMathField),h.InnerMathField=ot.InnerMathField(h),ot.TextField&&(h.TextField=ot.TextField(h)),d=function(t){var e,n,r,o,i,s,a,l;if(!t||!t.nodeType)return null;for(n=U(t).children().toElementArray(),r=0,o=n;r<o.length;r++)if(i=o[r],i.classList.contains("mq-root-block")){e=i;break}return s=X.getNodeOfElement(e),a=s&&s.controller,l=a&&h[a.KIND_OF_MQ],a&&l?new l(a):null},d.L=Ae,d.R=Me,d.config=function(t){return e(c.prototype,t),this},d.registerEmbed=function(t,e){if(!/^[a-z][a-z0-9]*$/i.test(t))throw"Embed name must start with letter and be only letters and digits";it[t]=e},d.StaticMath=r("StaticMath",h.StaticMath),d.MathField=r("MathField",h.MathField),d.InnerMathField=r("InnerMathField",h.InnerMathField),h.TextField&&(d.TextField=r("TextField",h.TextField)),d.prototype=u.prototype,d.EditableField=function(){throw"wtf don't call me, I'm 'abstract'"},d.EditableField.prototype=p.prototype,o<3&&(d.saneKeyboardEvents=k),d}function y(t){t.moveOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("moveOutOf",t)},t.deleteOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("deleteOutOf",t)},t.selectOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("selectOutOf",t)},t.upOutOf=function(){n("controller is defined",this.controller),this.controller.handle("upOutOf")},t.downOutOf=function(){n("controller is defined",this.controller),this.controller.handle("downOutOf")},t.reflow=function(){n("controller is defined",this.controller),this.controller.handle("reflow"),this.controller.handle("edited"),this.controller.handle("edit")}}function v(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}function x(t,e,n){var r,o,i=n.uncleanedStartIndex,s=n.uncleanedEndIndex;for(r=0,o=0;r<n.uncleanedEndIndex;r++)t[r]!==e[o]?(r<n.uncleanedStartIndex&&(i-=1),s-=1):o+=1;return{startIndex:i,endIndex:s}}function b(t,e,n){var r,o,i=n.startIndex,s=n.endIndex,a=i,l=s;for(r=0,o=0;r<e.length;r++)e[r]!==t[o]?(o<=i&&(a+=1),o<=s&&(l+=1)):o+=1;return{uncleanStartIndex:a,uncleanEndIndex:l}}function w(t){for(;t;){if(rt.isControllerRoot(t))return t;t=t.parent}}function E(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function k(t,e){return gt(t[0],e)}function L(t,e,n){return function(){return new At(t,e?Re.entityText(e):void 0,n)}}function S(t,e,n,r){return function(){return new Mt(t,e?Re.entityText(e):void 0,n,r)}}function _(t,e,n){return function(){return new Ht(t,Re.entityText(e))}}function q(t,e){for(var n="",r=0;t instanceof jt&&t.ctrlSeq===t.letter&&r<e;)n=t.letter+n,t=t[Ae],r+=1;return n}function O(t){var e,n,r,o;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters';for(e=t.split(" "),n={},r=0;r<e.length;r+=1){if(o=e[r],o.length<2)throw'"'+o+'" not minimum length of 2';n[o]=!0}return n}function C(t){return _("\\"+t+" ","&"+t+";",t)}function T(t){return function(){return new At("\\"+t+" ",Re.entityText("&"+t+";"))}}function F(t){return t instanceof Mt||t instanceof jt&&"infix"==t.endsCategory}function D(t){if(!t)return!1;var e=t[Ae];return e?!(F(e)||e instanceof jt&&"prefix"==e.endsCategory||!(e instanceof Le)&&/^(\\ )|[,;:\(\[]$/.test(e.ctrlSeq)):!!(t.parent&&t.parent.parent&&t.parent.parent.isStyleBlock())&&D(t.parent.parent)}function A(t){if(!t)return"";var e="";return t.eachChild(function(t){void 0!==t.ctrlSeq&&(e+=t.ctrlSeq)}),e}function M(t){var e=this.parent,n=t;do{if(n[Me])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function I(t,e){var n;return"0"===e?"to the 0 power":"2"===e?"squared":"3"===e?"cubed":(n="",/^[+-]?\d{1,3}$/.test(e)&&(/(11|12|13|4|5|6|7|8|9|0)$/.test(e)?n="th":/1$/.test(e)?n="st":/2$/.test(e)?n="nd":/3$/.test(e)&&(n="rd")),"to the "+("object"==typeof t?t.mathspeak():e)+n+" power")}function N(t){var e=t.side,n=t.sides[e];return{ch:Se[n.ch],ctrlSeq:Se[n.ctrlSeq]}}function R(t,e,n){var r,o;e=e||t,r=Se[t],o=Se[e],J[t]=function(){return new Le(Ae,t,r,e,o)},J[r]=function(){return new Le(Me,t,r,e,o)},_e[t]=_e[r]=n}var B,z,P,H,j,G,V,W,Q,$,U,K,X,Y,Z,J,tt,et,nt,rt,ot,it,st,at,lt,ct,ut,pt,ht,dt,ft,mt,gt,yt,vt,xt,bt,wt,Et,kt,Lt,St,_t,qt,Ot,Ct,Tt,Ft,Dt,At,Mt,It,Nt,Rt,Bt,zt,Pt,Ht,jt,Gt,Vt,Wt,Qt,$t,Ut,Kt,Xt,Yt,Zt,Jt,te,ee,ne,re,oe,ie,se,ae,le,ce,ue,pe,he,de,fe,me,ge,ye,ve,xe,be,we,Ee,ke,Le,Se,_e,qe,Oe,Ce,Te,Fe,De,Ae=-1,Me=1,Ie=Math.min,Ne=Math.max,Re=function(t,e,n){var r,o,i,s;switch(t){case"svg":case"path":r=document.createElementNS("http://www.w3.org/2000/svg",t);break;default:r=document.createElement(t)}for(o in e)void 0!==(i=e[o])&&r.setAttribute(o,"string"==typeof i?i:String(i));if(n)for(s=0;s<n.length;s++)r.appendChild(n[s]);return r};Re.text=function(t){return document.createTextNode(t)},Re.block=function(t,e,n,r){var o,i=[n.html()];return(null===r||void 0===r?void 0:r.beforeChild)&&i.unshift(r.beforeChild),(null===r||void 0===r?void 0:r.afterChild)&&i.push(r.afterChild),o=Re(t,e,i),n.setDOM(o),X.linkElementByBlockNode(o,n),o},Re.entityText=function(t){var e=o(t);return n("entity parses to a single text node",e instanceof DocumentFragment&&1===e.childNodes.length&&e.childNodes[0]instanceof Text),e.childNodes[0]},B=" ",z="​",P="˙",H="∑",j="∏",G="∐",V="∫",W=function(){var t,e;return"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(t=requestAnimationFrame,e=cancelAnimationFrame):(t=function(t){return setTimeout(t,13)},e=clearTimeout),function(n,r){function o(){var t=(Date.now()-l)/n;t<=c?s():c=t,r(c,s,i)}function i(){void 0!==a&&e(a),a=void 0}function s(){i(),a=t(o)}var a,l=Date.now(),c=0;r(n<=0?1:0,s,i)}}(),Q=function(){function t(t){this.span=Re("span",{class:"mq-aria-alert","aria-live":"assertive","aria-atomic":"true"}),this.msg="",this.items=[],this.controller=t}return t.prototype.attach=function(){var t=this.controller.container;this.span.parentNode!==t&&U(t).prepend(U(this.span))},t.prototype.queue=function(t,e){var n,r;return void 0===e&&(e=!1),n="",t instanceof bt?(r=t.mathspeak({ignoreShorthand:!0}),e&&(t.parent&&t.parent.ariaLabel&&"block"===t.ariaLabel?n=t.parent.ariaLabel+" "+r:t.ariaLabel&&(n=t.ariaLabel+" "+r)),""===n&&(n=r)):n=t||"",this.items.push(n),this},t.prototype.queueDirOf=function(t){return r(t),this.queue(t===Ae?"before":"after")},t.prototype.queueDirEndOf=function(t){return r(t),this.queue(t===Ae?"beginning of":"end of")},t.prototype.alert=function(t){return this.attach(),t&&this.queue(t),this.items.length&&(this.msg=this.items.join(" ").replace(/ +(?= )/g,"").trim(),this.controller.containerHasFocus()&&(this.controller.options.logAriaAlerts&&this.msg&&console.log(this.msg),this.span.textContent=this.msg)),this.clear()},t.prototype.clear=function(t){return this.items.length=0,(null===t||void 0===t?void 0:t.emptyContent)&&(this.span.textContent=""),this},t}(),$=function(){function t(t,e){var n;1===arguments.length&&(e=t),t&&e&&(this.ends=(n={},n[Ae]=t,n[Me]=e,n))}return t.create=function(e,r){1===arguments.length&&(r=e),n("No half-empty DOMFragments",!!e==!!r);var o=new t(e,r);return n("last is a forward sibling of first",o.isValid()),o},t.prototype.isEmpty=function(){return void 0===this.ends},t.prototype.isOneNode=function(){return!(!this.ends||this.ends[Ae]!==this.ends[Me])},t.prototype.isValid=function(){if(!this.ends)return!0;if(this.ends[Ae]===this.ends[Me])return!0;var t;return this.eachNode(function(e){return t=e}),t===this.ends[Me]},t.prototype.firstNode=function(){return n("Fragment is not empty",this.ends),this.ends[Ae]},t.prototype.lastNode=function(){return n("Fragment is not empty",this.ends),this.ends[Me]},t.prototype.children=function(){var e=this.oneNode(),n=e.firstChild,r=e.lastChild;return n&&r?new t(n,r):new t},t.prototype.join=function(e){var r,o;if(!this.ends)return e;if(!e.ends)return this;for(r=!1,o=this.ends[Me].nextSibling;o;){if(o===e.ends[Ae]){r=!0;break}o=o.nextSibling}return n("sibling must be a forward DOM sibling of this fragment",r),new t(this.ends[Ae],e.ends[Me])},t.prototype.oneNode=function(){return n("Fragment has a single node",this.ends&&this.ends[Ae]===this.ends[Me]),this.ends[Ae]},t.prototype.oneElement=function(){var t=this.oneNode();return n("Node is an Element",t.nodeType===Node.ELEMENT_NODE),t},t.prototype.oneText=function(){var t=this.oneNode();return n("Node is Text",t.nodeType===Node.TEXT_NODE),t},t.prototype.eachNode=function(t){var e,n,r;if(!this.ends)return this;for(e=this.ends[Me],n=this.ends[Ae],r=void 0;n&&(r=n.nextSibling,t(n),n!==e);n=r);return this},t.prototype.eachElement=function(t){return this.eachNode(function(e){e.nodeType===Node.ELEMENT_NODE&&t(e)}),this},t.prototype.text=function(){var t="";return this.eachNode(function(e){t+=e.textContent||""}),t},t.prototype.toNodeArray=function(){var t=[];return this.eachNode(function(e){return t.push(e)}),t},t.prototype.toElementArray=function(){var t=[];return this.eachElement(function(e){return t.push(e)}),t},t.prototype.toDocumentFragment=function(){var t=document.createDocumentFragment();return this.eachNode(function(e){return t.appendChild(e)}),t},t.prototype.insertBefore=function(t){return this.insDirOf(Ae,t)},t.prototype.insertAfter=function(t){return this.insDirOf(Me,t)},t.prototype.append=function(t){return t.appendTo(this.oneElement()),this},t.prototype.prepend=function(t){return t.prependTo(this.oneElement()),this},t.prototype.appendTo=function(t){return this.insAtDirEnd(Me,t)},t.prototype.prependTo=function(t){return this.insAtDirEnd(Ae,t)},t.prototype.parent=function(){if(!this.ends)return this;var e=this.ends[Ae].parentNode;return e?new t(e):new t},t.prototype.wrapAll=function(t){var e,n;return t.textContent="",this.ends?(e=this.ends[Ae].parentNode,n=this.ends[Me].nextSibling,this.appendTo(t),e&&e.insertBefore(t,n),this):this},t.prototype.replaceWith=function(t){var e,n,r=null===(e=this.ends)||void 0===e?void 0:e[Me],o=null===r||void 0===r?void 0:r.parentNode,i=null===r||void 0===r?void 0:r.nextSibling;return this.detach(),n=t.toDocumentFragment(),r&&o?(o.insertBefore(n,i||null),this):this},t.prototype.nthElement=function(t){if(this.ends&&!(t<0||t!==Math.floor(t)))for(var e=this.ends[Ae];e;){if(e.nodeType===Node.ELEMENT_NODE){if(t<=0)return e;t-=1}if(e===this.ends[Me])return;e=e.nextSibling}},t.prototype.firstElement=function(){return this.nthElement(0)},t.prototype.lastElement=function(){if(this.ends)for(var t=this.ends[Me];t;){if(t.nodeType===Node.ELEMENT_NODE)return t;if(t===this.ends[Ae])return;t=t.previousSibling}},t.prototype.first=function(){return new t(this.firstElement())},t.prototype.last=function(){return new t(this.lastElement())},t.prototype.eq=function(e){return new t(this.nthElement(e))},t.prototype.slice=function(e){if(!this.ends)return this;var n=this.nthElement(e);return n?new t(n,this.ends[Me]):new t},t.prototype.next=function(){for(var e=this.oneNode();e;)if((e=e.nextSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.prev=function(){for(var e=this.oneNode();e;)if((e=e.previousSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.empty=function(){return this.eachElement(function(t){t.textContent=""}),this},t.prototype.remove=function(){return this.toDocumentFragment(),this},t.prototype.detach=function(){return this.remove()},t.prototype.insDirOf=function(t,e){var n,r;return this.ends?(r=null===(n=e.ends)||void 0===n?void 0:n[t])&&r.parentNode?(c(t,r.parentNode,this.toDocumentFragment(),r),this):this.detach():this},t.prototype.insAtDirEnd=function(t,e){return this.ends?(u(t,this.toDocumentFragment(),e),this):this},t.prototype.hasClass=function(t){var e=!1;return this.eachElement(function(n){n.classList.contains(t)&&(e=!0)}),e},t.prototype.addClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.add(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.removeClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.remove(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.toggleClass=function(t,e){var n,r,o,i,s;if(!0===e)return this.addClass(t);if(!1===e)return this.removeClass(t);for(n=function(t){if(!t)return"continue";r.eachElement(function(e){e.classList.toggle(t)})},r=this,o=0,i=t.split(/\s+/);o<i.length;o++)s=i[o],n(s);return this},t}(),U=$.create,K=function(){function t(t,e,n){this.init(t,e,n)}return t.prototype.init=function(t,e,n){this.parent=t,this[Ae]=e,this[Me]=n},t.copy=function(e){return new t(e.parent,e[Ae],e[Me])},t}(),X=function(){function t(){var n;this[e]=0,this[o]=0,this.parent=0,this.ends=(n={},n[Ae]=0,n[Me]=0,n),this.id=t.uniqueNodeId()}t.uniqueNodeId=function(){return t.idCounter+=1},t.getNodeOfElement=function(t){if(t){if(!t.nodeType)throw new Error("must pass an Element to NodeBase.getNodeOfElement");var e=t;return e.mqBlockNode||e.mqCmdNode}},t.linkElementByBlockNode=function(t,e){t.mqBlockNode=e},t.linkElementByCmdNode=function(t,e){t.mqCmdNode=e},t.prototype.setEnds=function(t){this.ends=t,n("No half-empty node ends",!!this.ends[Ae]==!!this.ends[Me])},t.prototype.getEnd=function(t){return this.ends[t]},t.prototype.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.prototype.setDOM=function(t){return t&&n("DOM is an element or a text node",t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE),this._el=t,this},t.prototype.domFrag=function(){return U(this._el)},t.prototype.createDir=function(t,e){r(t);var n=this;return n.html(),n.domFrag().insDirOf(t,e.domFrag()),e[t]=n.adopt(e.parent,e[Ae],e[Me]),n},t.prototype.createLeftOf=function(t){this.createDir(Ae,t)},t.prototype.selectChildren=function(t,e){return new nt(t,e)},t.prototype.bubble=function(t){var e,n=this.getSelfNode();for(e=n;e&&!1!==t(e);e=e.parent);return this},t.prototype.postOrder=function(t){var e=this.getSelfNode();return function e(n){return!!n&&(n.eachChild(e),t(n),!0)}(e),e},t.prototype.isEmpty=function(){return 0===this.ends[Ae]&&0===this.ends[Me]},t.prototype.isQuietEmptyDelimiter=function(t){if(!this.isEmpty())return!1;if(!t)return!1;if(!this.parent||void 0===this.parent.ctrlSeq)return!1;var e=this.parent.ctrlSeq.replace(/^\\(left|right)?/,"");return t.hasOwnProperty(e)},t.prototype.isStyleBlock=function(){return!1},t.prototype.isTextBlock=function(){return!1},t.prototype.children=function(){return new Y(this.getEnd(Ae),this.getEnd(Me))},t.prototype.eachChild=function(t){return p(this.ends,t),this},t.prototype.foldChildren=function(t,e){return h(this.ends,t,e)},t.prototype.withDirAdopt=function(t,e,n,r){var o=this.getSelfNode();return new Y(o,o).withDirAdopt(t,e,n,r),this},t.prototype.adopt=function(t,e,n){var r=this.getSelfNode();return new Y(r,r).adopt(t,e,n),this.getSelfNode()},t.prototype.disown=function(){var t=this.getSelfNode();return new Y(t,t).disown(),this},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.shouldIgnoreSubstitutionInSimpleSubscript=function(t){var e,n=t.disableAutoSubstitutionInSubscripts;return!!n&&(!!this.parent&&(this.parent.parent instanceof ue&&(e=this.parent.parent[Ae],!("object"==typeof n&&e instanceof jt&&e.endsWord&&n.except[e.endsWord])&&!!this.parent.domFrag().hasClass("mq-sub"))))},t.prototype.getSelfNode=function(){return this},t.prototype.parser=function(){n("Abstract parser() method is never called",!1)},t.prototype.html=function(){throw new Error("html() unimplemented in NodeBase")},t.prototype.text=function(){return""},t.prototype.latex=function(){var t={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return this.latexRecursive(t),t.uncleanedLatex},t.prototype.latexRecursive=function(t){},t.prototype.checkCursorContextOpen=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionBefore===this&&(t.uncleanedStartIndex=n),t.endSelectionBefore===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedStartIndex&&(e.uncleanedEndIndex===e.uncleanedStartIndex?n===e.uncleanedStartIndex&&(e.cursorParent=this.parent):e.selectionL=this)},t.prototype.checkCursorContextClose=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionAfter===this&&(t.uncleanedStartIndex=n),t.endSelectionAfter===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedEndIndex&&(e.uncleanedStartIndex===e.uncleanedEndIndex?(e.cursorL||(e.cursorL=this),e.cursorParent?e.cursorParent===this.parent&&(e.cursorParent=this,e.cursorL=0):e.cursorParent=this.parent):e.selectionR||(e.selectionR=this))},t.prototype.finalizeTree=function(t,e){},t.prototype.contactWeld=function(t,e){},t.prototype.blur=function(t){},t.prototype.focus=function(){},t.prototype.intentionalBlur=function(){},t.prototype.reflow=function(){},t.prototype.registerInnerField=function(t,e){},t.prototype.chToCmd=function(t,e){n("Abstract chToCmd() method is never called",!1)},t.prototype.mathspeak=function(t){return""},t.prototype.seek=function(t,e){},t.prototype.siblingDeleted=function(t,e){},t.prototype.siblingCreated=function(t,e){},t.prototype.finalizeInsert=function(t,e){},t.prototype.fixDigitGrouping=function(t){},t.prototype.writeLatex=function(t,e){},t.prototype.write=function(t,e){};var e,o;return e=Ae,o=Me,t.idCounter=0,t}(),Y=function(){function t(t,e,o){var i,s,a,l;if(this.disowned=!1,void 0===o&&(o=Ae),r(o),n("no half-empty fragments",!t==!e,{withDir:t,oppDir:e}),!t||!e)return void this.setEnds((i={},i[Ae]=0,i[Me]=0,i));n("withDir is passed to Fragment",t instanceof bt),n("oppDir is passed to Fragment",e instanceof bt),n("withDir and oppDir have the same parent",t.parent===e.parent),s={},s[o]=t,s[-o]=e,a=s,this.setEnds(a),l=0,this.each(function(t){l=t}),n("following direction siblings from start reaches end",l===a[Me])}return t.prototype.getDOMFragFromEnds=function(){var t=this.ends[Ae],e=this.ends[Me];return 0===t||0===e?U():t===e?t.domFrag():t.domFrag().join(e.domFrag())},t.prototype.setEnds=function(t){this.ends=t},t.prototype.getEnd=function(t){return this.ends?this.ends[t]:0},t.prototype.domFrag=function(){return this.getDOMFragFromEnds()},t.prototype.withDirAdopt=function(t,e,n,r){return t===Ae?this.adopt(e,n,r):this.adopt(e,r,n)},t.prototype.adopt=function(t,e,n){var r,o,i,s,a;return d(t,e,n),o=this,this.disowned=!1,(i=o.ends[Ae])&&(s=o.ends[Me])?(r={},r[Ae]=t.getEnd(Ae),r[Me]=t.getEnd(Me),a=r,e||(a[Ae]=i),n?n[Ae]=s:a[Me]=s,t.setEnds(a),s[Me]=n,o.each(function(n){return n[Ae]=e,n.parent=t,e&&(e[Me]=n),e=n,!0}),o):this},t.prototype.disown=function(){var t,e,n,r,o,i,s=this,a=s.ends[Ae];return!a||s.disowned?s:(this.disowned=!0,(e=s.ends[Me])?(n=a.parent,d(n,a[Ae],a),d(n,e,e[Me]),t={},t[Ae]=n.getEnd(Ae),t[Me]=n.getEnd(Me),r=t,a[Ae]?(o=a[Ae],o[Me]=e[Me]):r[Ae]=e[Me],e[Me]?(i=e[Me],i[Ae]=a[Ae]):r[Me]=a[Ae],r[Ae]&&r[Me]?n.setEnds(r):n.ends=r,s):s)},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.each=function(t){return p(this.ends,t),this},t.prototype.fold=function(t,e){return h(this.ends,t,e)},t}(),Z={},J={},tt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.ancestors={},o}return __extends(e,t),e.fromCursor=function(t){return new e(t.parent,t[Ae],t[Me])},e}(K),et=function(t){function e(e,n,r){var o=t.call(this,e,0,0)||this;return o.upDownCache={},o.cursorElement=Re("span",{class:"mq-cursor"},[Re.text(z)]),o._domFrag=U(),o.controller=r,o.options=n,o.setDOMFrag(U(o.cursorElement)),o.blink=function(){U(o.cursorElement).toggleClass("mq-blink")},o}return __extends(e,t),e.prototype.setDOMFrag=function(t){return this._domFrag=t,this},e.prototype.domFrag=function(){return this._domFrag},e.prototype.show=function(){var t,e;return U(this.cursorElement).removeClass("mq-blink"),this.setDOMFrag(U(this.cursorElement)),this.intervalId?clearInterval(this.intervalId):(t=this[Me],t?(e=this.selection,e&&e.getEnd(Ae)[Ae]===this[Ae]?this.domFrag().insertBefore(e.domFrag()):this.domFrag().insertBefore(t.domFrag())):this.domFrag().appendTo(this.parent.domFrag().oneElement()),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},e.prototype.hide=function(){return this.intervalId&&clearInterval(this.intervalId),this.intervalId=0,this.domFrag().detach(),this.setDOMFrag(U()),this},e.prototype.withDirInsertAt=function(t,e,n,r){var o=this.parent;this.parent=e,this[t]=n,this[-t]=r,o!==e&&o.blur&&o.blur(this)},e.prototype.insDirOf=function(t,e){return r(t),this.domFrag().insDirOf(t,e.domFrag()),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.domFrag().addClass("mq-hasCursor"),this},e.prototype.insLeftOf=function(t){return this.insDirOf(Ae,t)},e.prototype.insRightOf=function(t){return this.insDirOf(Me,t)},e.prototype.insAtDirEnd=function(t,e){return r(t),this.domFrag().insAtDirEnd(t,e.domFrag().oneElement()),this.withDirInsertAt(t,e,0,e.getEnd(t)),e.focus(),this},e.prototype.insAtLeftEnd=function(t){return this.insAtDirEnd(Ae,t)},e.prototype.insAtRightEnd=function(t){return this.insAtDirEnd(Me,t)},e.prototype.jumpUpDown=function(t,e){var n,r,o,i=this;i.upDownCache[t.id]=K.copy(i),n=i.upDownCache[e.id],n?(r=n[Me],r?i.insLeftOf(r):i.insAtRightEnd(n.parent)):(o=i.getBoundingClientRectWithoutMargin().left,e.seek(o,i)),i.controller.aria.queue(e,!0)},e.prototype.getBoundingClientRectWithoutMargin=function(){var t,e,n,r=this.domFrag();return r.removeClass("mq-cursor"),t=s(r.oneElement()),e=t.left,n=t.right,r.addClass("mq-cursor"),{left:e,right:n}},e.prototype.unwrapGramp=function(){var t,e,n,r,o,i=this.parent.parent,s=i.parent,a=i[Me],l=this,c=i[Ae];if(i.disown().eachChild(function(t){return!!t.isEmpty()||(t.children().adopt(s,c,a).each(function(t){return t.domFrag().insertBefore(i.domFrag()),!0}),c=t.getEnd(Me),!0)}),!this[Me])if(t=this[Ae])this[Me]=t[Me];else for(;!this[Me];){if(!(e=this.parent[Me])){this[Me]=i[Me],this.parent=s;break}this.parent=e,this[Me]=e.getEnd(Ae)}n=this[Me],n?this.insLeftOf(n):this.insAtRightEnd(s),i.domFrag().remove(),r=i[Ae],o=i[Me],r&&r.siblingDeleted(l.options,Me),o&&o.siblingDeleted(l.options,Ae)},e.prototype.startSelection=function(){var t,e=this.anticursor=tt.fromCursor(this),n=e.ancestors;for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},e.prototype.endSelection=function(){delete this.anticursor},e.prototype.select=function(){var t,e,r,o,i,s,a,l,c,u=this.anticursor;if(this[Ae]===u[Ae]&&this.parent===u.parent)return!1;for(e=this;e.parent;e=e.parent)if(e.parent.id in u.ancestors){t=e.parent;break}if(n("cursor and anticursor in the same tree",t),r=t,o=u.ancestors[r.id],a=Me,e[Ae]!==o)for(l=e;l;l=l[Me])if(l[Me]===o[Me]){a=Ae,i=e,s=o;break}return a===Me&&(i=o,s=e),i instanceof K&&(i=i[Me]),s instanceof K&&(s=s[Ae]),this.hide().selection=r.selectChildren(i,s),c=this.selection.getEnd(a),this.insDirOf(a,c),this.selectionChanged(),!0},e.prototype.resetToEnd=function(t){this.clearSelection();var e=t.root;this[Me]=0,this[Ae]=e.getEnd(Me),this.parent=e
11
+ },e.prototype.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},e.prototype.deleteSelection=function(){var t=this.selection;t&&(this[Ae]=t.getEnd(Ae)[Ae],this[Me]=t.getEnd(Me)[Me],t.remove(),this.selectionChanged(),delete this.selection)},e.prototype.replaceSelection=function(){var t=this.selection;return t&&(this[Ae]=t.getEnd(Ae)[Ae],this[Me]=t.getEnd(Me)[Me],delete this.selection),t},e.prototype.depth=function(){for(var t=this,e=0;t=t.parent;)e+=t instanceof It?1:0;return e},e.prototype.isTooDeep=function(t){return void 0!==this.options.maxDepth&&this.depth()+(t||0)>this.options.maxDepth},e.prototype.selectionChanged=function(){},e}(K),nt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o._el=Re("span",{class:"mq-selection"}),o.getDOMFragFromEnds().wrapAll(o._el),o}return __extends(e,t),e.prototype.isCleared=function(){return void 0===this._el},e.prototype.domFrag=function(){return this.isCleared()?this.getDOMFragFromEnds():U(this._el)},e.prototype.setEnds=function(t){n("Selection ends are never empty",t[Ae]&&t[Me]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.adopt=function(e,n,r){return this.clear(),t.prototype.adopt.call(this,e,n,r)},e.prototype.clear=function(){var t=this.getDOMFragFromEnds();return this.domFrag().replaceWith(t),this._el=void 0,this},e.prototype.join=function(t,e){return void 0===e&&(e=""),this.fold("",function(n,r){return n+e+r[t]()})},e}(Y),rt=function(){function t(t,e,n){this.isMouseSelecting=!1,this.textareaEventListeners={},this.id=t.id,this.data={},this.root=t,this.container=e,this.options=n,this.aria=new Q(this.getControllerSelf()),this.ariaLabel="Math Input",this.ariaPostLabel="",t.controller=this.getControllerSelf(),this.cursor=t.cursor=new et(t,n,this.getControllerSelf())}return t.isControllerRoot=function(t){var e=t.controller;return e&&e.root===t},t.prototype.getControllerSelf=function(){return this},t.prototype.handle=function(t,e){var r,o,i,s=this.options.handlers,a=null===(r=this.options.handlers)||void 0===r?void 0:r.fns[t];a&&(o=null===s||void 0===s?void 0:s.APIClasses[this.KIND_OF_MQ],n("APIClass is defined",o),i=new o(this),e===Ae||e===Me?a(e,i):a(i))},t.onNotify=function(e){t.notifyees.push(e)},t.prototype.notify=function(e){for(var n=0;n<t.notifyees.length;n+=1)t.notifyees[n](this.cursor,e);return this},t.prototype.setAriaLabel=function(t){var e=this.getAriaLabel();return!t&&this.editable?this.ariaLabel="Math Input":this.ariaLabel=t,t===e||this.containerHasFocus()||this.updateMathspeak(),this},t.prototype.getAriaLabel=function(){return"Math Input"!==this.ariaLabel?this.ariaLabel:this.editable?"Math Input":""},t.prototype.setAriaPostLabel=function(t,e){var n=this;return t&&"string"==typeof t&&""!==t?(t!==this.ariaPostLabel&&"number"==typeof e&&(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this._ariaAlertTimeout=setTimeout(function(){n.containerHasFocus()?n.aria.alert(n.root.mathspeak().trim()+" "+t.trim()):n.updateMathspeak()},e)),this.ariaPostLabel=t):(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this.ariaPostLabel=""),this},t.prototype.getAriaPostLabel=function(){return this.ariaPostLabel||""},t.prototype.containerHasFocus=function(){return document.activeElement&&this.container.contains(document.activeElement)},t.prototype.getTextarea=function(){var t=this.textarea;return n("textarea initialized",t),t},t.prototype.getTextareaSpan=function(){var t=this.textareaSpan;return n("textareaSpan initialized",t),t},t.prototype.addTextareaEventListeners=function(t){var e,n;if(this.textarea)for(e in t)n=e,this.removeTextareaEventListener(n),this.textarea.addEventListener(n,t[n])},t.prototype.removeTextareaEventListener=function(t){if(this.textarea){var e=this.textareaEventListeners[t];e&&this.textarea.removeEventListener(t,e)}},t.prototype.exportMathSpeak=function(){return this.root.mathspeak()},t.prototype.updateMathspeak=function(t){},t.prototype.scrollHoriz=function(){},t.prototype.selectionChanged=function(){},t.prototype.setOverflowClasses=function(){},t.notifyees=[],t}(),ot={},it={},st={},at=function(){function t(t){this.version=t}return t.prototype.assertJquery=function(){return n("Interface versions > 2 do not depend on JQuery",this.version<=2),n("JQuery is set for interface v < 3",this.jQuery),this.jQuery},t}(),lt=function(){function t(){}return t}(),ct=function(){window.console&&console.warn('You are using the MathQuill API without specifying an interface version, which will fail in v1.0.0. Easiest fix is to do the following before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},m.prototype=lt.prototype,m.VERSION="v0.10.1",m.interfaceVersion=function(t){if(1!==t)throw"Only interface version 1 supported. You specified: "+t;return ct=function(){window.console&&console.warn('You called MathQuill.interfaceVersion(1); to specify the interface version, which will fail in v1.0.0. You can fix this easily by doing this before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},ct(),m},m.getInterface=g,pt=g.MIN=1,ht=g.MAX=3,m.noConflict=function(){return window.MathQuill=dt,m},dt=window.MathQuill,window.MathQuill=m,ft=function(){function t(t){this._=t}return t.prototype.parse=function(e){function n(t,e){return e}return this.skip(t.eof)._(""+e,n,v)},t.prototype.or=function(e){n("or is passed a parser",e instanceof t);var r=this;return new t(function(t,n,o){function i(r){return e._(t,n,o)}return r._(t,n,i)})},t.prototype.then=function(e){var r=this;return new t(function(o,i,s){function a(r,o){var a=e instanceof t?e:e(o);return n("a parser is returned",a instanceof t),a._(r,i,s)}return r._(o,a,s)})},t.prototype.many=function(){var e=this;return new t(function(t,n,r){function o(e,n){return t=e,s.push(n),!0}function i(){return!1}for(var s=[];e._(t,o,i););return n(t,s)})},t.prototype.times=function(e,n){arguments.length<2&&(n=e);var r=this;return new t(function(t,o,i){function s(e,n){return p.push(n),t=e,!0}function a(e,n){return c=n,t=e,!1}function l(t,e){return!1}var c,u,p=[],h=!0;for(u=0;u<e;u+=1)if(!(h=!!r._(t,s,a)))return i(t,c);for(;u<n&&h;u+=1)r._(t,s,l);return o(t,p)})},t.prototype.result=function(e){return this.then(t.succeed(e))},t.prototype.atMost=function(t){return this.times(0,t)},t.prototype.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.prototype.map=function(e){return this.then(function(n){return t.succeed(e(n))})},t.prototype.skip=function(t){return this.then(function(e){return t.result(e)})},t.string=function(e){var n=e.length,r="expected '"+e+"'";return new t(function(t,o,i){var s=t.slice(0,n);return s===e?o(t.slice(n),s):i(t,r)})},t.regex=function(e){n("regexp parser is anchored","^"===e.toString().charAt(1));var r="expected "+e;return new t(function(t,n,o){var i,s=e.exec(t);return s?(i=s[0],n(t.slice(i.length),i)):o(t,r)})},t.succeed=function(e){return new t(function(t,n){return n(t,e)})},t.fail=function(e){return new t(function(t,n,r){return r(t,e)})},t.letter=t.regex(/^[a-z]/i),t.letters=t.regex(/^[a-z]*/i),t.digit=t.regex(/^[0-9]/),t.digits=t.regex(/^[0-9]*/),t.whitespace=t.regex(/^\s+/),t.optWhitespace=t.regex(/^\s*/),t.any=new t(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),t.all=new t(function(t,e,n){return e("",t)}),t.eof=new t(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)}),t}(),mt=function(){function e(){this.fn=t}return e.prototype.listen=function(t){this.fn=t,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(this.fn)},e.prototype.listenOnce=function(t){var e=this;this.listen(function(){var n,r=[];for(n=0;n<arguments.length;n++)r[n]=arguments[n];e.clearListener(),t.apply(void 0,r)})},e.prototype.clearListener=function(){this.fn=t,clearTimeout(this.timeoutId)},e.prototype.trigger=function(){var t,e=[];for(t=0;t<arguments.length;t++)e[t]=arguments[t];this.fn.apply(this,e)},e}(),gt=function(){function t(t){switch(n(t)){case"Right":case"Left":case"Down":case"Up":return!0}return!1}function e(t){return 1===t.length&&t>="a"&&t<="z"}function n(t){var n,r;return void 0===t.key?(r=t.which||t.keyCode,o[r]||String.fromCharCode(r)):e(t.key)?t.key.toUpperCase():null!==(n=i[t.key])&&void 0!==n?n:t.key}function r(t){var e=n(t),r=[];return t.ctrlKey&&r.push("Ctrl"),t.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),r.length?("Alt"!==e&&"Control"!==e&&"Meta"!==e&&"Shift"!==e&&r.push(e),r.join("-")):e}var o={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"},i={ArrowRight:"Right",ArrowLeft:"Left",ArrowDown:"Down",ArrowUp:"Up",Delete:"Del",Escape:"Esc"," ":"Spacebar"};return function(e,n){function o(){try{e instanceof HTMLTextAreaElement&&e.select()}catch(t){}}function i(t){v.trigger(),v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value=t),t&&o(),x=!!t}function s(){return"selectionStart"in e&&(e instanceof HTMLTextAreaElement&&e.selectionStart!==e.selectionEnd)}function a(){n.options&&n.options.overrideKeystroke?n.options.overrideKeystroke(r(g),g):n.keystroke(r(g),g)}function l(t){v.trigger(t),t.target===e&&(g=t,y=null,x&&v.listenOnce(function(t){t&&"focusout"===t.type||o()}),a())}function c(n){v.trigger(n),n.target===e&&(g&&y&&a(),y=n,t(n)?v.listenOnce(h):v.listen(p))}function u(n){v.trigger(n),n.target===e&&g&&!y&&(t(n)?v.listenOnce(h):v.listen(p))}function p(){if(!s()&&e instanceof HTMLTextAreaElement){var t=e.value;(!g||"Unidentified"!==g.key&&(g.altKey||!g.ctrlKey||g.metaKey||!g.shiftKey||"U"!==g.key&&"Process"!==g.key))&&(1===t.length?(e.value="",n.options&&n.options.overrideTypedText?n.options.overrideTypedText(t):n.typedText(t)):h())}}function h(){e instanceof HTMLTextAreaElement&&e.value.length>1&&o()}function d(){g=null,y=null,v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value="")}function f(t){v.trigger(),t.target===e&&(document.activeElement!==e&&e.focus(),v.listen(function(){if(e instanceof HTMLTextAreaElement){var t=e.value;e.value="",t&&n.paste(t)}}))}function m(t){v.trigger(t)}var g=null,y=null,v=new mt,x=!1;return"StaticMath"===n.KIND_OF_MQ?(n.addTextareaEventListeners({keydown:function(t){var e,o;null===(o=(e=n.options).overrideKeystroke)||void 0===o||o.call(e,r(t),t)}}),{select:i}):(n.options&&n.options.disableCopyPaste?n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,copy:function(t){t.preventDefault()},cut:function(t){t.preventDefault()},paste:function(t){v.trigger(),t.preventDefault()},input:m}):n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,cut:function(){v.listenOnce(function(){n.cut()})},copy:function(){v.listenOnce(function(){n.copy()})},paste:f,input:m}),{select:i})}}(),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.exportText=function(){return this.root.foldChildren("",function(t,e){return t+e.text()})},e}(rt),rt.onNotify(function(t,e){if("edit"===e||"replace"===e||void 0===e){var n=t.controller;if(!n)return;if(!n.options.enableDigitGrouping)return;if(!1!==n.blurred)return;n.disableGroupingForSeconds(1)}}),vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.handleTextareaFocusEditable=function(){var t=e.cursor;e.updateMathspeak(),e.blurred=!1,clearTimeout(e.blurTimeout),U(e.container).addClass("mq-focused"),t.parent||t.insAtRightEnd(e.root),t.selection?(t.selection.domFrag().removeClass("mq-blur"),e.selectionChanged()):t.show(),e.setOverflowClasses()},e.handleTextareaBlurEditable=function(){e.textareaSelectionTimeout&&(clearTimeout(e.textareaSelectionTimeout),e.textareaSelectionTimeout=0),e.disableGroupingForSeconds(0),e.blurred=!0,e.blurTimeout=setTimeout(function(){e.root.postOrder(function(t){t.intentionalBlur()}),e.cursor.clearSelection().endSelection(),e.blur(),e.updateMathspeak({emptyContent:!0}),e.scrollHoriz()}),window.addEventListener("blur",e.handleWindowBlur)},e.handleTextareaFocusStatic=function(){e.cursor.selection||e.cursor.controller.selectAll(),e.blurred=!1},e.handleTextareaBlurStatic=function(){e.cursor.clearSelection(),e.updateMathspeak({emptyContent:!0})},e.handleWindowBlur=function(){clearTimeout(e.blurTimeout),e.cursor.selection&&e.cursor.selection.domFrag().addClass("mq-blur"),e.blurWithoutResettingCursor(),e.updateMathspeak({emptyContent:!0})},e}return __extends(e,t),e.prototype.disableGroupingForSeconds=function(t){var e=this;clearTimeout(this.__disableGroupingTimeout),0===t?this.root.domFrag().removeClass("mq-suppress-grouping"):(this.root.domFrag().addClass("mq-suppress-grouping"),this.__disableGroupingTimeout=setTimeout(function(){e.root.domFrag().removeClass("mq-suppress-grouping")},1e3*t))},e.prototype.blur=function(){this.blurWithoutResettingCursor(),this.options&&this.options.resetCursorOnBlur&&this.cursor.resetToEnd(this)},e.prototype.blurWithoutResettingCursor=function(){this.cursor.hide().parent.blur(this.cursor),U(this.container).removeClass("mq-focused"),window.removeEventListener("blur",this.handleWindowBlur)},e.prototype.addEditableFocusBlurListeners=function(){var t=this,e=t.cursor;this.addTextareaEventListeners({focus:this.handleTextareaFocusEditable,blur:this.handleTextareaBlurEditable}),t.blurred=!0,e.hide().parent.blur(e)},e.prototype.addStaticFocusBlurListeners=function(){this.addTextareaEventListeners({focus:this.handleTextareaFocusStatic,blur:this.handleTextareaBlurStatic})},e}(yt),xt=!1,bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,n,r){var o=r.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":r.ctrlDeleteDir(Ae);break;case"Shift-Backspace":case"Backspace":r.backspace();break;case"Esc":case"Tab":return void r.escapeDir(Me,t,n);case"Shift-Tab":case"Shift-Esc":return void r.escapeDir(Ae,t,n);case"End":r.notify("move").cursor.insAtRightEnd(o.parent),r.aria.queue("end of").queue(o.parent,!0);break;case"Ctrl-End":r.notify("move").cursor.insAtRightEnd(r.root),r.aria.queue("end of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-End":r.selectToBlockEndInDir(Me);break;case"Ctrl-Shift-End":r.selectToRootEndInDir(Me);break;case"Home":r.notify("move").cursor.insAtLeftEnd(o.parent),r.aria.queue("beginning of").queue(o.parent,!0);break;case"Ctrl-Home":r.notify("move").cursor.insAtLeftEnd(r.root),r.aria.queue("beginning of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-Home":r.selectToBlockEndInDir(Ae);break;case"Ctrl-Shift-Home":r.selectToRootEndInDir(Ae);break;case"Left":r.moveLeft();break;case"Shift-Left":r.selectLeft();break;case"Ctrl-Left":break;case"Right":r.moveRight();break;case"Shift-Right":r.selectRight();break;case"Ctrl-Right":break;case"Up":r.moveUp();break;case"Down":r.moveDown();break;case"Shift-Up":r.withIncrementalSelection(function(t){if(o[Ae])for(;o[Ae];)t(Ae);else t(Ae)});break;case"Shift-Down":r.withIncrementalSelection(function(t){if(o[Me])for(;o[Me];)t(Me);else t(Me)});break;case"Ctrl-Up":case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":r.ctrlDeleteDir(Me);break;case"Shift-Del":case"Del":r.deleteForward();break;case"Meta-A":case"Ctrl-A":r.selectAll();break;case"Ctrl-Alt-Up":o.parent.parent&&o.parent.parent instanceof e?r.aria.queue(o.parent.parent):r.aria.queue("nothing above");break;case"Ctrl-Alt-Down":o.parent&&o.parent instanceof e?r.aria.queue(o.parent):r.aria.queue("block is empty");break;case"Ctrl-Alt-Left":o.parent.parent&&o.parent.parent.getEnd(Ae)?r.aria.queue(o.parent.parent.getEnd(Ae)):r.aria.queue("nothing to the left");break;case"Ctrl-Alt-Right":o.parent.parent&&o.parent.parent.getEnd(Me)?r.aria.queue(o.parent.parent.getEnd(Me)):r.aria.queue("nothing to the right");break;case"Ctrl-Alt-Shift-Down":o.selection?r.aria.queue(o.selection.join("mathspeak"," ").trim()+" selected"):r.aria.queue("nothing selected");break;case"Ctrl-Alt-=":case"Ctrl-Alt-Shift-Right":r.ariaPostLabel.length?r.aria.queue(r.ariaPostLabel):r.aria.queue("no answer");break;default:return}r.aria.alert(),null===n||void 0===n||n.preventDefault(),r.scrollHoriz()},e.prototype.moveOutOf=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.moveTowards=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.deleteOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.deleteTowards=function(t,e){n("overridden or never called on this node",!1)},e.prototype.unselectInto=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectTowards=function(t,e){n("overridden or never called on this node",!1)},e}(X),rt.onNotify(function(t,e){"move"!==e&&"upDown"!==e||t.show().clearSelection()}),st.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},rt.onNotify(function(t,e){"upDown"!==e&&(t.upDownCache={})}),rt.onNotify(function(t,e){"edit"===e&&t.show().deleteSelection()}),rt.onNotify(function(t,e){"select"!==e&&t.endSelection()}),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this.getControllerSelf())},e.prototype.escapeDir=function(t,e,n){r(t);var o=this.cursor;if(o.parent!==this.root&&(null===n||void 0===n||n.preventDefault()),o.parent!==this.root)return o.clearSelection(),o.parent.moveOutOf(t,o),o.controller.aria.alert(),this.notify("move")},e.prototype.moveDir=function(t){var e,n,o;return r(t),e=this.cursor,n=e.options.leftRightIntoCmdGoes,o=e[t],e.selection?e.insDirOf(t,e.selection.getEnd(t)):o?o.moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.notify("move")},e.prototype.moveLeft=function(){return this.moveDir(Ae)},e.prototype.moveRight=function(){return this.moveDir(Me)},e.prototype.moveUp=function(){return this.moveUpDown("up")},e.prototype.moveDown=function(){return this.moveUpDown("down")},e.prototype.moveUpDown=function(t){var e,n,r,o,i,s,a=this,l=a.notify("upDown").cursor;return"up"===t?(e="upInto",n="upOutOf"):(e="downInto",n="downOutOf"),r=l[Ae],o=l[Me],i=o&&o[e],s=r&&r[e],i?l.insAtLeftEnd(i):s?l.insAtRightEnd(s):l.parent.bubble(function(t){var e=t[n];if(e&&("function"==typeof e&&(e=e.call(t,l)),e instanceof bt&&l.jumpUpDown(t,e),!0!==e))return!1}),a},e.prototype.deleteDir=function(t){var e,n,o,i,s,a,l,c,u,p;return r(t),e=this.cursor,n=e[t],o=e.parent.parent,i=e.controller,n&&n instanceof bt?n.sides?i.aria.queue(n.parent.chToCmd(n.sides[-t].ch).mathspeak({createdLeftOf:e})):n.blocks||"\\text"===n.parent.ctrlSeq||i.aria.queue(n):o&&o instanceof bt&&(o.sides?i.aria.queue(o.parent.chToCmd(o.sides[t].ch).mathspeak({createdLeftOf:e})):o.blocks&&o.mathspeakTemplate?o.upInto&&o.downInto?i.aria.queue(o.mathspeakTemplate[1]):(s=o.mathspeakTemplate,a=t===Ae?s[0]:s[s.length-1],i.aria.queue(a)):i.aria.queue(o)),l=e.selection,this.notify("edit"),l||(c=e[t],c?c.deleteTowards(t,e):e.parent.deleteOutOf(t,e)),u=e[Ae],p=e[Me],u.siblingDeleted&&u.siblingDeleted(e.options,Me),p.siblingDeleted&&p.siblingDeleted(e.options,Ae),e.parent.bubble(function(t){t.reflow()}),this},e.prototype.ctrlDeleteDir=function(t){var e,n,o,i;return r(t),e=this.cursor,!e[t]||e.selection?this.deleteDir(t):(this.notify("edit"),n=t===Ae?new Y(e.parent.getEnd(Ae),e[Ae]):new Y(e[Me],e.parent.getEnd(Me)),e.controller.aria.queue(n),n.remove(),e.insAtDirEnd(t,e.parent),o=e[Ae],i=e[Me],o&&o.siblingDeleted(e.options,Me),i&&i.siblingDeleted(e.options,Ae),e.parent.bubble(function(t){t.reflow()}),this)},e.prototype.backspace=function(){return this.deleteDir(Ae)},e.prototype.deleteForward=function(){return this.deleteDir(Me)},e.prototype.startIncrementalSelection=function(){n("Multiple selections can't be simultaneously open",!xt),xt=!0,this.notify("select");var t=this.cursor;t.anticursor||t.startSelection()},e.prototype.selectDirIncremental=function(t){var e,o,i;n("A selection is open",xt),xt=!0,e=this.cursor,o=e.selection,r(t),i=e[t],i?o&&o.getEnd(t)===i&&e.anticursor[-t]!==i?i.unselectInto(t,e):i.selectTowards(t,e):e.parent.selectOutOf(t,e)},e.prototype.finishIncrementalSelection=function(){var t,e;n("A selection is open",xt),t=this.cursor,t.clearSelection(),t.select()||t.show(),e=t.selection,e&&t.controller.aria.clear().queue(e.join("mathspeak"," ").trim()+" selected"),xt=!1},e.prototype.withIncrementalSelection=function(t){var e=this;try{this.startIncrementalSelection();try{t(function(t){return e.selectDirIncremental(t)})}finally{this.finishIncrementalSelection()}}finally{xt=!1}},e.prototype.selectDir=function(t){this.withIncrementalSelection(function(e){return e(t)})},e.prototype.selectLeft=function(){return this.selectDir(Ae)},e.prototype.selectRight=function(){return this.selectDir(Me)},e.prototype.selectAll=function(){this.notify("move");var t=this.cursor;t.insAtRightEnd(this.root),this.withIncrementalSelection(function(e){for(;t[Ae];)e(Ae)})},e.prototype.selectToBlockEndInDir=function(t){var e=this.cursor;this.withIncrementalSelection(function(n){for(;e[t];)n(t)})},e.prototype.selectToRootEndInDir=function(t){var e=this,n=this.cursor;this.withIncrementalSelection(function(r){for(;n[t]||n.parent!==e.root;)r(t)})},e}(vt),function(t){function e(e){return t.call(this)||this}__extends(e,t)}(bt),Et=function(){function t(t){var e=new It;return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||new It;for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.getEnd(Me),0);return n}var n=ft.string,r=ft.regex,o=ft.letter,i=ft.digit,s=ft.any,a=ft.optWhitespace,l=ft.succeed,c=ft.fail,u=o.map(function(t){return new jt(t)}),p=i.map(function(t){return new Pt(t)}),h=r(/^[^${}\\_^]/).map(function(t){return new At(t)}),d=r(/^[^\\a-eg-zA-Z]/).or(n("\\").then(r(/^[a-z]+/i).or(r(/^\s+/).result(" ")).or(s))).then(function(t){var e,n,r=Z[t];return r?r.constructor?(e=r,new e(t).parser()):(n=r,n(t).parser()):c("unknown command: \\"+t)}),f=d.or(u).or(p).or(h),m=n("{").then(function(){return y}).skip(n("}")),g=a.then(m.or(f.map(t))),y=g.many().map(e).skip(a),v=n("[").then(g.then(function(t){return"]"!==t.join("latex")?l(t):c("")}).many().map(e).skip(a)).skip(n("]")),x=y;return x.block=g,x.optBlock=v,x}(),st.maxDepth=function(t){return"number"==typeof t?t:void 0},kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.cleanLatex=function(t){return t.replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},e.prototype.exportLatex=function(){return this.cleanLatex(this.root.latex())},e.prototype.writeLatex=function(t){var e=this.notify("edit").cursor;return e.parent.writeLatex(e,t),this},e.prototype.prepareCursorForRestoration=function(){return this.cursor.clearSelection().endSelection(),this.notify("move").cursor},e.prototype.restoreLatexSelection=function(t){var e,n,r,o=this,i=this.exportLatexSelection(),s=i.selection,a=s.latex,l=t.latex;l===a&&(t.startIndex===s.startIndex&&t.endIndex===s.endIndex||(0===t.endIndex?this.prepareCursorForRestoration().insAtDirEnd(Ae,this.root):t.startIndex===l.length?this.prepareCursorForRestoration().insAtDirEnd(Me,this.root):(e=b(a,i.ctx.uncleanedLatex,t),n=this.exportLatexSelection(e).ctx.restoreInfo,t.startIndex===t.endIndex?(null===n||void 0===n?void 0:n.cursorL)?this.prepareCursorForRestoration().insRightOf(n.cursorL):(null===n||void 0===n?void 0:n.cursorParent)&&this.prepareCursorForRestoration().insAtLeftEnd(n.cursorParent):(null===n||void 0===n?void 0:n.selectionL)&&n.selectionR&&(this.prepareCursorForRestoration().insRightOf(n.selectionR),r=this.cursor.controller.root,this.withIncrementalSelection(function(t){do{if(t(Ae),!o.cursor[Ae]&&o.cursor.parent===r)break}while(o.cursor[Me]!==n.selectionL)})))))},e.prototype.exportLatexSelection=function(t){var e,n,r,o,i,s,a,l,c={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return t&&(c.restoreInfo={uncleanedStartIndex:t.uncleanStartIndex,uncleanedEndIndex:t.uncleanEndIndex}),e=this.cursor.selection,e&&this.cursor.anticursor?(c.startSelectionBefore=e.getEnd(Ae),c.endSelectionAfter=e.getEnd(Me)):(n=this.cursor[Ae],n?c.startSelectionAfter=n:c.startSelectionBefore=this.cursor.parent,r=this.cursor[Me],r?c.endSelectionBefore=r:c.endSelectionAfter=this.cursor.parent),this.root.latexRecursive(c),o=c.uncleanedLatex,i=this.cleanLatex(o),s=x(o,i,c),a=s.startIndex,l=s.endIndex,{selection:{latex:i,startIndex:a,endIndex:l},ctx:c}},e.prototype.classifyLatexForEfficientUpdate=function(t){if("string"==typeof t){var e=t.match(/-?[0-9.]+$/g);return e&&1===e.length?{latex:t,prefix:t.substr(0,t.length-e[0].length),digits:e[0]}:void 0}},e.prototype.updateLatexMathEfficiently=function(t,e){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b,w,E,k,L,S,_,q=this.root,O=this.classifyLatexForEfficientUpdate(t);if(!O)return!1;if(!(s=this.classifyLatexForEfficientUpdate(e))||s.prefix!==O.prefix)return!1;for(a=s.digits,l=O.digits,c=!1,u=!1,"-"===a[0]&&(c=!0,a=a.substr(1)),"-"===l[0]&&(u=!0,l=l.substr(1)),p=this.root.getEnd(Me),h=[],d=a.length-1;d>=0;d--){if(!p||p.ctrlSeq!==a[d])return!1;if(p.parent!==q)return!1;h.unshift(p),p=p[Ae]}if(c&&!u){if(!(f=p))return!1;if("-"!==f.ctrlSeq)return!1;if(f[Me]!==h[0])return!1;if(f.parent!==q)return!1;if((m=f[Ae])&&m.parent!==q)return!1;h[0][Ae]=f[Ae],q.getEnd(Ae)===f&&q.setEnds((n={},n[Ae]=h[0],n[Me]=q.getEnd(Me),n)),m&&(m[Me]=h[0]),f.domFrag().remove()}for(!c&&u&&(g=new Xt("-"),y=document.createElement("span"),y.textContent="-",g.setDOM(y),v=h[0][Ae],v&&(v[Me]=g),q.getEnd(Ae)===h[0]&&q.setEnds((r={},r[Ae]=g,r[Me]=q.getEnd(Me),r)),g.parent=q,g[Ae]=h[0][Ae],g[Me]=h[0],h[0][Ae]=g,g.contactWeld(this.cursor),g.domFrag().insertBefore(h[0].domFrag())),x=Math.min(a.length,l.length),d=0;d<x;d++)b=l[d],p=h[d],p.ctrlSeq!==b&&(p.ctrlSeq=b,p.domFrag().oneElement().textContent=b,p.mathspeakName=b);if(a.length>l.length)for(p=h[l.length-1],q.setEnds((o={},o[Ae]=q.getEnd(Ae),o[Me]=p,o)),p[Me]=0,d=a.length-1;d>=x;d--)h[d].domFrag().remove();if(l.length>a.length){for(w=document.createDocumentFragment(),d=x;d<l.length;d++)E=document.createElement("span"),E.className="mq-digit",E.textContent=l[d],k=new Pt(l[d]),k.parent=q,k.setDOM(E),w.appendChild(E),k[Ae]=q.getEnd(Me),k[Me]=0,L=k[Ae],L[Me]=k,q.setEnds((i={},i[Ae]=q.getEnd(Ae),i[Me]=k,i));q.domFrag().oneElement().appendChild(w)}return(S=this.exportLatex())!==t?(console.warn("tried updating latex efficiently but did not work. Attempted: "+t+" but wrote: "+S),!1):(_=q.getEnd(Me),_&&_.fixDigitGrouping(this.cursor.options),!0)},e.prototype.renderLatexMathFromScratch=function(t){var e,n,r=this.root,o=this.cursor,i=ft.all,s=ft.eof,a=Et.skip(s).or(i.result(!1)).parse(t);r.setEnds((e={},e[Ae]=0,e[Me]=0,e)),a&&a.children().adopt(r,0,0),a?(n=r.domFrag(),n.children().remove(),n.oneElement().appendChild(a.html()),r.finalizeInsert(o.options,o)):r.domFrag().empty()},e.prototype.renderLatexMath=function(t){var e,n=this.cursor,r=this.root;this.notify("replace"),n.clearSelection(),e=this.exportLatex(),r.getEnd(Ae)&&r.getEnd(Me)&&e===t||(this.updateLatexMathEfficiently(t,e)||this.renderLatexMathFromScratch(t),this.updateMathspeak()),n.insAtRightEnd(r)},e.prototype.renderLatexText=function(t){var e,n,r,o,i,s,a,l,c,u,p,h=this.root,d=this.cursor;if(h.domFrag().children().slice(1).remove(),h.setEnds((e={},e[Ae]=0,e[Me]=0,e)),delete d.selection,d.show().insAtRightEnd(h),n=ft.regex,r=ft.string,o=ft.eof,i=ft.all,s=r("$").then(Et).skip(r("$").or(o)).map(function(t){var e,n=new RootMathCommand(d);return n.createBlocks(),e=n.getEnd(Ae),t.children().adopt(e,0,0),n}),a=r("\\$").result("$"),l=a.or(n(/^[^$]/)).map(function(t){return new At(t)}),c=s.or(l).many(),u=c.skip(o).or(i.result(!1)).parse(t)){for(p=0;p<u.length;p+=1)u[p].adopt(h,h.getEnd(Me),0);U(h.html()).appendTo(h.domFrag().oneElement()),h.finalizeInsert(d.options,d)}},e}(wt),Lt=function(t){return!1},at.prototype.ignoreNextMousedown=Lt,function(){rt.onNotify(function(t,e){"edit"!==e&&"replace"!==e||St&&St.cursor===t&&St.cb()})}(),_t=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.handleMouseDown=function(e){function r(t){c=t.target}function o(t){m.anticursor||m.startSelection(),f.seek(c,t.clientX,t.clientY).cursor.select(),m.selection&&m.controller.aria.clear().queue(m.selection.join("mathspeak")+" selected").alert(),c=null}function s(){null===p||void 0===p||p.removeEventListener("mousemove",r),null===d||void 0===d||d.removeEventListener("mousemove",o),null===d||void 0===d||d.removeEventListener("mouseup",l),St=void 0,f.isMouseSelecting=!1}function a(){f.editable&&(m.show(),m.controller.aria.queue(m.parent).alert())}function l(){m.blink=g,m.selection||a(),s()}var c,u,p=i(e.target,".mq-root-block"),h=p&&X.getNodeOfElement(p)||X.getNodeOfElement(n.root.domFrag().oneElement()),d=h.domFrag().firstNode().ownerDocument,f=h.controller,m=f.cursor,g=m.blink,y=f.getTextarea();e.preventDefault(),e.target.unselectable=!0,m.options.ignoreNextMousedown(e)||i(e.target,".mq-ignore-mousedown")||(c=null,St={cursor:m,cb:function(){u=!0,m.blink=g,m.clearSelection(),a(),s()}},f.blurred&&(n.editable&&y.focus(),u)||(m.blink=t,f.isMouseSelecting=!0,f.seek(e.target,e.clientX,e.clientY).cursor.startSelection(),null===p||void 0===p||p.addEventListener("mousemove",r),null===d||void 0===d||d.addEventListener("mousemove",o),null===d||void 0===d||d.addEventListener("mouseup",l)))},n}return __extends(n,e),n.prototype.addMouseEventListener=function(){this.container.addEventListener("mousedown",this.handleMouseDown)},n.prototype.removeMouseEventListener=function(){this.container.removeEventListener("mousedown",this.handleMouseDown)},n.prototype.seek=function(t,e,n){for(var r,o,i=this.notify("select").cursor;t;){if(r=X.getNodeOfElement(t)){if(!(o=w(r))||o===this.root)break;t=o.controller.container}t=t.parentElement}return r||(r=this.root),i.clearSelection().show(),r.seek(e,i),this.scrollHoriz(),this},n}(kt),qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOverflowClasses=function(){var t,e,n,r=this.root.domFrag().oneElement(),o=!1,i=!1;this.blurred||(t=s(r).width,e=r.scrollWidth,n=r.scrollLeft,o=e>t+n,i=n>0),r.classList.contains("mq-editing-overflow-right")!==o&&r.classList.toggle("mq-editing-overflow-right"),r.classList.contains("mq-editing-overflow-left")!==i&&r.classList.toggle("mq-editing-overflow-left")},e.prototype.scrollHoriz=function(){var t,e,n,r,o,i,a,l,c,u,p=this,h=this.cursor,d=h.selection,f=s(this.root.domFrag().oneElement());if(h.domFrag().isEmpty()&&!d)return this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),t=this.root.domFrag().oneElement(),e=t.scrollLeft,void W(this.getScrollAnimationDuration(),function(n,r,o){n>=1?(p.cancelScrollHoriz=void 0,t.scrollLeft=0,p.setOverflowClasses()):(p.cancelScrollHoriz=o,r(),t.scrollLeft=Math.round((1-n)*e))});if(d)if(o=s(d.domFrag().oneElement()),i=o.left-(f.left+20),a=o.right-(f.right-20),d.getEnd(Ae)===h[Me])if(i<0)r=i;else{if(!(a>0))return;r=o.left-a<f.left+20?i:a}else if(a>0)r=a;else{if(!(i<0))return;r=o.right-i>f.right-20?a:i}else if((n=s(h.domFrag().oneElement()).left)>f.right-20)r=n-(f.right-20);else{if(!(n<f.left+20))return;r=n-(f.left+20)}l=this.root.domFrag().oneElement(),
12
+ r<0&&0===l.scrollLeft||r>0&&l.scrollWidth<=l.scrollLeft+f.width||(this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),c=this.root.domFrag().oneElement(),u=c.scrollLeft,W(this.getScrollAnimationDuration(),function(t,e,n){t>=1?(p.cancelScrollHoriz=void 0,c.scrollLeft=Math.round(u+r),p.setOverflowClasses()):(p.cancelScrollHoriz=n,e(),c.scrollLeft=Math.round(u+t*r))}))},e.prototype.getScrollAnimationDuration=function(){var t;return null!==(t=this.options.scrollAnimationDuration)&&void 0!==t?t:100},e}(_t),at.prototype.substituteTextarea=function(){return Re("textarea",{autocapitalize:"off",autocomplete:"off",autocorrect:"off",spellcheck:!1,"x-palm-disable-ste-all":!0})},at.prototype.substituteKeyboardEvents=k,Ot=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.selectFn=t,n}return __extends(n,e),n.prototype.createTextarea=function(){var t,e,n;if(this.textareaSpan=Re("span",{class:"mq-textarea"}),t=this.options.substituteTextarea(),!t.nodeType)throw"substituteTextarea() must return a DOM element, got "+t;this.textarea=U(t).appendTo(this.textareaSpan).oneElement(),this.mathspeakSpan||(this.mathspeakId=E(),this.mathspeakSpan=Re("span",{class:"mq-mathspeak",id:this.mathspeakId}),U(this.textareaSpan).prepend(U(this.mathspeakSpan))),this.mathspeakId&&(null===t||void 0===t||t.setAttribute("aria-labelledby",this.mathspeakId)),e=this,e.cursor.selectionChanged=function(){e.selectionChanged()},n=void 0!==this.options.tabindex?this.options.tabindex:"StaticMath"===this.KIND_OF_MQ?-1:0,this.setTabindex(n)},n.prototype.setTabindex=function(t){var e,n,r,o,i;t!==this.previousTabindex&&this.textarea&&(this.previousTabindex=t,null===(e=this.textarea)||void 0===e||e.setAttribute("tabindex",""+t),t<0&&"StaticMath"===this.KIND_OF_MQ?null===(n=this.textarea)||void 0===n||n.setAttribute("aria-hidden","true"):null===(r=this.textarea)||void 0===r||r.removeAttribute("aria-hidden"),t>=0?null===(o=this.mathspeakSpan)||void 0===o||o.setAttribute("aria-hidden","true"):null===(i=this.mathspeakSpan)||void 0===i||i.removeAttribute("aria-hidden"))},n.prototype.selectionChanged=function(){var t=this;t.textareaSelectionTimeout||(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},n.prototype.setTextareaSelection=function(){this.textareaSelectionTimeout=0;var t="";this.cursor.selection&&(t=this.cleanLatex(this.cursor.selection.join("latex")),this.options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},n.prototype.staticMathTextareaEvents=function(){var t,e,n,r=this;this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste"),r.options.disableCopyPaste?this.removeTextareaEventListener("copy"):this.addTextareaEventListeners({copy:function(){r.setTextareaSelection()}}),this.addStaticFocusBlurListeners(),t=this.getTextarea(),e=gt(t,this).select,this.selectFn=e,n=this.getTextareaSpan(),U(this.container).prepend(U(n))},n.prototype.editablesTextareaEvents=function(){var t,e,n,r=this,o=r.getTextarea(),i=r.getTextareaSpan();this.options.version<3?(t=this.options.assertJquery(),e=this.options.substituteKeyboardEvents(t(o),this),this.selectFn=function(t){e.select(t)}):(n=gt(o,this).select,this.selectFn=n),U(this.container).prepend(U(i)),this.addEditableFocusBlurListeners(),this.updateMathspeak()},n.prototype.unbindEditablesEvents=function(){var t=this,e=t.getTextarea(),n=t.getTextareaSpan();this.selectFn=function(t){e instanceof HTMLTextAreaElement&&(e.value=t,t&&e.select())},U(n).remove(),this.removeTextareaEventListener("focus"),this.removeTextareaEventListener("blur"),t.blurred=!0,this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste")},n.prototype.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify(void 0).cursor;e.parent.write(e,t),this.scrollHoriz()},n.prototype.cut=function(){var t=this,e=t.cursor;e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble(function(t){t.reflow()}),t.options&&t.options.onCut&&t.options.onCut()})},n.prototype.copy=function(){this.setTextareaSelection()},n.prototype.paste=function(t){this.options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show(),this.scrollHoriz(),this.options&&this.options.onPaste&&this.options.onPaste()},n.prototype.setupStaticField=function(){this.updateMathspeak(),this.blurred=!0,this.cursor.hide().parent.blur(this.cursor)},n.prototype.updateMathspeak=function(t){var e=this,n=e.getAriaLabel(),r=/[A-Za-z0-9]$/.test(n)?n+":":n,o=e.root.mathspeak().trim(),i=!!(null===t||void 0===t?void 0:t.emptyContent);this.aria.clear({emptyContent:i}),e.mathspeakSpan&&(e.mathspeakSpan.textContent=(r+" "+o+" "+e.ariaPostLabel).trim())},n}(qt),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeInsert=function(t,e){var n,r,o=this;o.postOrder(function(e){e.finalizeTree(t)}),o.postOrder(function(t){t.contactWeld(e)}),o.postOrder(function(t){t.blur(e)}),o.postOrder(function(t){t.reflow()}),n=o[Me],r=o[Ae],n&&n.siblingCreated(t,Ae),r&&r.siblingCreated(t,Me),o.bubble(function(t){t.reflow()})},e.prototype.prepareInsertionAt=function(t){var e,n=t.options.maxDepth;if(void 0!==n){if((e=t.depth())>n)return!1;this.removeNodesDeeperThan(n-e)}return!0},e.prototype.removeNodesDeeperThan=function(t){for(var e,n,r=0,o=[[this,r]];e=o.shift();)n=e,n[0].children().each(function(e){var i=e instanceof It?1:0;r=n[1]+i,r<=t?o.push([e,r]):(i?e.children():e).remove()})},e}(bt),Tt=function(){function t(t,e){this.childCount=t,this.render=e}return t}(),Ft=function(t){function e(e,n,r){var o=t.call(this)||this;return o.textTemplate=[""],o.mathspeakTemplate=[""],o.setCtrlSeqHtmlAndText(e,n,r),o}return __extends(e,t),e.prototype.setEnds=function(t){n("MathCommand ends are never empty",t[Ae]&&t[Me]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.setCtrlSeqHtmlAndText=function(t,e,n){this.ctrlSeq||(this.ctrlSeq=t),e&&(this.domView=e),n&&(this.textTemplate=n)},e.prototype.replaces=function(t){t.disown(),this.replacedFragment=t},e.prototype.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},e.prototype.parser=function(){var t=this;return Et.block.times(this.numBlocks()).map(function(e){t.blocks=e;for(var n=0;n<e.length;n+=1)e[n].adopt(t,t.getEnd(Me),0);return t})},e.prototype.createLeftOf=function(e){var n,r=this,o=r.replacedFragment;r.createBlocks(),t.prototype.createLeftOf.call(this,e),o&&(n=r.getEnd(Ae),o.adopt(n,0,0),o.domFrag().appendTo(n.domFrag().oneElement()),r.placeCursor(e),r.prepareInsertionAt(e)),r.finalizeInsert(e.options,e),r.placeCursor(e)},e.prototype.createBlocks=function(){var t,e,n=this,r=n.numBlocks(),o=n.blocks=Array(r);for(t=0;t<r;t+=1)e=o[t]=new It,e.adopt(n,n.getEnd(Me),0)},e.prototype.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.getEnd(Ae),function(t,e){return t.isEmpty()?t:e}))},e.prototype.moveTowards=function(t,e,n){var r,o;"up"===n?r=this.upInto:"down"===n&&(r=this.downInto),o=r||this.getEnd(-t),e.insAtDirEnd(-t,o),e.controller.aria.queueDirEndOf(-t).queue(e.parent,!0)},e.prototype.deleteTowards=function(t,e){this.isEmpty()?e[t]=this.remove()[t]:this.moveTowards(t,e)},e.prototype.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},e.prototype.selectChildren=function(){return new nt(this,this)},e.prototype.unselectInto=function(t,e){var n=e.anticursor,r=n.ancestors[this.id];e.insAtDirEnd(-t,r)},e.prototype.seek=function(t,e){function n(t){var e,n=t.domFrag().oneElement(),r=s(n).left,o=r+n.offsetWidth;return e={},e[Ae]=r,e[Me]=o,e}var r,o=this,i=n(o);return t<i[Ae]?e.insLeftOf(o):t>i[Me]?e.insRightOf(o):(r=i[Ae],void o.eachChild(function(s){var a=n(s);return t<a[Ae]?(t-r<a[Ae]-t?s[Ae]?e.insAtRightEnd(s[Ae]):e.insLeftOf(o):e.insAtLeftEnd(s),!1):t>a[Me]?void(s[Me]?r=a[Me]:i[Me]-t<t-a[Me]?e.insRightOf(o):e.insAtRightEnd(s)):(s.seek(t,e),!1)}))},e.prototype.numBlocks=function(){return this.domView.childCount},e.prototype.html=function(){var t,e,r=this.blocks;return n("domView is defined",this.domView),t=this.domView,e=t.render(r||[]),this.setDOM(e),X.linkElementByCmdNode(e,this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.eachChild(function(e){var n,r;t.uncleanedLatex+="{",n=t.uncleanedLatex.length,e.latexRecursive(t),r=t.uncleanedLatex.length,n===r&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this,e=0;return t.foldChildren(t.textTemplate[e],function(n,r){e+=1;var o=r.text();return n&&"("===t.textTemplate[e]&&"("===o[0]&&")"===o.slice(-1)?n+o.slice(1,-1)+t.textTemplate[e]:n+o+(t.textTemplate[e]||"")})},e.prototype.mathspeak=function(){var t=this,e=0;return t.foldChildren(t.mathspeakTemplate[e]||"Start"+t.ctrlSeq+" ",function(n,r){return e+=1,n+" "+r.mathspeak()+" "+(t.mathspeakTemplate[e]+" "||"End"+t.ctrlSeq+" ")})},e}(Ct),Dt=function(t){function e(e,n,r,o){var i=t.call(this)||this;return i.setCtrlSeqHtmlTextAndMathspeak(e,n?new Tt(0,function(){return n.cloneNode(!0)}):void 0,r,o),i}return __extends(e,t),e.prototype.setCtrlSeqHtmlTextAndMathspeak=function(e,n,r,o){!r&&e&&(r=e.replace(/^\\/,"")),this.mathspeakName=o||r,t.prototype.setCtrlSeqHtmlAndText.call(this,e,n,[r||""])},e.prototype.parser=function(){return ft.succeed(this)},e.prototype.numBlocks=function(){return 0},e.prototype.replaces=function(t){t.remove()},e.prototype.createBlocks=function(){},e.prototype.moveTowards=function(t,e){e.domFrag().insDirOf(t,this.domFrag()),e[-t]=this,e[t]=this[t],e.controller.aria.queue(this)},e.prototype.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.prototype.seek=function(t,e){var n=this.domFrag().oneElement();return t-s(n).left<n.offsetWidth/2?e.insLeftOf(this):e.insRightOf(this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.checkCursorContextClose(t)},e.prototype.text=function(){return this.textTemplate.join("")},e.prototype.mathspeak=function(t){return this.mathspeakName||""},e.prototype.placeCursor=function(){},e.prototype.isEmpty=function(){return!0},e}(Ft),At=function(t){function e(e,n,r){return t.call(this,e,Re("span",{},[n||Re.text(e)]),void 0,r)||this}return __extends(e,t),e}(Dt),Mt=function(t){function e(e,n,r,o,i){return i?t.call(this,e,Re("span",{},[n||Re.text(e||"")]),void 0,o)||this:t.call(this,e,Re("span",{class:"mq-binary-operator"},n?[n]:[]),r,o)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return!0},e}(Dt),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ariaLabel="block",e}return __extends(e,t),e.prototype.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},e.prototype.html=function(){var t=document.createDocumentFragment();return this.eachChild(function(e){var n=e.html();t.appendChild(n)}),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.eachChild(function(e){return e.latexRecursive(t)}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this.getEnd(Ae);return t===this.getEnd(Me)&&0!==t?t.text():this.join("text")},e.prototype.mathspeak=function(){var t="",e={};return this.controller&&(e=this.controller.options.autoOperatorNames),this.foldChildren([],function(n,r){var o,i,s;return r.isPartOfOperator?t+=r.mathspeak():(""!==t&&(e._maxLength>0&&"string"==typeof(o=e[t.toLowerCase()])&&(t=o),n.push(t+" "),t=""),i=r.mathspeak(),s=r.ctrlSeq,!isNaN(s)||"."===s||r.parent&&r.parent.parent&&r.parent.parent.isTextBlock()||(i=" "+i+" "),n.push(i)),n}).join("").replace(/ +(?= )/g,"").replace(/(\.)([0-9]+)/g,function(t,e,n){return e+n.split("").join(" ").trim()})},e.prototype.keystroke=function(e,n,r){return!r.options.spaceBehavesLikeTab||"Spacebar"!==e&&"Shift-Spacebar"!==e?t.prototype.keystroke.call(this,e,n,r):(null===n||void 0===n||n.preventDefault(),void r.escapeDir("Shift-Spacebar"===e?Ae:Me,e,n))},e.prototype.moveOutOf=function(t,e,n){var r,o;"up"===n?r=this.parent.upInto:"down"===n&&(r=this.parent.downInto),!r&&this[t]?(o=-t,e.insAtDirEnd(o,this[t]),e.controller.aria.queueDirEndOf(o).queue(e.parent,!0)):(e.insDirOf(t,this.parent),e.controller.aria.queueDirOf(t).queue(this.parent))},e.prototype.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},e.prototype.deleteOutOf=function(t,e){e.unwrapGramp()},e.prototype.seek=function(t,e){var n,r,o=this.getEnd(Me);if(!o)return e.insAtRightEnd(this);if(n=o.domFrag().oneElement(),s(n).left+n.offsetWidth<t)return e.insAtRightEnd(this);if(r=this.getEnd(Ae),t<s(r.domFrag().oneElement()).left)return e.insAtLeftEnd(this);for(;t<s(o.domFrag().oneElement()).left;)o=o[Ae];return o.seek(t,e)},e.prototype.chToCmd=function(t,e){var n;return t.match(/^[a-eg-zA-Z]$/)?new jt(t):/^\d$/.test(t)?new Pt(t):e&&e.typingSlashWritesDivisionSymbol&&"/"===t?Z["÷"](t):e&&e.typingAsteriskWritesTimesSymbol&&"*"===t?Z["×"](t):e&&e.typingPercentWritesPercentOf&&"%"===t?Z.percentof(t):(n=J[t]||Z[t])?n.constructor?new n(t):n(t):new At(t)},e.prototype.write=function(t,e){var n=this.chToCmd(e,t.options);t.selection&&n.replaces(t.replaceSelection()),t.isTooDeep()||(n.createLeftOf(t.show()),"/"===e?t.controller.aria.alert("over"):t.controller.aria.alert(n.mathspeak({createdLeftOf:t})))},e.prototype.writeLatex=function(t,e){var n,r,o,i,s=ft.all,a=ft.eof,l=Et.skip(a).or(s.result(!1)).parse(e);l&&!l.isEmpty()&&l.prepareInsertionAt(t)&&(l.children().adopt(t.parent,t[Ae],t[Me]),U(l.html()).insertBefore(t.domFrag()),t[Ae]=l.getEnd(Me),l.finalizeInsert(t.options,t),n=l.getEnd(Me),r=l.getEnd(Ae),o=n[Me],i=r[Ae],o&&o.siblingCreated(t.options,Ae),i&&i.siblingCreated(t.options,Me),t.parent.bubble(function(t){t.reflow()}))},e.prototype.focus=function(){return this.domFrag().addClass("mq-hasCursor"),this.domFrag().removeClass("mq-empty"),this},e.prototype.blur=function(t){return this.domFrag().removeClass("mq-hasCursor"),this.isEmpty()&&(this.domFrag().addClass("mq-empty"),t&&this.isQuietEmptyDelimiter(t.options.quietEmptyDelimiters)&&this.domFrag().addClass("mq-quiet-delimiter")),this},e}(Ct),at.prototype.mouseEvents=!0,ot.StaticMath=function(t){var e;return e=function(e){function n(n){var r=e.call(this,n)||this,o=r.innerFields=[];return r.__controller.root.postOrder(function(e){e.registerInnerField(o,t.InnerMathField)}),r}return __extends(n,e),n.prototype.__mathquillify=function(t,n){return this.config(t),e.prototype.mathquillify.call(this,"mq-math-mode"),this.__controller.setupStaticField(),this.__options.mouseEvents&&this.__controller.addMouseEventListener(),this.__controller.staticMathTextareaEvents(),this},n.prototype.latex=function(n){var r,o=e.prototype.latex.apply(this,arguments);return arguments.length>0&&(r=this.innerFields=[],this.__controller.root.postOrder(function(e){e.registerInnerField(r,t.InnerMathField)}),this.__controller.updateMathspeak()),o},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n}(t.AbstractMathQuill),e.RootBlock=It,e},Nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(It),y(Nt.prototype),ot.MathField=function(e){var n;return n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.__mathquillify=function(n,r){return this.config(n),r>1&&(this.__controller.root.reflow=t),e.prototype.mathquillify.call(this,"mq-editable-field mq-math-mode"),delete this.__controller.root.reflow,this},n}(e.EditableField),n.RootBlock=Nt,n},ot.InnerMathField=function(t){return n("MathField class is defined",t.MathField),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.makeStatic=function(){this.__controller.editable=!1,this.__controller.root.blur(),this.__controller.unbindEditablesEvents(),U(this.__controller.container).removeClass("mq-editable-field")},e.prototype.makeEditable=function(){this.__controller.editable=!0,this.__controller.editablesTextareaEvents(),this.__controller.cursor.insAtRightEnd(this.__controller.root),U(this.__controller.container).addClass("mq-editable-field")},e}(t.MathField)},Rt="\\ ",Bt=".",zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Ae&&this[Me]instanceof e||this.fixDigitGrouping(t)},e.prototype.fixDigitGrouping=function(t){var n,r;if(t.enableDigitGrouping){n=this,r=n;do{if(/^[0-9]$/.test(r.ctrlSeq))n=r;else if(r.ctrlSeq===Rt)n=r;else{if(r.ctrlSeq!==Bt)break;n=r}}while(r=n[Ae]);e.fixDigitGroupingFromLeft(t,n)}},e.fixDigitGroupingFromLeft=function(t,r){for(var o,i,s,a,l,c,u,p,h;r&&r.ctrlSeq===Rt;){if(!r[Me])return;r=r[Me]}if(r instanceof e){o=r,n("node",o),i=r,s=0,a=0,l=[];do{if(/^[0-9]$/.test(o.ctrlSeq))i=o,a=0;else if(o.ctrlSeq===Rt)i=o,s+=1,a=0;else{if(!(o.ctrlSeq===Bt&&o instanceof e))break;i=o,l.push(o),t.tripleDotsAreEllipsis&&(a+=1)}if(3==a)break}while(o=i[Me]);if(3!==a||(c=l.pop(),u=l.pop(),p=l.pop(),c[Me]instanceof e&&e.fixDigitGroupingFromLeft(t,c[Me]),c.setGroupingClass("mq-ellipsis-end"),u.setGroupingClass("mq-ellipsis-middle"),p.setGroupingClass("mq-ellipsis-start"),i=p[Ae],r!==p)){for(;i!==r&&i&&i.ctrlSeq===Rt;)i=i[Ae],s-=1;r===i&&r&&r.ctrlSeq===Rt||(h=s>0||l.length>1,h?e.removeGroupingBetween(r,i):l[0]?(l[0]!==r&&e.addGroupingBetween(l[0][Ae],r),l[0]!==i&&e.removeGroupingBetween(l[0],i)):e.addGroupingBetween(i,r))}}},e.removeGroupingBetween=function(t,n){var r=t;do{if(r instanceof e&&r.setGroupingClass(void 0),!r||r===n)break}while(r=r[Me])},e.addGroupingBetween=function(t,r){for(var o,i,s=t,a=0,l=0;s&&(l+=1,n("digit",s instanceof e),s!==r);)s=s[Ae];for(o=l%3,0===o&&(o=3),s=t;s&&(a+=1,i=void 0,l>=4&&(a===l?i="mq-group-leading-"+o:a%3==0&&a!==l&&(i="mq-group-start"),i||(i="mq-group-other")),s instanceof e&&s.setGroupingClass(i),s!==r);)s=s[Ae]},e.prototype.setGroupingClass=function(t){this._groupingClass!==t&&(this._groupingClass&&this.domFrag().removeClass(this._groupingClass),t&&this.domFrag().addClass(t),this._groupingClass=t)},e}(Dt),Pt=function(t){function e(e,n){return t.call(this,e,Re("span",{class:"mq-digit"},[Re.text(e)]),void 0,n)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Ae],r=n&&n[Ae],o=e.parent.parent instanceof ue?e.parent.parent.sub:void 0;e.options.autoSubscriptNumerals&&e.parent!==o&&(n instanceof Ht&&!1!==n.isItalic||n instanceof ue&&r instanceof Ht&&!1!==r.isItalic)?(new ue("sub").createLeftOf(e),t.prototype.createLeftOf.call(this,e),e.insRightOf(e.parent.parent)):t.prototype.createLeftOf.call(this,e)},e.prototype.mathspeak=function(e){var n,r,o,i;return e&&e.createdLeftOf&&(n=e.createdLeftOf,r=n[Ae],o=r&&r[Ae],i=n.parent.parent instanceof ue?n.parent.parent.sub:void 0,n.options.autoSubscriptNumerals&&n.parent!==i&&(r instanceof Ht&&!1!==r.isItalic||n[Ae]instanceof ue&&o instanceof Ht&&!1!==o.isItalic))?"Subscript "+t.prototype.mathspeak.call(this)+" Baseline":t.prototype.mathspeak.call(this)},e}(zt),Ht=function(t){function e(e,n){return t.call(this,e,Re("var",{},[n||Re.text(e)]))||this}return __extends(e,t),e.prototype.text=function(){var t=this.ctrlSeq||"";return this.isPartOfOperator?"\\"==t[0]?t=t.slice(1,t.length):" "==t[t.length-1]&&(t=t.slice(0,-1)):(!this[Ae]||this[Ae]instanceof e||this[Ae]instanceof Mt||"\\ "===this[Ae].ctrlSeq||(t="*"+t),!this[Me]||this[Me]instanceof Mt||this[Me]instanceof ue||(t+="*")),t},e.prototype.mathspeak=function(){var e=this.ctrlSeq||"";return this.isPartOfOperator||e.length>1||this.parent&&this.parent.parent&&this.parent.parent.isTextBlock()?t.prototype.mathspeak.call(this):'"'+e+'"'},e}(Dt),at.prototype.autoCommands={_maxLength:0},st.autoCommands=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';if(Z[i]===Wt)throw'"'+i+'" is a built-in operator name';n[i]=1,r=Ne(r,i.length)}return n._maxLength=r,n},at.prototype.quietEmptyDelimiters={},st.quietEmptyDelimiters=function(t){var e,n,r,o;for(void 0===t&&(t=""),e=t.split(" "),n={},r=0;r<e.length;r+=1)o=e[r],n[o]=1;return n},at.prototype.autoParenthesizedFunctions={_maxLength:0},st.autoParenthesizedFunctions=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';n[i]=1,r=Ne(r,i.length)}return n._maxLength=r,n},jt=function(t){function e(e){var n=t.call(this,e)||this;return n.letter=e,n}return __extends(e,t),e.prototype.checkAutoCmds=function(t){var e,n,r,o,i,s,a,l;if(!this.shouldIgnoreSubstitutionInSimpleSubscript(t.options)&&(n=t.options.autoCommands,(r=n._maxLength||0)>0))for(o=null!==(e=q(this,r))&&void 0!==e?e:"";o.length;){if(n.hasOwnProperty(o)){for(i=this,s=1;i&&s<o.length;s+=1,i=i[Ae]);return new Y(i,this).remove(),t[Ae]=i[Ae],a=Z[o],l=f(a)?new a(o):a(o),l.createLeftOf(t)}o=o.slice(1)}},e.prototype.autoParenthesize=function(t){var n,r,o,i,s,a,l=t.parent.getEnd(Me);if(!(l&&l instanceof Le&&"\\left("===l.ctrlSeq||this.shouldIgnoreSubstitutionInSimpleSubscript(t.options))){for(n="",r=this,o=0,i=t.options.autoParenthesizedFunctions,s=i._maxLength||0,a=t.options.autoOperatorNames;r instanceof e&&o<s;)n=r.letter+n,r=r[Ae],o+=1;for(;n.length;){if(i.hasOwnProperty(n)&&a.hasOwnProperty(n))return t.parent.write(t,"(");n=n.slice(1)}}},e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),this.checkAutoCmds(e),this.autoParenthesize(e)},e.prototype.italicize=function(t){return this.isItalic=t,this.isPartOfOperator=!t,t&&(delete this.endsCategory,delete this.endsWord),this.domFrag().toggleClass("mq-operator-name",!t),this},e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Ae&&this[Me]instanceof e||this.autoUnItalicize(t)},e.prototype.autoUnItalicize=function(t){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b=t.autoOperatorNames;if(0!==b._maxLength&&!this.shouldIgnoreSubstitutionInSimpleSubscript(t)){for(n=this.letter,r=this[Ae];r instanceof e;r=r[Ae])n=r.letter+n;for(o=this[Me];o instanceof e;o=o[Me])n+=o.letter;i=r&&r[Me],s=o&&o[Ae],new Y(i||this.parent.getEnd(Ae),s||this.parent.getEnd(Me)).each(function(t){t instanceof e&&(t.italicize(!0).domFrag().removeClass("mq-first mq-last mq-followed-by-supsub"),t.ctrlSeq=t.letter)}),a=b._maxLength||0;t:for(l=0,c=r[Me]||this.parent.getEnd(Ae);c&&l<n.length;l+=1,c=c[Me])for(u=Ie(a,n.length-l);u>0;u-=1)if(p=n.slice(l,l+u),h=void 0,b.hasOwnProperty(p)){for(d=0,f=c;d<u;d+=1,f=f[Me])f instanceof e&&(f.italicize(!1),h=f);m=Gt.hasOwnProperty(p),c.ctrlSeq=(m?"\\":"\\operatorname{")+c.ctrlSeq,h.ctrlSeq+=m?" ":"}",h.endsWord=p,t.infixOperatorNames[p]?h.endsCategory="infix":t.prefixOperatorNames[p]&&(h.endsCategory="prefix"),Vt.hasOwnProperty(p)&&(g=h[Ae],y=g&&g[Ae],v=y&&y[Ae],v.domFrag().addClass("mq-last")),this.shouldOmitPadding(c[Ae])||c.domFrag().addClass("mq-first"),this.shouldOmitPadding(h[Me])||(h[Me]instanceof ue?(x=h[Me],(x.siblingCreated=x.siblingDeleted=function(){x.domFrag().toggleClass("mq-after-operator-name",!(x[Me]instanceof Le))})()):h.domFrag().toggleClass("mq-last",!(h[Me]instanceof Le))),l+=u-1,c=h;continue t}}},e.prototype.shouldOmitPadding=function(t){return!t||("."===t.ctrlSeq||(!!(t instanceof Mt&&t.isBinaryOperator())||t instanceof fe))},e}(Ht),Gt={},at.prototype.autoOperatorNames=function(){var t,e,n,r,o={_maxLength:9},i="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<i.length;t+=1)Gt[i[t]]=o[i[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)Gt[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)o[n[t]]=o["arc"+n[t]]=o[n[t]+"h"]=o["ar"+n[t]+"h"]=o["arc"+n[t]+"h"]=1;for(r="gcf hcf lcm proj span".split(" "),t=0;t<r.length;t+=1)o[r[t]]=1;return o}(),Vt={limsup:1,liminf:1,projlim:1,injlim:1},st.autoOperatorNames=function(t){var e,n,r,o,i,s;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z\|\-]+(?: [a-z\|\-]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters or "|"';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'"'+i+'" not minimum length of 2';if(i.indexOf("|")<0)n[i]=i,r=Ne(r,i.length);else{if(s=i.split("|"),s.length>2)throw'"'+i+'" has more than 1 mathspeak delimiter';if(s[0].length<2)throw'"'+i[0]+'" not minimum length of 2';n[s[0]]=s[1].replace(/-/g," "),r=Ne(r,s[0].length)}}return n._maxLength=r,n},at.prototype.infixOperatorNames={},st.infixOperatorNames=O,at.prototype.prefixOperatorNames={},st.prefixOperatorNames=O,at.prototype.disableAutoSubstitutionInSubscripts=!1,st.disableAutoSubstitutionInSubscripts=function(t){if("boolean"==typeof t)return t;if("object"!=typeof t||null===t||!("except"in t))throw'"'+t+'" not an object with property "except"';return{except:O(t.except)}},Wt=function(t){function e(e){return t.call(this,e||"")||this}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n=this.ctrlSeq;for(e=0;e<n.length;e+=1)new jt(n.charAt(e)).createLeftOf(t)},e.prototype.parser=function(){var t,e=this.ctrlSeq,n=new It;for(t=0;t<e.length;t+=1)new jt(e.charAt(t)).adopt(n,n.getEnd(Me),0);return ft.succeed(n.children())},e}(Dt);for(Qt in at.prototype.autoOperatorNames)at.prototype.autoOperatorNames.hasOwnProperty(Qt)&&(Z[Qt]=Wt);if(Z.operatorname=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(){},e.prototype.numBlocks=function(){return 1},e.prototype.parser=function(){return Et.block.map(function(t){var e=!0,n="",r=t.children();return r.each(function(t){t instanceof jt?n+=t.letter:e=!1}),e&&"ans"===n?ye():r})},e}(Ft),Z.f=function(t){function e(){var e=this,n="f";return e=t.call(this,n)||this,e.letter=n,e.domView=new Tt(0,function(){return Re("var",{class:"mq-f"},[Re.text("f")])}),e}return __extends(e,t),e.prototype.italicize=function(e){return this.domFrag().eachElement(function(t){return t.textContent="f"}),this.domFrag().toggleClass("mq-f",e),t.prototype.italicize.call(this,e)},e}(jt),Z[" "]=Z.space=function(){return new zt("\\ ",Re("span",{},[Re.text(B)])," ")},Z["."]=function(){return new zt(".",Re("span",{class:"mq-digit"},[Re.text(".")]),".")},Z["'"]=Z.prime=L("'","&prime;","prime"),Z["″"]=Z.dprime=L("″","&Prime;","double prime"),Z.backslash=L("\\backslash ","\\","backslash"),J["\\"]||(J["\\"]=Z.backslash),Z.$=L("\\$","$","dollar"),Z["?"]=L("?","?","question mark"),Z["□"]=Z.square=L("\\square ","□","square"),Z.mid=L("\\mid ","∣","mid"),$t=function(t){function e(e,n){return t.call(this,e,Re("span",{class:n},[Re.text(e)]))||this}return __extends(e,t),e}(Dt),Z[","]=function(){return new $t(",","mq-comma")},Ut=function(t){function e(e,n,r){return t.call(this,e,Re("span",{class:"mq-nonSymbola"},[n||Re.text(e)]))||this}return __extends(e,t),e}(Dt),Z["@"]=function(){return new Ut("@")},Z["&"]=function(){return new Ut("\\&",Re.entityText("&amp;"),"and")},Z["%"]=function(t){function e(){return t.call(this,"\\%",Re.text("%"),"percent")||this}return __extends(e,t),e.prototype.parser=function(){var e=ft.optWhitespace,n=ft.string;return e.then(n("\\operatorname{of}").map(function(){return ve()})).or(t.prototype.parser.call(this))},e}(Ut),Z["∥"]=Z.parallel=L("\\parallel ","&#x2225;","parallel"),Z["∦"]=Z.nparallel=L("\\nparallel ","&#x2226;","not parallel"),Z["⟂"]=Z.perp=L("\\perp ","&#x27C2;","perpendicular"),Z["α"]=Z.alpha=C("alpha"),Z["β"]=Z.beta=C("beta"),Z["γ"]=Z.gamma=C("gamma"),Z["δ"]=Z.delta=C("delta"),Z["ζ"]=Z.zeta=C("zeta"),Z["η"]=Z.eta=C("eta"),Z["θ"]=Z.theta=C("theta"),Z["ι"]=Z.iota=C("iota"),Z["κ"]=Z.kappa=C("kappa"),Z["μ"]=Z.mu=C("mu"),Z["ν"]=Z.nu=C("nu"),Z["ξ"]=Z.xi=C("xi"),Z["ρ"]=Z.rho=C("rho"),Z["σ"]=Z.sigma=C("sigma"),Z["τ"]=Z.tau=C("tau"),Z["χ"]=Z.chi=C("chi"),Z["ψ"]=Z.psi=C("psi"),Z["ω"]=Z.omega=C("omega"),Z["ϕ"]=Z.phi=_("\\phi ","&#981;","phi"),Z["φ"]=Z.phiv=Z.varphi=_("\\varphi ","&phi;","phi"),Z["ϵ"]=Z.epsilon=_("\\epsilon ","&#1013;","epsilon"),Z["ε"]=Z.epsiv=Z.varepsilon=_("\\varepsilon ","&epsilon;","epsilon"),Z["ϖ"]=Z.piv=Z.varpi=_("\\varpi ","&piv;","piv"),Z["ς"]=Z.sigmaf=Z.sigmav=Z.varsigma=_("\\varsigma ","&sigmaf;","sigma"),Z["ϑ"]=Z.thetav=Z.vartheta=Z.thetasym=_("\\vartheta ","&thetasym;","theta"),Z["υ"]=Z.upsilon=Z.upsi=_("\\upsilon ","&upsilon;","upsilon"),Z["Ϝ"]=Z.gammad=Z.Gammad=Z.digamma=_("\\digamma ","&#989;","gamma"),Z["ϰ"]=Z.kappav=Z.varkappa=_("\\varkappa ","&#1008;","kappa"),Z["ϱ"]=Z.rhov=Z.varrho=_("\\varrho ","&#1009;","rho"),Z.pi=Z["π"]=function(){return new Ut("\\pi ",Re.entityText("&pi;"),"pi")},Z["λ"]=Z.lambda=function(){return new Ut("\\lambda ",Re.entityText("&lambda;"),"lambda")},Z["Υ"]=Z.Upsilon=Z.Upsi=Z.upsih=Z.Upsih=function(){return new Dt("\\Upsilon ",Re("var",{style:"font-family: serif"},[Re.entityText("&upsih;")]),"capital upsilon")},Z["Γ"]=Z.Gamma=T("Gamma"),Z["Δ"]=Z.Delta=T("Delta"),Z["Θ"]=Z.Theta=T("Theta"),Z["Λ"]=Z.Lambda=T("Lambda"),Z["Ξ"]=Z.Xi=T("Xi"),Z["Π"]=Z.Pi=T("Pi"),Z["Σ"]=Z.Sigma=T("Sigma"),Z["Φ"]=Z.Phi=T("Phi"),Z["Ψ"]=Z.Psi=T("Psi"),Z["Ω"]=Z.Omega=T("Omega"),Z["∀"]=Z.forall=T("forall"),Kt=function(t){function e(e){var n=t.call(this)||this;return n.latexStr=e,n}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n,r,o,i=Et.parse(this.latexStr);i.children().adopt(t.parent,t[Ae],t[Me]),t[Ae]=i.getEnd(Me),U(i.html()).insertBefore(t.domFrag()),i.finalizeInsert(t.options,t),e=i.getEnd(Me),n=e&&e[Me],n&&n.siblingCreated(t.options,Ae),r=i.getEnd(Ae),o=r&&r[Ae],o&&o.siblingCreated(t.options,Me),t.parent.bubble(function(t){t.reflow()})},e.prototype.mathspeak=function(){return Et.parse(this.latexStr).mathspeak()},e.prototype.parser=function(){var t=Et.parse(this.latexStr).children();return ft.succeed(t)},e}(Ft),Z["⁰"]=function(){return new Kt("^0")},Z["¹"]=function(){return new Kt("^1")},Z["²"]=function(){return new Kt("^2")},Z["³"]=function(){return new Kt("^3")},Z["⁴"]=function(){return new Kt("^4")},Z["⁵"]=function(){return new Kt("^5")},Z["⁶"]=function(){return new Kt("^6")},Z["⁷"]=function(){return new Kt("^7")},Z["⁸"]=function(){return new Kt("^8")},Z["⁹"]=function(){return new Kt("^9")},Z["¼"]=function(){return new Kt("\\frac14")},Z["½"]=function(){return new Kt("\\frac12")},Z["¾"]=function(){return new Kt("\\frac34")},Z["√"]=function(){return new Kt("\\sqrt{}")},Xt=function(t){function e(e,n,r){return t.call(this,e,n,void 0,r,!0)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return D(this)},e.prototype.contactWeld=function(t,e){this.sharedSiblingMethod(t.options,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,e){if(e!==Me)return this.domFrag().oneElement().className=D(this)?"mq-binary-operator":"",this},e}(Mt),Z["+"]=function(t){function e(){return t.call(this,"+",Re.text("+"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"plus":"positive"},e}(Xt),Yt=function(t){function e(){return t.call(this,"-",Re.entityText("&minus;"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"minus":"negative"},e}(Xt),Z["−"]=Z["—"]=Z["–"]=Z["-"]=Yt,
13
+ Z["±"]=Z.pm=Z.plusmn=Z.plusminus=function(){return new Xt("\\pm ",Re.entityText("&plusmn;"),"plus-or-minus")},Z.mp=Z.mnplus=Z.minusplus=function(){return new Xt("\\mp ",Re.entityText("&#8723;"),"minus-or-plus")},J["*"]=Z.sdot=Z.cdot=S("\\cdot ","&middot;","*","times"),Zt=function(t){function e(){return t.call(this,"\\to ",Re.entityText("&rarr;"),"to")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Ae){var r=n[Ae];return new Y(r,this).remove(),n[Ae]=r[Ae],(new Yt).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z["→"]=Z.to=Zt,Jt=function(t){function e(e,n){var r=this,o=n?"Strict":"";return r=t.call(this,e["ctrlSeq".concat(o)],Re.entityText(e["htmlEntity".concat(o)]),e["text".concat(o)],e["mathspeak".concat(o)])||this,r.data=e,r.strict=n,r}return __extends(e,t),e.prototype.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq".concat(e)],this.domFrag().children().replaceWith(U(Re.entityText(this.data["htmlEntity".concat(e)]))),this.textTemplate=[this.data["text".concat(e)]],this.mathspeakName=this.data["mathspeak".concat(e)]},e.prototype.deleteTowards=function(e,n){if(e===Ae&&!this.strict)return this.swap(!0),void this.bubble(function(t){t.reflow()});t.prototype.deleteTowards.call(this,e,n)},e}(Mt),te={ctrlSeq:"\\le ",htmlEntity:"&le;",text:"≤",mathspeak:"less than or equal to",ctrlSeqStrict:"<",htmlEntityStrict:"&lt;",textStrict:"<",mathspeakStrict:"less than"},ee={ctrlSeq:"\\ge ",htmlEntity:"&ge;",text:"≥",mathspeak:"greater than or equal to",ctrlSeqStrict:">",htmlEntityStrict:"&gt;",textStrict:">",mathspeakStrict:"greater than"},ne=function(t){function e(){return t.call(this,ee,!0)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r=e[Ae];if(r instanceof Mt&&"-"===r.ctrlSeq)return n=r,e[Ae]=n[Ae],n.remove(),(new Zt).createLeftOf(e),void e[Ae].bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Jt),Z["<"]=Z.lt=function(){return new Jt(te,!0)},Z[">"]=Z.gt=ne,Z["≤"]=Z.le=Z.leq=function(){return new Jt(te,!1)},Z["≥"]=Z.ge=Z.geq=function(){return new Jt(ee,!1)},Z["∞"]=Z.infty=Z.infin=Z.infinity=L("\\infty ","&infin;","infinity"),Z["≠"]=Z.ne=Z.neq=S("\\ne ","&ne;","not equal"),re=function(t){function e(){return t.call(this,"=",Re.text("="),"=","equals")||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Ae];if(n instanceof Jt&&n.strict)return n.swap(!1),void n.bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Mt),Z["="]=re,Z["×"]=Z.times=Z.cross=S("\\times ","&times;","[x]","times"),Z["÷"]=Z.div=Z.divide=Z.divides=S("\\div ","&divide;","[/]","divided by"),oe=function(t){function e(){return t.call(this,"\\sim ",Re.text("~"),"~","tilde")||this}return __extends(e,t),e.prototype.createLeftOf=function(n){if(n[Ae]instanceof e){var r=n[Ae];return n[Ae]=r[Ae],r.remove(),(new ie).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.createLeftOf.call(this,n)},e}(Mt),ie=function(t){function e(){return t.call(this,"\\approx ",Re.entityText("&approx;"),"≈","approximately equal")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Ae){var r=n[Ae];return new Y(r,this).remove(),n[Ae]=r[Ae],(new oe).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z.tildeNbsp=L("~",B," "),Z.sim=oe,Z["≈"]=Z.approx=ie,J["~"]=Z.sim,Z["~"]=Z.tildeNbsp,st.interpretTildeAsSim=function(t){var e=!!t;return Z["~"]=e?Z.sim:Z.tildeNbsp,e},Z["◯"]=Z.bigcirc=L("\\bigcirc ","&#9711;","circle"),Z["∠"]=Z.ang=Z.angle=L("\\angle ","&ang;","angle"),Z["°"]=Z.degree=L("\\degree ","&deg;","degrees"),Z["△"]=Z.triangle=L("\\triangle ","&#9651;","triangle"),Z["≅"]=Z.cong=S("\\cong ","&cong;","cong","congruent"),Z["∡"]=Z.measuredangle=L("\\measuredangle ","&#8737;","measured angle"),Z["▱"]=Z.parallelogram=L("\\parallelogram ","&#9649;","parallelogram"),Z["≇"]=Z.ncong=S("\\ncong ","&ncong;","ncong","not congruent"),Z["≁"]=Z.nsim=S("\\nsim ","&nsim;","nsim","not similar"),se={sqrt:{width:"",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 32 54"},[Re("path",{d:"M0 33 L7 27 L12.5 47 L13 47 L30 0 L32 0 L13 54 L11 54 L4.5 31 L0 33"})])}},"|":{width:".4em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M4.4 0 L4.4 54 L5.6 54 L5.6 0"})])}},"[":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Re("path",{d:"M8 0 L3 0 L3 24 L8 24 L8 23 L4 23 L4 1 L8 1"})])}},"]":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Re("path",{d:"M3 0 L8 0 L8 24 L3 24 L3 23 L7 23 L7 1 L3 1"})])}},"(":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Re("path",{d:"M85 0 A61 101 0 0 0 85 186 L75 186 A75 101 0 0 1 75 0"})])}},")":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Re("path",{d:"M24 0 A61 101 0 0 1 24 186 L34 186 A75 101 0 0 0 34 0"})])}},"{":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Re("path",{d:"M170 0 L170 6 A47 52 0 0 0 123 60 L123 127 A35 48 0 0 1 88 175 A35 48 0 0 1 123 223 L123 290 A47 52 0 0 0 170 344 L170 350 L160 350 A58 49 0 0 1 102 301 L103 220 A45 40 0 0 0 58 180 L58 170 A45 40 0 0 0 103 130 L103 49 A58 49 0 0 1 161 0"})])}},"}":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Re("path",{d:"M60 0 L60 6 A47 52 0 0 1 107 60 L107 127 A35 48 0 0 0 142 175 A35 48 0 0 0 107 223 L107 290 A47 52 0 0 1 60 344 L60 350 L70 350 A58 49 0 0 0 128 301 L127 220 A45 40 0 0 1 172 180 L172 170 A45 40 0 0 1 127 130 L127 49 A58 49 0 0 0 70 0"})])}},"&#8741;":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M3.2 0 L3.2 54 L4 54 L4 0 M6.8 0 L6.8 54 L6 54 L6 0"})])}},"&lang;":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M6.8 0 L3.2 27 L6.8 54 L7.8 54 L4.2 27 L7.8 0"})])}},"&rang;":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M3.2 0 L6.8 27 L3.2 54 L2.2 54 L5.8 27 L2.2 0"})])}}},ae="➤",le=function(t){function e(e,n,r,o,i){var s=t.call(this,e,new Tt(1,function(t){var e,o;return Re.block(n,r,t[0],{beforeChild:null===(e=null===i||void 0===i?void 0:i.beforeChild)||void 0===e?void 0:e.call(i),afterChild:null===(o=null===i||void 0===i?void 0:i.afterChild)||void 0===o?void 0:o.call(i)})}))||this;return s.ariaLabel=o||e.replace(/^\\/,""),s.mathspeakTemplate=["Start"+s.ariaLabel+",","End"+s.ariaLabel],s.shouldNotSpeakDelimiters=i&&i.shouldNotSpeakDelimiters,s}return __extends(e,t),e.prototype.mathspeak=function(e){return!this.shouldNotSpeakDelimiters||e&&e.ignoreShorthand?t.prototype.mathspeak.call(this):this.foldChildren("",function(t,n){return t+" "+n.mathspeak(e)}).trim()},e}(Ft),Z.mathrm=function(t){function e(){return t.call(this,"\\mathrm","span",{class:"mq-roman mq-font"},"Roman Font",{shouldNotSpeakDelimiters:!0})||this}return __extends(e,t),e.prototype.isTextBlock=function(){return!0},e}(le),Z.mathit=function(){return new le("\\mathit","i",{class:"mq-font"},"Italic Font")},Z.mathbf=function(){return new le("\\mathbf","b",{class:"mq-font"},"Bold Font")},Z.mathsf=function(){return new le("\\mathsf","span",{class:"mq-sans-serif mq-font"},"Serif Font")},Z.mathtt=function(){return new le("\\mathtt","span",{class:"mq-monospace mq-font"},"Math Text")},Z.underline=function(){return new le("\\underline","span",{class:"mq-non-leaf mq-underline"},"Underline")},Z.overline=Z.bar=function(){return new le("\\overline","span",{class:"mq-non-leaf mq-overline"},"Overline")},Z.overrightarrow=function(){return new le("\\overrightarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Right Arrow",{afterChild:function(){return Re("span",{class:"mq-arrow-right-content"},[Re.text(ae)])}})},Z.overleftarrow=function(){return new le("\\overleftarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Left Arrow",{beforeChild:function(){return Re("span",{class:"mq-arrow-left-content"},[Re.text(ae)])}})},Z.overleftrightarrow=function(){return new le("\\overleftrightarrow ","span",{class:"mq-non-leaf mq-overarrow"},"Over Left and Right Arrow",{beforeChild:function(){return Re("span",{class:"mq-arrow-left-content"},[Re.text(ae)])},afterChild:function(){return Re("span",{class:"mq-arrow-right-content"},[Re.text(ae)])}})},Z.overarc=function(){return new le("\\overarc","span",{class:"mq-non-leaf mq-overarc"},"Over Arc")},Z.dot=function(){return new Ft("\\dot",new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-dot-recurring-inner"},[Re("span",{class:"mq-dot-recurring"},[Re.text(P)]),Re.block("span",{class:"mq-empty-box"},t[0])])])}))},Z.textcolor=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setColor=function(t){this.color=t,this.domView=new Tt(1,function(e){return Re.block("span",{class:"mq-textcolor",style:"color:"+t},e[0])}),this.ariaLabel=t.replace(/^\\/,""),this.mathspeakTemplate=["Start "+this.ariaLabel+",","End "+this.ariaLabel]},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\textcolor{"+this.color+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.parser=function(){var e=this,n=ft.optWhitespace,r=ft.string,o=ft.regex;return n.then(r("{")).then(o(/^[#\w\s.,()%-]*/)).skip(r("}")).then(function(n){return e.setColor(n),t.prototype.parser.call(e)})},e.prototype.isStyleBlock=function(){return!0},e}(Ft),Z.class=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex;return ft.optWhitespace.then(n("{")).then(r(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return e.cls=n||"",e.domView=new Tt(1,function(t){return Re.block("span",{class:"mq-class ".concat(n)},t[0])}),e.ariaLabel=n+" class",e.mathspeakTemplate=["Start "+e.ariaLabel+",","End "+e.ariaLabel],t.prototype.parser.call(e)})},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\class{"+this.cls+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.isStyleBlock=function(){return!0},e}(Ft),ce=/^[\+\-]?[\d]+$/,at.prototype.charsThatBreakOutOfSupSub="",ue=function(t){function e(e){var n,r=this;return n="sub"===e?new Tt(1,function(t){return Re("span",{class:"mq-supsub mq-non-leaf"},[Re.block("span",{class:"mq-sub"},t[0]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])}):new Tt(1,function(t){return Re("span",{class:"mq-supsub mq-non-leaf mq-sup-only"},[Re.block("span",{class:"mq-sup"},t[0])])}),r=t.call(this,"_{...}^{...}",n)||this,r.ariaLabel="sub"===e?"subscript":"superscript",r.supsub=e,r}return __extends(e,t),e.prototype.setEnds=function(t){n("SupSub ends must be MathBlocks",t[Ae]instanceof It&&t[Me]instanceof It),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.createLeftOf=function(e){if(this.replacedFragment||e[Ae]||!e.options.supSubsRequireOperand)return t.prototype.createLeftOf.call(this,e)},e.prototype.contactWeld=function(t){var n,r,o,i,s,a,l;for(n=Ae;n;n=n===Ae&&Me)if(r=this[n],o=void 0,r instanceof e){for(i="sub";i;i="sub"===i&&"sup")s=this[i],a=r[i],s&&(a?s.isEmpty()?o=new K(a,0,a.getEnd(Ae)):(s.domFrag().children().insAtDirEnd(-n,a.domFrag().oneElement()),l=s.children().disown(),o=new K(a,l.getEnd(Me),a.getEnd(Ae)),n===Ae?l.adopt(a,a.getEnd(Me),0):l.adopt(a,0,a.getEnd(Ae))):r.addBlock(s.disown()),this.placeCursor=function(t,e){return function(r){r.insAtDirEnd(-n,t||e)}}(a,s));this.remove(),t&&t[Ae]===this&&(n===Me&&o?o[Ae]?t.insRightOf(o[Ae]):t.insAtLeftEnd(o.parent):t.insRightOf(r));break}},e.prototype.finalizeTree=function(){"sub"===this.supsub?(this.downInto=this.sub=this.getEnd(Ae),this.sub.upOutOf=M):"sup"===this.supsub&&(this.upInto=this.sup=this.getEnd(Me),this.sup.downOutOf=M),this.getEnd(Ae).write=function(t,e){if(t.options.autoSubscriptNumerals&&this===this.parent.sub&&"0123456789".indexOf(e)>=0){var n=this.chToCmd(e,t.options);return n instanceof Dt?t.deleteSelection():t.clearSelection().insRightOf(this.parent),n.createLeftOf(t.show()),void t.controller.aria.queue("Baseline").alert(n.mathspeak({createdLeftOf:t}))}t[Ae]&&!t[Me]&&!t.selection&&t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&(t.insRightOf(this.parent),t.controller.aria.queue("Baseline")),It.prototype.write.call(this,t,e)}},e.prototype.moveTowards=function(e,n,r){n.options.autoSubscriptNumerals&&!this.sup?n.insDirOf(e,this):t.prototype.moveTowards.call(this,e,n,r)},e.prototype.deleteTowards=function(e,n){if(n.options.autoSubscriptNumerals&&this.sub){var r=this.sub.getEnd(-e);r instanceof Dt?r.remove():r&&r.deleteTowards(e,n.insAtDirEnd(-e,this.sub)),this.sub.isEmpty()&&(this.sub.deleteOutOf(Ae,n.insAtLeftEnd(this.sub)),this.sup&&n.insDirOf(-e,this))}else t.prototype.deleteTowards.call(this,e,n)},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),this.sub&&(t.uncleanedLatex+="_{",e=t.uncleanedLatex.length,this.sub.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.sup&&(t.uncleanedLatex+="^{",e=t.uncleanedLatex.length,this.sup.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r;return void 0===this.sup||(n=A(this.sup),e&&e.ignoreShorthand||!ce.test(n))?(this.mathspeakTemplate=this.getMathspeakTemplate(),t.prototype.mathspeak.call(this)):(r="",this.sub&&(r=pe[0]+" "+this.sub.mathspeak()+" "+pe[1]+" "),r+I(this.sup,n))},e.prototype.getMathspeakTemplate=function(){return this.sub&&this.sup?de:this.sup?he:pe},e.prototype.text=function(){function t(t,e){var n=e&&e.text()||"";return e?t+(1===n.length?n:"("+(n||" ")+")"):""}return t("_",this.sub)+t("^",this.sup)},e.prototype.addBlock=function(t){var e,n,r;for("sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.setDOM(U(Re("span",{class:"mq-sup"})).append(t.domFrag().children()).prependTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,this.domFrag().removeClass("mq-sup-only"),t.setDOM(U(Re("span",{class:"mq-sub"})).append(t.domFrag().children()).appendTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t),this.domFrag().append(U(Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])))),e=function(t){var e=n,r=["sub","sup"][t],o=["sup","sub"][t],i=["down","up"][t];e[r].deleteOutOf=function(t,n){var s,a;n.insDirOf(this[t]?-t:t,this.parent),this.isEmpty()||(s=this.getEnd(t),this.children().disown().withDirAdopt(t,n.parent,n[t],n[-t]).domFrag().insDirOf(-t,n.domFrag()),n[-t]=s),e.supsub=o,delete e[r],delete e["".concat(i,"Into")],a=e[o],a["".concat(i,"OutOf")]=M,delete a.deleteOutOf,"sub"===r&&e.domFrag().addClass("mq-sup-only").children().last().remove(),this.remove()}},n=this,r=0;r<2;r+=1)e(r)},e}(Ft),pe=["Subscript,",", Baseline"],he=["Superscript,",", Baseline"],de=["Subscript,",", Baseline Superscript,",", Baseline"],Z.subscript=Z._=function(){return new ue("sub")},Z.superscript=Z.supscript=Z["^"]=function(){return new ue("sup")},fe=function(t){function e(e,n,r){var o,i=t.call(this)||this;return i.ariaLabel=r||e.replace(/^\\/,""),o=new Tt(2,function(t){return Re("span",{class:"mq-large-operator mq-non-leaf"},[Re("span",{class:"mq-to"},[Re.block("span",{},t[1])]),Re("big",{},[Re.text(n)]),Re("span",{class:"mq-from"},[Re.block("span",{},t[0])])])}),Dt.prototype.setCtrlSeqHtmlTextAndMathspeak.call(i,e,o),i}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),e.options.sumStartsWithNEquals&&(new jt("n").createLeftOf(e),(new re).createLeftOf(e))},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq+"_{",e=t.uncleanedLatex.length,this.getEnd(Ae).latexRecursive(t),n=t.uncleanedLatex.length,n===e&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}^{",e=t.uncleanedLatex.length,this.getEnd(Me).latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){return"Start "+this.ariaLabel+" from "+this.getEnd(Ae).mathspeak()+" to "+this.getEnd(Me).mathspeak()+", end "+this.ariaLabel+", "},e.prototype.parser=function(){var t,e=ft.string,n=ft.optWhitespace,r=ft.succeed,o=Et.block,i=this,s=i.blocks=[new It,new It];for(t=0;t<s.length;t+=1)s[t].adopt(i,i.getEnd(Me),0);return n.then(e("_").or(e("^"))).then(function(t){var e=s["_"===t?0:1];return o.then(function(t){return t.children().adopt(e,e.getEnd(Me),0),r(i)})}).many().result(i)},e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);t.ariaLabel="lower bound",e.ariaLabel="upper bound",this.downInto=t,this.upInto=e,t.upOutOf=e,e.downOutOf=t},e}(Ft),Z["∑"]=Z.sum=Z.summation=function(){return new fe("\\sum ",H,"sum")},Z["∏"]=Z.prod=Z.product=function(){return new fe("\\prod ",j,"product")},Z.coprod=Z.coproduct=function(){return new fe("\\coprod ",G,"co product")},Z["∫"]=Z.int=Z.integral=function(t){function e(){var e=t.call(this,"\\int ","","integral")||this;return e.ariaLabel="integral",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-int mq-non-leaf"},[Re("big",{},[Re.text(V)]),Re("span",{class:"mq-supsub mq-non-leaf"},[Re("span",{class:"mq-sup"},[Re.block("span",{class:"mq-sup-inner"},t[1])]),Re.block("span",{class:"mq-sub"},t[0]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])])}),e}return __extends(e,t),e.prototype.createLeftOf=function(t){Ft.prototype.createLeftOf.call(this,t)},e}(fe),me=Z.frac=Z.dfrac=Z.cfrac=Z.fraction=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\frac",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-fraction mq-non-leaf"},[Re.block("span",{class:"mq-numerator"},t[0]),Re.block("span",{class:"mq-denominator"},t[1]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])}),e.textTemplate=["(",")/(",")"],e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="numerator",e.ariaLabel="denominator",this.getFracDepth()>1?this.mathspeakTemplate=["StartNestedFraction,","NestedOver",", EndNestedFraction"]:this.mathspeakTemplate=["StartFraction,","Over",", EndFraction"]},e.prototype.mathspeak=function(e){var n,r,o,i,s,a,l,c;if(e&&e.createdLeftOf)return n=e.createdLeftOf,n.parent.mathspeak();if(r=A(this.getEnd(Ae)),o=A(this.getEnd(Me)),(!e||!e.ignoreShorthand)&&ce.test(r)&&ce.test(o)&&(i="1"===r||"-1"===r,s="","2"===o?s=i?"half":"halves":"3"===o?s=i?"third":"thirds":"4"===o?s=i?"fourth":"fourths":"5"===o?s=i?"fifth":"fifths":"6"===o?s=i?"sixth":"sixths":"7"===o?s=i?"seventh":"sevenths":"8"===o?s=i?"eighth":"eighths":"9"===o?s=i?"ninth":"ninths":"10"===o?s=i?"tenth":"tenths":"11"===o?s=i?"eleventh":"elevenths":"12"===o?s=i?"twelfth":"twelfths":"100"===o&&(s=i?"hundredth":"hundredths"),""!==s)){for(a="",l=!1,c=this[Ae];c&&void 0!==c[Ae];c=c[Ae])if("\\ "!==c.ctrlSeq){if(!ce.test(c.ctrlSeq||"")){l=!1;break}l=!0}return l&&(a+="and "),a+=this.getEnd(Ae).mathspeak()+" "+s}return t.prototype.mathspeak.call(this)},e.prototype.getFracDepth=function(){var t=function(e,n){return e instanceof bt&&e.ctrlSeq&&e.ctrlSeq.toLowerCase().search("frac")>=0&&(n+=1),e&&e.parent?t(e.parent,n):n};return t(this,0)},e}(Ft),ge=Z.over=J["/"]=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.createLeftOf=function(n){var r,o,i;if(!this.replacedFragment){if(r=n[Ae],!(n.options.typingSlashCreatesNewFraction&&this instanceof me))for(;r&&!(F(r)||r instanceof zt&&"mq-ellipsis-end"===r._groupingClass||r instanceof(Z.text||t)||r instanceof fe||"\\ "===r.ctrlSeq||/^[,;:]$/.test(r.ctrlSeq));)r=r[Ae];r instanceof fe&&r[Me]instanceof ue&&(r=r[Me],(o=r[Me])instanceof ue&&o.ctrlSeq!=r.ctrlSeq&&(r=r[Me])),r===n[Ae]||n.isTooDeep(1)||(o=r[Me],i=n[Ae],this.replaces(new Y(o||n.parent.getEnd(Ae),i)),n[Ae]=r)}e.prototype.createLeftOf.call(this,n)},n}(me),ye=function(){return new Dt("\\operatorname{ans}",Re("span",{class:"mq-ans"},[Re.text("ans")]),"ans")},Z.ans=ye,ve=function(){return new Dt("\\%\\operatorname{of}",Re("span",{class:"mq-nonSymbola mq-operator-name"},[Re.text("% of ")]),"percent of")},Z.percent=Z.percentof=ve,xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tokenId="",e.ctrlSeq="\\token",e.textTemplate=["token(",")"],e.mathspeakTemplate=["StartToken,",", EndToken"],e.ariaLabel="token",e}return __extends(e,t),e.prototype.html=function(){var t=Re("span",{class:"mq-token mq-ignore-mousedown","data-mq-token":this.tokenId});return this.setDOM(t),X.linkElementByCmdNode(t,this),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\token{"+this.tokenId+"}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=[];return this.domFrag().children().eachElement(function(e){var n=e.getAttribute("aria-label");"string"==typeof n&&""!==n&&t.push(n)}),t.length>0?t.join(" ").trim():"token "+this.tokenId},e.prototype.parser=function(){var t=this;return Et.block.map(function(e){var n=e.getEnd(Ae);if(n)for(t.tokenId+=n.ctrlSeq;n=n[Me];)t.tokenId+=n.ctrlSeq;return t})},e}(Dt),Z.token=xe,be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\sqrt",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf mq-sqrt-container"},[Re("span",{class:"mq-scaled mq-sqrt-prefix"},[se.sqrt.html()]),Re.block("span",{class:"mq-non-leaf mq-sqrt-stem"},t[0])])}),e.textTemplate=["sqrt(",")"],e.mathspeakTemplate=["StartRoot,",", EndRoot"],e.ariaLabel="root",e}return __extends(e,t),e.prototype.parser=function(){return Et.optBlock.then(function(t){return Et.block.map(function(e){var n=new we;return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(t.prototype.parser.call(this))},e.prototype.deleteTowards=function(e,n){if(!this.isEmpty()&&1===e)return this.moveTowards(Me,n),void n.parent.deleteOutOf(Ae,n);t.prototype.deleteTowards.call(this,e,n)},e}(Ft),Z.sqrt=J["√"]=be,Z.hat=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\hat",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-hat-prefix"},[Re.text("^")]),Re.block("span",{class:"mq-hat-stem"},t[0])])}),e.textTemplate=["hat(",")"],e}return __extends(e,t),e}(Ft),we=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.domView=new Tt(2,function(t){return Re("span",{class:"mq-nthroot-container mq-non-leaf"},[Re.block("sup",{class:"mq-nthroot mq-non-leaf"},t[0]),Re("span",{class:"mq-scaled mq-sqrt-container"},[Re("span",{class:"mq-sqrt-prefix mq-scaled"},[se.sqrt.html()]),Re.block("span",{class:"mq-sqrt-stem mq-non-leaf"},t[1])])])}),e.textTemplate=["sqrt[","](",")"],e}return __extends(e,t),e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\sqrt[",this.getEnd(Ae).latexRecursive(t),t.uncleanedLatex+="]{",this.getEnd(Me).latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=this.getEnd(Ae).mathspeak(),e=this.getEnd(Me).mathspeak();return this.getEnd(Ae).ariaLabel="Index",this.getEnd(Me).ariaLabel="Radicand","3"===t?"Start Cube Root, "+e+", End Cube Root":"Root Index "+t+", Start Root, "+e+", End Root"},e.prototype.deleteTowards=function(t,e){Ft.prototype.deleteTowards.call(this,t,e)},e}(be),Z.nthroot=we,Z.cbrt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),new Pt("3").createLeftOf(e),e.controller.moveRight()},e}(we),Ee=function(t){function e(e,n,r){var o=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-diacritic-above"},[n]),Re.block("span",{class:"mq-diacritic-stem"},t[0])])});return t.call(this,e,o,r)||this}return __extends(e,t),e}(Ft),Z.vec=function(){return new Ee("\\vec",Re.entityText("&rarr;"),["vec(",")"])},Z.tilde=function(){return new Ee("\\tilde",Re.text("~"),["tilde(",")"])},ke=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setDOM=function(e){var n,r;return t.prototype.setDOM.call(this,e),r=this.domFrag().children(),r.isEmpty()||(this.delimFrags=(n={},n[Ae]=r.first(),n[Me]=r.last(),n)),this},e}(Ft),Le=function(t){function e(e,n,r,o,i){var s,a=t.call(this,"\\left"+o,void 0,[n,r])||this;return a.side=e,a.sides=(s={},s[Ae]={ch:n,ctrlSeq:o},s[Me]={ch:r,ctrlSeq:i},s),a}return __extends(e,t),e.prototype.numBlocks=function(){return 1},e.prototype.html=function(){var e=this,n=this.getSymbol(Ae),r=this.getSymbol(Me);return this.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf mq-bracket-container"},[Re("span",{style:"width:"+n.width,class:"mq-scaled mq-bracket-l mq-paren"+(e.side===Me?" mq-ghost":"")},[n.html()]),Re.block("span",{style:"margin-left:"+n.width+";margin-right:"+r.width,class:"mq-bracket-middle mq-non-leaf"},t[0]),Re("span",{style:"width:"+r.width,class:"mq-scaled mq-bracket-r mq-paren"+(e.side===Ae?" mq-ghost":"")},[r.html()])])}),t.prototype.html.call(this)},e.prototype.getSymbol=function(t){var e=this.sides[t||Me].ch;return se[e]||{width:"0",html:""}},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\left"+this.sides[Ae].ctrlSeq,this.getEnd(Ae).latexRecursive(t),t.uncleanedLatex+="\\right"+this.sides[Me].ctrlSeq,this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r=this.sides[Ae].ch,o=this.sides[Me].ch;if("|"===r&&"|"===o)this.mathspeakTemplate=["StartAbsoluteValue,",", EndAbsoluteValue"],this.ariaLabel="absolute value";else{if(e&&e.createdLeftOf&&this.side)return n="",this.side===Ae?n=this.textTemplate[0]:this.side===Me&&(n=this.textTemplate[1]),(this.side===Ae?"left ":"right ")+_e[n];this.mathspeakTemplate=["left "+_e[r]+",",", right "+_e[o]],this.ariaLabel=_e[r]+" block"}return t.prototype.mathspeak.call(this)},e.prototype.matchBrack=function(t,n,r){return r instanceof e&&r.side&&r.side!==-n&&(!t.restrictMismatchedBrackets||Se[this.sides[this.side].ch]===r.sides[r.side].ch||"none"!==t.restrictMismatchedBrackets&&{"(":"]","[":")"}[this.sides[Ae].ch]===r.sides[Me].ch)&&r},e.prototype.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side];var e=t.delimFrags[this.side===Ae?Ae:Me].removeClass("mq-ghost");this.replaceBracket(e,this.side)},e.prototype.createLeftOf=function(e){var n,r,o;this.replacedFragment||(r=e.options,n="|"===this.sides[Ae].ch?this.matchBrack(r,Me,e[Me])||this.matchBrack(r,Ae,e[Ae])||this.matchBrack(r,0,e.parent.parent):this.matchBrack(r,-this.side,e[-this.side])||this.matchBrack(r,-this.side,e.parent.parent)),n?(o=this.side=-n.side,this.closeOpposing(n),n===e.parent.parent&&e[o]&&new Y(e[o],e.parent.getEnd(o),-o).disown().withDirAdopt(-o,n.parent,n,n[o]).domFrag().insDirOf(o,n.domFrag()),n.bubble(function(t){t.reflow()})):(n=this,o=n.side,n.replacedFragment?n.side=0:e[-o]&&(n.replaces(new Y(e[-o],e.parent.getEnd(-o),o)),e[-o]=0),t.prototype.createLeftOf.call(this,e)),o===Ae?e.insAtLeftEnd(n.getEnd(Ae)):e.insRightOf(n)},e.prototype.placeCursor=function(){},e.prototype.unwrap=function(){this.getEnd(Ae).children().disown().adopt(this.parent,this,this[Me]).domFrag().insertAfter(this.domFrag()),this.remove()},e.prototype.deleteSide=function(t,e,n){var r,o,i,s,a,l=this.parent,c=this[t],u=l.getEnd(t);if(t===this.side)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));if(r=n.options,o=!this.side,this.side=-t,this.matchBrack(r,t,this.getEnd(Ae).getEnd(this.side)))this.closeOpposing(this.getEnd(Ae).getEnd(this.side)),i=this.getEnd(Ae).getEnd(t),this.unwrap(),i&&i.siblingCreated(n.options,t),c?n.insDirOf(-t,c):n.insAtDirEnd(t,l);else{if(this.matchBrack(r,t,this.parent.parent))this.parent.parent.closeOpposing(this),this.parent.parent.unwrap();else{if(e&&o)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));this.sides[t]=N(this),this.delimFrags[Ae].removeClass("mq-ghost"),this.delimFrags[Me].removeClass("mq-ghost"),s=this.delimFrags[t].addClass("mq-ghost"),this.replaceBracket(s,t)}c?(a=this.getEnd(Ae),i=a.getEnd(t),a.domFrag().removeClass("mq-empty"),new Y(c,u,-t).disown().withDirAdopt(-t,a,i,0).domFrag().insAtDirEnd(t,a.domFrag().oneElement()),i&&i.siblingCreated(n.options,t),n.insDirOf(-t,c)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.getEnd(Ae))}},e.prototype.replaceBracket=function(t,e){var n,r,o=this.getSymbol(e);t.children().replaceWith(U(o.html())),t.oneElement().style.width=o.width,e===Ae?(n=t.next(),n.isEmpty()||(n.oneElement().style.marginLeft=o.width)):(r=t.prev(),r.isEmpty()||(r.oneElement().style.marginRight=o.width))},e.prototype.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.prototype.finalizeTree=function(){this.getEnd(Ae).deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimFrags[this.side===Ae?Me:Ae].removeClass("mq-ghost"),this.side=0}},e.prototype.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()},e}(ke),Se={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|","\\lVert ":"\\rVert ","\\rVert ":"\\lVert "},_e={"&lang;":"angle-bracket","&rang;":"angle-bracket","|":"pipe"},R("(","","parenthesis"),R("[","","bracket"),R("{","\\{","brace"),Z.langle=function(){return new Le(Ae,"&lang;","&rang;","\\langle ","\\rangle ")},Z.rangle=function(){return new Le(Me,"&lang;","&rang;","\\langle ","\\rangle ")},J["|"]=function(){return new Le(Ae,"|","|","|","|")},Z.lVert=function(){return new Le(Ae,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.rVert=function(){return new Le(Me,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.left=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var t=ft.regex,e=ft.string,n=ft.optWhitespace;return n.then(t(/^(?:[([|]|\\\{|\\langle(?![a-zA-Z])|\\lVert(?![a-zA-Z]))/)).then(function(r){var o=r.replace(/^\\/,"");return"\\langle"==r&&(o="&lang;",r+=" "),"\\lVert"==r&&(o="&#8741;",r+=" "),Et.then(function(i){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\}|\\rangle(?![a-zA-Z])|\\rVert(?![a-zA-Z]))/)).map(function(t){var e,n=t.replace(/^\\/,"");return"\\rangle"==t&&(n="&rang;",t+=" "),"\\rVert"==t&&(n="&#8741;",t+=" "),e=new Le(0,o,n,r,t),e.blocks=[i],i.adopt(e,0,0),e})})})},e}(Ft),Z.right=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){return ft.fail("unmatched \\right")},e}(Ft),qe=se["("],Oe=se[")"],Ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\binom",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-non-leaf mq-bracket-container"},[Re("span",{style:"width:"+qe.width,class:"mq-paren mq-bracket-l mq-scaled"},[qe.html()]),Re("span",{style:"margin-left:"+qe.width+"; margin-right:"+Oe.width,class:"mq-non-leaf mq-bracket-middle"},[Re("span",{class:"mq-array mq-non-leaf"},[Re.block("span",{},t[0]),Re.block("span",{},t[1])])]),Re("span",{style:"width:"+Oe.width,class:"mq-paren mq-bracket-r mq-scaled"
14
+ },[Oe.html()])])}),e.textTemplate=["choose(",",",")"],e.mathspeakTemplate=["StartBinomial,","Choose",", EndBinomial"],e.ariaLabel="binomial",e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="upper index",e.ariaLabel="lower index"},e}(ke),Z.binom=Z.binomial=Ce,Z.choose=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){ge.prototype.createLeftOf.call(this,t)},e}(Ce),Te=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\MathQuillMathField",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-editable-field"},[Re.block("span",{class:"mq-root-block","aria-hidden":"true"},t[0])])}),e}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex,o=ft.succeed;return n("[").then(r(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(t){e.name=t}).or(o(void 0)).then(t.prototype.parser.call(this))},e.prototype.finalizeTree=function(t){function e(t){if(t.parentNode&&!U(t).hasClass("mq-root-block")&&e(t.parentNode),t.nodeType===Node.ELEMENT_NODE){var n=t;"true"===n.getAttribute("aria-hidden")&&(n.removeAttribute("aria-hidden"),U(t).children().eachElement(function(t){t.setAttribute("aria-hidden","true")}))}}var n=new Ot(this.getEnd(Ae),this.domFrag().oneElement(),t);n.KIND_OF_MQ="MathField",n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(n.root),y(n.root),e(this.domFrag().parent().oneElement()),this.domFrag().oneElement().removeAttribute("aria-hidden")},e.prototype.registerInnerField=function(t,e){var n=this.getEnd(Ae).controller,r=new e(n);t[this.name]=r,t.push(r)},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.getEnd(Ae).latexRecursive(t),this.checkCursorContextClose(t)},e.prototype.text=function(){return this.getEnd(Ae).text()},e}(Ft),Z.editable=Z.MathQuillMathField=Te,Fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOptions=function(t){function e(){return""}return this.text=t.text||e,this.domView=new Tt(0,function(){return Re("span",{},[o(t.htmlString||"")])}),this.latex=t.latex||e,this},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.latex(),this.checkCursorContextClose(t)},e.prototype.parser=function(){var t=this,e=ft.string,n=ft.regex,r=ft.succeed;return e("{").then(n(/^[a-z][a-z0-9]*/i)).skip(e("}")).then(function(o){return e("[").then(n(/^[-\w\s]*/)).skip(e("]")).or(r(void 0)).map(function(e){return t.setOptions(it[o](e))})})},e}(Dt),Z.embed=Fe,window.jQuery){ut=g(1);for(De in ut)!function(t,e){"function"==typeof e?(m[t]=function(){return ct(),e.apply(this,arguments)},m[t].prototype=e.prototype):m[t]=e}(De,ut[De])}}();
package/package.json CHANGED
@@ -23,5 +23,5 @@
23
23
  "./dist/index.global.js",
24
24
  "./style.css"
25
25
  ],
26
- "version": "2025.9.21-experimental"
26
+ "version": "2025.10.2-experimental"
27
27
  }