mathquill_swiftcalcs_rails 0.9.3.117 → 0.9.3.118

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e53357084dbfb62d671f45f103f7faedb306ac7
4
- data.tar.gz: b0869d5f8309274d2bebc29fda6fbb7c93200ebc
3
+ metadata.gz: e722e1436330125cc16e869339a0854b6999f8c1
4
+ data.tar.gz: 10de99e0cb65a470fcfbecf037d4fedbe2fdb466
5
5
  SHA512:
6
- metadata.gz: c4f534c9d79fe76ec14d849b1ceb7399503158803e7a4ececc9f329ea042c21692719de0de6b06c4c5c2b3b9884ea0e0ea5b5112c3c3b079e3ea8ca358371add
7
- data.tar.gz: 7687c334722822e6ca7587c51e75351d0f1a62c3180a28f5cd49f6f8f875cc27e433f09d69211440081d0e174b65ee0f4c440e558226a04df158ec86dbbf48d2
6
+ metadata.gz: 07cc0dc2c0e68d6420a00a04ba7bbc1c840e1c89c5db69e5a8c0cd52de7ec05632bcfb7745e1b77498a89cf3aec459951b125e98df1f6d0639303286c6c4930c
7
+ data.tar.gz: 8a647a324bfc69da80a35d649cf9df0cdc42db69ff19c0238649284385e7530e59c4b310e9786e2cb291c8d2b894944819265c9793bb785768849a8e266efafc
@@ -1,3 +1,4 @@
1
- !function(){function t(){}function e(t){var e=t.length-1;return function(){var n=Oe.call(arguments,0,e),i=Oe.call(arguments,e);return t.apply(this,n.concat([i]))}}function n(t){return e(function(e,n){"function"!=typeof e&&(e=Ce(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function i(t){var e=Oe.call(arguments,1);return function(){return t.apply(this,e)}}function s(t,e){if(!e)throw new Error("prayer failed: "+t)}function r(t){s("a direction was passed",t===Se||t===je)}function o(t,e,n){s("a parent is always present",t),s("leftward is properly set up",function(){return e?e[je]===n&&e.parent===t:t.ends[Se]===n}()),s("rightward is properly set up",function(){return n?n[Se]===e&&n.parent===t:t.ends[je]===e}())}function a(t){if(!t||!t.nodeType)return null;var e=Qe(t).children(".mq-root-block").attr(we);return e?_e.byId[e].controller.API:null}function c(t){function e(e,n){var i=a(e);return i instanceof t||!e||!e.nodeType?i:t(Qe(e),n)}return e.prototype=t.prototype,e}function l(t){var e,n="moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function h(t){var e=this.parent,n=t;do{if(n[je])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function u(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);N(this.delimjQs,xe(1+.2*(t-1),1.2),1.05*t)}}function p(t,e){var e=e||t,n=fe[t],s=fe[e];Ee[t]=i(pe,Se,t,n,e,s,e,s),Ee[n]=i(pe,je,t,n,e,s,e,s)}var f,d,m,g,b,v,q,w,x,k,O,C,y,S,j,Q,T,_,A,L,E,D,R,I,z,B,P,F,M,U,$,W,G,N,H,V,X,Z,K,Y,J,te,ee,ne,ie,se,re,oe,ae,ce,le,he,ue,pe,fe,de,me,ge,be,ve=window.jQuery,qe="mathquill-command-id",we="mathquill-block-id",xe=Math.min,ke=Math.max,Oe=[].slice,Ce=e(function(t,n){return e(function(e,i){return t in e?e[t].apply(e,n.concat(i)):void 0})}),ye=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function r(){}return function o(a,c){function l(){var t=new h;return s(t.init)&&t.init.apply(t,arguments),t}function h(){}var u,p,f;return c===n&&(c=a,a=Object),l.Bare=h,u=r[t]=a[t],p=h[t]=l[t]=l.p=new r,p.constructor=l,l.mixin=function(e){return h[t]=l[t]=o(l,e)[t],l},(l.open=function(t){if(f={},s(t)?f=t.call(l,p,u,l,a):i(t)&&(f=t),i(f))for(var n in f)e.call(f,n)&&(p[n]=f[n]);return s(p.init)||(p.init=a),l})(c)}}("prototype",{}.hasOwnProperty),Se=a.L=-1,je=a.R=1,Qe=ye(ve,function(t){t.insDirOf=function(t,e){return t===Se?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===Se?this.prependTo(e):this.appendTo(e)}}),Te=ye(function(t){t.parent=0,t[Se]=0,t[je]=0,t.init=function(t,e,n){this.parent=t,this[Se]=e,this[je]=n},this.copy=function(t){return Te(t.parent,t[Se],t[je])}}),_e=ye(function(t){function e(){return i+=1}t[Se]=0,t[je]=0,t.parent=0;var i=0;this.byId={},t.init=function(){this.id=e(),_e.byId[this.id]=this,this.ends={},this.ends[Se]=0,this.ends[je]=0},t.getController=function(){return this.controller?this.controller:(this.controller=this.parent.getController(),this.controller)},t.dispose=function(){delete _e.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=Qe(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&_e.byId[n].jQadd(t),i&&_e.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=Qe(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){r(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[Se],e[je]),n},t.createLeftOf=function(t){return this.createDir(Se,t)},t.selectChildren=function(t,e){return Re(t,e)},t.bubble=n(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=n(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[Se]&&0===this.ends[je]},t.children=function(){return Ae(this.ends[Se],this.ends[je])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return Ae(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Ae(this,this).adopt(t,e,n),this},t.disown=function(){return Ae(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Ae=ye(function(t){t.init=function(t,e,n){n===f&&(n=Se),r(n),s("no half-empty fragments",!t==!e),this.ends={},t&&(s("withDir is passed to Fragment",t instanceof _e),s("oppDir is passed to Fragment",e instanceof _e),s("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=Qe(),t.withDirAdopt=function(t,e,n,i){return t===Se?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,r;return o(t,e,n),i=this,i.disowned=!1,(s=i.ends[Se])?(r=i.ends[je],e||(t.ends[Se]=s),n?n[Se]=r:t.ends[je]=r,i.ends[je][je]=n,i.each(function(n){n[Se]=e,n.parent=t,e&&(e[je]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[Se];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[je],e=i.parent,o(e,i[Se],i),o(e,t,t[je]),i[Se]?i[Se][je]=t[je]:e.ends[Se]=t[je],t[je]?t[je][Se]=i[Se]:e.ends[je]=i[Se],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=n(function(t){var e,n=this,i=n.ends[Se];if(!i)return n;for(;i!==n.ends[je][je]&&(e=t(i),e!==!1);i=i[je]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),Le={},Ee={},De=ye(Te,function(t){t.init=function(t,e,n){this.parent=t,this.options=e,this.container=n;var i=this.jQ=this._jQ=Qe('<span class="mq-cursor">&#8203;</span>');this.blink=function(){i.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[je]?this.jQ.insertBefore(this.selection&&this.selection.ends[Se][Se]===this[Se]?this.selection.jQ:this[je].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},t.hide=function(){return"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=Qe(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),e.unit&&e.unit.focus(),e.parent&&e.parent.unit&&e.parent.unit.focus(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return r(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(Se,t)},t.insRightOf=function(t){return this.insDirOf(je,t)},t.insAtDirEnd=function(t,e){return r(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(Se,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(je,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Te.copy(s),n=s.upDownCache[e.id],n?n[je]?s.insLeftOf(n[je]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[je],i=this,s=t[Se];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[je])}),!this[je])if(this[Se])this[je]=this[Se][je];else for(;!this[je];){if(this.parent=this.parent[je],!this.parent){this[je]=t[je],this.parent=e;break}this[je]=this.parent.ends[Se]}this[je]?this.insLeftOf(this[je]):this.insAtRightEnd(e),t.jQ.remove(),t[Se].siblingDeleted&&t[Se].siblingDeleted(i.options,je),t[je].siblingDeleted&&t[je].siblingDeleted(i.options,Se)},t.workingGroupChange=function(){var t,e=this.container,n=!1;e.find(".active_block").replaceWith(function(){return Qe(this).contents()}),e.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),t=this.jQ,t.addClass("hasCursor_highlighting"),n=!1,t.prevAll().each(function(){var t=Qe(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),n=!1,t.nextAll().each(function(){var t=Qe(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),e.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>")},t.startSelection=function(){var t,e=this.anticursor=Te.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,r,o,a,c=this.anticursor;if(this[Se]===c[Se]&&this.parent===c.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in c.ancestors){e=t.parent;break}if(s("cursor and anticursor in the same tree",e),n=c.ancestors[e.id],o=je,t[Se]!==n)for(a=t;a;a=a[je])if(a[je]===n[je]){o=Se,i=t,r=n;break}return o===je&&(i=n,r=t),i instanceof Te&&(i=i[je]),r instanceof Te&&(r=r[Se]),this.hide().selection=e.selectChildren(i,r),this.insDirOf(o,this.selection.ends[o]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[Se]=this.selection.ends[Se][Se],this[je]=this.selection.ends[je][je],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[Se]=t.ends[Se][Se],this[je]=t.ends[je][je],delete this.selection),t}}),Re=ye(Ae,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),Ie=ye(function(t){t.init=function(t,e,n){this.API=t,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=De(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===Se||e===je?n[t](e,this.API):n[t](this.API))};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this},t.createPopup=function(t,e,n,i){var s=this.container.children(".mq-popup").first();0==s.length&&(s=Qe("<div class='mq-popup mq-autocomplete'></div>"),this.container.append(s)),s.css({top:Math.ceil(e)+"px",left:Math.floor(n)+"px"}),s.html(t),s.find("li").mouseenter(function(){Qe(this).closest("ul").find("li").removeClass("mq-popup-selected"),Qe(this).addClass("mq-popup-selected")}).click(i)},t.closePopup=function(){this.container.children(".mq-popup").remove()}});a.noConflict=function(){return window.MathQuill=d,a},d=window.MathQuill,window.MathQuill=a,m=ye(),g={},a.__options=m.p,b=ye(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=m(),this.config(n),i=Ie(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=Qe('<span class="mq-root-block"/>').attr(we,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=a.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=g[e],this.__options[e]=i?i(n):n);return this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),a.prototype=b.prototype,a.StaticMath=c(ye(b,function(t,e){t.init=function(t){this.initRoot(j(),t.addClass("mq-math-mode")),this.__controller.delegateMouseEvents(),this.__controller.staticMathTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),v=a.EditableField=ye(b,function(e){e.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.delegateMouseEvents(),this.__controller.editablesTextareaEvents()},e.focus=function(){return this.__controller.textarea.focus(),this},e.blur=function(){return this.__controller.textarea.blur(),this},e.write=function(t){return this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},e.setAutocomplete=function(t){return this.__options.autocomplete=t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},e.addAutocomplete=function(t){return"undefined"==typeof this.__options.autocomplete?this.__options.autocomplete=[t]:this.__options.autocomplete.push(t),this},e.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=Le[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},e.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[Se];)t.selectLeft();return this},e.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.moveToLeftEnd=function(){return this.moveToDirEnd(Se)},e.moveToRightEnd=function(){return this.moveToDirEnd(je)},e.keystroke=function(e){var n;for(e=e.replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<e.length;n+=1)this.__controller.keystroke(e[n],{preventDefault:t});return this},e.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this}}),q=ye(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var r,o,a,c,l,h,u,p,f,d,m,g,b;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(b)._(t,e,i)},t.or=function(t){s("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function r(){return t._(n,i,s)}return e._(n,i,r)})},t.then=function(t){var e=this;return n(function(i,r,o){function a(e,i){var a=t instanceof n?t:t(i);return s("a parser is returned",a instanceof n),a._(e,r,o)}return e._(i,a,o)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,r.push(n),!0}function s(){return!1}for(var r=[];t._(e,i,s););return n(e,r)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,r){function o(t,e){return u.push(e),n=t,!0}function a(t,e){return l=e,n=t,!1}function c(){return!1}var l,h,u=[],p=!0;for(h=0;t>h;h+=1)if(p=i._(n,o,a),!p)return r(n,l);for(;e>h&&p;h+=1)p=i._(n,o,c);return s(n,u)})},t.result=function(t){return this.then(a(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return a(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},r=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,r){var o=n.slice(0,e);return o===t?s(n.slice(e),o):r(n,i)})},o=this.regex=function(t){s("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var r,o=t.exec(n);return o?(r=o[0],i(n.slice(r.length),r)):s(n,e)})},a=n.succeed=function(t){return n(function(e,n){return n(e,t)})},c=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},l=n.letter=o(/^[a-z]/i),h=n.letters=o(/^[a-z]*/i),u=n.digit=o(/^[0-9]/),p=n.digits=o(/^[0-9]*/),f=n.whitespace=o(/^\s+/),d=n.optWhitespace=o(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),g=n.all=n(function(t,e){return e("",t)}),b=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),w=function(){function e(t){var e,i=t.which||t.keyCode,s=n[i],r=[];return t.ctrlKey&&r.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),e=s||String.fromCharCode(i),r.length||s?(r.push(e),r.join("-")):e}var n={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"};return function(n,i){function s(t){w=t,clearTimeout(d),d=setTimeout(t)}function r(e){w(),w=t,clearTimeout(d),v.val(e),e&&v[0].select(),m=!!e}function o(){var t=v[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function a(){i.keystroke(e(g),g)}function c(e){g=e,b=null,a(),m&&s(function(){v[0].select(),w=t,clearTimeout(d)})}function l(t){g&&b&&a(),b=t,s(h)}function h(){if(!o()){var t=v.val();1===t.length?(v.val(""),i.typedText(t)):t&&v[0].select()}}function u(){g=b=null}function p(){v.focus(),s(f)}function f(){var t=v.val();v.val(""),t&&i.paste(t)}var d,m,g=null,b=null,v=ve(n),q=ve(i.container||v),w=t;return q.bind("keydown keypress input keyup focusout paste",function(){w()}),m=!1,q.bind({keydown:c,keypress:l,focusout:u,paste:p}),{select:r}}}(),Ie.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Ie.open(function(t){t.focusBlurEvents=function(){function t(){clearTimeout(n),r.selection&&r.selection.jQ.addClass("mq-blur"),e()}function e(){r.hide().parent.blur(),i.closePopup(),i.container.removeClass("mq-focused"),Qe(window).off("blur",t),i.handle("enter")}var n,i=this,s=i.root,r=i.cursor;i.textarea.focus(function(){i.blurred=!1,clearTimeout(n),i.container.addClass("mq-focused"),r.parent||r.insAtRightEnd(s),r.selection?(r.selection.jQ.removeClass("mq-blur"),i.selectionChanged()):r.show()}).blur(function(){i.blurred=!0,n=setTimeout(function(){s.postOrder("intentionalBlur"),r.clearSelection(),e()}),Qe(window).on("blur",t)}),i.blurred=!0,r.hide().parent.blur()}}),Ie.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),_e.open(function(t){t.keystroke=function(t,e,n){var i,s=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;s[Se]||s.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Enter":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return;case"Esc":case"Tab":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return void n.escapeDir(je,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(Se,t,e);case"End":n.notify("move").cursor.insAtRightEnd(s.parent);break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root);break;case"Shift-End":for(;s[je];)n.selectRight();break;case"Ctrl-Shift-End":for(;s[je]||s.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(s.parent);break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root);break;case"Shift-Home":for(;s[Se];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;s[Se]||s.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(s[Se])for(;s[Se];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(s[je])for(;s[je];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;s[je]||s.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);s[Se];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){s("overridden or never called on this node")}}),Ie.open(function(t){function e(t,e){var n,i,s,r,o,a=t.container.children(".mq-popup");return a.length>0?(n=a.find("li.mq-popup-selected"),i="up"===e?n.prev("li"):n.next("li"),0==i.length?t:(n.removeClass("mq-popup-selected"),i.addClass("mq-popup-selected"),t)):(s=t.notify("upDown").cursor,r=e+"Into",o=e+"OutOf",s[je][r]?s.insAtLeftEnd(s[je][r]):s[Se][r]?s.insAtRightEnd(s[Se][r]):s.parent.bubble(function(t){var e=t[o];return e&&("function"==typeof e&&(e=t[o](s)),e instanceof _e&&s.jumpUpDown(t,e),e!==!0)?!1:void 0}),s.workingGroupChange(),t)}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){r(t);var i=this.cursor;return i.parent!==this.root&&n.preventDefault(),i.parent!==this.root?(i.parent.moveOutOf(t,i),i.workingGroupChange(),this.notify("move")):void 0},g.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){r(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.container.children(".mq-autocomplete").length>0&&(e[Se]instanceof _?e[Se].autoComplete():e[je]instanceof _?e[je].autoComplete():e[Se]instanceof ne&&"sub"==e[Se].supsub&&e[Se].sub.ends[je]?e[Se].sub.ends[je].autoComplete():this.container.children(".mq-autocomplete").remove()),e.workingGroupChange(),this.notify("move")},t.moveLeft=function(){return this.moveDir(Se)},t.moveRight=function(){return this.moveDir(je)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return r(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[Se].siblingDeleted&&e[Se].siblingDeleted(e.options,je),e[je].siblingDeleted&&e[je].siblingDeleted(e.options,Se),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(Se)},t.deleteForward=function(){return this.deleteDir(je)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;r(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(Se)},t.selectRight=function(){return this.selectDir(je)}}),x=function(){function t(t){var e,n,i=j();if(t instanceof A&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)A(e[n]).adopt(i,i.ends[je],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||j();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[je],0);return n}var n=q.string,i=q.regex,s=(q.letter,q.any),r=q.optWhitespace,o=q.succeed,a=q.fail,c=i(/^[a-z]+[0-9]*/i).map(function(t){return A(t)}),l=i(/^[^${}\\_^]/).map(function(t){return y(t)}),h=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(s))).then(function(t){var e=Le[t];return e?e(t).parser():a("unknown command: \\"+t)}),u=h.or(c).or(l),p=n("{").then(function(){return d}).skip(n("}")),f=r.then(p.or(u.map(t))),d=f.many().map(e).skip(r),m=n("[").then(f.then(function(t){return"]"!==t.join("latex")?o(t):a()}).many().map(e).skip(r)).skip(n("]")),g=d;return g.block=f,g.optBlock=m,g}(),Ie.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=q.all,s=q.eof,r=x.skip(s).or(i.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[Se],n[je]),e=r.jQize(),e.insertBefore(n.jQ),n[Se]=r.ends[je],r.finalizeInsert(n.options,n),r.ends[je][je].siblingCreated&&r.ends[je][je].siblingCreated(n.options,Se),r.ends[Se][Se].siblingCreated&&r.ends[Se][Se].siblingCreated(n.options,je),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,r=q.all,o=q.eof,a=x.skip(o).or(r.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[Se]=i.ends[je]=0,a&&a.children().adopt(i,0,0),e=i.jQ,a?(n=a.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)}}),Ie.open(function(e){e.delegateMouseEvents=function(){var e=this.root.jQ;this.container.bind("contextmenu.mathquill",function(t){for(var n=Qe(t.target).closest(".mq-root-block"),i=_e.byId[n.attr(we)||e.attr(we)],s=i.controller,r=s.cursor,o=s.seek(Qe(t.target),t.pageX,t.pageY).cursor.parent;!(o instanceof O);)if(o=o.parent,"undefined"==typeof o){o=i;break}return o.contextMenu(r,t),t.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(n){function i(t){o=Qe(t.target)}function s(t){h.anticursor||h.startSelection(),l.seek(o,t.pageX,t.pageY).cursor.select(),o=f}function r(t){h.blink=u,h.selection||(l.editable?(p&&p.blur(),h.show(),h.parent.focus()):d.detach()),a.unbind("mousemove",i),Qe(t.target.ownerDocument).unbind("mousemove",s).unbind("mouseup",r)}var o,a=Qe(n.target).closest(".mq-root-block"),c=_e.byId[a.attr(we)||e.attr(we)],l=c.controller,h=l.cursor,u=h.blink,p=h.parent,d=l.textareaSpan,m=l.textarea;l.closePopup(),l.blurred&&(l.editable||a.prepend(d),m.focus()),n.preventDefault(),n.target.unselectable=!0,h.blink=t,l.seek(Qe(n.target),n.pageX,n.pageY).cursor.startSelection(),a.mousemove(i),Qe(n.target.ownerDocument).mousemove(s).mouseup(r)})}}),Ie.open(function(t){t.seek=function(t,e){var n,i,r,o=this.notify("select").cursor;return t&&(n=t.attr(we)||t.attr(qe),n||(i=t.parent(),n=i.attr(we)||i.attr(qe))),r=n?_e.byId[n]:this.root,s("nodeId is the id of some Node that exists",r),o.clearSelection().show(),r.seek(e,o),this.scrollHoriz(),o.workingGroupChange(),this}}),Ie.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,r=this.cursor,o=r.selection,a=this.root.jQ[0].getBoundingClientRect();if(o)if(n=o.jQ[0].getBoundingClientRect(),i=n.left-(a.left+20),s=n.right-(a.right-20),o.ends[Se]===r[je])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<a.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>a.right-20?s:i}else if(t=r.jQ[0].getBoundingClientRect().left,t>a.right-20)e=t-(a.right-20);else{if(!(t<a.left+20))return;e=t-(a.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),Ie.open(function(t){m.p.substituteTextarea=function(){return Qe("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=Qe('<span class="mq-textarea"></span>'),n=this.API.__options.substituteTextarea();if(!n.nodeType)throw"substituteTextarea() must return a DOM element, got "+n;n=this.textarea=Qe(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;H(t.container[0]),t.textareaSelectionTimeout===f&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=f;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),this.API.__options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},t.staticMathTextareaEvents=function(){function t(){s.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),i=e.textarea,s=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,i.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){i.val(t),t&&i.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,i=t.textareaSpan,s=w(n,this);this.selectFn=function(t){s.select(t)},this.container.prepend(i).on("cut",function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})}),this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.API.blur();var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){this.API.__options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show()}}),k=ye(_e,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[je].siblingCreated&&n[je].siblingCreated(t,Se),n[Se].siblingCreated&&n[Se].siblingCreated(t,je),n.bubble("reflow")},t.contextMenu=function(){}}),O=ye(k,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=x.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[je],0);return e})},t.createLeftOf=function(t){var n,i,s,r=this;if(this instanceof _||"sub"===this.supsub||t.container.children(".mq-popup").remove(),"undefined"!=typeof t.parent&&t.parent.parent instanceof he){if(","==r.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==r.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==r.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==r.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==r.ctrlSeq)return t.parent.parent.insertColumn(t)}else if("undefined"!=typeof t.parent&&t.parent.parent instanceof pe&&"\\left["===t.parent.parent.ctrlSeq&&(","==r.ctrlSeq||";"==r.ctrlSeq))return n=t.parent.parent,0!==n[Se]?t.insRightOf(n[Se]):t.insAtLeftEnd(n.parent),i=he("\\bmatrix",1,1),i.createLeftOf(t),n.ends[Se].children().disown().adopt(i.ends[Se],0,0).jQ.appendTo(i.ends[Se].jQ),n.remove(),","==r.ctrlSeq?i.insertColumn(t):i.insertRow(t);s=r.replacedFragment,r.createBlocks(),e.createLeftOf.call(r,t),s&&(s.adopt(r.ends[Se],0,0),s.jQ.appendTo(r.ends[Se].jQ)),r.finalizeInsert(t.options),r.placeCursor(t),(this instanceof S||this instanceof re||this instanceof ne||this instanceof ae)&&t.workingGroupChange()},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=j(),e.adopt(n,n.ends[je],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[Se],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Re(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[Se]=t.jQ.offset().left,e[je]=e[Se]+t.jQ.outerWidth(),e
2
- }var i,s=this,r=n(s);return t<r[Se]?e.insLeftOf(s):t>r[je]?e.insRightOf(s):(i=r[Se],void s.eachChild(function(o){var a=n(o);return t<a[Se]?(t-i<a[Se]-t?o[Se]?e.insAtRightEnd(o[Se]):e.insLeftOf(s):e.insAtLeftEnd(o),!1):t>a[je]?void(o[je]?i=a[je]:r[je]-t<t-a[je]?e.insRightOf(s):e.insAtRightEnd(o)):(o.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,r=i.blocks,o=" mathquill-command-id="+i.id,a=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(s("no unmatched angle brackets",a.join("")===this.htmlTemplate),t=0,e=a[0];e;t+=1,e=a[t])if("/>"===e.slice(-2))a[t]=e.slice(0,-2)+o+"/>";else if("<"===e.charAt(0)){s("not an unmatched top-level close tag","/"!==e.charAt(1)),a[t]=e.slice(0,-1)+o+">",n=1;do t+=1,e=a[t],s("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return a.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+r[e].id+">"+r[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var r=s.text(t);return i&&"("===e.textTemplate[n]&&"("===r[0]&&")"===r.slice(-1)?i+r.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})},t.setUnit=function(){this.parent.unit&&(this.unit=this.parent.unit,(this.parent instanceof ne||this.parent.unitsup)&&(this.unitsup=!0)),this.parent.parent&&this.parent.parent.unit&&(this.unit=this.parent.parent.unit,(this.parent.parent instanceof ne||this.parent.parent.unitsup)&&(this.unitsup=!0))},t.recursiveSetUnit=function(){this.setUnit(),this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()})}}),C=ye(O,function(e,n){e.init=function(t,e,i){i||(i=(t&&t.length>1?t.slice(1):t).trim()),n.init.call(this,t,e,[i])},e.parser=function(){return q.succeed(this)},e.numBlocks=function(){return 0},e.replaces=function(t){t.remove()},e.createBlocks=t,e.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},e.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},e.latex=function(){return this.ctrlSeq},e.text=function(){return this.textTemplate},e.placeCursor=t,e.isEmpty=function(){return!0}}),y=ye(C,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[Se]||t[Se]instanceof S)y("0").createLeftOf(t);else if(0!==t[Se]&&"."===t[Se].ctrlSeq)return t[Se].ctrlSeq="…",t[Se].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>'),void(t[Se].textTemplate="..");e.createLeftOf.call(this,t)}}),S=ye(C,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),j=ye(k,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[Se]&&0===this.ends[je]?"":this.ends[Se]===this.ends[je]?this.ends[Se].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){var s,r,o;if(i.API.__options.spaceBehavesLikeTab&&("Spacebar"===t||"Shift-Spacebar"===t))return s=i.container.children(".mq-popup"),s.length>0?s.find("li.mq-popup-selected").click():(r=i.cursor,r[Se]instanceof A&&r[Se].autoOperator(r),i.escapeDir("Shift-Spacebar"===t?Se:je,t,n)),void n.preventDefault();if("Tab"===t)r=i.cursor,r[Se]instanceof A&&r[Se].autoOperator(r);else if("Backspace"===t||"Del"===t)return o=e.keystroke.apply(this,arguments),r=i.cursor,r[Se]&&r[Se]instanceof _?r[Se].autoComplete():0===r[Se]&&r.parent&&r.parent.parent instanceof ne&&"sub"===r.parent.parent.supsub&&r.parent.parent[Se]?r.parent.parent[Se].autoComplete():i.closePopup(),o;return e.keystroke.apply(this,arguments)},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[je];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[Se].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[Se];return n.seek(t,e)},t.flash=function(){var t=this.jQ.closest(".mq-root-block");t.css("background-color","#ffe0e0"),window.setTimeout(function(){t.css("background-color","#ffffff")},100)},t.write=function(t,e,n){var i;if(e.match(/^[a-eg-zA-Z]$/)?i=A(e):e.match(/^[0-9\+\-]$/)&&t[Se]instanceof _&&"e"===t[Se].ctrlSeq&&0!==t[Se][Se]&&"undefined"!=typeof t[Se][Se]&&t[Se][Se].ctrlSeq.match(/^[0-9]$/)?i=ie(e):e.match(/^[0-9\+\-]$/)&&t[Se]instanceof _&&"e"===t[Se].ctrlSeq&&0!==t[Se][Se]&&"\\cdot "===t[Se][Se].ctrlSeq&&0!==t[Se][Se][Se]&&"undefined"!=typeof t[Se][Se][Se]&&t[Se][Se][Se].ctrlSeq.match(/^[0-9]$/)?(t[Se][Se].remove(),i=ie(e)):i=e.match(/^[0-9\.]$/)&&(t[Se]instanceof _||t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub)?A(e):(i=Ee[e]||Le[e])?i(e):y(e),t.parent&&t.parent.parent&&t.parent.parent.unitsup){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash()}else if(t.parent&&t.parent.parent&&t.parent.parent.unit)if(t.parent.parent instanceof ne){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[Se]instanceof y||t[Se]instanceof _))return n&&n.remove(),void this.flash()}else{if(!e.match(/^[a-z\^\*\/\(\)]$/i))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[Se]instanceof y||t[Se]instanceof _))return n&&n.remove(),void this.flash()}if(n&&i.replaces(n),!(!(i instanceof _)&&t[Se]instanceof A&&t[Se].autoOperator(t)&&i instanceof pe&&i.side===Se)){if(t.parent&&t.parent.parent instanceof E&&t.parent===t.parent.parent.ends[Se]){if(!(i instanceof _||"_"===e&&0===t[je]))return this.flash();if(t[Se]instanceof ne||"_"===e&&0===t[Se])return this.flash()}!(i instanceof _||i instanceof R)||!(t[Se]instanceof y||t[Se]instanceof be||t[Se]instanceof R)||t[Se].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof ne?i instanceof S||i instanceof re||i instanceof be||i instanceof ne||i instanceof pe&&i.side===je||0===t[Se]||!(t[Se]instanceof re||t[Se]instanceof pe||t[Se]instanceof ie||t[Se]instanceof ne&&!(i instanceof pe))||Le.cdot().createLeftOf(t):Le.cdot().createLeftOf(t),i.createLeftOf(t)}},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this.unit&&this.unit.focus(),this.parent&&this.parent.unit&&this.parent.unit.focus(),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this.unit&&this.unit.blur(),this.parent&&this.parent.unit&&this.parent.unit.blur(),this},t.recursiveSetUnit=function(){this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()})}}),Q=ye(j,l),a.MathField=c(ye(v,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(Q(),t,e)}})),T=Ee["\\"]=ye(O,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[Se].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[Se].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[Se].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[Se].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[Se].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):y(e).createLeftOf(t)):void(e.match(/[a-z]/i)?y(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[Se].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return Qe(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[Se].latex()+" "},t.renderCommand=function(t){var e,n,i;if(this.jQ=this.jQ.last(),this.remove(),this[je]?t.insLeftOf(this[je]):t.insAtRightEnd(this.parent),e=this.ends[Se].latex(),e||(e=" "),n=Le[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=E(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),i=0;i<e.length;i++)A(e[i]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}t.workingGroupChange()}}),Le.notin=Le.sim=Le.cong=Le.equiv=Le.oplus=Le.otimes=ye(S,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),Le.ast=Le.star=Le.loast=Le.lowast=i(S,"\\ast ","&lowast;"),Le.therefor=Le.therefore=i(S,"\\therefore ","&there4;"),Le.cuz=Le.because=i(S,"\\because ","&#8757;"),Le.prop=Le.propto=i(S,"\\propto ","&prop;"),Le["≈"]=Le.asymp=Le.approx=i(S,"\\approx ","&asymp;"),Le.isin=Le["in"]=i(S,"\\in ","&isin;"),Le.ni=Le.contains=i(S,"\\ni ","&ni;"),Le.notni=Le.niton=Le.notcontains=Le.doesnotcontain=i(S,"\\not\\ni ","&#8716;"),Le.sub=Le.subset=i(S,"\\subset ","&sub;"),Le.sup=Le.supset=Le.superset=i(S,"\\supset ","&sup;"),Le.nsub=Le.notsub=Le.nsubset=Le.notsubset=i(S,"\\not\\subset ","&#8836;"),Le.nsup=Le.notsup=Le.nsupset=Le.notsupset=Le.nsuperset=Le.notsuperset=i(S,"\\not\\supset ","&#8837;"),Le.sube=Le.subeq=Le.subsete=Le.subseteq=i(S,"\\subseteq ","&sube;"),Le.supe=Le.supeq=Le.supsete=Le.supseteq=Le.supersete=Le.superseteq=i(S,"\\supseteq ","&supe;"),Le.nsube=Le.nsubeq=Le.notsube=Le.notsubeq=Le.nsubsete=Le.nsubseteq=Le.notsubsete=Le.notsubseteq=i(S,"\\not\\subseteq ","&#8840;"),Le.nsupe=Le.nsupeq=Le.notsupe=Le.notsupeq=Le.nsupsete=Le.nsupseteq=Le.notsupsete=Le.notsupseteq=Le.nsupersete=Le.nsuperseteq=Le.notsupersete=Le.notsuperseteq=i(S,"\\not\\supseteq ","&#8841;"),Le.N=Le.naturals=Le.Naturals=i(y,"\\mathbb{N}","&#8469;"),Le.P=Le.primes=Le.Primes=Le.projective=Le.Projective=Le.probability=Le.Probability=i(y,"\\mathbb{P}","&#8473;"),Le.Z=Le.integers=Le.Integers=i(y,"\\mathbb{Z}","&#8484;"),Le.Q=Le.rationals=Le.Rationals=i(y,"\\mathbb{Q}","&#8474;"),Le.R=Le.reals=Le.Reals=i(y,"\\mathbb{R}","&#8477;"),Le.C=Le.complex=Le.Complex=Le.complexes=Le.Complexes=Le.complexplane=Le.Complexplane=Le.ComplexPlane=i(y,"\\mathbb{C}","&#8450;"),Le.H=Le.Hamiltonian=Le.quaternions=Le.Quaternions=i(y,"\\mathbb{H}","&#8461;"),Le.quad=Le.emsp=i(y,"\\quad "," "),Le.qquad=i(y,"\\qquad "," "),Le.diamond=i(y,"\\diamond ","&#9671;"),Le.bigtriangleup=i(y,"\\bigtriangleup ","&#9651;"),Le.ominus=i(y,"\\ominus ","&#8854;"),Le.uplus=i(y,"\\uplus ","&#8846;"),Le.bigtriangledown=i(y,"\\bigtriangledown ","&#9661;"),Le.sqcap=i(y,"\\sqcap ","&#8851;"),Le.triangleleft=i(y,"\\triangleleft ","&#8882;"),Le.sqcup=i(y,"\\sqcup ","&#8852;"),Le.triangleright=i(y,"\\triangleright ","&#8883;"),Le.odot=i(y,"\\odot ","&#8857;"),Le.bigcirc=i(y,"\\bigcirc ","&#9711;"),Le.dagger=i(y,"\\dagger ","&#0134;"),Le.ddagger=i(y,"\\ddagger ","&#135;"),Le.wr=i(y,"\\wr ","&#8768;"),Le.amalg=i(y,"\\amalg ","&#8720;"),Le.models=i(y,"\\models ","&#8872;"),Le.prec=i(y,"\\prec ","&#8826;"),Le.succ=i(y,"\\succ ","&#8827;"),Le.preceq=i(y,"\\preceq ","&#8828;"),Le.succeq=i(y,"\\succeq ","&#8829;"),Le.simeq=i(y,"\\simeq ","&#8771;"),Le.mid=i(y,"\\mid ","&#8739;"),Le.ll=i(y,"\\ll ","&#8810;"),Le.gg=i(y,"\\gg ","&#8811;"),Le.parallel=i(y,"\\parallel ","&#8741;"),Le.bowtie=i(y,"\\bowtie ","&#8904;"),Le.sqsubset=i(y,"\\sqsubset ","&#8847;"),Le.sqsupset=i(y,"\\sqsupset ","&#8848;"),Le.smile=i(y,"\\smile ","&#8995;"),Le.sqsubseteq=i(y,"\\sqsubseteq ","&#8849;"),Le.sqsupseteq=i(y,"\\sqsupseteq ","&#8850;"),Le.doteq=i(y,"\\doteq ","&#8784;"),Le.frown=i(y,"\\frown ","&#8994;"),Le.vdash=i(y,"\\vdash ","&#8870;"),Le.dashv=i(y,"\\dashv ","&#8867;"),Le.longleftarrow=i(y,"\\longleftarrow ","&#8592;"),Le.longrightarrow=i(y,"\\longrightarrow ","&#8594;"),Le.Longleftarrow=i(y,"\\Longleftarrow ","&#8656;"),Le.Longrightarrow=i(y,"\\Longrightarrow ","&#8658;"),Le.longleftrightarrow=i(y,"\\longleftrightarrow ","&#8596;"),Le.updownarrow=i(y,"\\updownarrow ","&#8597;"),Le.Longleftrightarrow=i(y,"\\Longleftrightarrow ","&#8660;"),Le.Updownarrow=i(y,"\\Updownarrow ","&#8661;"),Le.mapsto=i(y,"\\mapsto ","&#8614;"),Le.nearrow=i(y,"\\nearrow ","&#8599;"),Le.hookleftarrow=i(y,"\\hookleftarrow ","&#8617;"),Le.hookrightarrow=i(y,"\\hookrightarrow ","&#8618;"),Le.searrow=i(y,"\\searrow ","&#8600;"),Le.leftharpoonup=i(y,"\\leftharpoonup ","&#8636;"),Le.rightharpoonup=i(y,"\\rightharpoonup ","&#8640;"),Le.swarrow=i(y,"\\swarrow ","&#8601;"),Le.leftharpoondown=i(y,"\\leftharpoondown ","&#8637;"),Le.rightharpoondown=i(y,"\\rightharpoondown ","&#8641;"),Le.nwarrow=i(y,"\\nwarrow ","&#8598;"),Le.ldots=i(y,"\\ldots ","&#8230;"),Le.cdots=i(y,"\\cdots ","&#8943;"),Le.vdots=i(y,"\\vdots ","&#8942;"),Le.ddots=i(y,"\\ddots ","&#8944;"),Le.surd=i(y,"\\surd ","&#8730;"),Le.triangle=i(y,"\\triangle ","&#9653;"),Le.ell=i(y,"\\ell ","&#8467;"),Le.top=i(y,"\\top ","&#8868;"),Le.flat=i(y,"\\flat ","&#9837;"),Le.natural=i(y,"\\natural ","&#9838;"),Le.sharp=i(y,"\\sharp ","&#9839;"),Le.wp=i(y,"\\wp ","&#8472;"),Le.bot=i(y,"\\bot ","&#8869;"),Le.clubsuit=i(y,"\\clubsuit ","&#9827;"),Le.diamondsuit=i(y,"\\diamondsuit ","&#9826;"),Le.heartsuit=i(y,"\\heartsuit ","&#9825;"),Le.spadesuit=i(y,"\\spadesuit ","&#9824;"),Le.oint=i(y,"\\oint ","&#8750;"),Le.bigcap=i(y,"\\bigcap ","&#8745;"),Le.bigcup=i(y,"\\bigcup ","&#8746;"),Le.bigsqcup=i(y,"\\bigsqcup ","&#8852;"),Le.bigvee=i(y,"\\bigvee ","&#8744;"),Le.bigwedge=i(y,"\\bigwedge ","&#8743;"),Le.bigodot=i(y,"\\bigodot ","&#8857;"),Le.bigotimes=i(y,"\\bigotimes ","&#8855;"),Le.bigoplus=i(y,"\\bigoplus ","&#8853;"),Le.biguplus=i(y,"\\biguplus ","&#8846;"),Le.lfloor=i(y,"\\lfloor ","&#8970;"),Le.rfloor=i(y,"\\rfloor ","&#8971;"),Le.lceil=i(y,"\\lceil ","&#8968;"),Le.rceil=i(y,"\\rceil ","&#8969;"),Le.opencurlybrace=Le.lbrace=i(y,"\\lbrace ","{"),Le.closecurlybrace=Le.rbrace=i(y,"\\rbrace ","}"),Le["∫"]=Le["int"]=Le.integral=i(C,"\\int ","<big>&int;</big>"),Le.caret=i(y,"\\text{^}","^"),Le.underscore=i(y,"\\_","_"),Le.slash=i(y,"/"),Le.vert=i(y,"|"),Le.perp=Le.perpendicular=i(y,"\\perp ","&perp;"),Le.nabla=Le.del=i(y,"\\nabla ","&nabla;"),Le.hbar=i(y,"\\hbar ","&#8463;"),Le.AA=Le.Angstrom=Le.angstrom=i(y,"\\text\\AA ","&#8491;"),Le.ring=Le.circ=Le.circle=i(y,"\\circ ","&#8728;"),Le.bull=Le.bullet=i(y,"\\bullet ","&bull;"),Le.setminus=Le.smallsetminus=i(y,"\\setminus ","&#8726;"),Le.not=Le["¬"]=Le.neg=i(y,"\\neg ","&not;"),Le.dots=Le.ellip=Le.hellip=Le.ellipsis=Le.hellipsis=i(y,"\\dots ","&hellip;"),Le["…"]=i(y,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>',".."),Le.converges=Le.darr=Le.dnarr=Le.dnarrow=Le.downarrow=i(y,"\\downarrow ","&darr;"),Le.dArr=Le.dnArr=Le.dnArrow=Le.Downarrow=i(y,"\\Downarrow ","&dArr;"),Le.diverges=Le.uarr=Le.uparrow=i(y,"\\uparrow ","&uarr;"),Le.uArr=Le.Uparrow=i(y,"\\Uparrow ","&uArr;"),Le.to=i(S,"\\to ","&rarr;"),Le.rarr=Le.rightarrow=i(y,"\\rightarrow ","&rarr;"),Le.implies=i(S,"\\Rightarrow ","&rArr;"),Le.rArr=Le.Rightarrow=i(y,"\\Rightarrow ","&rArr;"),Le.gets=i(S,"\\gets ","&larr;"),Le.larr=Le.leftarrow=i(y,"\\leftarrow ","&larr;"),Le.impliedby=i(S,"\\Leftarrow ","&lArr;"),Le.lArr=Le.Leftarrow=i(y,"\\Leftarrow ","&lArr;"),Le.harr=Le.lrarr=Le.leftrightarrow=i(y,"\\leftrightarrow ","&harr;"),Le.iff=i(S,"\\Leftrightarrow ","&hArr;"),Le.hArr=Le.lrArr=Le.Leftrightarrow=i(y,"\\Leftrightarrow ","&hArr;"),Le.Re=Le.Real=Le.real=i(y,"\\Re ","&real;"),Le.Im=Le.imag=Le.image=Le.imagin=Le.imaginary=Le.Imaginary=i(y,"\\Im ","&image;"),Le.part=Le.partial=i(y,"\\partial ","&part;"),Le.infty=Le.infin=Le.infinity=i(y,"\\infty ","&infin;"),Le.alef=Le.alefsym=Le.aleph=Le.alephsym=i(y,"\\aleph ","&alefsym;"),Le.xist=Le.xists=Le.exist=Le.exists=i(y,"\\exists ","&exist;"),Le.and=Le.land=Le.wedge=i(y,"\\wedge ","&and;"),Le.or=Le.lor=Le.vee=i(y,"\\vee ","&or;"),Le.o=Le.O=Le.empty=Le.emptyset=Le.oslash=Le.Oslash=Le.nothing=Le.varnothing=i(S,"\\varnothing ","&empty;"),Le.cup=Le.union=i(S,"\\cup ","&cup;"),Le.cap=Le.intersect=Le.intersection=i(S,"\\cap ","&cap;"),Le.deg=Le.degree=i(y,"^\\circ ","&deg;"),Le.ang=Le.angle=i(y,"\\angle ","&ang;"),_=ye(C,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(){return this.textTemplate},t.autoUnItalicize=function(t){var e,n,i,s,r="",o=[];for(e=this;e instanceof _;e=e[Se])r=e.ctrlSeq+r,o.push(e);if(t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub){for(r="_"+r,o=[t.parent.parent],e=t.parent.parent[Se];e instanceof _;e=e[Se])r=e.ctrlSeq+r,o.push(e);t.insRightOf(t.parent.parent)}for(n=E(),n.createLeftOf(t),i=0;i<o.length;i++){if("f"===o[i].ctrlSeq&&o[i].jQ.removeClass("mq-florin").html("f"),o[i]instanceof ne&&"sub"===o[i].supsub)for(s=o[i].blocks[0].ends[Se];0!==s;s=s[je])"f"===s.ctrlSeq&&s.jQ.removeClass("mq-florin").html("f");o[i].disown(),o[i].adopt(n.ends[Se],0,n.ends[Se].ends[Se]),o[i].jQ.prependTo(n.ends[Se].jQ)}n.ends[Se].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.text()+"",n=[this];for(t=this[Se];t instanceof _;t=t[Se])n.unshift(t),e=t.text()+e;if(this.parent&&this.parent.parent instanceof ne&&"sub"===this.parent.parent.supsub)for(e="_"+e,n=[this.parent.parent],t=this.parent.parent[Se];t instanceof _;t=t[Se])n.unshift(t),e=t.text()+e;for(t=this[je];t instanceof _;t=t[je])n.push(t),e+=t.text();if(t instanceof ne&&"sub"===t.supsub)for(e+="_",n.push(t),t=t.sub.ends[Se];t instanceof _;t=t[je])e+=t.text();return[e,n]},t.finalizeTree=function(){this.autoComplete()},t.autoComplete=function(){var t,e,n,i,s,r,o,a,c,l,h,u,p,f,d;if(this.controller||this.getController(),t=this.fullWord(),e=t[0],n=t[1],e.length>2){for(i=function(t,e){var n,i=Object.keys(e.controller.API.__options.autoCommands);for(n=0;n<i.length;n++){if(t===i[n]){t=Le[i[n]](i[n]).htmlTemplate;break}t=t.replace(new RegExp("^"+i[n]+"_",""),Le[i[n]](i[n]).htmlTemplate+"_")}return t.indexOf("_")>-1?t.replace("_","<sub>")+"</sub>":t},s=this.controller.API.__options.autocomplete||[],r=this.controller.API.__options.staticAutocomplete||[],o=[],a=new RegExp("^"+e+".*$","i"),c=0;c<s.length;c++)s[c].match(a)&&o.push("<li data-word='"+s[c]+"'><span class='mq-nonSymbola'><i>"+i(s[c],this)+"</i></span></li>");for(c=0;c<r.length;c++)r[c].match(a)&&o.push("<li data-word='"+r[c]+"('><span class='mq-operator-name'>"+(r[c].indexOf("_")>-1?r[c].replace("_","<sub>")+"</sub>":r[c])+"(<span class='mq-inline-box'></span>)</span></li>");o.length>0?(o[0]=o[0].replace("<li",'<li class="mq-popup-selected"'),l=n[0].jQ,h=n[n.length-1].jQ,u=l.position(),p=h.position(),f=this,d=function(){var t,e=Qe(this).attr("data-word"),n=f.fullWord()[1],i=n[0][Se],s=n[0].parent;for(t=0;t<n.length;t++)n[t].remove();i?f.controller.cursor.insRightOf(i):f.controller.cursor.insAtRightEnd(s),f.controller.API.typedText(e),f.controller.closePopup(),"("!==e[e.length-1]&&f.controller.cursor.parent&&f.controller.cursor.parent.parent instanceof ne&&"sub"===f.controller.cursor.parent.parent.supsub&&f.controller.cursor.insRightOf(f.controller.cursor.parent.parent),f.controller.cursor.workingGroupChange()},this.controller.createPopup("<ul>"+o.join("\n")+"</ul>",p.top+h.height(),u.left,d)):this.controller.closePopup()}else this.controller.closePopup()}}),m.p.autoCommands={_maxLength:0},g.autoCommands=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'autocommand "'+r+'" not minimum length of 2';if(Le[r]===E)throw'"'+r+'" is a built-in operator name';n[r]=1,i=ke(i,r.length)}return n},A=ye(_,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[Se].letter,i=t[Se][Se],s=1;i instanceof A;)n=i.letter+n,i=i[Se],s+=1;if(n.length>1&&e.hasOwnProperty(n)){for(s=1,i=t[Se];s<n.length;s+=1,i=i[Se]);return Ae(i,t[Se]).remove(),t[Se]=i[Se],Le[n](n).createLeftOf(t),!0}return!1}}),L={},function(){var t,e,n,i=m.p.autoOperatorNames={_maxLength:9},s="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<s.length;t+=1)L[s[t]]=i[s[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)L[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}(),g.autoOperatorNames=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'"'+r+'" not minimum length of 2';n[r]=1,i=ke(i,r.length)}return n._maxLength=i,n},E=Le.operatorname=ye(O,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);N(t,xe(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return"undefined"!=typeof t.operatorNameTextOutput?t.operatorNameTextOutput(this,this.blocks[0].text(t),this.blocks[1].text(t)):this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return L.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=q.string,n=q.optWhitespace,i=q.succeed,s=x.block,r=this.ctrlSeq,o=this,a=o.blocks=[j(),j()];for(t=0;t<a.length;t+=1)a[t].adopt(o,o.ends[je],0);if(L.hasOwnProperty(this.ctrlSeq)){for(t=0;t<r.length;t+=1)A(r.charAt(t)).adopt(this.ends[Se],this.ends[Se].ends[je],0);return n.then(e("\\left(")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[je],0),i(o)})}).then(e("\\right)")).result(o)}return n.then(function(){var t=a[0];return s.then(function(e){var n,s;for(e.children().adopt(t,t.ends[je],0),n=e.ends[Se];0!==n;n=n[je])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof ne&&"sub"===n.supsub)for(s=n.blocks[0].ends[Se];0!==s;s=s[je])"f"===s.ctrlSeq&&(s.htmlTemplate="<var>f</var>");return i(o)})}).then(e("\\left(")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[je],0),i(o)})}).then(e("\\right)")).result(o)}});for(D in L)L.hasOwnProperty(D)&&(Le[D]=E);Le.f=ye(A,function(t,e){t.init=function(){C.p.init.call(this,this.letter="f",'<var class="mq-florin">&fnof;</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof E&&t.parent===t.parent.parent.blocks[0]?A("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof E&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?A("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),Le[" "]=Le.space=i(y,"\\ "," "),Le.backslash=i(y,"\\backslash ","\\"),Ee["\\"]||(Ee["\\"]=Le.backslash),R=ye(O,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[Se].write=function(t,e){RegExp(/[0-9\.]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)}}}),Le.$=i(R,"\\$","$"),I=ye(_,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),Le["@"]=I,Le["&"]=i(I,"\\&","&amp;"),Le["%"]=i(I,"\\%","%"),Le.alpha=Le.beta=Le.gamma=Le.delta=Le.zeta=Le.eta=Le.theta=Le.iota=Le.kappa=Le.mu=Le.nu=Le.xi=Le.rho=Le.sigma=Le.tau=Le.chi=Le.psi=Le.omega=ye(_,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),Le.phi=i(_,"\\phi ","&#981;"),Le.phiv=Le.varphi=i(_,"\\varphi ","&phi;"),Le.epsilon=i(_,"\\epsilon ","&#1013;"),Le.epsiv=Le.varepsilon=i(_,"\\varepsilon ","&epsilon;"),Le.piv=Le.varpi=i(_,"\\varpi ","&piv;"),Le.sigmaf=Le.sigmav=Le.varsigma=i(_,"\\varsigma ","&sigmaf;"),Le.thetav=Le.vartheta=Le.thetasym=i(_,"\\vartheta ","&thetasym;"),Le.upsilon=Le.upsi=i(_,"\\upsilon ","&upsilon;"),Le.gammad=Le.Gammad=Le.digamma=i(_,"\\digamma ","&#989;"),Le.kappav=Le.varkappa=i(_,"\\varkappa ","&#1008;"),Le.rhov=Le.varrho=i(_,"\\varrho ","&#1009;"),Le.pi=Le["π"]=i(I,"\\pi ","&pi;"),Le.lambda=i(I,"\\lambda ","&lambda;"),Le.Upsilon=Le.Upsi=Le.upsih=Le.Upsih=i(C,"\\Upsilon ",'<var style="font-family: serif">&upsih;</var>'),Le.Gamma=Le.Delta=Le.Theta=Le.Lambda=Le.Xi=Le.Pi=Le.Sigma=Le.Phi=Le.Psi=Le.Omega=Le.forall=ye(y,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),z=ye(O,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=x.parse(this.latex);e.children().adopt(t.parent,t[Se],t[je]),t[Se]=e.ends[je],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[je][je].siblingCreated&&e.ends[je][je].siblingCreated(t.options,Se),e.ends[Se][Se].siblingCreated&&e.ends[Se][Se].siblingCreated(t.options,je),t.parent.bubble("reflow")},t.parser=function(){var t=x.parse(this.latex).children();return q.succeed(t)}}),Le["¹"]=i(z,"^1"),Le["²"]=i(z,"^2"),Le["³"]=i(z,"^3"),Le["¼"]=i(z,"\\frac14"),Le["½"]=i(z,"\\frac12"),Le["¾"]=i(z,"\\frac34"),B=ye(S,function(t){t.init=y.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==je?(this.jQ[0].className=!this[Se]||this[Se]instanceof S?"":"mq-binary-operator",this):void 0}}),P=ye(S,function(t){t.finalizeTree=function(){var t,e;if(this[Se]&&"."===this[Se].ctrlSeq){for(t=[this[Se]],this[Se][Se]&&this[Se][Se][Se]&&"0"===this[Se][Se].ctrlSeq&&"\\cdot "===this[Se][Se][Se].ctrlSeq&&(t.push(this[Se][Se]),t.push(this[Se][Se][Se])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("&#8857;"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}}}),Le["+"]=i(B,"+","+"),Le["–"]=Le["-"]=i(B,"-","&minus;"),Le["±"]=Le.pm=Le.plusmn=Le.plusminus=i(B,"\\pm ","&plusmn;"),Le.mp=Le.mnplus=Le.minusplus=i(B,"\\mp ","&#8723;"),Ee["*"]=Le.sdot=Le.cdot=i(P,"\\cdot ","&middot;","*"),F=ye(S,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==Se||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),M={ctrlSeq:"\\le ",html:"&le;",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"&lt;",textStrict:" < "},U={ctrlSeq:"\\ge ",html:"&ge;",text:" >= ",ctrlSeqStrict:">",htmlStrict:"&gt;",textStrict:" > "},$={ctrlSeq:"\\ne ",html:"&ne;",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},Le["<"]=Le.lt=i(F,M,!0),Le[">"]=Le.gt=i(F,U,!0),Le["≤"]=Le.le=Le.leq=i(F,M,!1),Le["≥"]=Le.ge=Le.geq=i(F,U,!1),Le["!"]=i(F,$,!0),Le["≠"]=Le.ne=Le.neq=i(F,$,!1),W=ye(F,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[Se]instanceof F||t[Se]instanceof W)&&t[Se].strict?void t[Se].swap(!1):void e.createLeftOf.apply(this,arguments)}}),G={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},Le["="]=i(W,G,!0),Le.eq=i(W,G,!1),Le.times=i(S,"\\times ","&times;","[x]"),Le["÷"]=Le.div=Le.divide=Le.divides=i(S,"\\div ","&divide;","[/]"),H=t,V=document.createElement("div"),X=V.style,Z={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(Y in Z)if(Y in X){K=Y;break}K?N=function(t,e,n){t.css(K,"scale("+e+","+n+")")}:"filter"in X?(H=function(t){t.className=t.className},N=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,r;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),r=setInterval(i),Qe(window).load(function(){clearTimeout(r),i()})}):N=function(t,e,n){t.css("fontSize",n+"em")},J=ye(O,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),Le.mathrm=i(J,"\\mathrm","span",'class="mq-roman mq-font"'),Le.mathit=i(J,"\\mathit","i",'class="mq-font"'),Le.mathbf=i(J,"\\mathbf","b",'class="mq-font"'),Le.mathsf=i(J,"\\mathsf","span",'class="mq-sans-serif mq-font"'),Le.mathtt=i(J,"\\mathtt","span",'class="mq-monospace mq-font"'),Le.underline=i(J,"\\underline","span",'class="mq-non-leaf mq-underline"'),Le.overline=Le.bar=i(J,"\\overline","span",'class="mq-non-leaf mq-overline"'),te=Le.textcolor=ye(O,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=q.optWhitespace,i=q.string,s=q.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),ee=Le["class"]=ye(O,function(t,e){t.parser=function(){var t=this,n=q.string,i=q.regex;return q.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),ne=ye(O,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,i,s,r,o,a,c,l;if("sub"===this.supsub){if(!(t[Se]instanceof _))return;t[Se]instanceof _&&t[je]instanceof _&&(n=Le.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[Se]||t[Se]instanceof S)return;if("."===t[Se].ctrlSeq&&t[Se][Se]){for(i=[t[Se]],t[Se][Se]&&t[Se][Se][Se]&&t[Se][Se][Se][Se]&&"0"===t[Se][Se].ctrlSeq&&"\\cdot "===t[Se][Se][Se].ctrlSeq?(i.push(t[Se][Se]),i.push(t[Se][Se][Se]),s=t[Se][Se][Se][Se]):s=t[Se][Se],r=0;r<i.length;r++)i[r].remove();this.elementWise=!0,t.insRightOf(s)}if((t[Se]instanceof re||t[Se]instanceof ie||t[Se]instanceof se||t[Se]instanceof be)&&(o=Ee["("](),a=t[Se],o.createLeftOf(t),a.disown(),a.adopt(o.ends[Se],0,0),a.jQ.prependTo(o.ends[Se].jQ),c=Ee[")"](),c.createLeftOf(t),o.reflow()),t[Se]instanceof ne&&"sup"===t[Se].supsub){for(o=Ee["("](),a=[t[Se]],l=t[Se];!(l instanceof S)&&0!==l;l=l[Se])a.push(l);for(o.createLeftOf(t),r=0;r<a.length;r++)a[r].disown(),a[r].adopt(o.ends[Se],0,o.ends[Se].ends[Se]),a[r].jQ.prependTo(o.ends[Se].jQ);c=Ee[")"](),c.createLeftOf(t),o.reflow()}}return e.createLeftOf.call(this,t)},m.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t,e,n,i=this.supsub;this.setUnit(),this.unitsup=!1,this.ends[Se].write=function(t,e){return"sub"==i&&"_"===e?this.flash():(t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&t.insRightOf(this.parent),"sub"!=i||RegExp(/[A-Za-z0-9]/).test(e)||t.insRightOf(this.parent),void j.p.write.apply(this,arguments))
3
- },this.sup&&this.sup.ends[Se]&&"."===this.sup.ends[Se].ctrlSeq&&(this.sup.ends[Se].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise"),this.sub&&(t=this.jQ.closest(".mq-editable-field").children(".mq-autocomplete").first(),t.length>0&&(e=this.jQ,n=e.position(),t.css({top:Math.ceil(n.top+e.height())+"px"})))},t.latex=function(){function t(t,n){var i=n&&n.latex();return n?t+(1===i.length?i:"{"+(e?".":"")+(i||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[Se]&&this.sub.ends[Se]===this.sub.ends[je]?this.sub.ends[Se].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&this.sup.ends[Se]===this.sup.ends[je]?this.sup.ends[Se].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==je&&this.jQ.toggleClass("mq-limit","\\int "===this[Se].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=Qe('<span class="mq-sup"/>').append(t.jQ.children()).attr(we,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=Qe('<span class="mq-sub"></span>').append(t.jQ.children()).attr(we,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0">&nbsp;</span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,r){r.insDirOf(s,this.parent),this.isEmpty()||(r[-s]=this.ends[s],this.children().disown().withDirAdopt(s,r.parent,r[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=h,delete t[n].deleteOutOf,"sub"===e&&Qe(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),ie=Le.scientificNotation=ye(O,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">&times;</span><span>10</span><span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&1</span></span></span>',t.init=function(t){"scientificNotation"!==t&&(this.incorporate_previous=t),e.init.call(this)},t.text=function(t){return this.blocks[0].text(t)+"e"+this.blocks[1].text(t)},t.latex=function(){return"\\scientificNotation{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.finalizeTree=function(){this.downInto=this.ends[Se],this.upInto=this.ends[je],this.ends[Se].upOutOf=this.ends[je],this.ends[je].downOutOf=this.ends[Se],this.ends[Se].write=function(t,e){RegExp(/[0-9]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)},this.ends[je].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e)){if("+"===e||"-"===e){if(0===t[Se]&&0!==t[je]&&("-"===t[je].ctrlSeq||"+"===t[je].ctrlSeq))return t[je].ctrlSeq=e,t[je].textTemplate=e,void t[je].jQ.html(e);if(0!==t[Se]&&0===t[Se][Se]&&("-"===t[Se].ctrlSeq||"+"===t[Se].ctrlSeq))return t[Se].ctrlSeq=e,t[Se].textTemplate=e,void t[Se].jQ.html(e);0!==t[Se]&&t.insRightOf(this.parent)}}else t.insRightOf(this.parent);j.p.write.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[Se];if(0===n)return;if(0===n[Se])return;for(next=n[Se];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[Se])next.disown().adopt(this.ends[Se],0,this.ends[Se].ends[Se]),next.jQ.prependTo(this.ends[Se].jQ);n.remove(),t.insAtLeftEnd(this.ends[je]),this.ends[je].write(t,this.incorporate_previous)}}}),se=ye(O,function(t,e){t.init=function(t,e){var n='<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>';C.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),A("n").createLeftOf(t),Le["="]().createLeftOf(t)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);N(t,xe(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"},t.text=function(t){return" "+this.ctrlSeq+'("'+this.blocks[0].text(t).replace(" :=",'" , ')+" , "+this.blocks[1].text(t)+","+this.blocks[2].text(t)+")"},t.parser=function(){var t,e=q.string,n=q.optWhitespace,i=(q.whitespace,q.succeed),s=x.block,r=this,o=r.blocks=[j(),j(),j()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[je],0);return n.then(e("_")).then(function(){var t=o[0];return s.then(function(e){return e.children().adopt(t,t.ends[je],0),i(r)})}).then(n).then(e("^")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[je],0),i(r)})}).then(e("\\left(")).then(function(){var t=o[2];return s.then(function(e){return e.children().adopt(t,t.ends[je],0),i(r)})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[Se],this.upInto=this.ends[je],this.ends[Se].upOutOf=this.ends[je],this.ends[je].downOutOf=this.ends[Se]}}),Le["∑"]=Le.sum=Le.summation=i(se,"\\sum ","&sum;"),Le["∏"]=Le.prod=Le.product=i(se,"\\prod ","&prod;"),Le.coprod=Le.coproduct=i(se,"\\coprod ","&#8720;"),Le.subscript=Le._=ye(ne,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[Se],this.sub.upOutOf=h,e.finalizeTree.call(this)}}),Le.superscript=Le.supscript=Le["^"]=ye(ne,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[je],this.sup.downOutOf=h,e.finalizeTree.call(this)}}),re=Le.frac=Le.dfrac=Le.cfrac=Le.fraction=ye(O,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.setUnit(),this.jQ.closest(".mq-editable-field").children(".mq-popup").remove(),this.upInto=this.ends[je].upOutOf=this.ends[Se],this.downInto=this.ends[Se].downOutOf=this.ends[je],this.blocks[1].ends[Se]&&"."===this.blocks[1].ends[Se].ctrlSeq&&(this.blocks[1].ends[Se].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),oe=Le.over=Ee["/"]=ye(re,function(e,n){e.createLeftOf=function(e){var i,s,r,o;if(!this.replacedFragment){if(e[Se]&&"."===e[Se].ctrlSeq&&e[Se][Se]){for(i=[e[Se]],e[Se][Se]&&e[Se][Se][Se]&&e[Se][Se][Se][Se]&&"0"===e[Se][Se].ctrlSeq&&"\\cdot "===e[Se][Se][Se].ctrlSeq?(i.push(e[Se][Se]),i.push(e[Se][Se][Se]),s=e[Se][Se][Se][Se]):s=e[Se][Se],r=0;r<i.length;r++)i[r].remove();this.elementWise=!0,e.insRightOf(s)}for(o=e[Se];o&&!(o instanceof S||o instanceof(Le.text||t)||o instanceof se||"\\ "===o.ctrlSeq||/^[,;:]$/.test(o.ctrlSeq));)o=o[Se];o instanceof se&&o[je]instanceof ne&&(o=o[je],o[je]instanceof ne&&o[je].ctrlSeq!=o.ctrlSeq&&(o=o[je])),o!==e[Se]&&(this.replaces(Ae(o[je]||e.parent.ends[Se],e[Se])),e[Se]=o)}n.createLeftOf.call(this,e)}}),ae=Le.sqrt=Le["√"]=ye(O,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">&radic;</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return x.optBlock.then(function(t){return x.block.map(function(e){var n=le();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[je].jQ;N(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),ce=Le.vec=ye(O,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">&rarr;</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),le=Le.nthroot=ye(ae,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">&radic;</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[Se].latex()+"]{"+this.ends[je].latex()+"}"},t.text=function(t){return" "+this.ends[je].text(t)+"^(1/"+this.ends[Se].text(t)+")"}}),he=Le.begin=ye(O,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,r,o,a;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",r=0;i>r;r++){for(o="",a=0;n>a;a++)o+='<span class="mq-cell">&'+(r*n+a)+"</span>";s+='<span class="mq-row">'+o+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));N(t,xe(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenuOLD=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,Se)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,je)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,Se)}},{text:"Insert Row After",handler:function(){n.insertRow(t,je)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[Se]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[Se]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){var t=q.regex;return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,r,o,a,c,l;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,r=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),r=r.concat(e)}),o=he("\\"+e,s,i),a=o.blocks=Array(o.numBlocks()),c=0;c<a.length;c++)l=a[c]=x.parse(r[c]),l.deleteOutOf=ue().deleteOutOf,l.adopt(o,o.ends[je],0);return o})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[Se];)e++,e==this.col&&(e=0,n++),i=i[Se];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][Se]=this.blocks[n-1],this.blocks[n-1][je]=this.blocks[n]):0==n?this.blocks[n][Se]=0:this.blocks[n-1][je]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),t.workingGroupChange()}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][Se]=this.blocks[n-1],this.blocks[n-1][je]=this.blocks[n]):0==n?this.blocks[n][Se]=0:this.blocks[n-1][je]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),t.workingGroupChange()}},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=ue(),e.adopt(n,n.ends[je],0)},t.insertRow=function(t,e){var n,i,s,r,o=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Se]&&0!==t[je]:e==Se?!0:!1,i=o.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)r=ue(),r.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][je]:this.ends[Se]),r.jQ=Qe('<span class="mq-cell mq-empty" '+we+'="'+r.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][je]=r),this.blocks.splice(i+s,0,r),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row+(n?0:1)).append(r.jQ);i+s<this.blocks.length&&(this.blocks[i+s][Se]=r,r[je]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,i,s,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Se]&&0!==t[je]:e==Se?!0:!1,i=this.row-1;i>=0;i--)s=ue(),n?(s.adopt(this,i*this.col+r.col-1>=0?this.blocks[i*this.col+r.col-1]:0,this.blocks[i*this.col+r.col]),s.jQ=Qe('<span class="mq-cell mq-empty" '+we+'="'+s.id+'"></span>'),i*this.col+r.col-1>=0&&(this.blocks[i*this.col+r.col-1][je]=s),this.blocks[i*this.col+r.col][Se]=s,this.blocks.splice(i*this.col+r.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+r.col],i*this.col+r.col+1<this.row*this.col?this.blocks[i*this.col+r.col+1]:0),s.jQ=Qe('<span class="mq-cell mq-empty" '+we+'="'+s.id+'"></span>'),this.blocks[i*this.col+r.col][je]=s,i*this.col+r.col+1<this.row*this.col&&(this.blocks[i*this.col+r.col+1][Se]=s),this.blocks.splice(i*this.col+r.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?Se:je]),this.reflow(),t.workingGroupChange()},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[je]),void t.workingGroupChange())}}),Le.matrix=i(he,"\\matrix",1,1),Le.bmatrix=i(he,"\\bmatrix",1,1),Le.Bmatrix=i(he,"\\Bmatrix",1,1),Le.vmatrix=i(he,"\\vmatrix",1,1),Le.Vmatrix=i(he,"\\Vmatrix",1,1),Le.pmatrix=i(he,"\\pmatrix",1,1),ue=ye(j,function(t){t.deleteOutOf=function(t,e){var n,i,s,r,o;if(0===this.ends[Se])n=t===Se?this[Se]:this[je],this.parent.deleteColumn(e),t===Se&&(n?e.insAtRightEnd(n):n&&e.insAtLeftEnd(n));else if(i=this[t],s=this.parent.cursorRowCol(e),t===Se&&0===s.col&&(i=0),t===je&&s.col+1===this.parent.col&&(i=0),0===i)this.parent[Se]?(r=this.parent[Se],this.parent.remove(),e.insRightOf(r)):(r=this.parent.parent,this.parent.remove(),e.insAtLeftEnd(r));else{for(o=i.ends[Se];0!==o;o=o[je])o.remove();e.insAtRightEnd(i),this.parent.deleteColumn(e),t===Se?e.insAtLeftEnd(this):e.insAtRightEnd(this)}}}),pe=ye(ye(O,u),function(e,n){e.init=function(t,e,i,s,r,o,a){n.init.call(this,"\\left"+s,f,[e,i]),this.side=t,this.sides={},this.sides[Se]={ch:e,ctrlSeq:s,textTemplate:o},this.sides[je]={ch:i,ctrlSeq:r,textTemplate:a}},e.numBlocks=function(){return 1},e.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===je?" mq-ghost":"")+'">'+this.sides[Se].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===Se?" mq-ghost":"")+'">'+this.sides[je].ch+"</span></span>",n.html.call(this)},e.latex=function(){return"\\left"+this.sides[Se].ctrlSeq+this.ends[Se].latex()+"\\right"+this.sides[je].ctrlSeq},e.text=function(t){return"\\left["!==this.ctrlSeq||this[Se]instanceof _?this.sides[Se].textTemplate+this.ends[Se].text(t)+this.sides[je].textTemplate:"("+this.ends[Se].text(t)+")"},e.oppBrack=function(t,e){return t instanceof pe&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},e.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===Se?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},e.createLeftOf=function(t){var e,i,s,r,o,a,c;if(!this.replacedFragment){for(e=this.oppBrack(t[Se],Se)||this.oppBrack(t[je],je),i=!1,s=t.parent;0!==s&&!e;s=s.parent)if(i&&(e=this.oppBrack(s)),i=!0,this.side===je&&"\\left("===this.ctrlSeq){if(s instanceof E||s instanceof se)return t.insRightOf(s),t.workingGroupChange()}else if(this.side===je&&"\\left["===this.ctrlSeq&&s instanceof he)return t.insRightOf(s),t.workingGroupChange();if(!e&&"\\left("===this.ctrlSeq&&t[Se]instanceof _&&this.side===Se)return t[Se].autoUnItalicize(t);if(!e&&"\\left("===this.ctrlSeq&&t[Se]instanceof ne&&this.side===Se&&"sub"===t[Se].supsub&&t[Se].sub.ends[je]instanceof _)return t.insAtRightEnd(t[Se].sub),t[Se].autoUnItalicize(t);if(!e&&"\\left["===this.ctrlSeq&&0===t[Se]&&0===t[je]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return r=t.parent.parent[Se],o=t.parent.parent.parent,t.parent.parent.unwrap(),0!==r?t.insRightOf(r):t.insAtLeftEnd(o),a=he("\\bmatrix",1,1),void a.createLeftOf(t)}e?(c=this.side=-e.side,this.closeOpposing(e),e===t.parent.parent&&t[c]&&(Ae(t[c],t.parent.ends[c],-c).disown().withDirAdopt(-c,e.parent,e,e[c]).jQ.insDirOf(c,e.jQ),e.bubble("reflow"))):(e=this,c=e.side,e.replacedFragment?e.side=0:t[-c]&&(e.replaces(Ae(t[-c],t.parent.ends[-c],c)),t[-c]=0),n.createLeftOf.call(e,t)),c===Se?t.insAtLeftEnd(e.ends[Se]):t.insRightOf(e),t.workingGroupChange()},e.placeCursor=t,e.unwrap=function(){this.ends[Se].children().disown().adopt(this.parent,this,this[je]).jQ.insertAfter(this.jQ),this.remove()},e.deleteSide=function(t,e,n){var i,s=this.parent,r=this[t],o=s.ends[t];return t===this.side?(this.unwrap(),void(r?n.insDirOf(-t,r):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[Se].ends[this.side],t)?(this.closeOpposing(this.ends[Se].ends[this.side]),i=this.ends[Se].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),r?n.insDirOf(-t,r):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:fe[this.sides[this.side].ch],ctrlSeq:fe[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===Se?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(i=this.ends[Se].ends[t],Ae(r,o,-t).disown().withDirAdopt(-t,this.ends[Se],i,0).jQ.insAtDirEnd(t,this.ends[Se].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,r)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[Se]))))},e.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.finalizeTree=function(){this.setUnit(),this.ends[Se].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===Se?1:0).removeClass("mq-ghost"),this.side=0}},e.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),fe={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},p("("),p("["),Le.langle=i(pe,Se,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),Le.rangle=i(pe,je,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),Ee["|"]=i(pe,Se,"|","|","|","|","abs(",")"),Ee["{"]=i(pe,Se,"{","}","\\{","\\}","(",")"),Ee["}"]=i(pe,je,"{","}","\\{","\\}","(",")"),Le.left=ye(O,function(t){t.parser=function(){var t=q.regex,e=q.string,n=(q.succeed,q.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return x.then(function(r){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===s?"[":"|"===s?"abs(":"(",o="["===s?"]":")",a=pe(0,s,e,i,t,n,o);return a.blocks=[r],r.adopt(a,0,0),a})})})}}),Le.right=ye(O,function(t){t.parser=function(){return q.fail("unmatched \\right")}}),de=Le.binom=Le.binomial=ye(ye(O,u),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),me=Le.choose=ye(de,function(t){t.createLeftOf=oe.prototype.createLeftOf}),ge=ye(a.MathField,function(t){t.init=function(t,e){l(t),this.__options=m();var n=Ie(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),Le.MathQuillMathField=ye(O,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=q.string,i=q.regex,s=q.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){ge(this.ends[Se],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[Se].controller.API)},t.latex=function(){return this.ends[Se].latex()},t.text=function(t){return this.ends[Se].text(t)}}),be=Le.Unit=Ee["'"]=ye(O,function(t,e){t.ctrlSeq="Unit{...}{...}",t.replaces=function(t){t.disown(),this._replacedFragment=t},t.htmlTemplate='<span><span>&0</span><span class="mq-unit mq-non-leaf">&1</span></span>',t.finalizeTree=function(){this.ends[je].focus=function(){return this.jQ.addClass("mq-active"),this.isEmpty()&&this.jQ.removeClass("mq-empty"),this},this.ends[je].blur=function(){return this.jQ.removeClass("mq-active").removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this},this.ends[je].write=function(t,e,n){return cmd=e.match(/^[a-z]$/i)?A(e):(cmd=Ee[e]||Le[e])?cmd(e):y(e),e.match(/^[a-z\^\*\/\(\)]$/i)?(n&&cmd.replaces(n),void cmd.createLeftOf(t)):(n&&n.remove(),void this.flash())},this.ends[je].unit=this.ends[je],this.ends[je].eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()}),this.ends[je].deleteOutOf=function(t,e){for(var n=this.ends[Se];0!==n;n=n[je])n.remove();e.insAtRightEnd(this),e.unwrapGramp()},this.ends[Se].deleteOutOf=function(t,e){for(var n=this.parent.ends[je].ends[Se];0!==n;n=n[je])n.remove();e.insAtRightEnd(this),e.unwrapGramp()}},t.createLeftOf=function(t){var n,i,s,r,o;if(this._replacedFragment){for(n=!0,i=this._replacedFragment.ends[Se];0!==i;i=i[je])if(!(i instanceof y&&i.ctrlSeq.match(/[0-9\.]/))){n=!1;break}this._replacedFragment.ends[Se]===this._replacedFragment.ends[je]&&this._replacedFragment.ends[Se]instanceof ie&&(n=!0),n?(e.createLeftOf.call(this,t),this._replacedFragment.adopt(this.ends[Se],0,0),this._replacedFragment.jQ.appendTo(this.ends[Se].jQ)):(s=Ee["("](),s.replaces(this._replacedFragment),s.createLeftOf(t),s.reflow(),t.insRightOf(s),Le.cdot().createLeftOf(t),e.createLeftOf.call(this,t),t.insAtRightEnd(this.ends[Se]),y("1").createLeftOf(t))}else{for(r=[],t[Se]instanceof ie&&r.push(t[Se]),i=t[Se];0!==i&&(i instanceof y&&i.ctrlSeq.match(/[0-9\.]/));i=i[Se])r.push(i);for(0===r.length&&(t[Se]instanceof S||0===t[Se]?y("1").createLeftOf(t):(Le.cdot().createLeftOf(t),y("1").createLeftOf(t)),r.push(t[Se])),e.createLeftOf.call(this,t),o=0;o<r.length;o++)r[o].disown(),r[o].adopt(this.ends[Se],0,this.ends[Se].ends[Se]),r[o].jQ.prependTo(this.ends[Se].jQ)}t.insAtRightEnd(this.ends[je]),t.workingGroupChange()},t.latex=function(){return"\\Unit{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.text=function(t){return"UNIT("+this.blocks[0].text(t)+","+this.blocks[1].text(t)+")"}})}();
1
+ !function(){function noop(){}function variadic(t){var e=t.length-1;return function(){var n=__slice.call(arguments,0,e),i=__slice.call(arguments,e);return t.apply(this,n.concat([i]))}}function iterator(t){return variadic(function(e,n){"function"!=typeof e&&(e=send(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function bind(t){var e=__slice.call(arguments,1);return function(){return t.apply(this,e)}}function pray(t,e){if(!e)throw new Error("prayer failed: "+t)}function prayDirection(t){pray("a direction was passed",t===L||t===R)}function prayWellFormed(t,e,n){pray("a parent is always present",t),pray("leftward is properly set up",function(){return e?e[R]===n&&e.parent===t:t.ends[L]===n}()),pray("rightward is properly set up",function(){return n?n[L]===e&&n.parent===t:t.ends[R]===e}())}function MathQuill(t){if(!t||!t.nodeType)return null;var e=$(t).children(".mq-root-block").attr(mqBlockId);return e?Node.byId[e].controller.API:null}function APIFnFor(t){function e(e,n){var i=MathQuill(e);return i instanceof t||!e||!e.nodeType?i:t($(e),n)}return e.prototype=t.prototype,e}function RootBlockMixin(t){var e,n="moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function DelimsMixin(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);scale(this.delimjQs,min(1+.2*(t-1),1.2),1.05*t)}}function bindCharBracketPair(t,e){var e=e||t,n=OPP_BRACKS[t],i=OPP_BRACKS[e];CharCmds[t]=bind(Bracket,L,t,n,e,i,e,i),CharCmds[n]=bind(Bracket,R,t,n,e,i,e,i)}function insLeftOfMeUnlessAtEnd(t){var e=this.parent,n=t;do{if(n[R])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}var undefined,origMathQuill,Options,optionProcessors,AbstractMathQuill,EditableField,Parser,saneKeyboardEvents,latexMathParser,MathElement,MathCommand,DerivedMathCommand,Symbol,VanillaSymbol,BinaryOperator,MathBlock,RootMathBlock,Bracket,OPP_BRACKS,Binomial,Currency,Fraction,LiveFraction,Choose,FunctionCommand,LatexCommandInput,Matrix,MatrixMathBlock,OperatorName,fn,SquareRoot,NthRoot,ScientificNotation,SummationNotation,SupSub,Variable,Letter,BuiltInOpNames,NonSymbolaSymbol,LatexFragment,PlusMinus,Multiplication,Inequality,less,greater,factorial,Equality,equal,scale,forceIERedraw,div,div_style,transformPropNames,transformPropName,prop,Style,TextColor,Class,Vec,InnerMathField,Unit,jQuery=window.jQuery,mqCmdId="mathquill-command-id",mqBlockId="mathquill-block-id",min=Math.min,max=Math.max,__slice=[].slice,send=variadic(function(t,e){return variadic(function(n,i){return t in n?n[t].apply(n,e.concat(i)):void 0})}),P=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function a(){}return function r(o,l){function c(){var t=new d;return s(t.init)&&t.init.apply(t,arguments),t}function d(){}var h,u,p;return l===n&&(l=o,o=Object),c.Bare=d,h=a[t]=o[t],u=d[t]=c[t]=c.p=new a,u.constructor=c,c.mixin=function(e){return d[t]=c[t]=r(c,e)[t],c},(c.open=function(t){if(p={},s(t)?p=t.call(c,u,h,c,o):i(t)&&(p=t),i(p))for(var n in p)e.call(p,n)&&(u[n]=p[n]);return s(u.init)||(u.init=o),c})(l)}}("prototype",{}.hasOwnProperty),L=MathQuill.L=-1,R=MathQuill.R=1,$=P(jQuery,function(t){t.insDirOf=function(t,e){return t===L?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===L?this.prependTo(e):this.appendTo(e)}}),Point=P(function(t){t.parent=0,t[L]=0,t[R]=0,t.init=function(t,e,n){this.parent=t,this[L]=e,this[R]=n},this.copy=function(t){return Point(t.parent,t[L],t[R])}}),Node=P(function(t){function e(){return n+=1}t[L]=0,t[R]=0,t.parent=0;var n=0;this.byId={},t.init=function(){this.id=e(),Node.byId[this.id]=this,this.ends={},this.ends[L]=0,this.ends[R]=0},t.getController=function(){return this.controller?this.controller:(this.controller=this.parent.getController(),this.controller)},t.dispose=function(){delete Node.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=$(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&Node.byId[n].jQadd(t),i&&Node.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=$(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){prayDirection(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[L],e[R]),n},t.createLeftOf=function(t){return this.createDir(L,t)},t.selectChildren=function(t,e){return Selection(t,e)},t.bubble=iterator(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=iterator(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[L]&&0===this.ends[R]},t.children=function(){return Fragment(this.ends[L],this.ends[R])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return Fragment(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Fragment(this,this).adopt(t,e,n),this},t.disown=function(){return Fragment(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Fragment=P(function(t){t.init=function(t,e,n){n===undefined&&(n=L),prayDirection(n),pray("no half-empty fragments",!t==!e),this.ends={},t&&(pray("withDir is passed to Fragment",t instanceof Node),pray("oppDir is passed to Fragment",e instanceof Node),pray("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=$(),t.withDirAdopt=function(t,e,n,i){return t===L?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,a;return prayWellFormed(t,e,n),i=this,i.disowned=!1,(s=i.ends[L])?(a=i.ends[R],e||(t.ends[L]=s),n?n[L]=a:t.ends[R]=a,i.ends[R][R]=n,i.each(function(n){n[L]=e,n.parent=t,e&&(e[R]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[L];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[R],e=i.parent,prayWellFormed(e,i[L],i),prayWellFormed(e,t,t[R]),i[L]?i[L][R]=t[R]:e.ends[L]=t[R],t[R]?t[R][L]=i[L]:e.ends[R]=i[L],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=iterator(function(t){var e,n=this,i=n.ends[L];if(!i)return n;for(;i!==n.ends[R][R]&&(e=t(i),e!==!1);i=i[R]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),LatexCmds={},CharCmds={},Cursor=P(Point,function(t){t.init=function(t,e,n){this.parent=t,this.options=e,this.container=n;var i=this.jQ=this._jQ=$('<span class="mq-cursor">&#8203;</span>');this.blink=function(){i.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[R]?this.jQ.insertBefore(this.selection&&this.selection.ends[L][L]===this[L]?this.selection.jQ:this[R].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},t.hide=function(){return"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=$(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),e.unit&&e.unit.focus(),e.parent&&e.parent.unit&&e.parent.unit.focus(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(L,t)},t.insRightOf=function(t){return this.insDirOf(R,t)},t.insAtDirEnd=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(L,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(R,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Point.copy(s),n=s.upDownCache[e.id],n?n[R]?s.insLeftOf(n[R]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[R],i=this,s=t[L];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[R])}),!this[R])if(this[L])this[R]=this[L][R];else for(;!this[R];){if(this.parent=this.parent[R],!this.parent){this[R]=t[R],this.parent=e;break}this[R]=this.parent.ends[L]}this[R]?this.insLeftOf(this[R]):this.insAtRightEnd(e),t.jQ.remove(),t[L].siblingDeleted&&t[L].siblingDeleted(i.options,R),t[R].siblingDeleted&&t[R].siblingDeleted(i.options,L)},t.workingGroupChange=function(){var t,e=this.container,n=!1;e.find(".active_block").replaceWith(function(){return $(this).contents()}),e.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),t=this.jQ,t.addClass("hasCursor_highlighting"),n=!1,t.prevAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),n=!1,t.nextAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),e.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>")},t.startSelection=function(){var t,e=this.anticursor=Point.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,s,a,r,o=this.anticursor;if(this[L]===o[L]&&this.parent===o.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in o.ancestors){e=t.parent;break}if(pray("cursor and anticursor in the same tree",e),n=o.ancestors[e.id],a=R,t[L]!==n)for(r=t;r;r=r[R])if(r[R]===n[R]){a=L,i=t,s=n;break}return a===R&&(i=n,s=t),i instanceof Point&&(i=i[R]),s instanceof Point&&(s=s[L]),this.hide().selection=e.selectChildren(i,s),this.insDirOf(a,this.selection.ends[a]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[L]=this.selection.ends[L][L],this[R]=this.selection.ends[R][R],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[L]=t.ends[L][L],this[R]=t.ends[R][R],delete this.selection),t}}),Selection=P(Fragment,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),Controller=P(function(t){t.init=function(t,e,n){this.API=t,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=Cursor(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===L||e===R?n[t](e,this.API):n[t](this.API))};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this},t.createPopup=function(t,e,n,i){var s=this.container.children(".mq-popup").first();0==s.length&&(s=$("<div class='mq-popup mq-autocomplete'></div>"),this.container.append(s)),s.css({top:Math.ceil(e)+"px",left:Math.floor(n)+"px"}),s.html(t),s.find("li").mouseenter(function(){$(this).closest("ul").find("li").removeClass("mq-popup-selected"),$(this).addClass("mq-popup-selected")}).click(i)},t.closePopup=function(){this.container.children(".mq-popup").remove()}});MathQuill.noConflict=function(){return window.MathQuill=origMathQuill,MathQuill},origMathQuill=window.MathQuill,window.MathQuill=MathQuill,Options=P(),optionProcessors={},MathQuill.__options=Options.p,AbstractMathQuill=P(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=Options(),this.config(n),i=Controller(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=$('<span class="mq-root-block"/>').attr(mqBlockId,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=MathQuill.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=optionProcessors[e],this.__options[e]=i?i(n):n);return this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),MathQuill.prototype=AbstractMathQuill.prototype,MathQuill.StaticMath=APIFnFor(P(AbstractMathQuill,function(t,e){t.init=function(t){this.initRoot(MathBlock(),t.addClass("mq-math-mode")),this.__controller.delegateMouseEvents(),this.__controller.staticMathTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),EditableField=MathQuill.EditableField=P(AbstractMathQuill,function(t){t.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.delegateMouseEvents(),this.__controller.editablesTextareaEvents()},t.focus=function(){return this.__controller.textarea.focus(),this},t.blur=function(){return this.__controller.textarea.blur(),this},t.write=function(t){return this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},t.setAutocomplete=function(t){return this.__options.autocomplete=t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.addAutocomplete=function(t){if("undefined"==typeof this.__options.autocomplete)this.__options.autocomplete=[t];else{if(this.__options.autocomplete.indexOf(t)>-1)return;this.__options.autocomplete.push(t)}return this.__options.autocomplete=this.__options.autocomplete.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=LatexCmds[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},t.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[L];)t.selectLeft();return this},t.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},t.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},t.moveToLeftEnd=function(){return this.moveToDirEnd(L)},t.moveToRightEnd=function(){return this.moveToDirEnd(R)},t.keystroke=function(t){var e;for(t=t.replace(/^\s+|\s+$/g,"").split(/\s+/),e=0;e<t.length;e+=1)this.__controller.keystroke(t[e],{preventDefault:noop});return this},t.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this}}),Parser=P(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var s,a,r,o,l,c,d,h,u,p,m,f,L;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(L)._(t,e,i)},t.or=function(t){pray("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function a(){return t._(n,i,s)}return e._(n,i,a)})},t.then=function(t){var e=this;return n(function(i,s,a){function r(e,i){var r=t instanceof n?t:t(i);return pray("a parser is returned",r instanceof n),r._(e,s,a)}return e._(i,r,a)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,a.push(n),!0}function s(){return!1}for(var a=[];t._(e,i,s););return n(e,a)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,a){function r(t,e){return h.push(e),n=t,!0}function o(t,e){return c=e,n=t,!1}function l(){return!1}var c,d,h=[],u=!0;for(d=0;t>d;d+=1)if(u=i._(n,r,o),!u)return a(n,c);for(;e>d&&u;d+=1)u=i._(n,r,l);return s(n,h)})},t.result=function(t){return this.then(r(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return r(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},s=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,a){var r=n.slice(0,e);return r===t?s(n.slice(e),r):a(n,i)})},a=this.regex=function(t){pray("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var a,r=t.exec(n);return r?(a=r[0],i(n.slice(a.length),a)):s(n,e)})},r=n.succeed=function(t){return n(function(e,n){return n(e,t)})},o=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},l=n.letter=a(/^[a-z]/i),c=n.letters=a(/^[a-z]*/i),d=n.digit=a(/^[0-9]/),h=n.digits=a(/^[0-9]*/),u=n.whitespace=a(/^\s+/),p=n.optWhitespace=a(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),f=n.all=n(function(t,e){return e("",t)}),L=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),saneKeyboardEvents=function(){function t(t){var n,i=t.which||t.keyCode,s=e[i],a=[];return t.ctrlKey&&a.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&a.push("Meta"),t.altKey&&a.push("Alt"),t.shiftKey&&a.push("Shift"),n=s||String.fromCharCode(i),a.length||s?(a.push(n),a.join("-")):n}var e={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"};return function(e,n){function i(t){C=t,clearTimeout(p),p=setTimeout(t)}function s(t){C(),C=noop,clearTimeout(p),b.val(t),t&&b[0].select(),m=!!t}function a(){var t=b[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function r(){n.keystroke(t(f),f)}function o(t){f=t,L=null,r(),m&&i(function(){b[0].select(),C=noop,clearTimeout(p)})}function l(t){f&&L&&r(),L=t,i(c)}function c(){if(!a()){var t=b.val();1===t.length?(b.val(""),n.typedText(t)):t&&b[0].select()}}function d(){f=L=null}function h(){b.focus(),i(u)}function u(){var t=b.val();b.val(""),t&&n.paste(t)}var p,m,f=null,L=null,b=jQuery(e),x=jQuery(n.container||b),C=noop;return x.bind("keydown keypress input keyup focusout paste",function(){C()}),m=!1,x.bind({keydown:o,keypress:l,focusout:d,paste:h}),{select:s}}}(),Controller.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Controller.open(function(t){t.focusBlurEvents=function(){function t(){clearTimeout(n),a.selection&&a.selection.jQ.addClass("mq-blur"),e()}function e(){a.hide().parent.blur(),i.closePopup(),i.container.removeClass("mq-focused"),$(window).off("blur",t),i.handle("enter")}var n,i=this,s=i.root,a=i.cursor;i.textarea.focus(function(){i.blurred=!1,clearTimeout(n),i.container.addClass("mq-focused"),a.parent||a.insAtRightEnd(s),a.selection?(a.selection.jQ.removeClass("mq-blur"),i.selectionChanged()):a.show()}).blur(function(){i.blurred=!0,n=setTimeout(function(){s.postOrder("intentionalBlur"),a.clearSelection(),e()}),$(window).on("blur",t)}),i.blurred=!0,a.hide().parent.blur()}}),Controller.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),Node.open(function(t){t.keystroke=function(t,e,n){var i,s=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;s[L]||s.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Enter":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return;case"Esc":case"Tab":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return void n.escapeDir(R,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(L,t,e);case"End":n.notify("move").cursor.insAtRightEnd(s.parent);break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root);break;case"Shift-End":for(;s[R];)n.selectRight();break;case"Ctrl-Shift-End":for(;s[R]||s.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(s.parent);break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root);break;case"Shift-Home":for(;s[L];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;s[L]||s.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(s[L])for(;s[L];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(s[R])for(;s[R];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;s[R]||s.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);s[L];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){pray("overridden or never called on this node")}}),Controller.open(function(t){function e(t,e){var n,i,s,a,r,o=t.container.children(".mq-popup");return o.length>0?(n=o.find("li.mq-popup-selected"),i="up"===e?n.prev("li"):n.next("li"),0==i.length?t:(n.removeClass("mq-popup-selected"),i.addClass("mq-popup-selected"),t)):(s=t.notify("upDown").cursor,a=e+"Into",r=e+"OutOf",s[R][a]?s.insAtLeftEnd(s[R][a]):s[L][a]?s.insAtRightEnd(s[L][a]):s.parent.bubble(function(t){var e=t[r];return e&&("function"==typeof e&&(e=t[r](s)),e instanceof Node&&s.jumpUpDown(t,e),e!==!0)?!1:void 0}),s.workingGroupChange(),t)}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){prayDirection(t);var i=this.cursor;return i.parent!==this.root&&n.preventDefault(),i.parent!==this.root?(i.parent.moveOutOf(t,i),i.workingGroupChange(),this.notify("move")):void 0},optionProcessors.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){prayDirection(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.container.children(".mq-autocomplete").length>0&&(e[L]instanceof Variable?e[L].autoComplete():e[R]instanceof Variable?e[R].autoComplete():e[L]instanceof SupSub&&"sub"==e[L].supsub&&e[L].sub.ends[R]?e[L].sub.ends[R].autoComplete():this.container.children(".mq-autocomplete").remove()),e.workingGroupChange(),this.notify("move")},t.moveLeft=function(){return this.moveDir(L)},t.moveRight=function(){return this.moveDir(R)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return prayDirection(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[L].siblingDeleted&&e[L].siblingDeleted(e.options,R),e[R].siblingDeleted&&e[R].siblingDeleted(e.options,L),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(L)},t.deleteForward=function(){return this.deleteDir(R)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;prayDirection(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(L)},t.selectRight=function(){return this.selectDir(R)}}),latexMathParser=function(){function t(t){var e,n,i=MathBlock();if(t instanceof Letter&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)Letter(e[n]).adopt(i,i.ends[R],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||MathBlock();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[R],0);return n}var n=Parser.string,i=Parser.regex,s=(Parser.letter,Parser.any),a=Parser.optWhitespace,r=Parser.succeed,o=Parser.fail,l=i(/^[a-z]+[0-9]*/i).map(function(t){return Letter(t)}),c=i(/^[^${}\\_^]/).map(function(t){return VanillaSymbol(t)}),d=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(s))).then(function(t){var e=LatexCmds[t];return e?e(t).parser():o("unknown command: \\"+t)}),h=d.or(l).or(c),u=n("{").then(function(){return m}).skip(n("}")),p=a.then(u.or(h.map(t))),m=p.many().map(e).skip(a),f=n("[").then(p.then(function(t){return"]"!==t.join("latex")?r(t):o()}).many().map(e).skip(a)).skip(n("]")),L=m;return L.block=p,L.optBlock=f,L}(),Controller.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=Parser.all,s=Parser.eof,a=latexMathParser.skip(s).or(i.result(!1)).parse(t);return a&&!a.isEmpty()&&(a.children().adopt(n.parent,n[L],n[R]),e=a.jQize(),e.insertBefore(n.jQ),n[L]=a.ends[R],a.finalizeInsert(n.options,n),a.ends[R][R].siblingCreated&&a.ends[R][R].siblingCreated(n.options,L),a.ends[L][L].siblingCreated&&a.ends[L][L].siblingCreated(n.options,R),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,a=Parser.all,r=Parser.eof,o=latexMathParser.skip(r).or(a.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[L]=i.ends[R]=0,o&&o.children().adopt(i,0,0),e=i.jQ,o?(n=o.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)}}),Controller.open(function(t){t.delegateMouseEvents=function(){var t=this.root.jQ;this.container.bind("contextmenu.mathquill",function(e){for(var n=$(e.target).closest(".mq-root-block"),i=Node.byId[n.attr(mqBlockId)||t.attr(mqBlockId)],s=i.controller,a=s.cursor,r=s.seek($(e.target),e.pageX,e.pageY).cursor.parent;!(r instanceof MathCommand);)if(r=r.parent,"undefined"==typeof r){r=i;break}return r.contextMenu(a,e),e.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(e){function n(t){a=$(t.target)}function i(t){c.anticursor||c.startSelection(),l.seek(a,t.pageX,t.pageY).cursor.select(),a=undefined}function s(t){c.blink=d,c.selection||(l.editable?(h&&h.blur(),c.show(),c.parent.focus()):u.detach()),r.unbind("mousemove",n),$(t.target.ownerDocument).unbind("mousemove",i).unbind("mouseup",s)}var a,r=$(e.target).closest(".mq-root-block"),o=Node.byId[r.attr(mqBlockId)||t.attr(mqBlockId)],l=o.controller,c=l.cursor,d=c.blink,h=c.parent,u=l.textareaSpan,p=l.textarea;l.closePopup(),l.blurred&&(l.editable||r.prepend(u),p.focus()),e.preventDefault(),e.target.unselectable=!0,c.blink=noop,l.seek($(e.target),e.pageX,e.pageY).cursor.startSelection(),r.mousemove(n),$(e.target.ownerDocument).mousemove(i).mouseup(s)})}}),Controller.open(function(t){t.seek=function(t,e){var n,i,s,a=this.notify("select").cursor;return t&&(n=t.attr(mqBlockId)||t.attr(mqCmdId),n||(i=t.parent(),n=i.attr(mqBlockId)||i.attr(mqCmdId))),s=n?Node.byId[n]:this.root,pray("nodeId is the id of some Node that exists",s),a.clearSelection().show(),s.seek(e,a),this.scrollHoriz(),a.workingGroupChange(),this}}),Controller.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,a=this.cursor,r=a.selection,o=this.root.jQ[0].getBoundingClientRect();if(r)if(n=r.jQ[0].getBoundingClientRect(),i=n.left-(o.left+20),s=n.right-(o.right-20),r.ends[L]===a[R])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<o.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>o.right-20?s:i}else if(t=a.jQ[0].getBoundingClientRect().left,t>o.right-20)e=t-(o.right-20);else{if(!(t<o.left+20))return;e=t-(o.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),Controller.open(function(t){Options.p.substituteTextarea=function(){return $("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=$('<span class="mq-textarea"></span>'),n=this.API.__options.substituteTextarea();if(!n.nodeType)throw"substituteTextarea() must return a DOM element, got "+n;n=this.textarea=$(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;forceIERedraw(t.container[0]),t.textareaSelectionTimeout===undefined&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=undefined;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),this.API.__options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},t.staticMathTextareaEvents=function(){function t(){s.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),i=e.textarea,s=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,i.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){i.val(t),t&&i.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,i=t.textareaSpan,s=saneKeyboardEvents(n,this);this.selectFn=function(t){s.select(t)},this.container.prepend(i).on("cut",function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})}),this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.API.blur();var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){this.API.__options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show()}}),MathElement=P(Node,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[R].siblingCreated&&n[R].siblingCreated(t,L),n[L].siblingCreated&&n[L].siblingCreated(t,R),n.bubble("reflow")},t.contextMenu=function(){}}),MathCommand=P(MathElement,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=latexMathParser.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[R],0);return e})},t.createLeftOf=function(t){var n,i,s,a=this;
2
+ if(this instanceof Variable||"sub"===this.supsub||t.container.children(".mq-popup").remove(),"undefined"!=typeof t.parent&&t.parent.parent instanceof Matrix){if(","==a.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==a.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==a.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==a.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==a.ctrlSeq)return t.parent.parent.insertColumn(t)}else if("undefined"!=typeof t.parent&&t.parent.parent instanceof Bracket&&"\\left["===t.parent.parent.ctrlSeq&&(","==a.ctrlSeq||";"==a.ctrlSeq))return n=t.parent.parent,0!==n[L]?t.insRightOf(n[L]):t.insAtLeftEnd(n.parent),i=Matrix("\\bmatrix",1,1),i.createLeftOf(t),n.ends[L].children().disown().adopt(i.ends[L],0,0).jQ.appendTo(i.ends[L].jQ),n.remove(),","==a.ctrlSeq?i.insertColumn(t):i.insertRow(t);s=a.replacedFragment,a.createBlocks(),e.createLeftOf.call(a,t),s&&(s.adopt(a.ends[L],0,0),s.jQ.appendTo(a.ends[L].jQ)),a.finalizeInsert(t.options),a.placeCursor(t),(this instanceof BinaryOperator||this instanceof Fraction||this instanceof SupSub||this instanceof SquareRoot)&&t.workingGroupChange()},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MathBlock(),e.adopt(n,n.ends[R],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[L],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Selection(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[L]=t.jQ.offset().left,e[R]=e[L]+t.jQ.outerWidth(),e}var i,s=this,a=n(s);return t<a[L]?e.insLeftOf(s):t>a[R]?e.insRightOf(s):(i=a[L],void s.eachChild(function(r){var o=n(r);return t<o[L]?(t-i<o[L]-t?r[L]?e.insAtRightEnd(r[L]):e.insLeftOf(s):e.insAtLeftEnd(r),!1):t>o[R]?void(r[R]?i=o[R]:a[R]-t<t-o[R]?e.insRightOf(s):e.insAtRightEnd(r)):(r.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,s=i.blocks,a=" mathquill-command-id="+i.id,r=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(pray("no unmatched angle brackets",r.join("")===this.htmlTemplate),t=0,e=r[0];e;t+=1,e=r[t])if("/>"===e.slice(-2))r[t]=e.slice(0,-2)+a+"/>";else if("<"===e.charAt(0)){pray("not an unmatched top-level close tag","/"!==e.charAt(1)),r[t]=e.slice(0,-1)+a+">",n=1;do t+=1,e=r[t],pray("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return r.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+s[e].id+">"+s[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var a=s.text(t);return i&&"("===e.textTemplate[n]&&"("===a[0]&&")"===a.slice(-1)?i+a.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})},t.setUnit=function(){this.parent.unit&&(this.unit=this.parent.unit,(this.parent instanceof SupSub||this.parent.unitsup)&&(this.unitsup=!0)),this.parent.parent&&this.parent.parent.unit&&(this.unit=this.parent.parent.unit,(this.parent.parent instanceof SupSub||this.parent.parent.unitsup)&&(this.unitsup=!0))},t.recursiveSetUnit=function(){this.setUnit(),this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()})}}),DerivedMathCommand=P(MathCommand,function(){}),Symbol=P(MathCommand,function(t,e){t.init=function(t,n,i){i||(i=(t&&t.length>1?t.slice(1):t).trim()),e.init.call(this,t,n,[i])},t.parser=function(){return Parser.succeed(this)},t.numBlocks=function(){return 0},t.replaces=function(t){t.remove()},t.createBlocks=noop,t.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},t.deleteTowards=function(t,e){e[t]=this.remove()[t]},t.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},t.latex=function(){return this.ctrlSeq},t.text=function(){return this.textTemplate},t.placeCursor=noop,t.isEmpty=function(){return!0}}),VanillaSymbol=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[L]||t[L]instanceof BinaryOperator)VanillaSymbol("0").createLeftOf(t);else if(0!==t[L]&&"."===t[L].ctrlSeq)return t[L].ctrlSeq="…",t[L].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>'),void(t[L].textTemplate="..");e.createLeftOf.call(this,t)}}),BinaryOperator=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),MathBlock=P(MathElement,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[L]&&0===this.ends[R]?"":this.ends[L]===this.ends[R]?this.ends[L].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){var s,a,r;if(i.API.__options.spaceBehavesLikeTab&&("Spacebar"===t||"Shift-Spacebar"===t))return s=i.container.children(".mq-popup"),s.length>0?s.find("li.mq-popup-selected").click():(a=i.cursor,a[L]instanceof Letter&&a[L].autoOperator(a),i.escapeDir("Shift-Spacebar"===t?L:R,t,n)),void n.preventDefault();if("Tab"===t)a=i.cursor,a[L]instanceof Letter&&a[L].autoOperator(a);else if("Backspace"===t||"Del"===t)return r=e.keystroke.apply(this,arguments),a=i.cursor,a[L]&&a[L]instanceof Variable?a[L].autoComplete():0===a[L]&&a.parent&&a.parent.parent instanceof SupSub&&"sub"===a.parent.parent.supsub&&a.parent.parent[L]?a.parent.parent[L].autoComplete():i.closePopup(),r;return e.keystroke.apply(this,arguments)},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[R];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[L].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[L];return n.seek(t,e)},t.flash=function(){var t=this.jQ.closest(".mq-root-block");t.css("background-color","#ffe0e0"),window.setTimeout(function(){t.css("background-color","#ffffff")},100)},t.write=function(t,e,n){var i;if(e.match(/^[a-eg-zA-Z]$/)?i=Letter(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&"undefined"!=typeof t[L][L]&&t[L][L].ctrlSeq.match(/^[0-9]$/)?i=ScientificNotation(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&t[L][L]instanceof Multiplication&&t[L][L].addedImplicitly&&0!==t[L][L][L]&&"undefined"!=typeof t[L][L][L]&&t[L][L][L].ctrlSeq.match(/^[0-9]$/)?(t[L][L].remove(),i=ScientificNotation(e)):i=!e.match(/^[0-9\.]$/)||t.parent&&t.parent.unit||t.parent&&t.parent.parent&&t.parent.parent.unit||!(t[L]instanceof Variable||t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub)?(i=CharCmds[e]||LatexCmds[e])?i(e):VanillaSymbol(e):Letter(e),t.parent&&t.parent.parent&&t.parent.parent.unitsup){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash()}else if(t.parent&&t.parent.parent&&t.parent.parent.unit)if(t.parent.parent instanceof SupSub){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}else{if(!e.match(/^[a-z\u00b52\^\*\/\(\)]$/i))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}if(n&&i.replaces(n),!(!(i instanceof Variable)&&t[L]instanceof Letter&&t[L].autoOperator(t)&&i instanceof Bracket&&i.side===L)){if(t.parent&&(t.parent.parent instanceof OperatorName||t.parent.parent instanceof FunctionCommand)&&t.parent===t.parent.parent.ends[L]){if(!(i instanceof Variable||"_"===e&&0===t[R]))return this.flash();if(t[L]instanceof SupSub||"_"===e&&0===t[L])return this.flash()}!(i instanceof Variable||i instanceof Currency)||!(t[L]instanceof VanillaSymbol||t[L]instanceof DerivedMathCommand||t[L]instanceof Currency)||t[L].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof SupSub?i instanceof BinaryOperator||i instanceof Fraction||i instanceof DerivedMathCommand||i instanceof SupSub||i instanceof Bracket&&i.side===R||0===t[L]||!(t[L]instanceof Fraction||t[L]instanceof Bracket||t[L]instanceof DerivedMathCommand||t[L]instanceof SupSub&&!(i instanceof Bracket))||LatexCmds.cdot().implicit().createLeftOf(t):LatexCmds.cdot().implicit().createLeftOf(t),i.createLeftOf(t)}},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this.unit&&this.unit.focus(),this.parent&&this.parent.unit&&this.parent.unit.focus(),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this.unit&&this.unit.blur(),this.parent&&this.parent.unit&&this.parent.unit.blur(),this},t.recursiveSetUnit=function(){this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()}),this.eachChild(function(t){if(t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}})}}),RootMathBlock=P(MathBlock,RootBlockMixin),MathQuill.MathField=APIFnFor(P(EditableField,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(RootMathBlock(),t,e)}})),Bracket=P(P(MathCommand,DelimsMixin),function(t,e){t.init=function(t,n,i,s,a,r,o){e.init.call(this,"\\left"+s,undefined,[n,i]),this.side=t,this.sides={},this.sides[L]={ch:n,ctrlSeq:s,textTemplate:r},this.sides[R]={ch:i,ctrlSeq:a,textTemplate:o}},t.numBlocks=function(){return 1},t.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===R?" mq-ghost":"")+'">'+this.sides[L].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===L?" mq-ghost":"")+'">'+this.sides[R].ch+"</span></span>",e.html.call(this)},t.latex=function(){return"\\left"+this.sides[L].ctrlSeq+this.ends[L].latex()+"\\right"+this.sides[R].ctrlSeq},t.text=function(t){return"\\left["!==this.ctrlSeq||this[L]instanceof Variable?this.sides[L].textTemplate+this.ends[L].text(t)+this.sides[R].textTemplate:"("+this.ends[L].text(t)+")"},t.oppBrack=function(t,e){return t instanceof Bracket&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},t.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===L?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},t.createLeftOf=function(t){var n,i,s,a,r,o,l;if(!this.replacedFragment){for(n=this.oppBrack(t[L],L)||this.oppBrack(t[R],R),i=!1,s=t.parent;0!==s&&!n;s=s.parent)if(i&&(n=this.oppBrack(s)),i=!0,this.side===R&&"\\left("===this.ctrlSeq){if(s instanceof OperatorName||s instanceof SummationNotation)return t.insRightOf(s),t.workingGroupChange()}else if(this.side===R&&"\\left["===this.ctrlSeq&&s instanceof Matrix)return t.insRightOf(s),t.workingGroupChange();if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof Variable&&this.side===L)return t[L].autoUnItalicize(t);if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof SupSub&&this.side===L&&"sub"===t[L].supsub&&t[L].sub.ends[R]instanceof Variable)return t.insAtRightEnd(t[L].sub),t[L].autoUnItalicize(t);if(!n&&"\\left["===this.ctrlSeq&&0===t[L]&&0===t[R]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return a=t.parent.parent[L],r=t.parent.parent.parent,t.parent.parent.unwrap(),0!==a?t.insRightOf(a):t.insAtLeftEnd(r),o=Matrix("\\bmatrix",1,1),void o.createLeftOf(t)}n?(l=this.side=-n.side,this.closeOpposing(n),n===t.parent.parent&&t[l]&&(Fragment(t[l],t.parent.ends[l],-l).disown().withDirAdopt(-l,n.parent,n,n[l]).jQ.insDirOf(l,n.jQ),n.bubble("reflow"))):(n=this,l=n.side,n.replacedFragment?n.side=0:t[-l]&&(n.replaces(Fragment(t[-l],t.parent.ends[-l],l)),t[-l]=0),e.createLeftOf.call(n,t)),l===L?t.insAtLeftEnd(n.ends[L]):t.insRightOf(n),t.workingGroupChange()},t.placeCursor=noop,t.unwrap=function(){this.ends[L].children().disown().adopt(this.parent,this,this[R]).jQ.insertAfter(this.jQ),this.remove()},t.deleteSide=function(t,e,n){var i,s=this.parent,a=this[t],r=s.ends[t];return t===this.side?(this.unwrap(),void(a?n.insDirOf(-t,a):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[L].ends[this.side],t)?(this.closeOpposing(this.ends[L].ends[this.side]),i=this.ends[L].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),a?n.insDirOf(-t,a):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:OPP_BRACKS[this.sides[this.side].ch],ctrlSeq:OPP_BRACKS[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===L?0:1).addClass("mq-ghost").html(this.sides[t].ch)),a?(i=this.ends[L].ends[t],Fragment(a,r,-t).disown().withDirAdopt(-t,this.ends[L],i,0).jQ.insAtDirEnd(t,this.ends[L].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,a)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[L]))))},t.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},t.finalizeTree=function(){this.setUnit(),this.ends[L].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===L?1:0).removeClass("mq-ghost"),this.side=0}},t.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),OPP_BRACKS={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},bindCharBracketPair("("),bindCharBracketPair("["),LatexCmds.langle=bind(Bracket,L,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),LatexCmds.rangle=bind(Bracket,R,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),CharCmds["|"]=LatexCmds.abs=bind(Bracket,L,"|","|","|","|","abs(",")"),CharCmds["{"]=bind(Bracket,L,"{","}","\\{","\\}","(",")"),CharCmds["}"]=bind(Bracket,R,"{","}","\\{","\\}","(",")"),LatexCmds.left=P(MathCommand,function(t){t.parser=function(){var t=Parser.regex,e=Parser.string,n=(Parser.succeed,Parser.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return latexMathParser.then(function(a){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===s?"[":"|"===s?"abs(":"(",r="["===s?"]":")",o=Bracket(0,s,e,i,t,n,r);return o.blocks=[a],a.adopt(o,0,0),o})})})}}),LatexCmds.right=P(MathCommand,function(t){t.parser=function(){return Parser.fail("unmatched \\right")}}),Binomial=LatexCmds.binom=LatexCmds.binomial=P(P(MathCommand,DelimsMixin),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),Currency=P(MathCommand,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[L].write=function(t,e){RegExp(/[0-9\.]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))}}}),LatexCmds.$=bind(Currency,"\\$","$"),Fraction=LatexCmds.frac=LatexCmds.dfrac=LatexCmds.cfrac=LatexCmds.fraction=P(MathCommand,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.setUnit(),this.jQ.closest(".mq-editable-field").children(".mq-popup").remove(),this.upInto=this.ends[R].upOutOf=this.ends[L],this.downInto=this.ends[L].downOutOf=this.ends[R],this.blocks[1].ends[L]&&"."===this.blocks[1].ends[L].ctrlSeq&&(this.blocks[1].ends[L].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),LiveFraction=LatexCmds.over=CharCmds["/"]=P(Fraction,function(t,e){t.createLeftOf=function(t){var n,i,s,a;if(!this.replacedFragment){if(t[L]&&"."===t[L].ctrlSeq&&t[L][L]){for(n=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(n.push(t[L][L]),n.push(t[L][L][L]),i=t[L][L][L][L]):i=t[L][L],s=0;s<n.length;s++)n[s].remove();this.elementWise=!0,t.insRightOf(i)}for(a=t[L];a&&!(a instanceof BinaryOperator||a instanceof(LatexCmds.text||noop)||a instanceof SummationNotation||"\\ "===a.ctrlSeq||/^[,;:]$/.test(a.ctrlSeq));)a=a[L];a instanceof SummationNotation&&a[R]instanceof SupSub&&(a=a[R],a[R]instanceof SupSub&&a[R].ctrlSeq!=a.ctrlSeq&&(a=a[R])),a!==t[L]&&(this.replaces(Fragment(a[R]||t.parent.ends[L],t[L])),t[L]=a)}e.createLeftOf.call(this,t)}}),Choose=LatexCmds.choose=P(Binomial,function(t){t.createLeftOf=LiveFraction.prototype.createLeftOf}),FunctionCommand=LatexCmds.functionCommand=P(DerivedMathCommand,function(_,super_){_.ctrlSeq="FunctionCommand{...}{...}",_.htmlTemplate="<span><span>&0</span><span>.</span><span>&1</span></span>",_.init=function(t){"functionCommand"!==t&&(this.incorporate_previous=t),super_.init.call(this)},_.text=function(t){return this.blocks[0].text(t)+"__"+this.blocks[1].text(t)},_.latex=function(){return"\\functionCommand{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},_.finalizeTree=function(){this.ends[R].write=function(t,e){RegExp(/[A-Za-z0-9_\(]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e))}},_.getObject=function(){if(this.saved_object)return this.saved_object;try{return this.saved_object=SC_Objects[this.objectName()],"string"==typeof this.saved_object&&(SC_Objects[this.objectName()]=eval(this.saved_object),this.saved_object=SC_Objects[this.objectName()]),this.saved_object}catch(err){return this.saved_object=!1,SC_Object()}},_.objectName=function(){return this.blocks[0].text({})},_.createLeftOf=function(t){if(super_.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var e=this[L];if(0===e)return;if(0===e[L])return;for(next=e[L];0!==next&&next instanceof Variable;next=e[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);e.remove(),t.insAtLeftEnd(this.ends[R]),this.incorporate_previous!==!0&&Letter(this.incorporate_previous).createLeftOf(t)}}}),LatexCommandInput=CharCmds["\\"]=P(MathCommand,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[L].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[L].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[L].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[L].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[L].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):VanillaSymbol(e).createLeftOf(t)):void(e.match(/[a-z]/i)?VanillaSymbol(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[L].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return $(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[L].latex()+" "},t.renderCommand=function(t){var e,n,i;if(this.jQ=this.jQ.last(),this.remove(),this[R]?t.insLeftOf(this[R]):t.insAtRightEnd(this.parent),e=this.ends[L].latex(),e||(e=" "),n=LatexCmds[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=OperatorName(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),i=0;i<e.length;i++)Letter(e[i]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}t.workingGroupChange()}}),Matrix=LatexCmds.begin=P(MathCommand,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,a,r,o;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",a=0;i>a;a++){for(r="",o=0;n>o;o++)r+='<span class="mq-cell">&'+(a*n+o)+"</span>";s+='<span class="mq-row">'+r+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));scale(t,min(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenuOLD=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,L)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,R)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,L)}},{text:"Insert Row After",handler:function(){n.insertRow(t,R)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[L]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[L]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){var t=Parser.regex;return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,a,r,o,l,c;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,a=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),a=a.concat(e)}),r=Matrix("\\"+e,s,i),o=r.blocks=Array(r.numBlocks()),l=0;l<o.length;l++)c=o[l]=latexMathParser.parse(a[l]),c.deleteOutOf=MatrixMathBlock().deleteOutOf,c.adopt(r,r.ends[R],0);return r})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[L];)e++,e==this.col&&(e=0,n++),i=i[L];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),t.workingGroupChange()}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),t.workingGroupChange()}},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MatrixMathBlock(),e.adopt(n,n.ends[R],0)},t.insertRow=function(t,e){var n,i,s,a,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=r.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)a=MatrixMathBlock(),a.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][R]:this.ends[L]),a.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+a.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][R]=a),this.blocks.splice(i+s,0,a),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row+(n?0:1)).append(a.jQ);i+s<this.blocks.length&&(this.blocks[i+s][L]=a,a[R]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,i,s,a=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=this.row-1;i>=0;i--)s=MatrixMathBlock(),n?(s.adopt(this,i*this.col+a.col-1>=0?this.blocks[i*this.col+a.col-1]:0,this.blocks[i*this.col+a.col]),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),i*this.col+a.col-1>=0&&(this.blocks[i*this.col+a.col-1][R]=s),this.blocks[i*this.col+a.col][L]=s,this.blocks.splice(i*this.col+a.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(a.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+a.col],i*this.col+a.col+1<this.row*this.col?this.blocks[i*this.col+a.col+1]:0),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),this.blocks[i*this.col+a.col][R]=s,i*this.col+a.col+1<this.row*this.col&&(this.blocks[i*this.col+a.col+1][L]=s),this.blocks.splice(i*this.col+a.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(a.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?L:R]),this.reflow(),t.workingGroupChange()},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[R]),void t.workingGroupChange())}}),LatexCmds.matrix=bind(Matrix,"\\matrix",1,1),LatexCmds.bmatrix=bind(Matrix,"\\bmatrix",1,1),LatexCmds.Bmatrix=bind(Matrix,"\\Bmatrix",1,1),LatexCmds.vmatrix=bind(Matrix,"\\vmatrix",1,1),LatexCmds.Vmatrix=bind(Matrix,"\\Vmatrix",1,1),LatexCmds.pmatrix=bind(Matrix,"\\pmatrix",1,1),MatrixMathBlock=P(MathBlock,function(t){t.deleteOutOf=function(t,e){var n,i,s,a,r;if(0===this.ends[L])n=t===L?this[L]:this[R],this.parent.deleteColumn(e),t===L&&(n?e.insAtRightEnd(n):n&&e.insAtLeftEnd(n));else if(i=this[t],s=this.parent.cursorRowCol(e),t===L&&0===s.col&&(i=0),t===R&&s.col+1===this.parent.col&&(i=0),0===i)this.parent[L]?(a=this.parent[L],this.parent.remove(),e.insRightOf(a)):(a=this.parent.parent,this.parent.remove(),e.insAtLeftEnd(a));else{for(r=i.ends[L];0!==r;r=r[R])r.remove();e.insAtRightEnd(i),this.parent.deleteColumn(e),t===L?e.insAtLeftEnd(this):e.insAtRightEnd(this)}}}),OperatorName=LatexCmds.operatorname=P(MathCommand,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return"undefined"!=typeof t.operatorNameTextOutput?t.operatorNameTextOutput(this,this.blocks[0].text(t),this.blocks[1].text(t)):this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return BuiltInOpNames.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=Parser.succeed,s=latexMathParser.block,a=this.ctrlSeq,r=this,o=r.blocks=[MathBlock(),MathBlock()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[R],0);if(BuiltInOpNames.hasOwnProperty(this.ctrlSeq)){for(t=0;t<a.length;t+=1)Letter(a.charAt(t)).adopt(this.ends[L],this.ends[L].ends[R],0);return n.then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}return n.then(function(){var t=o[0];return s.then(function(e){var n,s;for(e.children().adopt(t,t.ends[R],0),n=e.ends[L];0!==n;n=n[R])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof SupSub&&"sub"===n.supsub)for(s=n.blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&(s.htmlTemplate="<var>f</var>");return i(r)})}).then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}});for(fn in BuiltInOpNames)BuiltInOpNames.hasOwnProperty(fn)&&(LatexCmds[fn]=OperatorName);SquareRoot=LatexCmds.sqrt=LatexCmds["√"]=P(MathCommand,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">&radic;</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return latexMathParser.optBlock.then(function(t){return latexMathParser.block.map(function(e){var n=NthRoot();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[R].jQ;scale(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),NthRoot=LatexCmds.nthroot=P(SquareRoot,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">&radic;</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[L].latex()+"]{"+this.ends[R].latex()+"}"
3
+ },t.text=function(t){return" "+this.ends[R].text(t)+"^(1/"+this.ends[L].text(t)+")"}}),ScientificNotation=LatexCmds.scientificNotation=P(DerivedMathCommand,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">&times;</span><span>10</span><span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&1</span></span></span>',t.init=function(t){"scientificNotation"!==t&&(this.incorporate_previous=t),e.init.call(this)},t.text=function(t){return this.blocks[0].text(t)+"e"+this.blocks[1].text(t)},t.latex=function(){return"\\scientificNotation{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L],this.ends[L].write=function(t,e){RegExp(/[0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))},this.ends[R].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e))if("+"===e||"-"===e){if(0===t[L]&&0!==t[R]&&("-"===t[R].ctrlSeq||"+"===t[R].ctrlSeq))return t[R].ctrlSeq=e,t[R].textTemplate=e,void t[R].jQ.html(e);if(0!==t[L]&&0===t[L][L]&&("-"===t[L].ctrlSeq||"+"===t[L].ctrlSeq))return t[L].ctrlSeq=e,t[L].textTemplate=e,void t[L].jQ.html(e);0!==t[L]&&(t.insRightOf(this.parent),t.parent.write(t,e))}else MathBlock.p.write.apply(this,arguments);else t.insRightOf(this.parent),t.parent.write(t,e)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[L];if(0===n)return;if(0===n[L])return;for(next=n[L];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);n.remove(),t.insAtLeftEnd(this.ends[R]),this.ends[R].write(t,this.incorporate_previous)}}}),SummationNotation=P(MathCommand,function(t,e){t.init=function(t,e){var n='<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>';Symbol.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),Letter("n").createLeftOf(t),LatexCmds["="]().createLeftOf(t)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"},t.text=function(t){return" "+this.ctrlSeq+'("'+this.blocks[0].text(t).replace(" :=",'" , ')+" , "+this.blocks[1].text(t)+","+this.blocks[2].text(t)+")"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,a=this,r=a.blocks=[MathBlock(),MathBlock(),MathBlock()];for(t=0;t<r.length;t+=1)r[t].adopt(a,a.ends[R],0);return n.then(e("_")).then(function(){var t=r[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(n).then(e("^")).then(function(){var t=r[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\left(")).then(function(){var t=r[2];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\right)")).result(a)},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L]}}),LatexCmds["∑"]=LatexCmds.sum=LatexCmds.summation=bind(SummationNotation,"\\sum ","&sum;"),LatexCmds["∏"]=LatexCmds.prod=LatexCmds.product=bind(SummationNotation,"\\prod ","&prod;"),LatexCmds.coprod=LatexCmds.coproduct=bind(SummationNotation,"\\coprod ","&#8720;"),SupSub=P(MathCommand,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,i,s,a,r,o,l,c;if("sub"===this.supsub){if(!(t[L]instanceof Variable))return;t[L]instanceof Variable&&t[R]instanceof Variable&&(n=LatexCmds.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[L]||t[L]instanceof BinaryOperator)return;if("."===t[L].ctrlSeq&&t[L][L]){for(i=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(i.push(t[L][L]),i.push(t[L][L][L]),s=t[L][L][L][L]):s=t[L][L],a=0;a<i.length;a++)i[a].remove();this.elementWise=!0,t.insRightOf(s)}if((t[L]instanceof Fraction||t[L]instanceof DerivedMathCommand)&&(r=CharCmds["("](),o=t[L],r.createLeftOf(t),o.disown(),o.adopt(r.ends[L],0,0),o.jQ.prependTo(r.ends[L].jQ),l=CharCmds[")"](),l.createLeftOf(t),r.reflow()),t[L]instanceof SupSub&&"sup"===t[L].supsub){for(r=CharCmds["("](),o=[t[L]],c=t[L];!(c instanceof BinaryOperator)&&0!==c;c=c[L])o.push(c);for(r.createLeftOf(t),a=0;a<o.length;a++)o[a].disown(),o[a].adopt(r.ends[L],0,r.ends[L].ends[L]),o[a].jQ.prependTo(r.ends[L].jQ);l=CharCmds[")"](),l.createLeftOf(t),r.reflow()}}return e.createLeftOf.call(this,t)},Options.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t,e,n,i=this.supsub;this.setUnit(),this.unitsup=!1,this.ends[L].write=function(t,e){return"sub"==i&&"_"===e?this.flash():void(t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1?(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)):"sub"!=i||RegExp(/[A-Za-z0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)))},this.sup&&this.sup.ends[L]&&"."===this.sup.ends[L].ctrlSeq&&(this.sup.ends[L].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise"),this.sub&&(t=this.jQ.closest(".mq-editable-field").children(".mq-autocomplete").first(),t.length>0&&(e=this.jQ,n=e.position(),t.css({top:Math.ceil(n.top+e.height())+"px"})))},t.latex=function(){function t(t,n){var i=n&&n.latex();return n?t+(1===i.length?i:"{"+(e?".":"")+(i||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[L]&&this.sub.ends[L]===this.sub.ends[R]?this.sub.ends[L].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&0!==this.sup.ends[L]&&this.sup.ends[L]===this.sup.ends[R]?this.sup.ends[L].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==R&&this.jQ.toggleClass("mq-limit","\\int "===this[L].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=$('<span class="mq-sup"/>').append(t.jQ.children()).attr(mqBlockId,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=$('<span class="mq-sub"></span>').append(t.jQ.children()).attr(mqBlockId,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0">&nbsp;</span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,a){a.insDirOf(s,this.parent),this.isEmpty()||(a[-s]=this.ends[s],this.children().disown().withDirAdopt(s,a.parent,a[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=insLeftOfMeUnlessAtEnd,delete t[n].deleteOutOf,"sub"===e&&$(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),LatexCmds.subscript=LatexCmds._=P(SupSub,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[L],this.sub.upOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.superscript=LatexCmds.supscript=LatexCmds["^"]=P(SupSub,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[R],this.sup.downOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.notin=LatexCmds.sim=LatexCmds.cong=LatexCmds.equiv=LatexCmds.oplus=LatexCmds.otimes=P(BinaryOperator,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.ast=LatexCmds.star=LatexCmds.loast=LatexCmds.lowast=bind(BinaryOperator,"\\ast ","&lowast;"),LatexCmds.therefor=LatexCmds.therefore=bind(BinaryOperator,"\\therefore ","&there4;"),LatexCmds.cuz=LatexCmds.because=bind(BinaryOperator,"\\because ","&#8757;"),LatexCmds.prop=LatexCmds.propto=bind(BinaryOperator,"\\propto ","&prop;"),LatexCmds["≈"]=LatexCmds.asymp=LatexCmds.approx=bind(BinaryOperator,"\\approx ","&asymp;"),LatexCmds.isin=LatexCmds["in"]=bind(BinaryOperator,"\\in ","&isin;"),LatexCmds.ni=LatexCmds.contains=bind(BinaryOperator,"\\ni ","&ni;"),LatexCmds.notni=LatexCmds.niton=LatexCmds.notcontains=LatexCmds.doesnotcontain=bind(BinaryOperator,"\\not\\ni ","&#8716;"),LatexCmds.sub=LatexCmds.subset=bind(BinaryOperator,"\\subset ","&sub;"),LatexCmds.sup=LatexCmds.supset=LatexCmds.superset=bind(BinaryOperator,"\\supset ","&sup;"),LatexCmds.nsub=LatexCmds.notsub=LatexCmds.nsubset=LatexCmds.notsubset=bind(BinaryOperator,"\\not\\subset ","&#8836;"),LatexCmds.nsup=LatexCmds.notsup=LatexCmds.nsupset=LatexCmds.notsupset=LatexCmds.nsuperset=LatexCmds.notsuperset=bind(BinaryOperator,"\\not\\supset ","&#8837;"),LatexCmds.sube=LatexCmds.subeq=LatexCmds.subsete=LatexCmds.subseteq=bind(BinaryOperator,"\\subseteq ","&sube;"),LatexCmds.supe=LatexCmds.supeq=LatexCmds.supsete=LatexCmds.supseteq=LatexCmds.supersete=LatexCmds.superseteq=bind(BinaryOperator,"\\supseteq ","&supe;"),LatexCmds.nsube=LatexCmds.nsubeq=LatexCmds.notsube=LatexCmds.notsubeq=LatexCmds.nsubsete=LatexCmds.nsubseteq=LatexCmds.notsubsete=LatexCmds.notsubseteq=bind(BinaryOperator,"\\not\\subseteq ","&#8840;"),LatexCmds.nsupe=LatexCmds.nsupeq=LatexCmds.notsupe=LatexCmds.notsupeq=LatexCmds.nsupsete=LatexCmds.nsupseteq=LatexCmds.notsupsete=LatexCmds.notsupseteq=LatexCmds.nsupersete=LatexCmds.nsuperseteq=LatexCmds.notsupersete=LatexCmds.notsuperseteq=bind(BinaryOperator,"\\not\\supseteq ","&#8841;"),LatexCmds.N=LatexCmds.naturals=LatexCmds.Naturals=bind(VanillaSymbol,"\\mathbb{N}","&#8469;"),LatexCmds.P=LatexCmds.primes=LatexCmds.Primes=LatexCmds.projective=LatexCmds.Projective=LatexCmds.probability=LatexCmds.Probability=bind(VanillaSymbol,"\\mathbb{P}","&#8473;"),LatexCmds.Z=LatexCmds.integers=LatexCmds.Integers=bind(VanillaSymbol,"\\mathbb{Z}","&#8484;"),LatexCmds.Q=LatexCmds.rationals=LatexCmds.Rationals=bind(VanillaSymbol,"\\mathbb{Q}","&#8474;"),LatexCmds.R=LatexCmds.reals=LatexCmds.Reals=bind(VanillaSymbol,"\\mathbb{R}","&#8477;"),LatexCmds.C=LatexCmds.complex=LatexCmds.Complex=LatexCmds.complexes=LatexCmds.Complexes=LatexCmds.complexplane=LatexCmds.Complexplane=LatexCmds.ComplexPlane=bind(VanillaSymbol,"\\mathbb{C}","&#8450;"),LatexCmds.H=LatexCmds.Hamiltonian=LatexCmds.quaternions=LatexCmds.Quaternions=bind(VanillaSymbol,"\\mathbb{H}","&#8461;"),LatexCmds.quad=LatexCmds.emsp=bind(VanillaSymbol,"\\quad "," "),LatexCmds.qquad=bind(VanillaSymbol,"\\qquad "," "),LatexCmds.diamond=bind(VanillaSymbol,"\\diamond ","&#9671;"),LatexCmds.bigtriangleup=bind(VanillaSymbol,"\\bigtriangleup ","&#9651;"),LatexCmds.ominus=bind(VanillaSymbol,"\\ominus ","&#8854;"),LatexCmds.uplus=bind(VanillaSymbol,"\\uplus ","&#8846;"),LatexCmds.bigtriangledown=bind(VanillaSymbol,"\\bigtriangledown ","&#9661;"),LatexCmds.sqcap=bind(VanillaSymbol,"\\sqcap ","&#8851;"),LatexCmds.triangleleft=bind(VanillaSymbol,"\\triangleleft ","&#8882;"),LatexCmds.sqcup=bind(VanillaSymbol,"\\sqcup ","&#8852;"),LatexCmds.triangleright=bind(VanillaSymbol,"\\triangleright ","&#8883;"),LatexCmds.odot=bind(VanillaSymbol,"\\odot ","&#8857;"),LatexCmds.bigcirc=bind(VanillaSymbol,"\\bigcirc ","&#9711;"),LatexCmds.dagger=bind(VanillaSymbol,"\\dagger ","&#0134;"),LatexCmds.ddagger=bind(VanillaSymbol,"\\ddagger ","&#135;"),LatexCmds.wr=bind(VanillaSymbol,"\\wr ","&#8768;"),LatexCmds.amalg=bind(VanillaSymbol,"\\amalg ","&#8720;"),LatexCmds.models=bind(VanillaSymbol,"\\models ","&#8872;"),LatexCmds.prec=bind(VanillaSymbol,"\\prec ","&#8826;"),LatexCmds.succ=bind(VanillaSymbol,"\\succ ","&#8827;"),LatexCmds.preceq=bind(VanillaSymbol,"\\preceq ","&#8828;"),LatexCmds.succeq=bind(VanillaSymbol,"\\succeq ","&#8829;"),LatexCmds.simeq=bind(VanillaSymbol,"\\simeq ","&#8771;"),LatexCmds.mid=bind(VanillaSymbol,"\\mid ","&#8739;"),LatexCmds.ll=bind(VanillaSymbol,"\\ll ","&#8810;"),LatexCmds.gg=bind(VanillaSymbol,"\\gg ","&#8811;"),LatexCmds.parallel=bind(VanillaSymbol,"\\parallel ","&#8741;"),LatexCmds.bowtie=bind(VanillaSymbol,"\\bowtie ","&#8904;"),LatexCmds.sqsubset=bind(VanillaSymbol,"\\sqsubset ","&#8847;"),LatexCmds.sqsupset=bind(VanillaSymbol,"\\sqsupset ","&#8848;"),LatexCmds.smile=bind(VanillaSymbol,"\\smile ","&#8995;"),LatexCmds.sqsubseteq=bind(VanillaSymbol,"\\sqsubseteq ","&#8849;"),LatexCmds.sqsupseteq=bind(VanillaSymbol,"\\sqsupseteq ","&#8850;"),LatexCmds.doteq=bind(VanillaSymbol,"\\doteq ","&#8784;"),LatexCmds.frown=bind(VanillaSymbol,"\\frown ","&#8994;"),LatexCmds.vdash=bind(VanillaSymbol,"\\vdash ","&#8870;"),LatexCmds.dashv=bind(VanillaSymbol,"\\dashv ","&#8867;"),LatexCmds.longleftarrow=bind(VanillaSymbol,"\\longleftarrow ","&#8592;"),LatexCmds.longrightarrow=bind(VanillaSymbol,"\\longrightarrow ","&#8594;"),LatexCmds.Longleftarrow=bind(VanillaSymbol,"\\Longleftarrow ","&#8656;"),LatexCmds.Longrightarrow=bind(VanillaSymbol,"\\Longrightarrow ","&#8658;"),LatexCmds.longleftrightarrow=bind(VanillaSymbol,"\\longleftrightarrow ","&#8596;"),LatexCmds.updownarrow=bind(VanillaSymbol,"\\updownarrow ","&#8597;"),LatexCmds.Longleftrightarrow=bind(VanillaSymbol,"\\Longleftrightarrow ","&#8660;"),LatexCmds.Updownarrow=bind(VanillaSymbol,"\\Updownarrow ","&#8661;"),LatexCmds.mapsto=bind(VanillaSymbol,"\\mapsto ","&#8614;"),LatexCmds.nearrow=bind(VanillaSymbol,"\\nearrow ","&#8599;"),LatexCmds.hookleftarrow=bind(VanillaSymbol,"\\hookleftarrow ","&#8617;"),LatexCmds.hookrightarrow=bind(VanillaSymbol,"\\hookrightarrow ","&#8618;"),LatexCmds.searrow=bind(VanillaSymbol,"\\searrow ","&#8600;"),LatexCmds.leftharpoonup=bind(VanillaSymbol,"\\leftharpoonup ","&#8636;"),LatexCmds.rightharpoonup=bind(VanillaSymbol,"\\rightharpoonup ","&#8640;"),LatexCmds.swarrow=bind(VanillaSymbol,"\\swarrow ","&#8601;"),LatexCmds.leftharpoondown=bind(VanillaSymbol,"\\leftharpoondown ","&#8637;"),LatexCmds.rightharpoondown=bind(VanillaSymbol,"\\rightharpoondown ","&#8641;"),LatexCmds.nwarrow=bind(VanillaSymbol,"\\nwarrow ","&#8598;"),LatexCmds.ldots=bind(VanillaSymbol,"\\ldots ","&#8230;"),LatexCmds.cdots=bind(VanillaSymbol,"\\cdots ","&#8943;"),LatexCmds.vdots=bind(VanillaSymbol,"\\vdots ","&#8942;"),LatexCmds.ddots=bind(VanillaSymbol,"\\ddots ","&#8944;"),LatexCmds.surd=bind(VanillaSymbol,"\\surd ","&#8730;"),LatexCmds.triangle=bind(VanillaSymbol,"\\triangle ","&#9653;"),LatexCmds.ell=bind(VanillaSymbol,"\\ell ","&#8467;"),LatexCmds.top=bind(VanillaSymbol,"\\top ","&#8868;"),LatexCmds.flat=bind(VanillaSymbol,"\\flat ","&#9837;"),LatexCmds.natural=bind(VanillaSymbol,"\\natural ","&#9838;"),LatexCmds.sharp=bind(VanillaSymbol,"\\sharp ","&#9839;"),LatexCmds.wp=bind(VanillaSymbol,"\\wp ","&#8472;"),LatexCmds.bot=bind(VanillaSymbol,"\\bot ","&#8869;"),LatexCmds.clubsuit=bind(VanillaSymbol,"\\clubsuit ","&#9827;"),LatexCmds.diamondsuit=bind(VanillaSymbol,"\\diamondsuit ","&#9826;"),LatexCmds.heartsuit=bind(VanillaSymbol,"\\heartsuit ","&#9825;"),LatexCmds.spadesuit=bind(VanillaSymbol,"\\spadesuit ","&#9824;"),LatexCmds.oint=bind(VanillaSymbol,"\\oint ","&#8750;"),LatexCmds.bigcap=bind(VanillaSymbol,"\\bigcap ","&#8745;"),LatexCmds.bigcup=bind(VanillaSymbol,"\\bigcup ","&#8746;"),LatexCmds.bigsqcup=bind(VanillaSymbol,"\\bigsqcup ","&#8852;"),LatexCmds.bigvee=bind(VanillaSymbol,"\\bigvee ","&#8744;"),LatexCmds.bigwedge=bind(VanillaSymbol,"\\bigwedge ","&#8743;"),LatexCmds.bigodot=bind(VanillaSymbol,"\\bigodot ","&#8857;"),LatexCmds.bigotimes=bind(VanillaSymbol,"\\bigotimes ","&#8855;"),LatexCmds.bigoplus=bind(VanillaSymbol,"\\bigoplus ","&#8853;"),LatexCmds.biguplus=bind(VanillaSymbol,"\\biguplus ","&#8846;"),LatexCmds.lfloor=bind(VanillaSymbol,"\\lfloor ","&#8970;"),LatexCmds.rfloor=bind(VanillaSymbol,"\\rfloor ","&#8971;"),LatexCmds.lceil=bind(VanillaSymbol,"\\lceil ","&#8968;"),LatexCmds.rceil=bind(VanillaSymbol,"\\rceil ","&#8969;"),LatexCmds.opencurlybrace=LatexCmds.lbrace=bind(VanillaSymbol,"\\lbrace ","{"),LatexCmds.closecurlybrace=LatexCmds.rbrace=bind(VanillaSymbol,"\\rbrace ","}"),LatexCmds["∫"]=LatexCmds["int"]=LatexCmds.integral=bind(Symbol,"\\int ","<big>&int;</big>"),LatexCmds.caret=bind(VanillaSymbol,"\\text{^}","^"),LatexCmds.underscore=bind(VanillaSymbol,"\\_","_"),LatexCmds.slash=bind(VanillaSymbol,"/"),LatexCmds.vert=bind(VanillaSymbol,"|"),LatexCmds.perp=LatexCmds.perpendicular=bind(VanillaSymbol,"\\perp ","&perp;"),LatexCmds.nabla=LatexCmds.del=bind(VanillaSymbol,"\\nabla ","&nabla;"),LatexCmds.hbar=bind(VanillaSymbol,"\\hbar ","&#8463;"),LatexCmds.AA=LatexCmds.Angstrom=LatexCmds.angstrom=bind(VanillaSymbol,"\\text\\AA ","&#8491;"),LatexCmds.ring=LatexCmds.circ=LatexCmds.circle=bind(VanillaSymbol,"\\circ ","&#8728;"),LatexCmds.bull=LatexCmds.bullet=bind(VanillaSymbol,"\\bullet ","&bull;"),LatexCmds.setminus=LatexCmds.smallsetminus=bind(VanillaSymbol,"\\setminus ","&#8726;"),LatexCmds.not=LatexCmds["¬"]=LatexCmds.neg=bind(VanillaSymbol,"\\neg ","&not;"),LatexCmds.dots=LatexCmds.ellip=LatexCmds.hellip=LatexCmds.ellipsis=LatexCmds.hellipsis=bind(VanillaSymbol,"\\dots ","&hellip;"),LatexCmds["…"]=bind(VanillaSymbol,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>',".."),LatexCmds.converges=LatexCmds.darr=LatexCmds.dnarr=LatexCmds.dnarrow=LatexCmds.downarrow=bind(VanillaSymbol,"\\downarrow ","&darr;"),LatexCmds.dArr=LatexCmds.dnArr=LatexCmds.dnArrow=LatexCmds.Downarrow=bind(VanillaSymbol,"\\Downarrow ","&dArr;"),LatexCmds.diverges=LatexCmds.uarr=LatexCmds.uparrow=bind(VanillaSymbol,"\\uparrow ","&uarr;"),LatexCmds.uArr=LatexCmds.Uparrow=bind(VanillaSymbol,"\\Uparrow ","&uArr;"),LatexCmds.to=bind(BinaryOperator,"\\to ","&rarr;"),LatexCmds.rarr=LatexCmds.rightarrow=bind(VanillaSymbol,"\\rightarrow ","&rarr;"),LatexCmds.implies=bind(BinaryOperator,"\\Rightarrow ","&rArr;"),LatexCmds.rArr=LatexCmds.Rightarrow=bind(VanillaSymbol,"\\Rightarrow ","&rArr;"),LatexCmds.gets=bind(BinaryOperator,"\\gets ","&larr;"),LatexCmds.larr=LatexCmds.leftarrow=bind(VanillaSymbol,"\\leftarrow ","&larr;"),LatexCmds.impliedby=bind(BinaryOperator,"\\Leftarrow ","&lArr;"),LatexCmds.lArr=LatexCmds.Leftarrow=bind(VanillaSymbol,"\\Leftarrow ","&lArr;"),LatexCmds.harr=LatexCmds.lrarr=LatexCmds.leftrightarrow=bind(VanillaSymbol,"\\leftrightarrow ","&harr;"),LatexCmds.iff=bind(BinaryOperator,"\\Leftrightarrow ","&hArr;"),LatexCmds.hArr=LatexCmds.lrArr=LatexCmds.Leftrightarrow=bind(VanillaSymbol,"\\Leftrightarrow ","&hArr;"),LatexCmds.Re=LatexCmds.Real=LatexCmds.real=bind(VanillaSymbol,"\\Re ","&real;"),LatexCmds.Im=LatexCmds.imag=LatexCmds.image=LatexCmds.imagin=LatexCmds.imaginary=LatexCmds.Imaginary=bind(VanillaSymbol,"\\Im ","&image;"),LatexCmds.part=LatexCmds.partial=bind(VanillaSymbol,"\\partial ","&part;"),LatexCmds.infty=LatexCmds.infin=LatexCmds.infinity=bind(VanillaSymbol,"\\infty ","&infin;"),LatexCmds.alef=LatexCmds.alefsym=LatexCmds.aleph=LatexCmds.alephsym=bind(VanillaSymbol,"\\aleph ","&alefsym;"),LatexCmds.xist=LatexCmds.xists=LatexCmds.exist=LatexCmds.exists=bind(VanillaSymbol,"\\exists ","&exist;"),LatexCmds.and=LatexCmds.land=LatexCmds.wedge=bind(VanillaSymbol,"\\wedge ","&and;"),LatexCmds.or=LatexCmds.lor=LatexCmds.vee=bind(VanillaSymbol,"\\vee ","&or;"),LatexCmds.o=LatexCmds.O=LatexCmds.empty=LatexCmds.emptyset=LatexCmds.oslash=LatexCmds.Oslash=LatexCmds.nothing=LatexCmds.varnothing=bind(BinaryOperator,"\\varnothing ","&empty;"),LatexCmds.cup=LatexCmds.union=bind(BinaryOperator,"\\cup ","&cup;"),LatexCmds.cap=LatexCmds.intersect=LatexCmds.intersection=bind(BinaryOperator,"\\cap ","&cap;"),LatexCmds.deg=LatexCmds.degree=bind(VanillaSymbol,"^\\circ ","&deg;"),LatexCmds.ang=LatexCmds.angle=bind(VanillaSymbol,"\\angle ","&ang;"),Variable=P(Symbol,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(t){return!t||!t.unit||this[L]instanceof Variable||this[L]&&"µ"==this[L].ctrlSeq?this.textTemplate:"_"+this.textTemplate},t.autoUnItalicize=function(t){var e,n,i,s,a="",r=[];for(e=this;e instanceof Variable;e=e[L])a=e.ctrlSeq+a,r.push(e);if(t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub){for(a="_"+a,r=[t.parent.parent],e=t.parent.parent[L];e instanceof Variable;e=e[L])a=e.ctrlSeq+a,r.push(e);t.insRightOf(t.parent.parent)}for(n=OperatorName(),n.createLeftOf(t),i=0;i<r.length;i++){if("f"===r[i].ctrlSeq&&r[i].jQ.removeClass("mq-florin").html("f"),r[i]instanceof SupSub&&"sub"===r[i].supsub)for(s=r[i].blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&s.jQ.removeClass("mq-florin").html("f");r[i].disown(),r[i].adopt(n.ends[L],0,n.ends[L].ends[L]),r[i].jQ.prependTo(n.ends[L].jQ)}n.ends[L].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.text({})+"",n=[this];for(t=this[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;if(this.parent&&this.parent.parent instanceof SupSub&&"sub"===this.parent.parent.supsub)for(e="_"+e,n=[this.parent.parent],t=this.parent.parent[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;for(t=this[R];t instanceof Variable;t=t[R])n.push(t),e+=t.text({});if(t instanceof SupSub&&"sub"===t.supsub)for(e+="_",n.push(t),t=t.ends[L].ends[L];t instanceof Variable;t=t[R])e+=t.text({});return[e,n]},t.finalizeTree=function(){this.autoComplete()},t.autoComplete=function(){var t,e,n,i,s,a,r,o,l,c,d,h,u,p,m,f,b,x,C;if(this.controller||this.getController(),t=this.fullWord(),e=t[0],n=t[1],i=[],s=new RegExp("^"+e+".*$","i"),this.parent.unit||this.parent.parent&&this.parent.parent.unit){if(1==e.length&&(s=new RegExp("^"+e+"$","")),e.length>0){for(prefix_to_ignore=["micro","yocto","zepto","atto","femto","pico","nano","milli","centi","deci","deca","hecto","kilo","mega","giga","tera","peta","exa","zetta","yotta"],skip_this=!1,a=function(t){return t[0].toUpperCase()+t.slice(1)},r=0;r<prefix_to_ignore.length;r++)if(prefix_to_ignore[r].match(s)){skip_this=!0;break}if(!skip_this){for(o=this.controller.API.__options.unitList||{names:[],symbols:[]},l={},r=0;r<o.symbols.length;r++)o.symbols[r].match(s)&&(i.push("<li data-word='"+o.symbols[r]+"'><span class='mq-operator-name'>"+o.symbols[r]+" ("+a(o.symbol_to_name[o.symbols[r]])+")</span></li>"),l[o.symbols[r]]=!0);for(r=0;r<o.names.length;r++)o.names[r].match(s)&&!l[o.name_to_symbol[o.names[r]]]&&i.push("<li data-word='"+o.name_to_symbol[o.names[r]]+"'><span class='mq-operator-name'>"+o.name_to_symbol[o.names[r]]+" ("+a(o.names[r])+")</span></li>")}}}else if(e.length>0){if(c=function(t,e){var n,i=Object.keys(e.controller.API.__options.autoCommands);for(n=0;n<i.length;n++){if(t===i[n]){t=LatexCmds[i[n]](i[n]).htmlTemplate;break}t=t.replace(new RegExp("^"+i[n]+"_",""),LatexCmds[i[n]](i[n]).htmlTemplate+"_")}return t=t.indexOf("_")>-1?t.replace("_","<sub>")+"</sub>":t,t.indexOf(".")>-1&&(t=t.replace(".","")+".<span class='mq-inline-box'></span>"),t},d=[],h=[],u="",this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R])d=this.parent.parent.getObject().propertyList,h=this.parent.parent.getObject().methodList,u=this.parent.parent.objectName()+".";else{if(e.length<3)return;d=this.controller.API.__options.autocomplete||[],h=this.controller.API.__options.staticAutocomplete||[]}for(r=0;r<d.length;r++)d[r].match(s)&&i.push("<li data-word='"+d[r]+"'><span class='mq-nonSymbola'><i>"+u+c(d[r],this)+"</i></span></li>");for(r=0;r<h.length;r++)h[r].match(s)&&i.push("<li data-word='"+h[r]+"('><span class='mq-nonSymbola'><i>"+u+"</i></span><span class='mq-operator-name'>"+(h[r].indexOf("_")>-1?h[r].replace("_","<sub>")+"</sub>":h[r])+"(<span class='mq-inline-box'></span>)</span></li>")}i.length>0?(i[0]=i[0].replace("<li",'<li class="mq-popup-selected"'),p=this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R]?this.parent.parent.jQ:n[0].jQ,m=n[n.length-1].jQ,f=p.position(),b=m.position(),x=this,C=function(){var t,e=$(this).attr("data-word"),n=x.fullWord()[1],i=n[0][L],s=n[0].parent;for(t=0;t<n.length;t++)n[t].remove();i?x.controller.cursor.insRightOf(i):x.controller.cursor.insAtRightEnd(s),x.controller.API.typedText(e),"."===e[e.length-1]&&FunctionCommand(!0).createLeftOf(x.controller.cursor),x.controller.closePopup(),"("!==e[e.length-1]&&"."!==e[e.length-1]&&x.controller.cursor.parent&&x.controller.cursor.parent.parent instanceof SupSub&&"sub"===x.controller.cursor.parent.parent.supsub&&x.controller.cursor.insRightOf(x.controller.cursor.parent.parent),x.controller.cursor.workingGroupChange()},this.controller.createPopup("<ul>"+i.join("\n")+"</ul>",b.top+m.height(),f.left,C)):this.controller.closePopup()}}),Options.p.autoCommands={_maxLength:0},optionProcessors.autoCommands=function(t){var e,n,i,s,a;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(a=e[s],a.length<2)throw'autocommand "'+a+'" not minimum length of 2';if(LatexCmds[a]===OperatorName)throw'"'+a+'" is a built-in operator name';n[a]=1,i=max(i,a.length)}return n},Letter=P(Variable,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[L].letter,i=t[L][L],s=1;i instanceof Letter;)n=i.letter+n,i=i[L],s+=1;if(n.length>1&&e.hasOwnProperty(n)){for(s=1,i=t[L];s<n.length;s+=1,i=i[L]);return Fragment(i,t[L]).remove(),t[L]=i[L],LatexCmds[n](n).createLeftOf(t),!0}return!1},t.createLeftOf=function(t){"u"!=this.ctrlSeq||!(t.parent.unit||t.parent.parent&&t.parent.parent.unit)||t[L]instanceof Variable||t[L]&&"µ"==t[L].ctrlSeq?t[L]&&t[L][L]&&"."===t[L].ctrlSeq&&t[L][L]instanceof Variable?FunctionCommand(this.ctrlSeq).createLeftOf(t):e.createLeftOf.apply(this,arguments):Letter("µ").createLeftOf(t)}}),BuiltInOpNames={},function(){var t,e,n,i=Options.p.autoOperatorNames={_maxLength:9},s="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<s.length;t+=1)BuiltInOpNames[s[t]]=i[s[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)BuiltInOpNames[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}(),optionProcessors.autoOperatorNames=function(t){var e,n,i,s,a;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(a=e[s],a.length<2)throw'"'+a+'" not minimum length of 2';n[a]=1,i=max(i,a.length)}return n._maxLength=i,n},optionProcessors.unitList=function(t){var e,n,i,s={},a={},r=[],o=[],l={micro:"µ",yocto:"y",zepto:"z",atto:"a",femto:"f",pico:"p",nano:"n",milli:"m",centi:"c",deci:"d",deca:"D",hecto:"h",kilo:"k",mega:"M",giga:"G",tera:"T",peta:"P",exa:"E",zetta:"Z",yotta:"Y"};for(e=0;e<t.length;e++)if(r.push(t[e].name),o.push(t[e].symbol),s[t[e].name]=t[e].symbol,a[t[e].symbol]=t[e].name,t[e].prefix)for(n in l)r.push(n+t[e].name),o.push(l[n]+t[e].symbol),s[n+t[e].name]=l[n]+t[e].symbol,a[l[n]+t[e].symbol]=n+t[e].name;return i=function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())},{name_to_symbol:s,symbol_to_name:a,names:r.sort(i),symbols:o.sort(i)}},LatexCmds.µ=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"µ")},t.createLeftOf=function(t){t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("µ").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[2]=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"2")},t.createLeftOf=function(t){t.parent&&t.parent.parent&&t.parent.parent instanceof Unit||t.parent&&t.parent.parent&&t.parent.parent.unit&&!(t.parent.parent instanceof SupSub)?t[L]&&"H"===t[L].ctrlSeq?Letter("2").createLeftOf(t):t.parent.flash():e.createLeftOf.call(this,t)}}),LatexCmds.f=P(Letter,function(t,e){t.init=function(){Symbol.p.init.call(this,this.letter="f",'<var class="mq-florin">&fnof;</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof OperatorName&&t.parent===t.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof OperatorName&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[" "]=LatexCmds.space=bind(VanillaSymbol,"\\ "," "),LatexCmds.backslash=bind(VanillaSymbol,"\\backslash ","\\"),CharCmds["\\"]||(CharCmds["\\"]=LatexCmds.backslash),NonSymbolaSymbol=P(Variable,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),LatexCmds["@"]=NonSymbolaSymbol,LatexCmds["&"]=bind(NonSymbolaSymbol,"\\&","&amp;"),LatexCmds["%"]=bind(NonSymbolaSymbol,"\\%","%"),LatexCmds.alpha=LatexCmds.beta=LatexCmds.gamma=LatexCmds.delta=LatexCmds.zeta=LatexCmds.eta=LatexCmds.theta=LatexCmds.iota=LatexCmds.kappa=LatexCmds.mu=LatexCmds.nu=LatexCmds.xi=LatexCmds.rho=LatexCmds.sigma=LatexCmds.tau=LatexCmds.chi=LatexCmds.psi=LatexCmds.omega=P(Variable,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.phi=bind(Variable,"\\phi ","&#981;"),LatexCmds.phiv=LatexCmds.varphi=bind(Variable,"\\varphi ","&phi;"),LatexCmds.epsilon=bind(Variable,"\\epsilon ","&#1013;"),LatexCmds.epsiv=LatexCmds.varepsilon=bind(Variable,"\\varepsilon ","&epsilon;"),LatexCmds.piv=LatexCmds.varpi=bind(Variable,"\\varpi ","&piv;"),LatexCmds.sigmaf=LatexCmds.sigmav=LatexCmds.varsigma=bind(Variable,"\\varsigma ","&sigmaf;"),LatexCmds.thetav=LatexCmds.vartheta=LatexCmds.thetasym=bind(Variable,"\\vartheta ","&thetasym;"),LatexCmds.upsilon=LatexCmds.upsi=bind(Variable,"\\upsilon ","&upsilon;"),LatexCmds.gammad=LatexCmds.Gammad=LatexCmds.digamma=bind(Variable,"\\digamma ","&#989;"),LatexCmds.kappav=LatexCmds.varkappa=bind(Variable,"\\varkappa ","&#1008;"),LatexCmds.rhov=LatexCmds.varrho=bind(Variable,"\\varrho ","&#1009;"),LatexCmds.pi=LatexCmds["π"]=bind(NonSymbolaSymbol,"\\pi ","&pi;"),LatexCmds.lambda=bind(NonSymbolaSymbol,"\\lambda ","&lambda;"),LatexCmds.Upsilon=LatexCmds.Upsi=LatexCmds.upsih=LatexCmds.Upsih=bind(Symbol,"\\Upsilon ",'<var style="font-family: serif">&upsih;</var>'),LatexCmds.Gamma=LatexCmds.Delta=LatexCmds.Theta=LatexCmds.Lambda=LatexCmds.Xi=LatexCmds.Pi=LatexCmds.Sigma=LatexCmds.Phi=LatexCmds.Psi=LatexCmds.Omega=LatexCmds.forall=P(VanillaSymbol,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexFragment=P(MathCommand,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=latexMathParser.parse(this.latex);e.children().adopt(t.parent,t[L],t[R]),t[L]=e.ends[R],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[R][R].siblingCreated&&e.ends[R][R].siblingCreated(t.options,L),e.ends[L][L].siblingCreated&&e.ends[L][L].siblingCreated(t.options,R),t.parent.bubble("reflow")
4
+ },t.parser=function(){var t=latexMathParser.parse(this.latex).children();return Parser.succeed(t)}}),LatexCmds["¹"]=bind(LatexFragment,"^1"),LatexCmds["²"]=bind(LatexFragment,"^2"),LatexCmds["³"]=bind(LatexFragment,"^3"),LatexCmds["¼"]=bind(LatexFragment,"\\frac14"),LatexCmds["½"]=bind(LatexFragment,"\\frac12"),LatexCmds["¾"]=bind(LatexFragment,"\\frac34"),PlusMinus=P(BinaryOperator,function(t){t.init=VanillaSymbol.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==R?(this.jQ[0].className=!this[L]||this[L]instanceof BinaryOperator?"":"mq-binary-operator",this):void 0}}),Multiplication=P(BinaryOperator,function(t){t.addedImplicitly=!1,t.finalizeTree=function(){var t,e;if(this[L]&&"."===this[L].ctrlSeq){for(t=[this[L]],this[L][L]&&this[L][L][L]&&"0"===this[L][L].ctrlSeq&&"\\cdot "===this[L][L][L].ctrlSeq&&(t.push(this[L][L]),t.push(this[L][L][L])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("&#8857;"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}},t.implicit=function(){return this.addedImplicitly=!0,this}}),LatexCmds["+"]=bind(PlusMinus,"+","+"),LatexCmds["–"]=LatexCmds["-"]=bind(PlusMinus,"-","&minus;"),LatexCmds["±"]=LatexCmds.pm=LatexCmds.plusmn=LatexCmds.plusminus=bind(PlusMinus,"\\pm ","&plusmn;"),LatexCmds.mp=LatexCmds.mnplus=LatexCmds.minusplus=bind(PlusMinus,"\\mp ","&#8723;"),CharCmds["*"]=LatexCmds.sdot=LatexCmds.cdot=bind(Multiplication,"\\cdot ","&middot;","*"),Inequality=P(BinaryOperator,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==L||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),less={ctrlSeq:"\\le ",html:"&le;",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"&lt;",textStrict:" < "},greater={ctrlSeq:"\\ge ",html:"&ge;",text:" >= ",ctrlSeqStrict:">",htmlStrict:"&gt;",textStrict:" > "},factorial={ctrlSeq:"\\ne ",html:"&ne;",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},LatexCmds["<"]=LatexCmds.lt=bind(Inequality,less,!0),LatexCmds[">"]=LatexCmds.gt=bind(Inequality,greater,!0),LatexCmds["≤"]=LatexCmds.le=LatexCmds.leq=bind(Inequality,less,!1),LatexCmds["≥"]=LatexCmds.ge=LatexCmds.geq=bind(Inequality,greater,!1),LatexCmds["!"]=bind(Inequality,factorial,!0),LatexCmds["≠"]=LatexCmds.ne=LatexCmds.neq=bind(Inequality,factorial,!1),Equality=P(Inequality,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[L]instanceof Inequality||t[L]instanceof Equality)&&t[L].strict?void t[L].swap(!1):void e.createLeftOf.apply(this,arguments)}}),equal={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},LatexCmds["="]=bind(Equality,equal,!0),LatexCmds.eq=bind(Equality,equal,!1),LatexCmds.times=bind(BinaryOperator,"\\times ","&times;","[x]"),LatexCmds["÷"]=LatexCmds.div=LatexCmds.divide=LatexCmds.divides=bind(BinaryOperator,"\\div ","&divide;","[/]"),forceIERedraw=noop,div=document.createElement("div"),div_style=div.style,transformPropNames={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(prop in transformPropNames)if(prop in div_style){transformPropName=prop;break}transformPropName?scale=function(t,e,n){t.css(transformPropName,"scale("+e+","+n+")")}:"filter"in div_style?(forceIERedraw=function(t){t.className=t.className},scale=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,a;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),a=setInterval(i),$(window).load(function(){clearTimeout(a),i()})}):scale=function(t,e,n){t.css("fontSize",n+"em")},Style=P(MathCommand,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),LatexCmds.mathrm=bind(Style,"\\mathrm","span",'class="mq-roman mq-font"'),LatexCmds.mathit=bind(Style,"\\mathit","i",'class="mq-font"'),LatexCmds.mathbf=bind(Style,"\\mathbf","b",'class="mq-font"'),LatexCmds.mathsf=bind(Style,"\\mathsf","span",'class="mq-sans-serif mq-font"'),LatexCmds.mathtt=bind(Style,"\\mathtt","span",'class="mq-monospace mq-font"'),LatexCmds.underline=bind(Style,"\\underline","span",'class="mq-non-leaf mq-underline"'),LatexCmds.overline=LatexCmds.bar=bind(Style,"\\overline","span",'class="mq-non-leaf mq-overline"'),TextColor=LatexCmds.textcolor=P(MathCommand,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=Parser.optWhitespace,i=Parser.string,s=Parser.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),Class=LatexCmds["class"]=P(MathCommand,function(t,e){t.parser=function(){var t=this,n=Parser.string,i=Parser.regex;return Parser.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),Vec=LatexCmds.vec=P(MathCommand,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">&rarr;</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),InnerMathField=P(MathQuill.MathField,function(t){t.init=function(t,e){RootBlockMixin(t),this.__options=Options();var n=Controller(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),LatexCmds.MathQuillMathField=P(MathCommand,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=Parser.string,i=Parser.regex,s=Parser.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){InnerMathField(this.ends[L],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[L].controller.API)},t.latex=function(){return this.ends[L].latex()},t.text=function(t){return this.ends[L].text(t)}}),Unit=LatexCmds.Unit=CharCmds["'"]=P(DerivedMathCommand,function(t,e){t.ctrlSeq="Unit{...}{...}",t.replaces=function(t){t.disown(),this._replacedFragment=t},t.htmlTemplate='<span><span>&0</span><span class="mq-unit mq-non-leaf">&1</span></span>',t.finalizeTree=function(){this.ends[R].focus=function(){return this.jQ.addClass("mq-active"),this.isEmpty()&&this.jQ.removeClass("mq-empty"),this},this.ends[R].blur=function(){return this.jQ.removeClass("mq-active").removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this},this.ends[R].write=function(t,e,n){return cmd=e.match(/^[a-z]$/i)?Letter(e):(cmd=CharCmds[e]||LatexCmds[e])?cmd(e):VanillaSymbol(e),e.match(/^[a-z\u00b52\^\*\/\(\)]$/i)?(n&&cmd.replaces(n),void cmd.createLeftOf(t)):(n&&n.remove(),void this.flash())},this.ends[R].unit=this.ends[R],this.ends[R].eachChild(function(t){if(t.recursiveSetUnit&&t.recursiveSetUnit(),t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}}),this.ends[R].deleteOutOf=function(t,e){for(var n=this.ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()},this.ends[L].deleteOutOf=function(t,e){for(var n=this.parent.ends[R].ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()}},t.createLeftOf=function(t){var n,i,s,a,r;if(this._replacedFragment){for(n=!0,i=this._replacedFragment.ends[L];0!==i;i=i[R])if(!(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/))){n=!1;break}this._replacedFragment.ends[L]===this._replacedFragment.ends[R]&&this._replacedFragment.ends[L]instanceof ScientificNotation&&(n=!0),n?(e.createLeftOf.call(this,t),this._replacedFragment.adopt(this.ends[L],0,0),this._replacedFragment.jQ.appendTo(this.ends[L].jQ)):(s=CharCmds["("](),s.replaces(this._replacedFragment),s.createLeftOf(t),s.reflow(),t.insRightOf(s),LatexCmds.cdot().createLeftOf(t),e.createLeftOf.call(this,t),t.insAtRightEnd(this.ends[L]),VanillaSymbol("1").createLeftOf(t))}else{for(a=[],t[L]instanceof ScientificNotation&&a.push(t[L]),i=t[L];0!==i&&(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/));i=i[L])a.push(i);for(0===a.length&&(t[L]instanceof BinaryOperator||0===t[L]?VanillaSymbol("1").createLeftOf(t):(LatexCmds.cdot().createLeftOf(t),VanillaSymbol("1").createLeftOf(t)),a.push(t[L])),e.createLeftOf.call(this,t),r=0;r<a.length;r++)a[r].disown(),a[r].adopt(this.ends[L],0,this.ends[L].ends[L]),a[r].jQ.prependTo(this.ends[L].jQ)}t.insAtRightEnd(this.ends[R]),t.workingGroupChange()},t.latex=function(){return"\\Unit{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.text=function(t){return this.blocks[0].text(t)+"*("+this.blocks[1].text(jQuery.extend({unit:!0},t))+")"}})}();
@@ -292,7 +292,7 @@
292
292
  margin-right: 1px;
293
293
  margin-left: 2px;
294
294
  font-size: 0.8em;
295
- color: #444444;
295
+ color: #666666;
296
296
  }
297
297
  .mq-math-mode span.mq-unit var,
298
298
  .mq-math-mode span.mq-unit span {
@@ -1,3 +1,3 @@
1
1
  module MathquillSwiftCalcsRails
2
- VERSION = "0.9.3.117"
2
+ VERSION = "0.9.3.118"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathquill_swiftcalcs_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3.117
4
+ version: 0.9.3.118
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brentan Alexander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-14 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties