You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2016/04/28 22:15:06 UTC

[2/6] allura git commit: [#8040] update SimpleMDE dev version, including our code block contribution

http://git-wip-us.apache.org/repos/asf/allura/blob/7576c372/Allura/allura/lib/widgets/resources/js/simplemde.min.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/simplemde.min.js b/Allura/allura/lib/widgets/resources/js/simplemde.min.js
index 0736a15..e30ca89 100644
--- a/Allura/allura/lib/widgets/resources/js/simplemde.min.js
+++ b/Allura/allura/lib/widgets/resources/js/simplemde.min.js
@@ -1,13 +1,14 @@
 /**
- * simplemde v1.7.1
+ * simplemde v1.10.0
  * Copyright Next Step Webs, Inc.
  * @link https://github.com/NextStepWebs/simplemde-markdown-editor
  * @license MIT
  */
-function fixShortcut(e){return e=isMac?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function createIcon(e,t){e=e||{};var r=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(r.title=e.title,isMac&&(r.title=r.title.replace("Ctrl","⌘"),r.title=r.title.replace("Alt","⌥"))),r.className=e.className,r}function createSep(){return el=document.createElement("i"),el.className="separator",el.innerHTML="|",el}function getState(e,t){t=t||e.getCursor("start");var r=e.getTokenAt(t);if(!r.type)return{};for(var n,i,o=r.type.split(" "),l={},a=0;a<o.length;a++)n=o[a],"strong"===n?l.bold=!0:"variable-2"===n?(i=e.getLine(t.line),/^\s*\d+\.\s/.test(i)?l["ordered-list"]=!0:l["unordered-list"]=!0):"atom"===n?l.quote=!0:"em"===n?l.italic=!0:"quote"===n?l.quote=!0:"strikethrough"===n?l.strikethrough=!0:"comment"===n&&(l.code=!0);return l}function toggleFullScreen(e){var t=e.codemirror;t.setOption("fullScreen",!t.getOption("fullScreen")),t.getOption("fullScreen")?(saved_overflow=document.
 body.style.overflow,document.body.style.overflow="hidden"):document.body.style.overflow=saved_overflow;var r=t.getWrapperElement();/fullscreen/.test(r.previousSibling.className)?r.previousSibling.className=r.previousSibling.className.replace(/\s*fullscreen\b/,""):r.previousSibling.className+=" fullscreen";var n=e.toolbarElements.fullscreen;/active/.test(n.className)?n.className=n.className.replace(/\s*active\s*/g,""):n.className+=" active";var i=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(i.className)&&toggleSideBySide(e)}function toggleBold(e){_toggleBlock(e,"bold","**")}function toggleItalic(e){_toggleBlock(e,"italic","*")}function toggleStrikethrough(e){_toggleBlock(e,"strikethrough","~~")}function toggleCodeBlock(e){_toggleBlock(e,"code","```\r\n","\r\n```")}function toggleBlockquote(e){var t=e.codemirror;_toggleLine(t,"quote")}function toggleHeadingSmaller(e){var t=e.codemirror;_toggleHeading(t,"smaller")}function toggleHeadingBigger(e){var t=e.codemirro
 r;_toggleHeading(t,"bigger")}function toggleHeading1(e){var t=e.codemirror;_toggleHeading(t,void 0,1)}function toggleHeading2(e){var t=e.codemirror;_toggleHeading(t,void 0,2)}function toggleHeading3(e){var t=e.codemirror;_toggleHeading(t,void 0,3)}function toggleUnorderedList(e){var t=e.codemirror;_toggleLine(t,"unordered-list")}function toggleOrderedList(e){var t=e.codemirror;_toggleLine(t,"ordered-list")}function drawLink(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.link,"[","](http://)")}function drawImage(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.image,"![](http://",")")}function drawHorizontalRule(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.image,"","\n\n-----\n\n")}function undo(e){var t=e.codemirror;t.undo(),t.focus()}function redo(e){var t=e.codemirror;t.redo(),t.focus()}function toggleSideBySide(e){var t=e.codemirror,r=t.getWrapperElement(),n=(r.firstChild,r.nextSibling),i=e.toolbarElements["side-by-side"];/editor-preview-active-si
 de/.test(n.className)?(n.className=n.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||toggleFullScreen(e),n.className+=" editor-preview-active-side"},1),i.className+=" active",r.className+=" CodeMirror-sided");var o=r.lastChild;if(/editor-preview-active/.test(o.className)){o.className=o.className.replace(/\s*editor-preview-active\s*/g,"");var l=e.toolbarElements.preview,a=r.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),a.className=a.className.replace(/\s*disabled-for-preview*/g,"")}n.innerHTML=e.options.previewRender(e.value(),n),t.on("update",function(){n.innerHTML=e.options.previewRender(e.value(),n)})}function togglePreview(e){var t=e.codemirror,r=t.getWrapperElement(),n=r.previousSibling,i=e.toolbarElements.preview,o=r.lastChild;o&&/editor-preview/.test(o.className)||(o=document.create
 Element("div"),o.className="editor-preview",r.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*disabled-for-preview*/g,"")):(setTimeout(function(){o.className+=" editor-preview-active"},1),i.className+=" active",n.className+=" disabled-for-preview"),o.innerHTML=e.options.previewRender(e.value(),o);var l=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(l.className)&&toggleSideBySide(e)}function _replaceSelection(e,t,r,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=e.getCursor("start"),l=e.getCursor("end");t?(i=e.getLine(o.line),r=i.slice(0,o.ch),n=i.slice(o.ch),e.replaceRange(r+n,{line:o.line,ch:0})):(i=e.getSelection(),e.replaceSelection(r+i+n),o.ch+=r.length,o!==l&&(l.ch+=r.length)),e.setSelection(o,l),e.focus()}}function _toggleHeading(e,t,r){if(!/editor-previ
 ew-active/.test(e.getWrapperElement().lastChild.className)){for(var n=e.getCursor("start"),i=e.getCursor("end"),o=n.line;o<=i.line;o++)!function(n){var i=e.getLine(n),o=i.search(/[^#]/);i=void 0!==t?0>=o?"bigger"==t?"###### "+i:"# "+i:6==o&&"smaller"==t?i.substr(7):1==o&&"bigger"==t?i.substr(2):"bigger"==t?i.substr(1):"#"+i:1==r?0>=o?"# "+i:o==r?i.substr(o+1):"# "+i.substr(o+1):2==r?0>=o?"## "+i:o==r?i.substr(o+1):"## "+i.substr(o+1):0>=o?"### "+i:o==r?i.substr(o+1):"### "+i.substr(o+1),e.replaceRange(i,{line:n,ch:0},{line:n,ch:99999999999999})}(o);e.focus()}}function _toggleLine(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var r=getState(e),n=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},l={quote:"> ","unordered-list":"* ","ordered-list":"1. "},a=n.line;a<=i.line;a++)!function(n){var i=e.getLine(n);i=r[t]?i.replace(o[t],"$1"):l[t]+i,e.replaceRange(i,{l
 ine:n,ch:0},{line:n,ch:99999999999999})}(a);e.focus()}}function _toggleBlock(e,t,r,n){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){n="undefined"==typeof n?r:n;var i,o=e.codemirror,l=getState(o),a=r,s=n,u=o.getCursor("start"),c=o.getCursor("end");l[t]?(i=o.getLine(u.line),a=i.slice(0,u.ch),s=i.slice(u.ch),"bold"==t?(a=a.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),s=s.replace(/(\*\*|__)/,"")):"italic"==t?(a=a.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),s=s.replace(/(\*|_)/,"")):"strikethrough"==t&&(a=a.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),s=s.replace(/(\*\*|~~)/,"")),o.replaceRange(a+s,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==c&&(c.ch-=2)):"italic"==t&&(u.ch-=1,u!==c&&(c.ch-=1))):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t?(i=i.split("*").join(""),i=i.split("_").join("")):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(a+
 i+s),u.ch+=r.length,c.ch=u.ch+i.length),o.setSelection(u,c),o.focus()}}function wordCount(e){var t=/[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g,r=e.match(t),n=0;if(null===r)return n;for(var i=0;i<r.length;i++)n+=r[i].charCodeAt(0)>=19968?r[i].length:1;return n}function SimpleMDE(e){if(e=e||{},e.parent=this,e.element)this.element=e.element;else if(null===e.element)return void console.log("SimpleMDE: Error. No element was found.");e.toolbar!==!1&&(e.toolbar=e.toolbar||SimpleMDE.toolbar),e.hasOwnProperty("status")||(e.status=["autosave","lines","words","cursor"]),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=e.parsingConfig||{},this.options=e,this.render(),e.initialValue&&this.value(e.initialValue)}!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use 
 strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Ii(n):{},Ii(Xo,n,!1),f(n);var i=n.value;"string"==typeof i&&(i=new bl(i,n.mode,null,n.lineSeparator)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),a(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Lo&&l.input.focus(),v(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ni,keySeq:null,specialChars:null};var s=this;go&&11>mo&&setTimeout(function(){s.display.input.reset(!0)},20),Rt(this),Vi(),bt(this),this.curOp.forceUpdate=!0,Xn(this,i),n.autofocus&&!Lo||s.hasFocus()?setTimeout(Pi(gr,this),20):mr(this);for(var c in Yo)Yo.hasOwnProperty(c)&&Yo[c](this,n[c],Zo);C(this),n.finishInit&&n.finishInit(this);for(var h=0;h<tl.length;++h)tl[h](this);wt(this),vo&&n.
 lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=zi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=zi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=zi("div",null,"CodeMirror-code"),n.selectionDiv=zi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=zi("div",null,"CodeMirror-cursors"),n.measure=zi("div",null,"CodeMirror-measure"),n.lineMeasure=zi("div",null,"CodeMirror-measure"),n.lineSpace=zi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=zi("div",[zi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=zi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=zi("div",null,null,"position: absolute; height: "+Al+"px; 
 width: 1px;"),n.gutters=zi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=zi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=zi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),go&&8>mo&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),vo||ho&&Lo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null
 ,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,_e(e,100),e.state.modeGen++,e.curOp&&Wt(e)}function i(e){e.options.lineWrapping?(jl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):($l(e.display.wrapper,"CodeMirror-wrap"),d(e)),l(e),Wt(e),lt(e),setTimeout(function(){y(e)},100)}function o(e){var t=vt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/yt(e.display)-3);return function(i){if(wn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&Jn(e,t)})}function a(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.th
 eme.replace(/(^|\s)\s*/g," cm-s-"),lt(e)}function s(e){u(e),Wt(e),setTimeout(function(){w(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Ri(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(zi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function h(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=pn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=gn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function d(e){var t=e.display,r=e.doc;t.maxLine=Yn(r,r.first),t.maxLineLength=h(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=h(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function f(e){var t=Di(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e
 .gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ue(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+$e(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=zi("div",[zi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=zi("div",[zi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Ll(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Ll(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,go&&8>mo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}funct
 ion m(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&$l(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Ll(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?nr(t,e):rr(t,e)},t),t.display.scrollbars.addClass&&jl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&D(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right
 &&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function x(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-qe(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=ti(t,n),l=ti(t,i);if(r&&r.ensure){var a=r.ensure.from.line,s=r.ensure.to.line;o>a?(o=a,l=ti(t,ri(Yn(t,a))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=l&&(o=ti(t,ri(Yn(t,s))-e.wrapper.clientHeight),l=s)}return{from:o,to:Math.max(l,o+1)}}function w(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=k(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px"
 ,l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var a=r[l].alignable;if(a)for(var s=0;s<a.length;s++)a[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(zi("div",[zi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function k(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function L(e,t,r){var n=e.display;this.viewport=t,this.visible=x(n,e.doc,t),th
 is.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=je(e),this.force=r,this.dims=O(e),this.events=[]}function M(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=$e(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=$e(e)+"px",t.scrollbarsClipped=!0)}function T(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return Pt(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==zt(e))return!1;C(e)&&(Pt(e),t.dims=O(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.
 viewTo)),Eo&&(o=bn(e.doc,o),l=xn(e.doc,l));var a=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Bt(e,o,l),r.viewOffset=ri(Yn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var s=zt(e);if(!a&&0==s&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Ui();return s>4&&(r.lineDiv.style.display="none"),W(e,r.updateLineNumbers,t.dims),s>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Ui()!=u&&u.offsetHeight&&u.focus(),Ri(r.cursorDiv),Ri(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,a&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,_e(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=je(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ue(e.display)-Ve(e),r.top)}),t.visible=x(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.disp
 lay.viewTo)))&&T(e,t);n=!1){D(e);var i=p(e);Oe(e),H(e,i),y(e,i)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new L(e,t);if(T(e,r)){D(e),N(e,r);var n=p(e);Oe(e),H(e,n),y(e,n),r.finish()}}function H(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+$e(e),t.clientHeight)+"px"}function D(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(go&&8>mo){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var a=o.node.getBoundingClientRect();i=a.bottom-a.top}var s=o.line.height-i;if(2>i&&(i=vt(t)),(s>.001||-.001>s)&&(Jn(o.line,i),E(o.line),o.rest))for(var u=0;u<o.res
 t.length;u++)E(o.rest[u])}}}function E(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function O(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:k(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function W(e,t,r){function n(t){var r=t.nextSibling;return vo&&Mo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,a=l.firstChild,s=i.view,u=i.viewFrom,c=0;c<s.length;c++){var h=s[c];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;a!=h.node;)a=n(a);var d=o&&null!=t&&u>=t&&h.lineNumber;h.changes&&(Di(h.changes,"gutter")>-1&&(d=!1),I(e,h,u,r)),d&&(Ri(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(S(e.options,
 u)))),a=h.node.nextSibling}else{var f=U(e,h,u,r);l.insertBefore(f,a)}u+=h.size}for(;a;)a=n(a)}function I(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?B(e,t):"gutter"==o?R(e,t,r,n):"class"==o?z(t):"widget"==o&&q(e,t,n)}t.changes=null}function P(e){return e.node==e.text&&(e.node=zi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),go&&8>mo&&(e.node.style.zIndex=2)),e.node}function F(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=P(e);e.background=r.insertBefore(zi("div",null,t),r.firstChild)}}function _(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Fn(e,t)}function B(e,t){var r=t.text.className,n=_(e,t);t.text==t.n
 ode&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,z(t)):r&&(t.text.className=r)}function z(e){F(e),e.line.wrapClass?P(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function R(e,t,r,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=P(t);t.gutterBackground=zi("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=P(t),l=t.gutter=zi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutte
 rTotalWidth)+"px");if(e.display.input.setUneditable(l),i.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(zi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var a=0;a<e.options.gutters.length;++a){var s=e.options.gutters[a],u=o.hasOwnProperty(s)&&o[s];u&&l.appendChild(zi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[s]+"px; width: "+n.gutterWidth[s]+"px"))}}}function q(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}G(e,t,r)}function U(e,t,r,n){var i=_(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),z(t),R(e,t,r,n),G(e,t,n),t.node}function G(e,t,r){if($(e,t.line,t,r,!0),t.rest)
 for(var n=0;n<t.rest.length;n++)$(e,t.rest[n],t,r,!1)}function $(e,t,r,n,i){if(t.widgets)for(var o=P(r),l=0,a=t.widgets;l<a.length;++l){var s=a[l],u=zi("div",[s.node],"CodeMirror-linewidget");s.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),j(s,u,r,n),e.display.input.setUneditable(u),i&&s.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),Ci(s,"redraw")}}function j(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function V(e){return Oo(e.line,e.ch)}function K(e,t){return Wo(e,t)<0?t:e}function X(e,t){return Wo(e,t)<0?e:t}function Y(e){e.state.focused||(e.display.input.focus(),gr(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n,i){var o=e.doc;e.di
 splay.shift=!1,n||(n=o.sel);var l=e.state.pasteIncoming||"paste"==i,a=o.splitLines(t),s=null;if(l&&n.ranges.length>1)if(Io&&Io.join("\n")==t){if(n.ranges.length%Io.length==0){s=[];for(var u=0;u<Io.length;u++)s.push(o.splitLines(Io[u]))}}else a.length==n.ranges.length&&(s=Ei(a,function(e){return[e]}));for(var u=n.ranges.length-1;u>=0;u--){var c=n.ranges[u],h=c.from(),d=c.to();c.empty()&&(r&&r>0?h=Oo(h.line,h.ch-r):e.state.overwrite&&!l&&(d=Oo(d.line,Math.min(Yn(o,d.line).text.length,d.ch+Hi(a).length))));var f=e.curOp.updateInput,p={from:h,to:d,text:s?s[u%s.length]:a,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};kr(e.doc,p),Ci(e,"inputRead",e,p)}t&&!l&&ee(e,t),Pr(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var r=e.clipboardData&&e.clipboardData.getData("text/plain");return r?(e.preventDefault(),Z(t)||t.options.disableInput||Nt(t,function(){Q(t,r,0,null,"paste")}),!0):void 0}function ee(e,t){if(e.options.electricC
 hars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var a=0;a<o.electricChars.length;a++)if(t.indexOf(o.electricChars.charAt(a))>-1){l=_r(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Yn(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=_r(e,i.head.line,"smart"));l&&Ci(e,"electricInput",e,i.head.line)}}}function te(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:Oo(i,0),head:Oo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function re(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function ne(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ni,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function ie(){var e
 =zi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=zi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return vo?e.style.width="1000px":e.setAttribute("wrap","off"),ko&&(e.style.border="1px solid black"),re(e),t}function oe(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ni,this.gracePeriod=!1}function le(e,t){var r=Qe(e,t.line);if(!r||r.hidden)return null;var n=Yn(e.doc,t.line),i=Xe(r,n,t.line),o=ni(n),l="left";if(o){var a=ao(o,t.ch);l=a%2?"right":"left"}var s=tt(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function ae(e,t){return t&&(e.bad=!0),e}function se(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return ae(e.clipPos(Oo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)bre
 ak}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return ue(o,t,r)}}function ue(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var a=o[l+2];if(a==t||a==r){var s=ei(0>i?e.line:e.rest[i]),h=o[l]+n;return(0>n||a!=t)&&(h=o[l+(n?1:0)]),Oo(s,h)}}}var i=e.text.firstChild,o=!1;if(!t||!ql(i,t))return ae(Oo(ei(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Hi(e.rest):e.line;return ae(Oo(ei(l),l.text.length),o)}var a=3==t.nodeType?t:null,s=t;for(a||1!=t.childNodes.length||3!=t.firstChild.nodeType||(a=t.firstChild,r&&(r=a.nodeValue.length));s.parentNode!=i;)s=s.parentNode;var u=e.measure,c=u.maps,h=n(a,s,r);if(h)return ae(h,o);for(var d=s.nextSibling,f=a?a.nodeValue.length-r:0;d;d=d.nextSibling){if(h=n(d,d.firstChild,0))return ae(Oo(h.line,h.ch-f),o);f+=d.textContent.length}for(var p=s.previousSibling,f=r;p;p=p.previousSibling){if(h=n(p,p.firstChild,-1))return ae(Oo(h.line,h.ch+f),o);
 f+=d.textContent.length}}function ce(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(a+=r);var c,h=t.getAttribute("cm-marker");if(h){var d=e.findMarks(Oo(n,0),Oo(i+1,0),o(+h));return void(d.length&&(c=d[0].find())&&(a+=Zn(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var f=0;f<t.childNodes.length;f++)l(t.childNodes[f]);/^(pre|div|p)$/i.test(t.nodeName)&&(s=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;s&&(a+=u,s=!1),a+=p}}for(var a="",s=!1,u=e.doc.lineSeparator();l(t),t!=r;)t=t.nextSibling;return a}function he(e,t){this.ranges=e,this.primIndex=t}function de(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Wo(e.from(),t.from())}),t=Di(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Wo(o.to(),i.from())>=0){var l=X(o.from(),i.from()),a=K(o.to(),i.
 to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new de(s?a:l,s?l:a))}}return new he(e,t)}function pe(e,t){return new he([new de(e,t||e)],0)}function ge(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function me(e,t){if(t.line<e.first)return Oo(e.first,0);var r=e.first+e.size-1;return t.line>r?Oo(r,Yn(e,r).text.length):ve(t,Yn(e,t.line).text.length)}function ve(e,t){var r=e.ch;return null==r||r>t?Oo(e.line,t):0>r?Oo(e.line,0):e}function ye(e,t){return t>=e.first&&t<e.first+e.size}function be(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=me(e,t[n]);return r}function xe(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Wo(r,i)<0;o!=Wo(n,i)<0?(i=r,r=n):o!=Wo(r,n)<0&&(r=n)}return new de(i,r)}return new de(n||r,r)}function we(e,t,r,n){Te(e,new he([xe(e,e.sel.primary(),t,r)],0),n)}function Ce(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=xe(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);Te(e,o,r)}function Se(e
 ,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,Te(e,fe(i,e.sel.primIndex),n)}function ke(e,t,r,n){Te(e,pe(t,r),n)}function Le(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new de(me(e,t[r].anchor),me(e,t[r].head))}};return Tl(e,"beforeSelectionChange",e,r),e.cm&&Tl(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Me(e,t,r){var n=e.history.done,i=Hi(n);i&&i.ranges?(n[n.length-1]=t,Ne(e,t,r)):Te(e,t,r)}function Te(e,t,r){Ne(e,t,r),ci(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Ne(e,t,r){(Mi(e,"beforeSelectionChange")||e.cm&&Mi(e.cm,"beforeSelectionChange"))&&(t=Le(e,t));var n=r&&r.bias||(Wo(t.primary().head,e.sel.primary().head)<0?-1:1);Ae(e,De(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Pr(e.cm)}function Ae(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Li(e.cm)),Ci(e,"cursorActivity",e))}function He(e){Ae(e,De(e,e.sel,null,!1),Dl)}function De(e,t
 ,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],a=Ee(e,l.anchor,r,n),s=Ee(e,l.head,r,n);(i||a!=l.anchor||s!=l.head)&&(i||(i=t.ranges.slice(0,o)),
-i[o]=new de(a,s))}return i?fe(i,t.primIndex):t}function Ee(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var a=Yn(e,o.line);if(a.markedSpans)for(var s=0;s<a.markedSpans.length;++s){var u=a.markedSpans[s],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Tl(c,"beforeCursorEnter"),c.explicitlyCleared)){if(a.markedSpans){--s;continue}break}if(!c.atomic)continue;var h=c.find(0>l?-1:1);if(0==Wo(h,o)&&(h.ch+=l,h.ch<0?h=h.line>e.first?me(e,Oo(h.line-1)):null:h.ch>a.text.length&&(h=h.line<e.first+e.size-1?Oo(h.line+1,0):null),!h)){if(i)return n?(e.cantEdit=!0,Oo(e.first,0)):Ee(e,t,r,!0);i=!0,h=t,l=-l}o=h;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function We(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var 
 a=r.sel.ranges[l],s=a.empty();(s||e.options.showCursorWhenSelecting)&&Ie(e,a.head,i),s||Pe(e,a,o)}return n}function Ie(e,t,r){var n=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(zi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(zi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Pe(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),a.appendChild(zi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ht(e,Oo(t,r),"div",h,n)}var a,s,h=Yn(l,t),d=h.text.length;return Qi(ni(h),r||0,null==i?d:i,function(e,t,l){var h,f,p,g=o(e,"left")
 ;if(e==t)h=g,f=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var m=g;g=h,h=m}f=g.left,p=h.right}null==r&&0==e&&(f=u),h.top-g.top>3&&(n(f,g.top,null,g.bottom),f=u,g.bottom<h.top&&n(f,g.bottom,null,h.top)),null==i&&t==d&&(p=c),(!a||g.top<a.top||g.top==a.top&&g.left<a.left)&&(a=g),(!s||h.bottom>s.bottom||h.bottom==s.bottom&&h.right>s.right)&&(s=h),u+1>f&&(f=u),n(f,h.top,p-f,h.bottom)}),{start:a,end:s}}var o=e.display,l=e.doc,a=document.createDocumentFragment(),s=Ge(e.display),u=s.left,c=Math.max(o.sizerWidth,je(e)-o.sizer.offsetLeft)-s.right,h=t.from(),d=t.to();if(h.line==d.line)i(h.line,h.ch,d.ch);else{var f=Yn(l,h.line),p=Yn(l,d.line),g=vn(f)==vn(p),m=i(h.line,h.ch,g?f.text.length+1:null).end,v=i(d.line,g?0:null,d.ch).start;g&&(m.top<v.top-2?(n(m.right,m.top,null,m.bottom),n(u,v.top,v.left,v.bottom)):n(m.right,m.top,v.left-m.right,m.bottom)),m.bottom<v.top&&n(u,m.bottom,null,v.top)}r.appendChild(a)}function Fe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.c
 ursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _e(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Pi(Be,e))}function Be(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=nl(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,a=o.text.length>e.options.maxHighlightLength,s=On(e,o,a?nl(t.mode,n):n,!0);o.styles=s.styles;var u=o.styleClasses,c=s.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),d=0;!h&&d<l.length;++d)h=l[d]!=o.styles[d];h&&i.push(t.frontier),o.stateAfter=a?
 n:nl(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&In(e,o.text,n),o.stateAfter=t.frontier%5==0?nl(t.mode,n):null;return++t.frontier,+new Date>r?(_e(e,e.options.workDelay),!0):void 0}),i.length&&Nt(e,function(){for(var t=0;t<i.length;t++)It(e,i[t],"text")})}}function ze(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),a=t;a>l;--a){if(a<=o.first)return o.first;var s=Yn(o,a-1);if(s.stateAfter&&(!r||a<=o.frontier))return a;var u=Wl(s.text,null,e.options.tabSize);(null==i||n>u)&&(i=a-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=ze(e,t,r),l=o>n.first&&Yn(n,o-1).stateAfter;return l=l?nl(n.mode,l):il(n.mode),n.iter(o,t,function(r){In(e,r.text,l);var a=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=a?nl(n.mode,l):null,++o}),r&&(n.frontier=o),l}function qe(e){return e.lineSpace.offsetTop}function Ue(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ge(e){if(e.cachedPaddingH)return e.cache
 dPaddingH;var t=qi(e.measure,zi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function $e(e){return Al-e.display.nativeBarWidth}function je(e){return e.display.scroller.clientWidth-$e(e)-e.display.barWidth}function Ve(e){return e.display.scroller.clientHeight-$e(e)-e.display.barHeight}function Ke(e,t,r){var n=e.options.lineWrapping,i=n&&je(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),a=0;a<l.length-1;a++){var s=l[a],u=l[a+1];Math.abs(s.bottom-u.bottom)>2&&o.push((s.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Xe(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(e
 i(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=vn(t);var r=ei(t),n=e.display.externalMeasured=new Et(e.doc,t,r);n.lineN=r;var i=n.built=Fn(e,n);return n.text=i.pre,qi(e.display.lineMeasure,i.pre),n}function Ze(e,t,r,n){return et(e,Je(e,t),r,n)}function Qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ft(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Je(e,t){var r=ei(t),n=Qe(e,r);n&&!n.text?n=null:n&&n.changes&&(I(e,n,r,O(e)),e.curOp.forceUpdate=!0),n||(n=Ye(e,t));var i=Xe(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function et(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Ke(e,t.view,t.rect),t.hasHeights=!0),o=rt(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bott
 om:i?o.rbottom:o.bottom}}function tt(e,t,r){for(var n,i,o,l,a=0;a<e.length;a+=3){var s=e[a],u=e[a+1];if(s>t?(i=0,o=1,l="left"):u>t?(i=t-s,o=i+1):(a==e.length-3||t==u&&e[a+3]>t)&&(o=u-s,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[a+2],s==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;a&&e[a-2]==e[a-3]&&e[a-1].insertLeft;)n=e[(a-=3)+2],l="left";if("right"==r&&i==u-s)for(;a<e.length-3&&e[a+3]==e[a+4]&&!e[a+5].insertLeft;)n=e[(a+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:s,coverEnd:u}}function rt(e,t,r,n){var i,o=tt(t.map,r,n),l=o.node,a=o.start,s=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;a&&Bi(t.line.text.charAt(o.coverStart+a));)--a;for(;o.coverStart+s<o.coverEnd&&Bi(t.line.text.charAt(o.coverStart+s));)++s;if(go&&9>mo&&0==a&&s==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(go&&e.options.lineWrapping){var h=_l(l,a,s).getClientRects();i=h.length?h["right"==n?h.length-1:0]:Bo}else i=_l(l,a,s).getB
 oundingClientRect()||Bo;if(i.left||i.right||0==a)break;s=a,a-=1,u="right"}go&&11>mo&&(i=nt(e.display.measure,i))}else{a>0&&(u=n="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==n?h.length-1:0]:l.getBoundingClientRect()}if(go&&9>mo&&!a&&(!i||!i.left&&!i.right)){var d=l.parentNode.getClientRects()[0];i=d?{left:d.left,right:d.left+yt(e.display),top:d.top,bottom:d.bottom}:Bo}for(var f=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(f+p)/2,m=t.view.measure.heights,c=0;c<m.length-1&&!(g<m[c]);c++);var v=c?m[c-1]:0,y=m[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:v,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=f,b.rbottom=p),b}function nt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Zi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top
 :t.top*n,bottom:t.bottom*n}}function it(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ot(e){e.display.externalMeasure=null,Ri(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)it(e.display.view[t])}function lt(e){ot(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function at(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function st(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ut(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=kn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=ri(t);if("local"==n?l+=qe(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var a=e.display.lineSpace.getBoundingClientRect();l+=a.top+("wi
 ndow"==n?0:st());var s=a.left+("window"==n?0:at());r.left+=s,r.right+=s}return r.top+=l,r.bottom+=l,r}function ct(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=at(),i-=st();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ht(e,t,r,n,i){return n||(n=Yn(e.doc,t.line)),ut(e,n,Ze(e,n,t.ch,i),r)}function dt(e,t,r,n,i,o){function l(t,l){var a=et(e,i,t,l?"right":"left",o);return l?a.left=a.right:a.right=a.left,ut(e,n,a,r)}function a(e,t){var r=s[t],n=r.level%2;return e==Ji(r)&&t&&r.level<s[t-1].level?(r=s[--t],e=eo(r)-(r.level%2?0:1),n=!0):e==eo(r)&&t<s.length-1&&r.level<s[t+1].level&&(r=s[++t],e=Ji(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Yn(e.doc,t.line),i||(i=Je(e,n));var s=ni(n),u=t.ch;if(!s)return l(u);var c=ao(s,u),h=a(u,c);return null!=ea&&(h.other=a(u,ea)),h}function ft(e,t){var r=0,t=me(e.doc,t);e.options.lineWrap
 ping||(r=yt(e.display)*t.ch);var n=Yn(e.doc,t.line),i=ri(n)+qe(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function pt(e,t,r,n){var i=Oo(e,t);return i.xRel=n,r&&(i.outside=!0),i}function gt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return pt(n.first,0,!0,-1);var i=ti(n,r),o=n.first+n.size-1;if(i>o)return pt(n.first+n.size-1,Yn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Yn(n,i);;){var a=mt(e,l,i,t,r),s=gn(l),u=s&&s.find(0,!0);if(!s||!(a.ch>u.from.ch||a.ch==u.from.ch&&a.xRel>0))return a;i=ei(l=u.to.line)}}function mt(e,t,r,n,i){function o(n){var i=dt(e,Oo(r,n),"line",t,u);return a=!0,l>i.bottom?i.left-s:l<i.top?i.left+s:(a=!1,i.left)}var l=i-ri(t),a=!1,s=2*e.display.wrapper.clientWidth,u=Je(e,t),c=ni(t),h=t.text.length,d=to(t),f=ro(t),p=o(d),g=a,m=o(f),v=a;if(n>m)return pt(r,f,v,1);for(;;){if(c?f==d||f==uo(t,d,1):1>=f-d){for(var y=p>n||m-n>=n-p?d:f,b=n-(y==d?p:m);Bi(t.text.charAt(y));)++y;var x=pt(r,y,y==d?g:v,-1>b?-1:b>1?1:0);return x}var w=Math.ceil(h/2),C=d+w
 ;if(c){C=d;for(var S=0;w>S;++S)C=uo(t,C,1)}var k=o(C);k>n?(f=C,m=k,(v=a)&&(m+=1e3),h=w):(d=C,p=k,g=a,h-=w)}}function vt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Po){Po=zi("pre");for(var t=0;49>t;++t)Po.appendChild(document.createTextNode("x")),Po.appendChild(zi("br"));Po.appendChild(document.createTextNode("x"))}qi(e.measure,Po);var r=Po.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Ri(e.measure),r||1}function yt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=zi("span","xxxxxxxxxx"),r=zi("pre",[t]);qi(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function bt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ro},zo?zo.ops.push(e.curOp):e.curOp.ownsGroup=zo={ops:[e.curOp
 ],delayedCallbacks:[]}}function xt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r].call(null);for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(r<t.length)}function wt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{xt(r)}finally{zo=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;Ct(r)}}function Ct(e){for(var t=e.ops,r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)kt(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)Mt(t[r]);for(var r=0;r<t.length;r++)Tt(t[r])}function St(e){var t=e.cm,r=t.display;M(t),e.updateMaxLine&&d(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new L(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scroll
 ToPos},e.forceUpdate)}function kt(e){e.updatedDisplay=e.mustUpdate&&T(e.cm,e.update)}function Lt(e){var t=e.cm,r=t.display;e.updatedDisplay&&D(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Ze(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+$e(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-je(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&nr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&H(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selecti
 onChanged&&Fe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),e.focus&&e.focus==Ui()&&Y(e.cm)}function Tt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-je(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,w(t)),e.scrollToPos){var i=Er(t,me(n,e.scrollToPos.from),me(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Dr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var a=0;a<o.len
 gth;++a)o[a].lines.length||Tl(o[a],"hide");if(l)for(var a=0;a<l.length;++a)l[a].lines.length&&Tl(l[a],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Tl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Nt(e,t){if(e.curOp)return t();bt(e);try{return t()}finally{wt(e)}}function At(e,t){return function(){if(e.curOp)return t.apply(e,arguments);bt(e);try{return t.apply(e,arguments)}finally{wt(e)}}}function Ht(e){return function(){if(this.curOp)return e.apply(this,arguments);bt(this);try{return e.apply(this,arguments)}finally{wt(this)}}}function Dt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);bt(t);try{return e.apply(this,arguments)}finally{wt(t)}}}function Et(e,t,r){this.line=t,this.rest=yn(t),this.size=this.rest?ei(Hi(this.rest))-r+1:1,this.node=this.text=null,this.hidden=wn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Et(e.doc,Yn(e.doc,o),o);n=o+l.size,i.push(l)}return i}func
 tion Wt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Eo&&bn(e.doc,t)<i.viewTo&&Pt(e);else if(r<=i.viewFrom)Eo&&xn(e.doc,r+n)>i.viewFrom?Pt(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Pt(e);else if(t<=i.viewFrom){var o=_t(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Pt(e)}else if(r>=i.viewTo){var o=_t(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Pt(e)}else{var l=_t(e,t,t,-1),a=_t(e,r,r+n,1);l&&a?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):Pt(e)}var s=i.externalMeasured;s&&(r<s.lineN?s.lineN+=n:t<s.lineN+s.size&&(i.externalMeasured=null))}function It(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=nu
 ll),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Ft(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Di(l,r)&&l.push(r)}}}function Pt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ft(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function _t(e,t,r,n){var i,o=Ft(e,t),l=e.display.view;if(!Eo||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var a=0,s=e.display.viewFrom;o>a;a++)s+=l[a].size;if(s!=t){if(n>0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;bn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Bt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Ft(e,t))),n.viewFrom=t,n.
 viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Ft(e,r)))),n.viewTo=r}function zt(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Ll(i.scroller,"mousedown",At(e,jt)),go&&11>mo?Ll(i.scroller,"dblclick",At(e,function(t){if(!ki(e,t)){var r=$t(e,t);if(r&&!Zt(e,t)&&!Gt(e.display,t)){Cl(t);var n=e.findWordAt(r);we(e.doc,n.anchor,n.head)}}})):Ll(i.scroller,"dblclick",function(t){ki(e,t)||Cl(t)}),Ho||Ll(i.scroller,"contextmenu",function(t){vr(e,t)});var o,l={end:0};Ll(i.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,mov
 ed:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Ll(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ll(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Gt(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,a=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new de(a,a):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(a):new de(Oo(a.line,0),me(e.doc,Oo(a.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Cl(r)}t()}),Ll(i.scroller,"touchcancel",t),Ll(i.scroller,"scroll",function(){i.scroller.clientHeight&&(rr(e,i.scroller.scrollTop),nr(e,i.scroller.scrollLeft,!0),Tl(e,"scroll",e))}),Ll(i.scroller,"mousewheel",function(t){ir(e,t)}),Ll(i.scroller,"DOMMouseScroll",function(t){ir(e,t)}),Ll(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){ki(e,t)||kl(t)},over:function(t){ki(e,t)||(er(e,t),kl(t))
 },start:function(t){Jt(e,t)},drop:At(e,Qt),leave:function(){tr(e)}};var a=i.input.getField();Ll(a,"keyup",function(t){dr.call(e,t)}),Ll(a,"keydown",At(e,cr)),Ll(a,"keypress",At(e,fr)),Ll(a,"focus",Pi(gr,e)),Ll(a,"blur",Pi(mr,e))}function qt(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,l=r?Ll:Ml;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.enter),l(t.display.scroller,"dragover",o.over),l(t.display.scroller,"dragleave",o.leave),l(t.display.scroller,"drop",o.drop)}}function Ut(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var r=xi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function $t(e,t,r,n){var i=e.display;if(!r&&"true"==xi(t).getAttribute("cm-not-content"))return
  null;var o,l,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,l=t.clientY-a.top}catch(t){return null}var s,u=gt(e,o,l);if(n&&1==u.xRel&&(s=Yn(e.doc,u.line).text).length==u.ch){var c=Wl(s,s.length,e.options.tabSize)-s.length;u=Oo(u.line,Math.max(0,Math.round((o-Ge(e.display).left)/yt(e.display))-c))}return u}function jt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||ki(t,e))){if(r.shift=e.shiftKey,Gt(r,e))return void(vo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Zt(t,e)){var n=$t(t,e);switch(window.focus(),wi(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?Vt(t,e,n):xi(e)==r.scroller&&Cl(e);break;case 2:vo&&(t.state.lastMiddleDown=+new Date),n&&we(t.doc,n),setTimeout(function(){r.input.focus()},20),Cl(e);break;case 3:Ho?vr(t,e):pr(t)}}}}function Vt(e,t,r){go?setTimeout(Pi(Y,e),0):e.curOp.focus=Ui();var n,i=+new Date;_o&&_o.time>i-400&&0==Wo(_o.pos,r)?n="triple":Fo&&Fo.time>i-400&&0==Wo(Fo.pos,r)
 ?(n="double",_o={time:i,pos:r}):(n="single",Fo={time:i,pos:r});var o,l=e.doc.sel,a=Mo?t.metaKey:t.ctrlKey;e.options.dragDrop&&Kl&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&(Wo((o=l.ranges[o]).from(),r)<0||r.xRel>0)&&(Wo(o.to(),r)>0||r.xRel<0)?Kt(e,t,r,a):Xt(e,t,r,n,a)}function Kt(e,t,r,n){var i=e.display,o=+new Date,l=At(e,function(a){vo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ml(document,"mouseup",l),Ml(i.scroller,"drop",l),Math.abs(t.clientX-a.clientX)+Math.abs(t.clientY-a.clientY)<10&&(Cl(a),!n&&+new Date-200<o&&we(e.doc,r),vo||go&&9==mo?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});vo&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Ll(document,"mouseup",l),Ll(i.scroller,"drop",l)}function Xt(e,t,r,n,i){function o(t){if(0!=Wo(m,t))if(m=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Wl(Yn(u,r.line).text,r.ch,o),a=Wl(Yn(u,t.line).text,t.ch,o),s=Math.min(l,a),f=Math.max(l,a),p=Math.min(r.l
 ine,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var v=Yn(u,p).text,y=Il(v,s,o);s==f?i.push(new de(Oo(p,y),Oo(p,y))):v.length>y&&i.push(new de(Oo(p,y),Oo(p,Il(v,f,o))))}i.length||i.push(new de(r,r)),Te(u,fe(d.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,x=b.anchor,w=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new de(Oo(t.line,0),me(u,Oo(t.line+1,0)));Wo(C.anchor,x)>0?(w=C.head,x=X(b.from(),C.anchor)):(w=C.anchor,x=K(b.to(),C.head))}var i=d.ranges.slice(0);i[h]=new de(me(u,x),w),Te(u,fe(i,h),El)}}function l(t){var r=++y,i=$t(e,t,!0,"rect"==n);if(i)if(0!=Wo(i,m)){e.curOp.focus=Ui(),o(i);var a=x(s,u);(i.line>=a.to||i.line<a.from)&&setTimeout(At(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<v.top?-20:t.clientY>v.bottom?20:0;c&&setTimeout(At(e,function(){y==r&&(s.scroller.scrollTop+=c,l(t))}),50)}}function a(t){e.state.selectingText=!1,y=1/0,Cl(t),s.input.focus(),Ml(document,"mousemove",b),M
 l(document,"mouseup",w),u.history.lastSelOrigin=null}var s=e.display,u=e.doc;Cl(t);var c,h,d=u.sel,f=d.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(r),c=h>-1?f[h]:new de(r,r)):(c=u.sel.primary(),h=u.sel.primIndex),t.altKey)n="rect",i||(c=new de(r,r)),r=$t(e,t,!0,!0),h=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?xe(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new de(Oo(r.line,0),me(u,Oo(r.line+1,0)));c=e.display.shift||u.extend?xe(u,c,g.anchor,g.head):g}else c=xe(u,c,r);i?-1==h?(h=f.length,Te(u,fe(f.concat([c]),h),{scroll:!1,origin:"*mouse"})):f.length>1&&f[h].empty()&&"single"==n&&!t.shiftKey?(Te(u,fe(f.slice(0,h).concat(f.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),d=u.sel):Se(u,h,c,El):(h=0,Te(u,new he([c],0),El),d=u.sel);var m=r,v=s.wrapper.getBoundingClientRect(),y=0,b=At(e,function(e){wi(e)?l(e):a(e)}),w=At(e,a);e.state.selectingText=w,Ll(document,"mousemove",b),Ll(document,"mouseup",w)}function Yt(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catc
 h(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Cl(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(l>s.bottom||!Mi(e,r))return bi(t);l-=s.top-a.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=a.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var h=ti(e.doc,l),d=e.options.gutters[u];return i(e,r,e,h,d,t),bi(t)}}}function Zt(e,t){return Yt(e,t,"gutterClick",!0,Ci)}function Qt(e){var t=this;if(tr(t),!ki(t,e)&&!Gt(t.display,e)){Cl(e),go&&(qo=+new Date);var r=$t(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,a=function(e,n){var a=new FileReader;a.onload=At(t,function(){if(o[n]=a.result,++l==i){r=me(t.doc,r);var e={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};kr(t.doc,e),Me(t.doc,pe(r,Ko(e)))}}),a.readAsText(e)},s=0;i>s;++s)a(n[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t
 .state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Mo?e.altKey:e.ctrlKey))var u=t.listSelections();if(Ne(t.doc,pe(r,r)),u)for(var s=0;s<u.length;++s)Hr(t.doc,"",u[s].anchor,u[s].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Jt(e,t){if(go&&(!e.state.draggingText||+new Date-qo<100))return void kl(t);if(!ki(e,t)&&!Gt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!wo)){var r=zi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",xo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),xo&&r.parentNode.removeChild(r)}}function er(e,t){var r=$t(e,t);if(r){var n=document.createDocumentFragment();Ie(e,r,n),e.display.dragCursor||(e.display.dragCursor=zi("div
 ",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),qi(e.display.dragCursor,n)}}function tr(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function rr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,ho||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),ho&&A(e),_e(e,100))}function nr(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,w(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function ir(e,t){var r=$o(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&Mo&&vo)e:for(var a=t.target,s=o.view;a!=l;a=a.parentNode)for(var u=0;u<s.length;u++)if(s[u]
 .node==a){e.display.currentWheelTarget=a;break e}if(n&&!ho&&!xo&&null!=Go)return i&&rr(e,Math.max(0,Math.min(l.scrollTop+i*Go,l.scrollHeight-l.clientHeight))),nr(e,Math.max(0,Math.min(l.scrollLeft+n*Go,l.scrollWidth-l.clientWidth))),Cl(t),void(o.wheelStartX=null);if(i&&null!=Go){var c=i*Go,h=e.doc.scrollTop,d=h+o.wrapper.clientHeight;0>c?h=Math.max(0,h+c-50):d=Math.min(e.doc.height,d+c+50),A(e,{top:h,bottom:d})}20>Uo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Go=(Go*Uo+r)/(Uo+1),++Uo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function or(e,t,r){if("string"==typeof t&&(t=ol[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Hl}finally{e.display.s
 hift=n,e.state.suppressEdits=!1}return i}function lr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=al(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&al(t,e.options.extraKeys,r,e)||al(t,e.options.keyMap,r,e)}function ar(e,t,r,n){var i=e.state.keySeq;if(i){if(sl(t))return"handled";jo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=lr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Ci(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(Cl(r),Fe(e)),i&&!o&&/\'$/.test(t)?(Cl(r),!0):!!o}function sr(e,t){var r=ul(t,!0);return r?t.shiftKey&&!e.state.keySeq?ar(e,"Shift-"+r,t,function(t){return or(e,t,!0)})||ar(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?or(e,t):void 0}):ar(e,r,t,function(t){return or(e,t)}):!1}function ur(e,t,r){return ar(e,"'"+r+"'",t,function(t){return or(e,t,!0)})}function cr(e){var t=this;if(t.curOp.focus=Ui(),!ki(t,e)){go&&11>mo&&27==e.keyCode&&(e.ret
 urnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=sr(t,e);xo&&(Vo=n?r:null,!n&&88==r&&!Zl&&(Mo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||hr(t)}}function hr(e){function t(e){18!=e.keyCode&&e.altKey||($l(r,"CodeMirror-crosshair"),Ml(document,"keyup",t),Ml(document,"mouseover",t))}var r=e.display.lineDiv;jl(r,"CodeMirror-crosshair"),Ll(document,"keyup",t),Ll(document,"mouseover",t)}function dr(e){16==e.keyCode&&(this.doc.sel.shift=!1),ki(this,e)}function fr(e){var t=this;if(!(Gt(t.display,e)||ki(t,e)||e.ctrlKey&&!e.altKey||Mo&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(xo&&r==Vo)return Vo=null,void Cl(e);if(!xo||e.which&&!(e.which<10)||!sr(t,e)){var i=String.fromCharCode(null==n?r:n);ur(t,e,i)||t.display.input.onKeyPress(e)}}}function pr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,mr(e))},100)}function gr(e){e.state.d
 elayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Tl(e,"focus",e),
-e.state.focused=!0,jl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),vo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Fe(e))}function mr(e){e.state.delayingBlurEvent||(e.state.focused&&(Tl(e,"blur",e),e.state.focused=!1,$l(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function vr(e,t){Gt(e.display,t)||yr(e,t)||e.display.input.onContextMenu(t)}function yr(e,t){return Mi(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Tl):!1}function br(e,t){if(Wo(e,t.from)<0)return e;if(Wo(e,t.to)<=0)return Ko(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Ko(t).ch-t.to.ch),Oo(r,n)}function xr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new de(br(i.anchor,t),br(i.head,t)))}return fe(r,e.sel.primIndex)}function wr(e,t
 ,r){return e.line==t.line?Oo(r.line,e.ch-t.ch+r.ch):Oo(r.line+(e.line-t.line),e.ch)}function Cr(e,t,r){for(var n=[],i=Oo(e.first,0),o=i,l=0;l<t.length;l++){var a=t[l],s=wr(a.from,i,o),u=wr(Ko(a),i,o);if(i=a.to,o=u,"around"==r){var c=e.sel.ranges[l],h=Wo(c.head,c.anchor)<0;n[l]=new de(h?u:s,h?s:u)}else n[l]=new de(s,s)}return new he(n,e.sel.primIndex)}function Sr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=me(e,t)),r&&(this.to=me(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Tl(e,"beforeChange",e,n),e.cm&&Tl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function kr(e,t,r){if(e.cm){if(!e.cm.curOp)return At(e.cm,kr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Mi(e,"beforeChange")||e.cm&&Mi(e.cm,"beforeChange"))||(t=Sr(e,t,!0))){var n=Do&&!r&&an(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)Lr(e,{from:n[i].fr
 om,to:n[i].to,text:i?[""]:t.text});else Lr(e,t)}}function Lr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Wo(t.from,t.to)){var r=xr(e,t);si(e,t,r,e.cm?e.cm.curOp.id:NaN),Nr(e,t,r,nn(e,t));var n=[];Kn(e,function(e,r){r||-1!=Di(n,e.history)||(yi(e.history,t),n.push(e.history)),Nr(e,t,null,nn(e,t))})}}function Mr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,a="undo"==t?i.undone:i.done,s=0;s<l.length&&(n=l[s],r?!n.ranges||n.equals(e.sel):n.ranges);s++);if(s!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(hi(n,a),r&&!n.equals(e.sel))return void Te(e,n,{clearRedo:!1});o=n}var u=[];hi(o,a),a.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Mi(e,"beforeChange")||e.cm&&Mi(e.cm,"beforeChange"),s=n.changes.length-1;s>=0;--s){var h=n.changes[s];if(h.origin=t,c&&!Sr(e,h,!1))return void(l.length=0);u.push(oi(e,h));var d=s?xr(e,h):Hi(l);Nr(e,h,d,ln(e,h)),!s&&e.cm&&e.cm.s
 crollIntoView({from:h.from,to:Ko(h)});var f=[];Kn(e,function(e,t){t||-1!=Di(f,e.history)||(yi(e.history,h),f.push(e.history)),Nr(e,h,null,ln(e,h))})}}}}function Tr(e,t){if(0!=t&&(e.first+=t,e.sel=new he(Ei(e.sel.ranges,function(e){return new de(Oo(e.anchor.line+t,e.anchor.ch),Oo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Wt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)It(e.cm,n,"gutter")}}function Nr(e,t,r,n){if(e.cm&&!e.cm.curOp)return At(e.cm,Nr)(e,t,r,n);if(t.to.line<e.first)return void Tr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Tr(e,i),t={from:Oo(e.first,0),to:Oo(t.to.line+i,t.to.ch),text:[Hi(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Oo(o,Yn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Zn(e,t.from,t.to),r||(r=xr(e,t)),e.cm?Ar(e.cm,t,n):$n(e,t,n),Ne(e,r,Dl)}}function Ar(e,t,r){var n=e.d
 oc,i=e.display,l=t.from,a=t.to,s=!1,u=l.line;e.options.lineWrapping||(u=ei(vn(Yn(n,l.line))),n.iter(u,a.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&Li(e),$n(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),_e(e,400);var c=t.text.length-(a.line-l.line)-1;t.full?Wt(e):l.line!=a.line||1!=t.text.length||Gn(e.doc,t)?Wt(e,l.line,a.line+1,c):It(e,l.line,"text");var d=Mi(e,"changes"),f=Mi(e,"change");if(f||d){var p={from:l,to:a,text:t.text,removed:t.removed,origin:t.origin};f&&Ci(e,"change",e,p),d&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Hr(e,t,r,n,i){if(n||(n=r),Wo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),kr(e,{from:r,to:n,text:t,origin:i})}function Dr(e,t){if(!ki(e,"scrollCursorI
 ntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!So){var o=zi("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-qe(e.display))+"px; height: "+(t.bottom-t.top+$e(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Er(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=dt(e,t),a=r&&r!=t?dt(e,r):l,s=Wr(e,Math.min(l.left,a.left),Math.min(l.top,a.top)-n,Math.max(l.left,a.left),Math.max(l.bottom,a.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=s.scrollTop&&(rr(e,s.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=s.scrollLeft&&(nr(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Or(e,t,r,n,i){var o=Wr(e,t,r,n,i);null!=o.scrollTop&&rr(e,o.scrollTop),null!=o.scrollLeft&&nr(e,o.scrollLeft)}
 function Wr(e,t,r,n,i){var o=e.display,l=vt(e.display);0>r&&(r=0);var a=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Ve(e),u={};i-r>s&&(i=r+s);var c=e.doc.height+Ue(o),h=l>r,d=i>c-l;if(a>r)u.scrollTop=h?0:r;else if(i>a+s){var f=Math.min(r,(d?c:i)-s);f!=a&&(u.scrollTop=f)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=je(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),m=n-t>g;return m&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(m?0:10)):n>g+p-3&&(u.scrollLeft=n+(m?0:10)-g),u}function Ir(e,t,r){(null!=t||null!=r)&&Fr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Pr(e){Fr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?Oo(t.line,t.ch-1):t,n=Oo(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}
 }function Fr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Wr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function _r(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,a=Yn(o,t),s=Wl(a.text,null,l);a.stateAfter&&(a.stateAfter=null);var u,c=a.text.match(/^\s*/)[0];if(n||/\S/.test(a.text)){if("smart"==r&&(u=o.mode.indent(i,a.text.slice(c.length),a.text),u==Hl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Wl(Yn(o,t-1).text,null,l):0:"add"==r?u=s+e.options.indentUnit:"subtract"==r?u=s-e.options.indentUnit:"number"==typeof r&&(u=s+r),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)d+=l,h+="	";if(u>d&&(h+=Ai(u-d)),h!=c)return Hr(o,h,Oo(t,0),Oo(t,c.length),"+input"),a.stateAfter=null,!0;for(var f=0;f<o.
 sel.ranges.length;f++){var p=o.sel.ranges[f];if(p.head.line==t&&p.head.ch<c.length){var d=Oo(t,c.length);Se(o,f,new de(d,d));break}}}function Br(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Yn(e,ge(e,t)):i=ei(t),null==i?null:(n(o,i)&&e.cm&&It(e.cm,i,r),o)}function zr(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Wo(o.from,Hi(n).to)<=0;){var l=n.pop();if(Wo(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Nt(e,function(){for(var t=n.length-1;t>=0;t--)Hr(e.doc,"",n[t].from,n[t].to,"+delete");Pr(e)})}function Rr(e,t,r,n,i){function o(){var t=a+r;return t<e.first||t>=e.first+e.size?h=!1:(a=t,c=Yn(e,t))}function l(e){var t=(i?uo:co)(c,s,r,!0);if(null==t){if(e||!o())return h=!1;s=i?(0>r?ro:to)(c):0>r?c.text.length:0}else s=t;return!0}var a=t.line,s=t.ch,u=r,c=Yn(e,a),h=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var d=null,f="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var m=c.text.c
 harAt(s)||"\n",v=Fi(m,p)?"w":f&&"\n"==m?"n":!f||/\s/.test(m)?null:"p";if(!f||g||v||(v="s"),d&&d!=v){0>r&&(r=1,l());break}if(v&&(d=v),r>0&&!l(!g))break}var y=Ee(e,Oo(a,s),u,!0);return h||(y.hitSide=!0),y}function qr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(a-(0>r?1.5:.5)*vt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var s=gt(e,l,i);if(!s.outside)break;if(0>r?0>=i:i>=o.height){s.hitSide=!0;break}i+=5*r}return s}function Ur(t,r,n,i){e.defaults[t]=r,n&&(Yo[t]=i?function(e,t,r){r!=Zo&&n(e,t,r)}:n)}function Gr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var a=o[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))t=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else{if(!/^s(hift)$/i.test(a))throw new Error("Unrecognized modifier name: "+a);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="
 Shift-"+e),e}function $r(e){return"string"==typeof e?ll[e]:e}function jr(e,t,r,n,i){if(n&&n.shared)return Vr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return At(e.cm,jr)(e,t,r,n,i);var o=new dl(e,i),l=Wo(t,r);if(n&&Ii(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=zi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(mn(e,t.line,t,r,o)||t.line!=r.line&&mn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Eo=!0}o.addToHistory&&si(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,s=t.line,u=e.cm;if(e.iter(s,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&vn(e)==u.display.maxLine&&(a=!0),o.collapsed&&s!=t.line&&Jn(e,0),en(e,new Zr(o,s==t.line?t.ch:null,s==r.line?r.ch:null)),++s}),o.collapsed&&e.iter(t.line,r.line+1,function(t){wn(e,t)&&Jn(t,0)}),o.clearOnE
 nter&&Ll(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Do=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++hl,o.atomic=!0),u){if(a&&(u.curOp.updateMaxLine=!0),o.collapsed)Wt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)It(u,c,"text");o.atomic&&He(u.doc),Ci(u,"markerAdded",u,o)}return o}function Vr(e,t,r,n,i){n=Ii(n),n.shared=!1;var o=[jr(e,t,r,n,i)],l=o[0],a=n.widgetNode;return Kn(e,function(e){a&&(n.widgetNode=a.cloneNode(!0)),o.push(jr(e,me(e,t),me(e,r),n,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;l=Hi(o)}),new fl(o,l)}function Kr(e){return e.findMarks(Oo(e.first,0),e.clipPos(Oo(e.lastLine())),function(e){return e.parent})}function Xr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Wo(o,l)){var a=jr(e,o,l,n.primary,n.primary.type);n.markers.push(a),a.parent=n}}}function Yr(e){for(var t=0;
 t<e.length;t++){var r=e[t],n=[r.primary.doc];Kn(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Di(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function Zr(e,t,r){this.marker=e,this.from=t,this.to=r}function Qr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function Jr(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function en(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function tn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(a||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new Zr(l,o.from,s?null:o.to))}}return n}function rn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(a||o.from==t&&"bookmark"==l.type&&(!r||o.
 marker.insertLeft)){var s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new Zr(l,s?null:o.from-t,null==o.to?null:o.to-t))}}return n}function nn(e,t){if(t.full)return null;var r=ye(e,t.from.line)&&Yn(e,t.from.line).markedSpans,n=ye(e,t.to.line)&&Yn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Wo(t.from,t.to),a=tn(r,i,l),s=rn(n,o,l),u=1==t.text.length,c=Hi(t.text).length+(u?i:0);if(a)for(var h=0;h<a.length;++h){var d=a[h];if(null==d.to){var f=Qr(s,d.marker);f?u&&(d.to=null==f.to?null:f.to+c):d.to=i}}if(s)for(var h=0;h<s.length;++h){var d=s[h];if(null!=d.to&&(d.to+=c),null==d.from){var f=Qr(a,d.marker);f||(d.from=c,u&&(a||(a=[])).push(d))}else d.from+=c,u&&(a||(a=[])).push(d)}a&&(a=on(a)),s&&s!=a&&(s=on(s));var p=[a];if(!u){var g,m=t.text.length-2;if(m>0&&a)for(var h=0;h<a.length;++h)null==a[h].to&&(g||(g=[])).push(new Zr(a[h].marker,null,null));for(var h=0;m>h;++h)p.push(g);p.push(s)}return p}function on(e){for(var t=0;t<e.length;
 ++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function ln(e,t){var r=pi(e,t),n=nn(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var a=0;a<l.length;++a){for(var s=l[a],u=0;u<o.length;++u)if(o[u].marker==s.marker)continue e;o.push(s)}else l&&(r[i]=l)}return r}function an(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Di(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],a=l.find(0),s=0;s<i.length;++s){var u=i[s];if(!(Wo(u.to,a.from)<0||Wo(u.from,a.to)>0)){var c=[s,1],h=Wo(u.from,a.from),d=Wo(u.to,a.to);(0>h||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:a.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:a.to,to:u.to}),i.splice.apply(i,c),s+=c.length-1}}return i}function sn(e){var t=e.markedSpans;if(t){fo
 r(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function un(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function cn(e){return e.inclusiveLeft?-1:0}function hn(e){return e.inclusiveRight?1:0}function dn(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Wo(n.from,i.from)||cn(e)-cn(t);if(o)return-o;var l=Wo(n.to,i.to)||hn(e)-hn(t);return l?l:t.id-e.id}function fn(e,t){var r,n=Eo&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||dn(r,i.marker)<0)&&(r=i.marker);return r}function pn(e){return fn(e,!0)}function gn(e){return fn(e,!1)}function mn(e,t,r,n,i){var o=Yn(e,t),l=Eo&&o.markedSpans;if(l)for(var a=0;a<l.length;++a){var s=l[a];if(s.marker.collapsed){var u=s.marker.find(0),c=Wo(u.from,r)||cn(s.marker)-cn(i),h=Wo(u.to,n)||hn(s.marker)-hn(i);if(!(c>=0&&0>=h||0>=c&&h>=0)&&(0>=c&&(Wo(u.to,r)>0||s.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&
 &(Wo(u.from,n)<0||s.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function vn(e){for(var t;t=pn(e);)e=t.find(-1,!0).line;return e}function yn(e){for(var t,r;t=gn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function bn(e,t){var r=Yn(e,t),n=vn(r);return r==n?t:ei(n)}function xn(e,t){if(t>e.lastLine())return t;var r,n=Yn(e,t);if(!wn(e,n))return t;for(;r=gn(n);)n=r.find(1,!0).line;return ei(n)+1}function wn(e,t){var r=Eo&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&Cn(e,t,n))return!0}}function Cn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return Cn(e,n.line,Qr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&Cn(e,t,i))
 return!0}function Sn(e,t,r){ri(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ir(e,null,r)}function kn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!ql(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),qi(t.display.measure,zi("div",[e.node],null,r))}return e.height=e.node.offsetHeight}function Ln(e,t,r,n){var i=new pl(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Br(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!wn(e,t)){var n=ri(t)<e.scrollTop;Jn(t,t.height+kn(i)),n&&Ir(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Mn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),sn(e),un(e,r);var i=n?n(e):1;i!=e.height&&Jn(e,i)}fu
 nction Tn(e){e.parent=null,sn(e)}function Nn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function An(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Hn(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Dn(e,t,r,n){function i(e){return{start:h.start,end:h.pos,string:h.current(),type:o||null,state:e?nl(l.mode,c):c}}var o,l=e.doc,a=l.mode;t=me(l,t);var s,u=Yn(l,t.line),c=Re(e,t.line,r),h=new cl(u.text,e.options.tabSize);for(n&&(s=[]);(n||h.pos<t.ch)&&!h.eol();)h.start=h.pos,o=Hn(a,h,c),n&&s.push(i(!0));return n?s:i()}function En(e,t,r,n,i,o,l){var a=
 r.flattenSpans;null==a&&(a=e.options.flattenSpans);var s,u=0,c=null,h=new cl(t,e.options.tabSize),d=e.options.addModeClass&&[null];for(""==t&&Nn(An(r,n),o);!h.eol();){if(h.pos>e.options.maxHighlightLength?(a=!1,l&&In(e,t,n,h.pos),h.pos=t.length,s=null):s=Nn(Hn(r,h,n,d),o),d){var f=d[0].name;f&&(s="m-"+(s?f+" "+s:f))}if(!a||c!=s){for(;u<h.start;)u=Math.min(h.start,u+5e4),i(u,c);c=s}h.start=h.pos}for(;u<h.pos;){var p=Math.min(h.pos,u+5e4);i(p,c),u=p}}function On(e,t,r,n){var i=[e.state.modeGen],o={};En(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var a=e.state.overlays[l],s=1,u=0;En(e,t.text,a.mode,!0,function(e,t){for(var r=s;e>u;){var n=i[s];n>e&&i.splice(s,1,e,i[s+1],n),s+=2,u=Math.min(e,n)}if(t)if(a.opaque)i.splice(r,s-r,e,"cm-overlay "+t),s=r+2;else for(;s>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Wn(e,t,r){if(!t.styles||t.styles[0]!=e.state.mode
 Gen){var n=Re(e,ei(t)),i=On(e,t,t.text.length>e.options.maxHighlightLength?nl(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function In(e,t,r,n){var i=e.doc.mode,o=new cl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&An(i,r);!o.eol();)Hn(i,o,r),o.start=o.pos}function Pn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?vl:ml;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Fn(e,t){var r=zi("span",null,null,vo?"padding-right: .1px":null),n={pre:zi("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,splitSpaces:(go||vo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Bn,Yi(e.display.measure)&&(o=ni(l))&&(n.addToken=Rn(n.addToken,o)),n.map=[];var a=t!=e.display.externalMeasured&&ei(l);Un(l,n,Wn(e,l,a)),l.styleClasses&&(l.styleClasses.bgClass&&(n.
 bgClass=$i(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=$i(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Xi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return vo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Tl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=$i(n.pre.className,n.textClass||"")),n}function _n(e){var t=zi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Bn(e,t,r,n,i,o,l){if(t){var a=e.splitSpaces?t.replace(/ {3,}/g,zn):t,s=e.cm.state.specialChars,u=!1;if(s.test(t))for(var c=document.createDocumentFragment(),h=0;;){s.lastIndex=h;var d=s.exec(t),f=d?d.index-h:t.length-h;if(f){var p=document.createTextNode(a.slice(h,h+f));go&&9
 >mo?c.appendChild(zi("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+f,p),e.col+=f,e.pos+=f}if(!d)break;if(h+=f+1,"	"==d[0]){var g=e.cm.options.tabSize,m=g-e.col%g,p=c.appendChild(zi("span",Ai(m),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text","	"),e.col+=m}else if("\r"==d[0]||"\n"==d[0]){var p=c.appendChild(zi("span","\r"==d[0]?"␍":"␤","cm-invalidchar"));p.setAttribute("cm-text",d[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(d[0]);p.setAttribute("cm-text",d[0]),go&&9>mo?c.appendChild(zi("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(a);e.map.push(e.pos,e.pos+t.length,c),go&&9>mo&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var v=r||"";n&&(v+=n),i&&(v+=i);var y=zi("span",[c],v,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function zn(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function Rn(e,t){return funct
 ion(r,n,i,o,l,a,s){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var h=0;h<t.length;h++){var d=t[h];if(d.to>u&&d.from<=u)break}if(d.to>=c)return e(r,n,i,o,l,a,s);e(r,n.slice(0,d.to-u),i,o,null,a,s),o=null,n=n.slice(d.to-u),u=d.to}}}function qn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Un(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,a,s,u,c,h,d,f=i.length,p=0,g=1,m="",v=0;;){if(v==p){s=u=c=h=a="",d=null,v=1/0;for(var y=[],b=0;b<n.length;++b){var x=n[b],w=x.marker;"bookmark"==w.type&&x.from==p&&w.widgetNode?y.push(w):x.from<=p&&(null==x.to||x.to>p||w.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,u=""),w.className&&(s+=" "+w.className),w.css&&(a=w.css),w.startStyle&&x.from==p&&(
 c+=" "+w.startStyle),w.endStyle&&x.to==v&&(u+=" "+w.endStyle),w.title&&!h&&(h=w.title),w.collapsed&&(!d||dn(d.marker,w)<0)&&(d=x)):x.from>p&&v>x.from&&(v=x.from)}if(d&&(d.from||0)==p){if(qn(t,(null==d.to?f+1:d.to)-p,d.marker,null==d.from),null==d.to)return;d.to==p&&(d=!1)}if(!d&&y.length)for(var b=0;b<y.length;++b)qn(t,0,y[b])}if(p>=f)break;for(var C=Math.min(f,v);;){if(m){var S=p+m.length;if(!d){var k=S>C?m.slice(0,C-p):m;t.addToken(t,k,l?l+s:s,c,p+k.length==v?u:"",h,a)}if(S>=C){m=m.slice(C-p),p=C;break}p=S,c=""}m=i.slice(o,o=r[g++]),l=Pn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Pn(r[g+1],t.cm.options))}function Gn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Hi(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function $n(e,t,r,n){function i(e){return r?r[e]:null}function

<TRUNCATED>