UNPKG

afd

Version:

Accrual Failure Detector

1,027 lines (1,026 loc) 149 kB
window.CodeMirror = function() { "use strict"; function t(i, o) { if (!(this instanceof t)) return new t(i, o); this.options = o = o || {}; for (var a in ti) !o.hasOwnProperty(a) && ti.hasOwnProperty(a) && (o[a] = ti[a]); h(o); var u = this.display = e(i); u.wrapper.CodeMirror = this, l(this), o.autofocus && !$r && J(this), this.view = n(new An([ new Mn([ yn("", null, q(u)) ]) ])), this.nextOpId = 0, r(this), s(this), o.lineWrapping && (this.display.wrapper.className += " CodeMirror-wrap"), this.setValue(o.value || ""), Er && setTimeout(or(Q, this, !0), 20), this.view.history = jn(), ee(this); var c; try { c = document.activeElement == u.input; } catch (f) {} c || o.autofocus && !$r ? setTimeout(or(me, this), 20) : ye(this), Y(this, function() { for (var t in Jr) Jr.propertyIsEnumerable(t) && Jr[t](this, o[t], ei); for (var e = 0; oi.length > e; ++e) oi[e](this); })(); } function e(t) { var e = {}, n = e.input = lr("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none;"); n.setAttribute("wrap", "off"), n.setAttribute("autocorrect", "off"), n.setAttribute("autocapitalize", "off"), e.inputDiv = lr("div", [ n ], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"), e.scrollbarH = lr("div", [ lr("div", null, null, "height: 1px") ], "CodeMirror-hscrollbar"), e.scrollbarV = lr("div", [ lr("div", null, null, "width: 1px") ], "CodeMirror-vscrollbar"), e.scrollbarFiller = lr("div", null, "CodeMirror-scrollbar-filler"), e.lineDiv = lr("div"), e.selectionDiv = lr("div", null, null, "position: relative; z-index: 1"), e.cursor = lr("pre", " ", "CodeMirror-cursor"), e.otherCursor = lr("pre", " ", "CodeMirror-cursor CodeMirror-secondarycursor"), e.measure = lr("div", null, "CodeMirror-measure"), e.lineSpace = lr("div", [ e.measure, e.selectionDiv, e.lineDiv, e.cursor, e.otherCursor ], null, "position: relative; outline: none"), e.mover = lr("div", [ lr("div", [ e.lineSpace ], "CodeMirror-lines") ], null, "position: relative"), e.sizer = lr("div", [ e.mover ], "CodeMirror-sizer"), e.heightForcer = lr("div", " ", null, "position: absolute; height: " + ci + "px"), e.gutters = lr("div", null, "CodeMirror-gutters"), e.lineGutter = null; var r = lr("div", [ e.sizer, e.heightForcer, e.gutters ], null, "position: relative; min-height: 100%"); return e.scroller = lr("div", [ r ], "CodeMirror-scroll"), e.scroller.setAttribute("tabIndex", "-1"), e.wrapper = lr("div", [ e.inputDiv, e.scrollbarH, e.scrollbarV, e.scrollbarFiller, e.scroller ], "CodeMirror"), Br && (e.gutters.style.zIndex = -1, e.scroller.style.paddingRight = 0), t.appendChild ? t.appendChild(e.wrapper) : t(e.wrapper), qr && (n.style.width = "0px"), Hr || (e.scroller.draggable = !0), zr ? (e.inputDiv.style.height = "1px", e.inputDiv.style.position = "absolute") : Br && (e.scrollbarH.style.minWidth = e.scrollbarV.style.minWidth = "18px"), e.viewOffset = e.showingFrom = e.showingTo = e.lastSizeC = 0, e.lineNumWidth = e.lineNumInnerWidth = e.lineNumChars = null, e.prevInput = "", e.alignWidgets = !1, e.pollingFast = !1, e.poll = new Qn(), e.draggingText = !1, e.cachedCharWidth = e.cachedTextHeight = null, e.measureLineCache = [], e.measureLineCachePos = 0, e.inaccurateSelection = !1, e.pasteIncoming = !1, e; } function n(t) { var e = { line: 0, ch: 0 }; return { doc: t, frontier: 0, highlight: new Qn(), sel: { from: e, to: e, head: e, anchor: e, shift: !1, extend: !1 }, scrollTop: 0, scrollLeft: 0, overwrite: !1, focused: !1, maxLine: En(t, 0), maxLineLength: 0, maxLineChanged: !1, suppressEdits: !1, goalColumn: null, cantEdit: !1, keyMaps: [] }; } function r(e) { var n = e.view.doc; e.view.mode = t.getMode(e.options, e.options.mode), n.iter(0, n.size, function(t) { t.stateAfter = null; }), e.view.frontier = 0, N(e, 100); } function i(t) { var e = t.view.doc, n = q(t.display); if (t.options.lineWrapping) { t.display.wrapper.className += " CodeMirror-wrap"; var r = t.display.scroller.clientWidth / $(t.display) - 3; e.iter(0, e.size, function(t) { if (0 != t.height) { var e = Math.ceil(t.text.length / r) || 1; 1 != e && Bn(t, e * n); } }), t.display.sizer.style.minWidth = ""; } else t.display.wrapper.className = t.display.wrapper.className.replace(" CodeMirror-wrap", ""), c(t.view), e.iter(0, e.size, function(t) { 0 != t.height && Bn(t, n); }); U(t, 0, e.size), j(t), setTimeout(function() { f(t.display, t.view.doc.height); }, 100); } function o(t) { var e = ai[t.options.keyMap].style; t.display.wrapper.className = t.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") + (e ? " cm-keymap-" + e : ""); } function s(t) { t.display.wrapper.className = t.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + t.options.theme.replace(/(^|\s)\s*/g, " cm-s-"), j(t); } function a(t) { l(t), y(t, !0); } function l(t) { var e = t.display.gutters, n = t.options.gutters; ur(e); for (var r = 0; n.length > r; ++r) { var i = n[r], o = e.appendChild(lr("div", null, "CodeMirror-gutter " + i)); "CodeMirror-linenumbers" == i && (t.display.lineGutter = o, o.style.width = (t.display.lineNumWidth || 1) + "px"); } e.style.display = r ? "" : "none"; } function u(t, e) { if (0 == e.height) return 0; for (var n, r = e.text.length, i = e; n = ln(i); ) { var o = n.find(); i = En(t, o.from.line), r += o.from.ch - o.to.ch; } for (i = e; n = un(i); ) { var o = n.find(); r -= i.text.length - o.from.ch, i = En(t, o.to.line), r += i.text.length - o.to.ch; } return r; } function c(t) { t.maxLine = En(t.doc, 0), t.maxLineLength = u(t.doc, t.maxLine), t.maxLineChanged = !0, t.doc.iter(1, t.doc.size, function(e) { var n = u(t.doc, e); n > t.maxLineLength && (t.maxLineLength = n, t.maxLine = e); }); } function h(t) { for (var e = !1, n = 0; t.gutters.length > n; ++n) "CodeMirror-linenumbers" == t.gutters[n] && (t.lineNumbers ? e = !0 : t.gutters.splice(n--, 1)); !e && t.lineNumbers && t.gutters.push("CodeMirror-linenumbers"); } function f(t, e) { var n = e + 2 * B(t); t.sizer.style.minHeight = t.heightForcer.style.top = n + "px"; var r = Math.max(n, t.scroller.scrollHeight), i = t.scroller.scrollWidth > t.scroller.clientWidth, o = r > t.scroller.clientHeight; o ? (t.scrollbarV.style.display = "block", t.scrollbarV.style.bottom = i ? fr(t.measure) + "px" : "0", t.scrollbarV.firstChild.style.height = r - t.scroller.clientHeight + t.scrollbarV.clientHeight + "px") : t.scrollbarV.style.display = "", i ? (t.scrollbarH.style.display = "block", t.scrollbarH.style.right = o ? fr(t.measure) + "px" : "0", t.scrollbarH.firstChild.style.width = t.scroller.scrollWidth - t.scroller.clientWidth + t.scrollbarH.clientWidth + "px") : t.scrollbarH.style.display = "", i && o ? (t.scrollbarFiller.style.display = "block", t.scrollbarFiller.style.height = t.scrollbarFiller.style.width = fr(t.measure) + "px") : t.scrollbarFiller.style.display = "", Wr && 0 === fr(t.measure) && (t.scrollbarV.style.minWidth = t.scrollbarH.style.minHeight = Pr ? "18px" : "12px"); } function p(t, e, n) { var r = t.scroller.scrollTop, i = t.wrapper.clientHeight; "number" == typeof n ? r = n : n && (r = n.top, i = n.bottom - n.top), r = Math.floor(r - B(t)); var o = Math.ceil(r + i); return { from: Hn(e, r), to: Hn(e, o) }; } function d(t) { var e = t.display; if (e.alignWidgets || e.gutters.firstChild) { for (var n = m(e) - e.scroller.scrollLeft + t.view.scrollLeft, r = e.gutters.offsetWidth, i = n + "px", o = e.lineDiv.firstChild; o; o = o.nextSibling) if (o.alignable) for (var s = 0, a = o.alignable; a.length > s; ++s) a[s].style.left = i; e.gutters.style.left = n + r + "px"; } } function g(t) { if (!t.options.lineNumbers) return !1; var e = t.view.doc, n = v(t.options, e.size - 1), r = t.display; if (n.length != r.lineNumChars) { var i = r.measure.appendChild(lr("div", [ lr("div", n) ], "CodeMirror-linenumber CodeMirror-gutter-elt")), o = i.firstChild.offsetWidth, s = i.offsetWidth - o; return r.lineGutter.style.width = "", r.lineNumInnerWidth = Math.max(o, r.lineGutter.offsetWidth - s), r.lineNumWidth = r.lineNumInnerWidth + s, r.lineNumChars = r.lineNumInnerWidth ? n.length : -1, r.lineGutter.style.width = r.lineNumWidth + "px", !0; } return !1; } function v(t, e) { return t.lineNumberFormatter(e + t.firstLineNumber) + ""; } function m(t) { return t.scroller.getBoundingClientRect().left - t.sizer.getBoundingClientRect().left; } function y(t, e, n) { var r = t.display.showingFrom, i = t.display.showingTo, o = x(t, e, n); return o && (Kn(t, t, "update", t), (t.display.showingFrom != r || t.display.showingTo != i) && Kn(t, t, "viewportChange", t, t.display.showingFrom, t.display.showingTo)), _(t), f(t.display, t.view.doc.height), o; } function x(t, e, n) { var r = t.display, i = t.view.doc; if (!r.wrapper.clientWidth) return r.showingFrom = r.showingTo = r.viewOffset = 0, void 0; var o = p(r, i, n); if (!(e !== !0 && 0 == e.length && o.from > r.showingFrom && o.to < r.showingTo)) { if (e && g(t) && (e = !0), r.sizer.style.marginLeft = r.scrollbarH.style.left = r.gutters.offsetWidth + "px", e !== !0 && Yr) for (var s = 0; e.length > s; ++s) for (var a, l = e[s]; a = ln(En(i, l.from)); ) { var u = a.find().from.line; l.diff && (l.diff -= l.from - u), l.from = u; } var c = e === !0 ? 0 : 1/0; if (t.options.lineNumbers && e && e !== !0) for (var s = 0; e.length > s; ++s) if (e[s].diff) { c = e[s].from; break; } var u = Math.max(o.from - t.options.viewportMargin, 0), h = Math.min(i.size, o.to + t.options.viewportMargin); if (u > r.showingFrom && 20 > u - r.showingFrom && (u = r.showingFrom), r.showingTo > h && 20 > r.showingTo - h && (h = Math.min(i.size, r.showingTo)), Yr) for (u = Dn(cn(i, En(i, u))); i.size > h && hn(En(i, h)); ) ++h; for (var f = e === !0 ? [] : b([ { from: r.showingFrom, to: r.showingTo } ], e), d = 0, s = 0; f.length > s; ++s) { var v = f[s]; u > v.from && (v.from = u), v.to > h && (v.to = h), v.from >= v.to ? f.splice(s--, 1) : d += v.to - v.from; } if (d != h - u || u != r.showingFrom || h != r.showingTo) { f.sort(function(t, e) { return t.from - e.from; }), .7 * (h - u) > d && (r.lineDiv.style.display = "none"), C(t, u, h, f, c), r.lineDiv.style.display = ""; var m = u != r.showingFrom || h != r.showingTo || r.lastSizeC != r.wrapper.clientHeight; m && (r.lastSizeC = r.wrapper.clientHeight), r.showingFrom = u, r.showingTo = h, N(t, 100); for (var y, x = r.lineDiv.offsetTop, w = r.lineDiv.firstChild; w; w = w.nextSibling) if (w.lineObj) { if (Br) { var k = w.offsetTop + w.offsetHeight; y = k - x, x = k; } else { var _ = w.getBoundingClientRect(); y = _.bottom - _.top; } var S = w.lineObj.height - y; 2 > y && (y = q(r)), (S > .001 || -.001 > S) && Bn(w.lineObj, y); } return r.viewOffset = Fn(t, En(i, u)), r.mover.style.top = r.viewOffset + "px", !0; } } } function b(t, e) { for (var n = 0, r = e.length || 0; r > n; ++n) { for (var i = e[n], o = [], s = i.diff || 0, a = 0, l = t.length; l > a; ++a) { var u = t[a]; i.to <= u.from && i.diff ? o.push({ from: u.from + s, to: u.to + s }) : i.to <= u.from || i.from >= u.to ? o.push(u) : (i.from > u.from && o.push({ from: u.from, to: i.from }), i.to < u.to && o.push({ from: i.to + s, to: u.to + s })); } t = o; } return t; } function w(t) { for (var e = t.display, n = {}, r = {}, i = e.gutters.firstChild, o = 0; i; i = i.nextSibling, ++o) n[t.options.gutters[o]] = i.offsetLeft, r[t.options.gutters[o]] = i.offsetWidth; return { fixedPos: m(e), gutterTotalWidth: e.gutters.offsetWidth, gutterLeft: n, gutterWidth: r, wrapperWidth: e.wrapper.clientWidth }; } function C(t, e, n, r, i) { function o(e) { var n = e.nextSibling; return Hr && Vr && t.display.currentWheelTarget == e ? (e.style.display = "none", e.lineObj = null) : u.removeChild(e), n; } var s = w(t), a = t.display, l = t.options.lineNumbers; r.length || Er || Hr && t.display.currentWheelTarget || ur(a.lineDiv); var u = a.lineDiv, c = u.firstChild, h = r.shift(), f = e; for (t.view.doc.iter(e, n, function(e) { if (h && h.to == f && (h = r.shift()), hn(e)) 0 != e.height && Bn(e, 0); else if (h && f >= h.from && h.to > f) { for (;c.lineObj != e; ) c = o(c); l && f >= i && c.lineNumber && hr(c.lineNumber, v(t.options, f)), c = c.nextSibling; } else { var n = k(t, e, f, s); u.insertBefore(n, c), n.lineObj = e; } ++f; }); c; ) c = o(c); } function k(t, e, n, r) { var i = _n(t, e), o = e.gutterMarkers, s = t.display; if (!(t.options.lineNumbers || o || e.bgClass || e.wrapClass || e.widgets && e.widgets.length)) return i; var a = lr("div", null, e.wrapClass, "position: relative"); if (t.options.lineNumbers || o) { var l = a.appendChild(lr("div", null, null, "position: absolute; left: " + r.fixedPos + "px")); if (a.alignable = [ l ], !t.options.lineNumbers || o && o["CodeMirror-linenumbers"] || (a.lineNumber = l.appendChild(lr("div", v(t.options, n), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + r.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + s.lineNumInnerWidth + "px"))), o) for (var u = 0; t.options.gutters.length > u; ++u) { var c = t.options.gutters[u], h = o.hasOwnProperty(c) && o[c]; h && l.appendChild(lr("div", [ h ], "CodeMirror-gutter-elt", "left: " + r.gutterLeft[c] + "px; width: " + r.gutterWidth[c] + "px")); } } if (e.bgClass && a.appendChild(lr("div", " ", e.bgClass + " CodeMirror-linebackground")), a.appendChild(i), e.widgets) for (var f = 0, p = e.widgets; p.length > f; ++f) { var d = p[f], g = lr("div", [ d.node ], "CodeMirror-linewidget"); if (g.widget = d, d.noHScroll) { (a.alignable || (a.alignable = [])).push(g); var m = r.wrapperWidth; g.style.left = r.fixedPos + "px", d.coverGutter || (m -= r.gutterTotalWidth, g.style.paddingLeft = r.gutterTotalWidth + "px"), g.style.width = m + "px"; } d.coverGutter && (g.style.zIndex = 5, g.style.position = "relative", d.noHScroll || (g.style.marginLeft = -r.gutterTotalWidth + "px")), d.above ? a.insertBefore(g, t.options.lineNumbers && 0 != e.height ? l : i) : a.appendChild(g); } return Br && (a.style.zIndex = 2), a; } function _(t) { var e = t.display, n = Se(t.view.sel.from, t.view.sel.to); n || t.options.showCursorWhenSelecting ? S(t) : e.cursor.style.display = e.otherCursor.style.display = "none", n ? e.selectionDiv.style.display = "none" : T(t); var r = W(t, t.view.sel.head, "div"), i = e.wrapper.getBoundingClientRect(), o = e.lineDiv.getBoundingClientRect(); e.inputDiv.style.top = Math.max(0, Math.min(e.wrapper.clientHeight - 10, r.top + o.top - i.top)) + "px", e.inputDiv.style.left = Math.max(0, Math.min(e.wrapper.clientWidth - 10, r.left + o.left - i.left)) + "px"; } function S(t) { var e = t.display, n = W(t, t.view.sel.head, "div"); e.cursor.style.left = n.left + "px", e.cursor.style.top = n.top + "px", e.cursor.style.height = Math.max(0, n.bottom - n.top) * t.options.cursorHeight + "px", e.cursor.style.display = "", n.other ? (e.otherCursor.style.display = "", e.otherCursor.style.left = n.other.left + "px", e.otherCursor.style.top = n.other.top + "px", e.otherCursor.style.height = .85 * (n.other.bottom - n.other.top) + "px") : e.otherCursor.style.display = "none"; } function T(t) { function e(t, e, n, r) { 0 > e && (e = 0), s.appendChild(lr("div", null, "CodeMirror-selected", "position: absolute; left: " + t + "px; top: " + e + "px; width: " + (null == n ? a - t : n) + "px; height: " + (r - e) + "px")); } function n(n, r, o, s) { function u(e) { return z(t, { line: n, ch: e }, "div", c); } var c = En(i, n), h = c.text.length, f = s ? 1/0 : -1/0; return dr(On(c), r || 0, null == o ? h : o, function(t, n, i) { var c = u("rtl" == i ? n - 1 : t), p = u("rtl" == i ? t : n - 1), d = c.left, g = p.right; p.top - c.top > 3 && (e(d, c.top, null, c.bottom), d = l, c.bottom < p.top && e(d, c.bottom, null, p.top)), null == o && n == h && (g = a), null == r && 0 == t && (d = l), f = s ? Math.min(p.top, f) : Math.max(p.bottom, f), l + 1 > d && (d = l), e(d, p.top, g - d, p.bottom); }), f; } var r = t.display, i = t.view.doc, o = t.view.sel, s = document.createDocumentFragment(), a = r.lineSpace.offsetWidth, l = D(t.display); if (o.from.line == o.to.line) n(o.from.line, o.from.ch, o.to.ch); else { for (var u, c, h = En(i, o.from.line), f = h, p = [ o.from.line, o.from.ch ]; u = un(f); ) { var d = u.find(); if (p.push(d.from.ch, d.to.line, d.to.ch), d.to.line == o.to.line) { p.push(o.to.ch), c = !0; break; } f = En(i, d.to.line); } if (c) for (var g = 0; p.length > g; g += 3) n(p[g], p[g + 1], p[g + 2]); else { var v, m, y = En(i, o.to.line); v = o.from.ch ? n(o.from.line, o.from.ch, null, !1) : Fn(t, h) - r.viewOffset, m = o.to.ch ? n(o.to.line, ln(y) ? null : 0, o.to.ch, !0) : Fn(t, y) - r.viewOffset, m > v && e(l, v, null, m); } } cr(r.selectionDiv, s), r.selectionDiv.style.display = ""; } function L(t) { var e = t.display; clearInterval(e.blinker); var n = !0; e.cursor.style.visibility = e.otherCursor.style.visibility = "", e.blinker = setInterval(function() { e.cursor.offsetHeight && (e.cursor.style.visibility = e.otherCursor.style.visibility = (n = !n) ? "" : "hidden"); }, t.options.cursorBlinkRate); } function N(t, e) { t.view.frontier < t.display.showingTo && t.view.highlight.set(e, or(M, t)); } function M(t) { var e = t.view, n = e.doc; if (!(e.frontier >= t.display.showingTo)) { var r, i = +new Date() + t.options.workTime, o = Ve(e.mode, E(t, e.frontier)), s = []; n.iter(e.frontier, Math.min(n.size, t.display.showingTo + 500), function(n) { return e.frontier >= t.display.showingFrom ? (wn(t, n, o) && e.frontier >= t.display.showingFrom && (r && r.end == e.frontier ? r.end++ : s.push(r = { start: e.frontier, end: e.frontier + 1 })), n.stateAfter = Ve(e.mode, o)) : (Cn(t, n, o), n.stateAfter = 0 == e.frontier % 5 ? Ve(e.mode, o) : null), ++e.frontier, +new Date() > i ? (N(t, t.options.workDelay), !0) : void 0; }), s.length && Y(t, function() { for (var t = 0; s.length > t; ++t) U(this, s[t].start, s[t].end); })(); } } function A(t, e) { for (var n, r, i = t.view.doc, o = e, s = e - 100; o > s; --o) { if (0 == o) return 0; var a = En(i, o - 1); if (a.stateAfter) return o; var l = Jn(a.text, null, t.options.tabSize); (null == r || n > l) && (r = o - 1, n = l); } return r; } function E(t, e) { var n = t.view, r = A(t, e), i = r && En(n.doc, r - 1).stateAfter; return i = i ? Ve(n.mode, i) : Xe(n.mode), n.doc.iter(r, e, function(o) { Cn(t, o, i); var s = r == e - 1 || 0 == r % 5 || r >= n.showingFrom && n.showingTo > r; o.stateAfter = s ? Ve(n.mode, i) : null, ++r; }), i; } function B(t) { return t.lineSpace.offsetTop; } function D(t) { var e = cr(t.measure, lr("pre")).appendChild(lr("span", "x")); return e.offsetLeft; } function H(t, e, n, r) { for (var r = r || F(t, e), i = -1, o = n; ;o += i) { var s = r[o]; if (s) break; 0 > i && 0 == o && (i = 1); } return { left: n > o ? s.right : s.left, right: o > n ? s.left : s.right, top: s.top, bottom: s.bottom }; } function F(t, e) { for (var n = t.display, r = t.display.measureLineCache, i = 0; r.length > i; ++i) { var o = r[i]; if (o.text == e.text && o.markedSpans == e.markedSpans && n.scroller.clientWidth == o.width) return o.measure; } var s = O(t, e), o = { text: e.text, width: n.scroller.clientWidth, markedSpans: e.markedSpans, measure: s }; return 16 == r.length ? r[++n.measureLineCachePos % 16] = o : r.push(o), s; } function O(t, e) { var n = t.display, r = ir(e.text.length), i = _n(t, e, r); if (Er && !Br && !t.options.lineWrapping && i.childNodes.length > 100) { for (var o = document.createDocumentFragment(), s = 10, a = i.childNodes.length, l = 0, u = Math.ceil(a / s); u > l; ++l) { for (var c = lr("div", null, null, "display: inline-block"), h = 0; s > h && a; ++h) c.appendChild(i.firstChild), --a; o.appendChild(c); } i.appendChild(o); } cr(n.measure, i); for (var f, p = n.lineDiv.getBoundingClientRect(), d = [], g = ir(e.text.length), v = i.offsetHeight, l = 0; r.length > l; ++l) if (f = r[l]) { for (var m = f.getBoundingClientRect(), y = Math.max(0, m.top - p.top), x = Math.min(m.bottom - p.top, v), h = 0; d.length > h; h += 2) { var b = d[h], w = d[h + 1]; if (!(b > x || y > w) && (y >= b && w >= x || b >= y && x >= w || Math.min(x, w) - Math.max(y, b) >= x - y >> 1)) { d[h] = Math.min(y, b), d[h + 1] = Math.max(x, w); break; } } h == d.length && d.push(y, x), g[l] = { left: m.left - p.left, right: m.right - p.left, top: h }; } for (var f, l = 0; g.length > l; ++l) if (f = g[l]) { var C = f.top; f.top = d[C], f.bottom = d[C + 1]; } return g; } function j(t) { t.display.measureLineCache.length = t.display.measureLineCachePos = 0, t.display.cachedCharWidth = t.display.cachedTextHeight = null, t.view.maxLineChanged = !0; } function I(t, e, n, r) { if (e.widgets) for (var i = 0; e.widgets.length > i; ++i) if (e.widgets[i].above) { var o = e.widgets[i].node.offsetHeight; n.top += o, n.bottom += o; } if ("line" == r) return n; r || (r = "local"); var s = Fn(t, e); if ("local" != r && (s -= t.display.viewOffset), "page" == r) { var a = t.display.lineSpace.getBoundingClientRect(); s += a.top + (window.pageYOffset || (document.documentElement || document.body).scrollTop); var l = a.left + (window.pageXOffset || (document.documentElement || document.body).scrollLeft); n.left += l, n.right += l; } return n.top += s, n.bottom += s, n; } function z(t, e, n, r) { return r || (r = En(t.view.doc, e.line)), I(t, r, H(t, r, e.ch), n); } function W(t, e, n, r, i) { function o(e, o) { var s = H(t, r, e, i); return o ? s.left = s.right : s.right = s.left, I(t, r, s, n); } r = r || En(t.view.doc, e.line), i || (i = F(t, r)); var s = On(r), a = e.ch; if (!s) return o(a); for (var l, u, c = s[0].level, h = 0; s.length > h; ++h) { var f, p, d = s[h], g = d.level % 2; if (a > d.from && d.to > a) return o(a, g); var v = g ? d.to : d.from, m = g ? d.from : d.to; if (v == a) p = h && d.level < (f = s[h - 1]).level ? o(f.level % 2 ? f.from : f.to - 1, !0) : o(g && d.from != d.to ? a - 1 : a), g == c ? l = p : u = p; else if (m == a) { var f = s.length - 1 > h && s[h + 1]; if (!g && f && f.from == f.to) continue; p = f && d.level < f.level ? o(f.level % 2 ? f.to - 1 : f.from) : o(g ? a : a - 1, !0), g == c ? l = p : u = p; } } return c && !a && (u = o(s[0].to - 1)), l ? (u && (l.other = u), l) : u; } function P(t, e, n) { var r = t.view.doc; if (n += t.display.viewOffset, 0 > n) return { line: 0, ch: 0, outside: !0 }; var i = Hn(r, n); if (i >= r.size) return { line: r.size - 1, ch: En(r, r.size - 1).text.length }; for (0 > e && (e = 0); ;) { var o = En(r, i), s = R(t, o, i, e, n), a = un(o); if (!a || s.ch != yr(o)) return s; i = a.find().to.line; } } function R(t, e, n, r, i) { function o(r) { var i = W(t, { line: n, ch: r }, "line", e, u); return a = !0, s > i.bottom ? Math.max(0, i.left - l) : i.top > s ? i.left + l : (a = !1, i.left); } var s = i - Fn(t, e), a = !1, l = t.display.wrapper.clientWidth, u = F(t, e), c = On(e), h = e.text.length, f = mr(e), p = yr(e), d = D(t.display), g = o(p); if (r > g) return { line: n, ch: p, outside: a }; for (;;) { if (c ? p == f || p == wr(e, f, 1) : 1 >= p - f) { for (var v = g - r > r - d, m = v ? f : p; di.test(e.text.charAt(m)); ) ++m; return { line: n, ch: m, after: v, outside: a }; } var y = Math.ceil(h / 2), x = f + y; if (c) { x = f; for (var b = 0; y > b; ++b) x = wr(e, x, 1); } var w = o(x); w > r ? (p = x, g = w, a && (g += 1e3), h -= y) : (f = x, d = w, h = y); } } function q(t) { if (null != t.cachedTextHeight) return t.cachedTextHeight; if (null == kr) { kr = lr("pre"); for (var e = 0; 49 > e; ++e) kr.appendChild(document.createTextNode("x")), kr.appendChild(lr("br")); kr.appendChild(document.createTextNode("x")); } cr(t.measure, kr); var n = kr.offsetHeight / 50; return n > 3 && (t.cachedTextHeight = n), ur(t.measure), n || 1; } function $(t) { if (null != t.cachedCharWidth) return t.cachedCharWidth; var e = lr("span", "x"), n = lr("pre", [ e ]); cr(t.measure, n); var r = e.offsetWidth; return r > 2 && (t.cachedCharWidth = r), r || 10; } function V(t) { t.curOp ? ++t.curOp.depth : t.curOp = { depth: 1, changes: [], delayedCallbacks: [], updateInput: null, userSelChange: null, textChanged: null, selectionChanged: !1, updateMaxLine: !1, id: ++t.nextOpId }; } function X(t) { var e = t.curOp; if (!--e.depth) { t.curOp = null; var n = t.view, r = t.display; if (e.updateMaxLine && c(n), n.maxLineChanged && !t.options.lineWrapping) { var i = H(t, n.maxLine, n.maxLine.text.length).right; r.sizer.style.minWidth = i + 3 + ci + "px", n.maxLineChanged = !1; } var o, s; if (e.selectionChanged) { var a = W(t, n.sel.head); o = Ie(t, a.left, a.top, a.left, a.bottom); } (e.changes.length || o && null != o.scrollTop) && (s = y(t, e.changes, o && o.scrollTop)), !s && e.selectionChanged && _(t), o && Fe(t), e.selectionChanged && L(t), n.focused && e.updateInput && Q(t, e.userSelChange), e.textChanged && Gn(t, "change", t, e.textChanged), e.selectionChanged && Gn(t, "cursorActivity", t); for (var l = 0; e.delayedCallbacks.length > l; ++l) e.delayedCallbacks[l](t); } } function Y(t, e) { return function() { var n = t || this; V(n); try { var r = e.apply(n, arguments); } finally { X(n); } return r; }; } function U(t, e, n, r) { t.curOp.changes.push({ from: e, to: n, diff: r }); } function G(t) { t.view.pollingFast || t.display.poll.set(t.options.pollInterval, function() { Z(t), t.view.focused && G(t); }); } function K(t) { function e() { var r = Z(t); r || n ? (t.display.pollingFast = !1, G(t)) : (n = !0, t.display.poll.set(60, e)); } var n = !1; t.display.pollingFast = !0, t.display.poll.set(20, e); } function Z(t) { var e = t.display.input, n = t.display.prevInput, r = t.view, i = r.sel; if (!r.focused || bi(e) || te(t)) return !1; var o = e.value; if (o == n && Se(i.from, i.to)) return !1; V(t), r.sel.shift = !1; for (var s = 0, a = Math.min(n.length, o.length); a > s && n[s] == o[s]; ) ++s; var l = i.from, u = i.to; n.length > s ? l = { line: l.line, ch: l.ch - (n.length - s) } : r.overwrite && Se(l, u) && !t.display.pasteIncoming && (u = { line: u.line, ch: Math.min(En(t.view.doc, u.line).text.length, u.ch + (o.length - s)) }); var c = t.curOp.updateInput; return be(t, l, u, xi(o.slice(s)), "end", t.display.pasteIncoming ? "paste" : "input", { from: l, to: u }), t.curOp.updateInput = c, o.length > 1e3 ? e.value = t.display.prevInput = "" : t.display.prevInput = o, X(t), t.display.pasteIncoming = !1, !0; } function Q(t, e) { var n, r, i = t.view; Se(i.sel.from, i.sel.to) ? e && (t.display.prevInput = t.display.input.value = "") : (t.display.prevInput = "", n = wi && (i.sel.to.line - i.sel.from.line > 100 || (r = t.getSelection()).length > 1e3), t.display.input.value = n ? "-" : r || t.getSelection(), i.focused && nr(t.display.input)), t.display.inaccurateSelection = n; } function J(t) { "nocursor" == t.options.readOnly || !Er && document.activeElement == t.display.input || t.display.input.focus(); } function te(t) { return t.options.readOnly || t.view.cantEdit; } function ee(t) { function e() { t.view.focused && setTimeout(or(J, t), 0); } function n(e) { t.options.onDragEvent && t.options.onDragEvent(t, Wn(e)) || qn(e); } function r() { i.inaccurateSelection && (i.prevInput = "", i.inaccurateSelection = !1, i.input.value = t.getSelection(), nr(i.input)); } var i = t.display; Yn(i.scroller, "mousedown", Y(t, ie)), Yn(i.scroller, "dblclick", Y(t, Pn)), Yn(i.lineSpace, "selectstart", function(t) { ne(i, t) || Pn(t); }), Ar || Yn(i.scroller, "contextmenu", function(e) { xe(t, e); }), Yn(i.scroller, "scroll", function() { le(t, i.scroller.scrollTop), ue(t, i.scroller.scrollLeft, !0), Gn(t, "scroll", t); }), Yn(i.scrollbarV, "scroll", function() { le(t, i.scrollbarV.scrollTop); }), Yn(i.scrollbarH, "scroll", function() { ue(t, i.scrollbarH.scrollLeft); }), Yn(i.scroller, "mousewheel", function(e) { ce(t, e); }), Yn(i.scroller, "DOMMouseScroll", function(e) { ce(t, e); }), Yn(i.scrollbarH, "mousedown", e), Yn(i.scrollbarV, "mousedown", e), Yn(i.wrapper, "scroll", function() { i.wrapper.scrollTop = i.wrapper.scrollLeft = 0; }), Yn(window, "resize", function o() { i.cachedCharWidth = i.cachedTextHeight = null, j(t), i.wrapper.parentNode ? y(t, !0) : Un(window, "resize", o); }), Yn(i.input, "keyup", Y(t, function(e) { t.options.onKeyEvent && t.options.onKeyEvent(t, Wn(e)) || 16 == Xn(e, "keyCode") && (t.view.sel.shift = !1); })), Yn(i.input, "input", or(K, t)), Yn(i.input, "keydown", Y(t, ge)), Yn(i.input, "keypress", Y(t, ve)), Yn(i.input, "focus", or(me, t)), Yn(i.input, "blur", or(ye, t)), t.options.dragDrop && (Yn(i.scroller, "dragstart", function(e) { ae(t, e); }), Yn(i.scroller, "dragenter", n), Yn(i.scroller, "dragover", n), Yn(i.scroller, "drop", Y(t, oe))), Yn(i.scroller, "paste", function() { J(t), K(t); }), Yn(i.input, "paste", function() { i.pasteIncoming = !0, K(t); }), Yn(i.input, "cut", r), Yn(i.input, "copy", r), zr && Yn(i.sizer, "mouseup", function() { document.activeElement == i.input && i.input.blur(), J(t); }); } function ne(t, e) { for (var n = $n(e); n != t.wrapper; n = n.parentNode) if (/\bCodeMirror-(?:line)?widget\b/.test(n.className) || n.parentNode == t.sizer && n != t.mover) return !0; } function re(t, e, n) { var r = t.display; if (!n) { var i = $n(e); if (i == r.scrollbarH || i == r.scrollbarH.firstChild || i == r.scrollbarV || i == r.scrollbarV.firstChild || i == r.scrollbarFiller) return null; } var o, s, a = r.lineSpace.getBoundingClientRect(); try { o = e.clientX, s = e.clientY; } catch (e) { return null; } return P(t, o - a.left, s - a.top); } function ie(t) { function e(t) { if ("single" == h) return Ee(i, Me(l, u), t), void 0; if (v = Me(l, v), m = Me(l, m), "double" == h) { var e = Re(En(l, t.line).text, t); Te(t, v) ? Ee(i, e.from, m) : Ee(i, v, e.to); } else "triple" == h && (Te(t, v) ? Ee(i, m, Me(l, { line: t.line, ch: 0 })) : Ee(i, v, Me(l, { line: t.line + 1, ch: 0 }))); } function n(t) { var r = ++x, a = re(i, t, !0); if (a) if (Se(a, d)) { var u = t.clientY < y.top ? -20 : t.clientY > y.bottom ? 20 : 0; u && setTimeout(Y(i, function() { x == r && (o.scroller.scrollTop += u, n(t)); }), 50); } else { s.focused || me(i), d = a, e(a); var c = p(o, l); (a.line >= c.to || a.line < c.from) && setTimeout(Y(i, function() { x == r && n(t); }), 150); } } function r(t) { x = 1/0; var n = re(i, t); n && e(n), Pn(t), J(i), Un(document, "mousemove", b), Un(document, "mouseup", w); } var i = this, o = i.display, s = i.view, a = s.sel, l = s.doc; if (a.shift = Xn(t, "shiftKey"), ne(o, t)) return Hr || (o.scroller.draggable = !1, setTimeout(function() { o.scroller.draggable = !0; }, 100)), void 0; if (!se(i, t)) { var u = re(i, t); switch (Vn(t)) { case 3: return Ar && xe.call(i, i, t), void 0; case 2: return u && Ee(i, u), setTimeout(or(J, i), 20), Pn(t), void 0; } if (!u) return $n(t) == o.scroller && Pn(t), void 0; s.focused || me(i); var c = +new Date(), h = "single"; if (Sr && Sr.time > c - 400 && Se(Sr.pos, u)) h = "triple", Pn(t), setTimeout(or(J, i), 20), qe(i, u.line); else if (_r && _r.time > c - 400 && Se(_r.pos, u)) { h = "double", Sr = { time: c, pos: u }, Pn(t); var f = Re(En(l, u.line).text, u); Ee(i, f.from, f.to); } else _r = { time: c, pos: u }; var d = u; if (i.options.dragDrop && gi && !te(i) && !Se(a.from, a.to) && !Te(u, a.from) && !Te(a.to, u) && "single" == h) { var g = Y(i, function(e) { Hr && (o.scroller.draggable = !1), s.draggingText = !1, Un(document, "mouseup", g), Un(o.scroller, "drop", g), 10 > Math.abs(t.clientX - e.clientX) + Math.abs(t.clientY - e.clientY) && (Pn(e), Ee(i, u), J(i)); }); return Hr && (o.scroller.draggable = !0), s.draggingText = g, o.scroller.dragDrop && o.scroller.dragDrop(), Yn(document, "mouseup", g), Yn(o.scroller, "drop", g), void 0; } Pn(t), "single" == h && Ee(i, Me(l, u)); var v = a.from, m = a.to, y = o.wrapper.getBoundingClientRect(), x = 0, b = Y(i, function(t) { Er || Vn(t) ? n(t) : r(t); }), w = Y(i, r); Yn(document, "mousemove", b), Yn(document, "mouseup", w); } } function oe(t) { var e = this; if (!e.options.onDragEvent || !e.options.onDragEvent(e, Wn(t))) { Pn(t); var n = re(e, t, !0), r = t.dataTransfer.files; if (n && !te(e)) if (r && r.length && window.FileReader && window.File) for (var i = r.length, o = Array(i), s = 0, a = function(t, r) { var a = new FileReader(); a.onload = function() { o[r] = a.result, ++s == i && (n = Me(e.view.doc, n), Y(e, function() { var t = _e(e, o.join(""), n, n, "paste"); Be(e, n, t); })()); }, a.readAsText(t); }, l = 0; i > l; ++l) a(r[l], l); else { if (e.view.draggingText && !Te(n, e.view.sel.from) && !Te(e.view.sel.to, n)) return e.view.draggingText(t), Er && setTimeout(or(J, e), 50), void 0; try { var o = t.dataTransfer.getData("Text"); if (o) { var u = e.view.sel.from, c = e.view.sel.to; Be(e, n, n), e.view.draggingText && _e(e, "", u, c, "paste"), e.replaceSelection(o, null, "paste"), J(e), me(e); } } catch (t) {} } } } function se(t, e) { var n = t.display; try { var r = e.clientX, i = e.clientY; } catch (e) { return !1; } if (r >= Math.floor(n.gutters.getBoundingClientRect().right)) return !1; if (Pn(e), !Zn(t, "gutterClick")) return !0; var o = n.lineDiv.getBoundingClientRect(); if (i > o.bottom) return !0; i -= o.top - n.viewOffset; for (var s = 0; t.options.gutters.length > s; ++s) { var a = n.gutters.childNodes[s]; if (a && a.getBoundingClientRect().right >= r) { var l = Hn(t.view.doc, i), u = t.options.gutters[s]; Kn(t, t, "gutterClick", t, l, u, e); break; } } return !0; } function ae(t, e) { var n = t.getSelection(); e.dataTransfer.setData("Text", n), e.dataTransfer.setDragImage && !Ir && e.dataTransfer.setDragImage(lr("img"), 0, 0); } function le(t, e) { 2 > Math.abs(t.view.scrollTop - e) || (t.view.scrollTop = e, Ar || y(t, [], e), t.display.scroller.scrollTop != e && (t.display.scroller.scrollTop = e), t.display.scrollbarV.scrollTop != e && (t.display.scrollbarV.scrollTop = e), Ar && y(t, [])); } function ue(t, e, n) { (n ? e == t.view.scrollLeft : 2 > Math.abs(t.view.scrollLeft - e)) || (t.view.scrollLeft = e, d(t), t.display.scroller.scrollLeft != e && (t.display.scroller.scrollLeft = e), t.display.scrollbarH.scrollLeft != e && (t.display.scrollbarH.scrollLeft = e)); } function ce(t, e) { var n = e.wheelDeltaX, r = e.wheelDeltaY; if (null == n && e.detail && e.axis == e.HORIZONTAL_AXIS && (n = e.detail), null == r && e.detail && e.axis == e.VERTICAL_AXIS ? r = e.detail : null == r && (r = e.wheelDelta), r && Vr && Hr) for (var i = e.target; i != o; i = i.parentNode) if (i.lineObj) { t.display.currentWheelTarget = i; break; } var o = t.display.scroller; if (n && !Ar && !jr && null != Gr) return r && le(t, Math.max(0, Math.min(o.scrollTop + r * Gr, o.scrollHeight - o.clientHeight))), ue(t, Math.max(0, Math.min(o.scrollLeft + n * Gr, o.scrollWidth - o.clientWidth))), Pn(e), Nr = null, void 0; if (r && null != Gr) { var s = r * Gr, a = t.view.scrollTop, l = a + t.display.wrapper.clientHeight; 0 > s ? a = Math.max(0, a + s - 50) : l = Math.min(t.view.doc.height, l + s + 50), y(t, [], { top: a, bottom: l }); } 20 > Ur && (null == Nr ? (Nr = o.scrollLeft, Mr = o.scrollTop, Tr = n, Lr = r, setTimeout(function() { if (null != Nr) { var t = o.scrollLeft - Nr, e = o.scrollTop - Mr, n = e && Lr && e / Lr || t && Tr && t / Tr; Nr = Mr = null, n && (Gr = (Gr * Ur + n) / (Ur + 1), ++Ur); } }, 200)) : (Tr += n, Lr += r)); } function he(t, e, n) { if ("string" == typeof e && (e = si[e], !e)) return !1; t.display.pollingFast && Z(t) && (t.display.pollingFast = !1); var r = t.view, i = r.sel.shift; try { te(t) && (r.suppressEdits = !0), n && (r.sel.shift = !1), e(t); } catch (o) { if (o != hi) throw o; return !1; } finally { r.sel.shift = i, r.suppressEdits = !1; } return !0; } function fe(t) { var e = t.view.keyMaps.slice(0); return e.push(t.options.keyMap), t.options.extraKeys && e.unshift(t.options.extraKeys), e; } function pe(t, e) { function n() { l = !0; } var r = Ye(t.options.keyMap), i = r.auto; clearTimeout(Kr), i && !Ge(e) && (Kr = setTimeout(function() { Ye(t.options.keyMap) == r && (t.options.keyMap = i.call ? i.call(null, t) : i); }, 50)); var o = Ci[Xn(e, "keyCode")], s = !1, a = Vr && (jr || Fr); if (null == o || e.altGraphKey) return !1; Xn(e, "altKey") && (o = "Alt-" + o), Xn(e, a ? "metaKey" : "ctrlKey") && (o = "Ctrl-" + o), Xn(e, a ? "ctrlKey" : "metaKey") && (o = "Cmd-" + o); var l = !1, u = fe(t); return s = Xn(e, "shiftKey") ? Ue("Shift-" + o, u, function(e) { return he(t, e, !0); }, n) || Ue(o, u, function(e) { return "string" == typeof e && /^go[A-Z]/.test(e) ? he(t, e) : void 0; }, n) : Ue(o, u, function(e) { return he(t, e); }, n), l && (s = !1), s && (Pn(e), L(t), Dr && (e.oldKeyCode = e.keyCode, e.keyCode = 0)), s; } function de(t, e, n) { var r = Ue("'" + n + "'", fe(t), function(e) { return he(t, e, !0); }); return r && (Pn(e), L(t)), r; } function ge(t) { var e = this; if (e.view.focused || me(e), Er && 27 == t.keyCode && (t.returnValue = !1), !e.options.onKeyEvent || !e.options.onKeyEvent(e, Wn(t))) { var n = Xn(t, "keyCode"); e.view.sel.shift = 16 == n || Xn(t, "shiftKey"); var r = pe(e, t); jr && (Qr = r ? n : null, r || 88 != n || wi || !Xn(t, Vr ? "metaKey" : "ctrlKey") || e.replaceSelection("")); } } function ve(t) { var e = this; if (!e.options.onKeyEvent || !e.options.onKeyEvent(e, Wn(t))) { var n = Xn(t, "keyCode"), r = Xn(t, "charCode"); if (jr && n == Qr) return Qr = null, Pn(t), void 0; if (!(jr && (!t.which || 10 > t.which) || zr) || !pe(e, t)) { var i = String.fromCharCode(null == r ? n : r); this.options.electricChars && this.view.mode.electricChars && this.options.smartIndent && !te(this) && this.view.mode.electricChars.indexOf(i) > -1 && setTimeout(Y(e, function() { ze(e, e.view.sel.to.line, "smart"); }), 75), de(e, t, i) || K(e); } } } function me(t) { "nocursor" != t.options.readOnly && (t.view.focused || (Gn(t, "focus", t), t.view.focused = !0, -1 == t.display.scroller.className.search(/\bCodeMirror-focused\b/) && (t.display.scroller.className += " CodeMirror-focused"), Q(t, !0)), G(t), L(t)); } function ye(t) { t.view.focused && (Gn(t, "blur", t), t.view.focused = !1, t.display.scroller.className = t.display.scroller.className.replace(" CodeMirror-focused", "")), clearInterval(t.display.blinker), setTimeout(function() { t.view.focused || (t.view.sel.shift = !1); }, 150); } function xe(t, e) { function n() { if (r.inputDiv.style.position = "relative", r.input.style.cssText = a, Dr && (r.scrollbarV.scrollTop = r.scroller.scrollTop = s), G(t), null != r.input.selectionStart) { clearTimeout(Zr); var e = r.input.value = " " + (Se(i.from, i.to) ? "" : r.input.value), n = 0; r.prevInput = " ", r.input.selectionStart = 1, r.input.selectionEnd = e.length, Zr = setTimeout(function o() { " " == r.prevInput && 0 == r.input.selectionStart ? Y(t, si.selectAll)(t) : 10 > n++ ? Zr = setTimeout(o, 500) : Q(t); }, 200); } } var r = t.display, i = t.view.sel, o = re(t, e), s = r.scroller.scrollTop; if (o && !jr) { (Se(i.from, i.to) || Te(o, i.from) || !Te(o, i.to)) && Y(t, Be)(t, o, o); var a = r.input.style.cssText; r.inputDiv.style.position = "absolute", r.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; outline: none;" + "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);", J(t), Q(t, !0), Se(i.from, i.to) && (r.input.value = r.prevInput = " "), Ar ? (qn(e), Yn(window, "mouseup", function l() { Un(window, "mouseup", l), setTimeout(n, 20); })) : setTimeout(n, 50); } } function be(t, e, n, r, i, o) { var s = Xr && sn(t.view.doc, e, n); if (!s) return we(t, e, n, r, i,