vite-plugin-inspect
Version:
Inspect the intermediate state of Vite plugins
1,249 lines • 645 kB
JavaScript
import { __commonJSMin, __toESM, getHot } from "./hot-D67q3Up2.js";
import { Fragment, computed, createBaseVNode, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, customRef, defineComponent, getCurrentInstance, h, inject, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toRefs, toValue, unref, useSlots, useTemplateRef, watch, watchEffect, withAsyncContext, withCtx, withDirectives } from "./runtime-core.esm-bundler-Cyv4obHQ.js";
import { useRoute, useRouter, vShow } from "./vue-router-BxYGFXy-.js";
import { guessMode, inspectSourcemaps, isStaticMode, onModuleUpdated, rpc, safeJsonParse, tryOnScopeDispose, usePayloadStore } from "./payload-BX9lTMvN.js";
import "./_plugin-vue_export-helper-DfavQbjy.js";
import { Badge_default, Container_default, NavBar_default, PluginName_default, QuerySelector_default } from "./QuerySelector-iLRAQoow.js";
import { DurationDisplay_default, useOptionsStore } from "./options-D_MMddT_.js";
import { ModuleId_default, ModuleList_default, kt } from "./ModuleList-ByxGSHde.js";
const Pe = {
__name: "splitpanes",
props: {
horizontal: {
type: Boolean,
default: !1
},
pushOtherPanes: {
type: Boolean,
default: !0
},
maximizePanes: {
type: Boolean,
default: !0
},
rtl: {
type: Boolean,
default: !1
},
firstSplitter: {
type: Boolean,
default: !1
}
},
emits: [
"ready",
"resize",
"resized",
"pane-click",
"pane-maximize",
"pane-add",
"pane-remove",
"splitter-click",
"splitter-dblclick"
],
setup(D, { emit: h$1 }) {
const y = h$1, u = D, E = useSlots(), l = ref([]), M = computed(() => l.value.reduce((e, n) => (e[~~n.id] = n) && e, {})), m = computed(() => l.value.length), x = ref(null), S = ref(!1), c = ref({
mouseDown: !1,
dragging: !1,
activeSplitter: null,
cursorOffset: 0
}), f = ref({
splitter: null,
timeoutId: null
}), _ = computed(() => ({
[`splitpanes splitpanes--${u.horizontal ? "horizontal" : "vertical"}`]: !0,
"splitpanes--dragging": c.value.dragging
})), R = () => {
document.addEventListener("mousemove", r, { passive: !1 }), document.addEventListener("mouseup", P), "ontouchstart" in window && (document.addEventListener("touchmove", r, { passive: !1 }), document.addEventListener("touchend", P));
}, O = () => {
document.removeEventListener("mousemove", r, { passive: !1 }), document.removeEventListener("mouseup", P), "ontouchstart" in window && (document.removeEventListener("touchmove", r, { passive: !1 }), document.removeEventListener("touchend", P));
}, b = (e, n) => {
const t = e.target.closest(".splitpanes__splitter");
if (t) {
const { left: i, top: a } = t.getBoundingClientRect(), { clientX: s, clientY: o } = "ontouchstart" in window && e.touches ? e.touches[0] : e;
c.value.cursorOffset = u.horizontal ? o - a : s - i;
}
R(), c.value.mouseDown = !0, c.value.activeSplitter = n;
}, r = (e) => {
c.value.mouseDown && (e.preventDefault(), c.value.dragging = !0, requestAnimationFrame(() => {
K(I(e)), d("resize", { event: e }, !0);
}));
}, P = (e) => {
c.value.dragging && (window.getSelection().removeAllRanges(), d("resized", { event: e }, !0)), c.value.mouseDown = !1, c.value.activeSplitter = null, setTimeout(() => {
c.value.dragging = !1, O();
}, 100);
}, A = (e, n) => {
"ontouchstart" in window && (e.preventDefault(), f.value.splitter === n ? (clearTimeout(f.value.timeoutId), f.value.timeoutId = null, U(e, n), f.value.splitter = null) : (f.value.splitter = n, f.value.timeoutId = setTimeout(() => f.value.splitter = null, 500))), c.value.dragging || d("splitter-click", {
event: e,
index: n
}, !0);
}, U = (e, n) => {
if (d("splitter-dblclick", {
event: e,
index: n
}, !0), u.maximizePanes) {
let t = 0;
l.value = l.value.map((i, a) => (i.size = a === n ? i.max : i.min, a !== n && (t += i.min), i)), l.value[n].size -= t, d("pane-maximize", {
event: e,
index: n,
pane: l.value[n]
}), d("resized", {
event: e,
index: n
}, !0);
}
}, W = (e, n) => {
d("pane-click", {
event: e,
index: M.value[n].index,
pane: M.value[n]
});
}, I = (e) => {
const n = x.value.getBoundingClientRect(), { clientX: t, clientY: i } = "ontouchstart" in window && e.touches ? e.touches[0] : e;
return {
x: t - (u.horizontal ? 0 : c.value.cursorOffset) - n.left,
y: i - (u.horizontal ? c.value.cursorOffset : 0) - n.top
};
}, J = (e) => {
e = e[u.horizontal ? "y" : "x"];
const n = x.value[u.horizontal ? "clientHeight" : "clientWidth"];
return u.rtl && !u.horizontal && (e = n - e), e * 100 / n;
}, K = (e) => {
const n = c.value.activeSplitter;
let t = {
prevPanesSize: $(n),
nextPanesSize: N(n),
prevReachedMinPanes: 0,
nextReachedMinPanes: 0
};
const i = 0 + (u.pushOtherPanes ? 0 : t.prevPanesSize), a = 100 - (u.pushOtherPanes ? 0 : t.nextPanesSize), s = Math.max(Math.min(J(e), a), i);
let o = [n, n + 1], v = l.value[o[0]] || null, p = l.value[o[1]] || null;
const H = v.max < 100 && s >= v.max + t.prevPanesSize, ue = p.max < 100 && s <= 100 - (p.max + N(n + 1));
if (H || ue) {
H ? (v.size = v.max, p.size = Math.max(100 - v.max - t.prevPanesSize - t.nextPanesSize, 0)) : (v.size = Math.max(100 - p.max - t.prevPanesSize - N(n + 1), 0), p.size = p.max);
return;
}
if (u.pushOtherPanes) {
const j = Q(t, s);
if (!j) return;
({sums: t, panesToResize: o} = j), v = l.value[o[0]] || null, p = l.value[o[1]] || null;
}
v !== null && (v.size = Math.min(Math.max(s - t.prevPanesSize - t.prevReachedMinPanes, v.min), v.max)), p !== null && (p.size = Math.min(Math.max(100 - s - t.nextPanesSize - t.nextReachedMinPanes, p.min), p.max));
}, Q = (e, n) => {
const t = c.value.activeSplitter, i = [t, t + 1];
return n < e.prevPanesSize + l.value[i[0]].min && (i[0] = V(t).index, e.prevReachedMinPanes = 0, i[0] < t && l.value.forEach((a, s) => {
s > i[0] && s <= t && (a.size = a.min, e.prevReachedMinPanes += a.min);
}), e.prevPanesSize = $(i[0]), i[0] === void 0) ? (e.prevReachedMinPanes = 0, l.value[0].size = l.value[0].min, l.value.forEach((a, s) => {
s > 0 && s <= t && (a.size = a.min, e.prevReachedMinPanes += a.min);
}), l.value[i[1]].size = 100 - e.prevReachedMinPanes - l.value[0].min - e.prevPanesSize - e.nextPanesSize, null) : n > 100 - e.nextPanesSize - l.value[i[1]].min && (i[1] = Z(t).index, e.nextReachedMinPanes = 0, i[1] > t + 1 && l.value.forEach((a, s) => {
s > t && s < i[1] && (a.size = a.min, e.nextReachedMinPanes += a.min);
}), e.nextPanesSize = N(i[1] - 1), i[1] === void 0) ? (e.nextReachedMinPanes = 0, l.value.forEach((a, s) => {
s < m.value - 1 && s >= t + 1 && (a.size = a.min, e.nextReachedMinPanes += a.min);
}), l.value[i[0]].size = 100 - e.prevPanesSize - N(i[0] - 1), null) : {
sums: e,
panesToResize: i
};
}, $ = (e) => l.value.reduce((n, t, i) => n + (i < e ? t.size : 0), 0), N = (e) => l.value.reduce((n, t, i) => n + (i > e + 1 ? t.size : 0), 0), V = (e) => [...l.value].reverse().find((t) => t.index < e && t.size > t.min) || {}, Z = (e) => l.value.find((t) => t.index > e + 1 && t.size > t.min) || {}, ee = () => {
var n;
const e = Array.from(((n = x.value) == null ? void 0 : n.children) || []);
for (const t of e) {
const i = t.classList.contains("splitpanes__pane"), a = t.classList.contains("splitpanes__splitter");
!i && !a && (t.remove(), console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."));
}
}, F = (e, n, t = !1) => {
const i = e - 1, a = document.createElement("div");
a.classList.add("splitpanes__splitter"), t || (a.onmousedown = (s) => b(s, i), typeof window < "u" && "ontouchstart" in window && (a.ontouchstart = (s) => b(s, i)), a.onclick = (s) => A(s, i + 1)), a.ondblclick = (s) => U(s, i + 1), n.parentNode.insertBefore(a, n);
}, ne = (e) => {
e.onmousedown = void 0, e.onclick = void 0, e.ondblclick = void 0, e.remove();
}, C = () => {
var t;
const e = Array.from(((t = x.value) == null ? void 0 : t.children) || []);
for (const i of e) i.className.includes("splitpanes__splitter") && ne(i);
let n = 0;
for (const i of e) i.className.includes("splitpanes__pane") && (!n && u.firstSplitter ? F(n, i, !0) : n && F(n, i), n++);
}, ie = ({ uid: e,...n }) => {
const t = M.value[e];
for (const [i, a] of Object.entries(n)) t[i] = a;
}, te = (e) => {
var t;
let n = -1;
Array.from(((t = x.value) == null ? void 0 : t.children) || []).some((i) => (i.className.includes("splitpanes__pane") && n++, i.isSameNode(e.el))), l.value.splice(n, 0, {
...e,
index: n
}), l.value.forEach((i, a) => i.index = a), S.value && nextTick(() => {
C(), L({ addedPane: l.value[n] }), d("pane-add", { pane: l.value[n] });
});
}, ae = (e) => {
const n = l.value.findIndex((i) => i.id === e);
l.value[n].el = null;
const t = l.value.splice(n, 1)[0];
l.value.forEach((i, a) => i.index = a), nextTick(() => {
C(), d("pane-remove", { pane: t }), L({ removedPane: { ...t } });
});
}, L = (e = {}) => {
!e.addedPane && !e.removedPane ? le() : l.value.some((n) => n.givenSize !== null || n.min || n.max < 100) ? oe(e) : se(), S.value && d("resized");
}, se = () => {
const e = 100 / m.value;
let n = 0;
const t = [], i = [];
for (const a of l.value) a.size = Math.max(Math.min(e, a.max), a.min), n -= a.size, a.size >= a.max && t.push(a.id), a.size <= a.min && i.push(a.id);
n > .1 && q(n, t, i);
}, le = () => {
let e = 100;
const n = [], t = [];
let i = 0;
for (const s of l.value) e -= s.size, s.givenSize !== null && i++, s.size >= s.max && n.push(s.id), s.size <= s.min && t.push(s.id);
let a = 100;
if (e > .1) {
for (const s of l.value) s.givenSize === null && (s.size = Math.max(Math.min(e / (m.value - i), s.max), s.min)), a -= s.size;
a > .1 && q(a, n, t);
}
}, oe = ({ addedPane: e, removedPane: n } = {}) => {
let t = 100 / m.value, i = 0;
const a = [], s = [];
((e == null ? void 0 : e.givenSize) ?? null) !== null && (t = (100 - e.givenSize) / (m.value - 1));
for (const o of l.value) i -= o.size, o.size >= o.max && a.push(o.id), o.size <= o.min && s.push(o.id);
if (!(Math.abs(i) < .1)) {
for (const o of l.value) (e == null ? void 0 : e.givenSize) !== null && (e == null ? void 0 : e.id) === o.id || (o.size = Math.max(Math.min(t, o.max), o.min)), i -= o.size, o.size >= o.max && a.push(o.id), o.size <= o.min && s.push(o.id);
i > .1 && q(i, a, s);
}
}, q = (e, n, t) => {
let i;
e > 0 ? i = e / (m.value - n.length) : i = e / (m.value - t.length), l.value.forEach((a, s) => {
if (e > 0 && !n.includes(a.id)) {
const o = Math.max(Math.min(a.size + i, a.max), a.min), v = o - a.size;
e -= v, a.size = o;
} else if (!t.includes(a.id)) {
const o = Math.max(Math.min(a.size + i, a.max), a.min), v = o - a.size;
e -= v, a.size = o;
}
}), Math.abs(e) > .1 && nextTick(() => {
S.value && console.warn("Splitpanes: Could not resize panes correctly due to their constraints.");
});
}, d = (e, n = void 0, t = !1) => {
const i = (n == null ? void 0 : n.index) ?? c.value.activeSplitter ?? null;
y(e, {
...n,
...i !== null && { index: i },
...t && i !== null && {
prevPane: l.value[i - (u.firstSplitter ? 1 : 0)],
nextPane: l.value[i + (u.firstSplitter ? 0 : 1)]
},
panes: l.value.map((a) => ({
min: a.min,
max: a.max,
size: a.size
}))
});
};
watch(() => u.firstSplitter, () => C()), onMounted(() => {
ee(), C(), L(), d("ready"), S.value = !0;
}), onBeforeUnmount(() => S.value = !1);
const re = () => {
var e;
return h("div", {
ref: x,
class: _.value
}, (e = E.default) == null ? void 0 : e.call(E));
};
return provide("panes", l), provide("indexedPanes", M), provide("horizontal", computed(() => u.horizontal)), provide("requestUpdate", ie), provide("onPaneAdd", te), provide("onPaneRemove", ae), provide("onPaneClick", W), (e, n) => (openBlock(), createBlock(resolveDynamicComponent(re)));
}
}, ge = {
__name: "pane",
props: {
size: { type: [Number, String] },
minSize: {
type: [Number, String],
default: 0
},
maxSize: {
type: [Number, String],
default: 100
}
},
setup(D) {
var b;
const h$1 = D, y = inject("requestUpdate"), u = inject("onPaneAdd"), E = inject("horizontal"), l = inject("onPaneRemove"), M = inject("onPaneClick"), m = (b = getCurrentInstance()) == null ? void 0 : b.uid, x = inject("indexedPanes"), S = computed(() => x.value[m]), c = ref(null), f = computed(() => {
const r = isNaN(h$1.size) || h$1.size === void 0 ? 0 : parseFloat(h$1.size);
return Math.max(Math.min(r, R.value), _.value);
}), _ = computed(() => {
const r = parseFloat(h$1.minSize);
return isNaN(r) ? 0 : r;
}), R = computed(() => {
const r = parseFloat(h$1.maxSize);
return isNaN(r) ? 100 : r;
}), O = computed(() => {
var r;
return `${E.value ? "height" : "width"}: ${(r = S.value) == null ? void 0 : r.size}%`;
});
return watch(() => f.value, (r) => y({
uid: m,
size: r
})), watch(() => _.value, (r) => y({
uid: m,
min: r
})), watch(() => R.value, (r) => y({
uid: m,
max: r
})), onMounted(() => {
u({
id: m,
el: c.value,
min: _.value,
max: R.value,
givenSize: h$1.size === void 0 ? null : f.value,
size: f.value
});
}), onBeforeUnmount(() => l(m)), (r, P) => (openBlock(), createElementBlock("div", {
ref_key: "paneEl",
ref: c,
class: "splitpanes__pane",
onClick: P[0] || (P[0] = (A) => unref(M)(A, r._.uid)),
style: normalizeStyle(O.value)
}, [renderSlot(r.$slots, "default")], 4));
}
};
var require_codemirror = __commonJSMin((exports, module) => {
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.CodeMirror = factory());
})(exports, function() {
"use strict";
var userAgent = navigator.userAgent;
var platform = navigator.platform;
var gecko = /gecko\/\d/i.test(userAgent);
var ie_upto10 = /MSIE \d/.test(userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
var edge = /Edge\/(\d+)/.exec(userAgent);
var ie = ie_upto10 || ie_11up || edge;
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
var webkit = !edge && /WebKit\//.test(userAgent);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
var chrome = !edge && /Chrome\/(\d+)/.exec(userAgent);
var chrome_version = chrome && +chrome[1];
var presto = /Opera\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent);
var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
var android = /Android/.test(userAgent);
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
var mac = ios || /Mac/.test(platform);
var chromeOS = /\bCrOS\b/.test(userAgent);
var windows = /win/i.test(platform);
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
if (presto_version) presto_version = Number(presto_version[1]);
if (presto_version && presto_version >= 15) {
presto = false;
webkit = true;
}
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
var captureRightClick = gecko || ie && ie_version >= 9;
function classTest(cls) {
return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*");
}
var rmClass = function(node, cls) {
var current = node.className;
var match = classTest(cls).exec(current);
if (match) {
var after = current.slice(match.index + match[0].length);
node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
}
};
function removeChildren(e) {
for (var count = e.childNodes.length; count > 0; --count) e.removeChild(e.firstChild);
return e;
}
function removeChildrenAndAdd(parent, e) {
return removeChildren(parent).appendChild(e);
}
function elt(tag, content, className, style) {
var e = document.createElement(tag);
if (className) e.className = className;
if (style) e.style.cssText = style;
if (typeof content == "string") e.appendChild(document.createTextNode(content));
else if (content) for (var i$3 = 0; i$3 < content.length; ++i$3) e.appendChild(content[i$3]);
return e;
}
function eltP(tag, content, className, style) {
var e = elt(tag, content, className, style);
e.setAttribute("role", "presentation");
return e;
}
var range;
if (document.createRange) range = function(node, start, end, endNode) {
var r = document.createRange();
r.setEnd(endNode || node, end);
r.setStart(node, start);
return r;
};
else range = function(node, start, end) {
var r = document.body.createTextRange();
try {
r.moveToElementText(node.parentNode);
} catch (e) {
return r;
}
r.collapse(true);
r.moveEnd("character", end);
r.moveStart("character", start);
return r;
};
function contains(parent, child) {
if (child.nodeType == 3) child = child.parentNode;
if (parent.contains) return parent.contains(child);
do {
if (child.nodeType == 11) child = child.host;
if (child == parent) return true;
} while (child = child.parentNode);
}
function activeElt(rootNode$1) {
var doc$1 = rootNode$1.ownerDocument || rootNode$1;
var activeElement;
try {
activeElement = rootNode$1.activeElement;
} catch (e) {
activeElement = doc$1.body || null;
}
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) activeElement = activeElement.shadowRoot.activeElement;
return activeElement;
}
function addClass(node, cls) {
var current = node.className;
if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
}
function joinClasses(a, b) {
var as = a.split(" ");
for (var i$3 = 0; i$3 < as.length; i$3++) if (as[i$3] && !classTest(as[i$3]).test(b)) b += " " + as[i$3];
return b;
}
var selectInput = function(node) {
node.select();
};
if (ios) selectInput = function(node) {
node.selectionStart = 0;
node.selectionEnd = node.value.length;
};
else if (ie) selectInput = function(node) {
try {
node.select();
} catch (_e) {}
};
function doc(cm) {
return cm.display.wrapper.ownerDocument;
}
function root(cm) {
return rootNode(cm.display.wrapper);
}
function rootNode(element) {
return element.getRootNode ? element.getRootNode() : element.ownerDocument;
}
function win(cm) {
return doc(cm).defaultView;
}
function bind(f) {
var args = Array.prototype.slice.call(arguments, 1);
return function() {
return f.apply(null, args);
};
}
function copyObj(obj, target, overwrite) {
if (!target) target = {};
for (var prop$1 in obj) if (obj.hasOwnProperty(prop$1) && (overwrite !== false || !target.hasOwnProperty(prop$1))) target[prop$1] = obj[prop$1];
return target;
}
function countColumn(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) end = string.length;
}
for (var i$3 = startIndex || 0, n = startValue || 0;;) {
var nextTab = string.indexOf(" ", i$3);
if (nextTab < 0 || nextTab >= end) return n + (end - i$3);
n += nextTab - i$3;
n += tabSize - n % tabSize;
i$3 = nextTab + 1;
}
}
var Delayed = function() {
this.id = null;
this.f = null;
this.time = 0;
this.handler = bind(this.onTimeout, this);
};
Delayed.prototype.onTimeout = function(self$1) {
self$1.id = 0;
if (self$1.time <= +new Date()) self$1.f();
else setTimeout(self$1.handler, self$1.time - +new Date());
};
Delayed.prototype.set = function(ms, f) {
this.f = f;
var time = +new Date() + ms;
if (!this.id || time < this.time) {
clearTimeout(this.id);
this.id = setTimeout(this.handler, ms);
this.time = time;
}
};
function indexOf(array, elt$1) {
for (var i$3 = 0; i$3 < array.length; ++i$3) if (array[i$3] == elt$1) return i$3;
return -1;
}
var scrollerGap = 50;
var Pass = { toString: function() {
return "CodeMirror.Pass";
} };
var sel_dontScroll = { scroll: false }, sel_mouse = { origin: "*mouse" }, sel_move = { origin: "+move" };
function findColumn(string, goal, tabSize) {
for (var pos = 0, col = 0;;) {
var nextTab = string.indexOf(" ", pos);
if (nextTab == -1) nextTab = string.length;
var skipped = nextTab - pos;
if (nextTab == string.length || col + skipped >= goal) return pos + Math.min(skipped, goal - col);
col += nextTab - pos;
col += tabSize - col % tabSize;
pos = nextTab + 1;
if (col >= goal) return pos;
}
}
var spaceStrs = [""];
function spaceStr(n) {
while (spaceStrs.length <= n) spaceStrs.push(lst(spaceStrs) + " ");
return spaceStrs[n];
}
function lst(arr) {
return arr[arr.length - 1];
}
function map(array, f) {
var out = [];
for (var i$3 = 0; i$3 < array.length; i$3++) out[i$3] = f(array[i$3], i$3);
return out;
}
function insertSorted(array, value, score) {
var pos = 0, priority = score(value);
while (pos < array.length && score(array[pos]) <= priority) pos++;
array.splice(pos, 0, value);
}
function nothing() {}
function createObj(base, props) {
var inst;
if (Object.create) inst = Object.create(base);
else {
nothing.prototype = base;
inst = new nothing();
}
if (props) copyObj(props, inst);
return inst;
}
var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
function isWordCharBasic(ch) {
return /\w/.test(ch) || ch > "" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
}
function isWordChar(ch, helper) {
if (!helper) return isWordCharBasic(ch);
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
return helper.test(ch);
}
function isEmpty(obj) {
for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
return true;
}
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
function isExtendingChar(ch) {
return ch.charCodeAt(0) >= 768 && extendingChars.test(ch);
}
function skipExtendingChars(str, pos, dir) {
while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) pos += dir;
return pos;
}
function findFirst(pred, from, to) {
var dir = from > to ? -1 : 1;
for (;;) {
if (from == to) return from;
var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
if (mid == from) return pred(mid) ? from : to;
if (pred(mid)) to = mid;
else from = mid + dir;
}
}
function iterateBidiSections(order, from, to, f) {
if (!order) return f(from, to, "ltr", 0);
var found = false;
for (var i$3 = 0; i$3 < order.length; ++i$3) {
var part = order[i$3];
if (part.from < to && part.to > from || from == to && part.to == from) {
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i$3);
found = true;
}
}
if (!found) f(from, to, "ltr");
}
var bidiOther = null;
function getBidiPartAt(order, ch, sticky) {
var found;
bidiOther = null;
for (var i$3 = 0; i$3 < order.length; ++i$3) {
var cur = order[i$3];
if (cur.from < ch && cur.to > ch) return i$3;
if (cur.to == ch) if (cur.from != cur.to && sticky == "before") found = i$3;
else bidiOther = i$3;
if (cur.from == ch) if (cur.from != cur.to && sticky != "before") found = i$3;
else bidiOther = i$3;
}
return found != null ? found : bidiOther;
}
var bidiOrdering = function() {
var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
function charType(code) {
if (code <= 247) return lowTypes.charAt(code);
else if (1424 <= code && code <= 1524) return "R";
else if (1536 <= code && code <= 1785) return arabicTypes.charAt(code - 1536);
else if (1774 <= code && code <= 2220) return "r";
else if (8192 <= code && code <= 8203) return "w";
else if (code == 8204) return "b";
else return "L";
}
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
function BidiSpan(level, from, to) {
this.level = level;
this.from = from;
this.to = to;
}
return function(str, direction) {
var outerType = direction == "ltr" ? "L" : "R";
if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) return false;
var len = str.length, types = [];
for (var i$3 = 0; i$3 < len; ++i$3) types.push(charType(str.charCodeAt(i$3)));
for (var i$1$1 = 0, prev = outerType; i$1$1 < len; ++i$1$1) {
var type = types[i$1$1];
if (type == "m") types[i$1$1] = prev;
else prev = type;
}
for (var i$2$1 = 0, cur = outerType; i$2$1 < len; ++i$2$1) {
var type$1 = types[i$2$1];
if (type$1 == "1" && cur == "r") types[i$2$1] = "n";
else if (isStrong.test(type$1)) {
cur = type$1;
if (type$1 == "r") types[i$2$1] = "R";
}
}
for (var i$3$1 = 1, prev$1 = types[0]; i$3$1 < len - 1; ++i$3$1) {
var type$2 = types[i$3$1];
if (type$2 == "+" && prev$1 == "1" && types[i$3$1 + 1] == "1") types[i$3$1] = "1";
else if (type$2 == "," && prev$1 == types[i$3$1 + 1] && (prev$1 == "1" || prev$1 == "n")) types[i$3$1] = prev$1;
prev$1 = type$2;
}
for (var i$4 = 0; i$4 < len; ++i$4) {
var type$3 = types[i$4];
if (type$3 == ",") types[i$4] = "N";
else if (type$3 == "%") {
var end = void 0;
for (end = i$4 + 1; end < len && types[end] == "%"; ++end);
var replace = i$4 && types[i$4 - 1] == "!" || end < len && types[end] == "1" ? "1" : "N";
for (var j = i$4; j < end; ++j) types[j] = replace;
i$4 = end - 1;
}
}
for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
var type$4 = types[i$5];
if (cur$1 == "L" && type$4 == "1") types[i$5] = "L";
else if (isStrong.test(type$4)) cur$1 = type$4;
}
for (var i$6 = 0; i$6 < len; ++i$6) if (isNeutral.test(types[i$6])) {
var end$1 = void 0;
for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1);
var before = (i$6 ? types[i$6 - 1] : outerType) == "L";
var after = (end$1 < len ? types[end$1] : outerType) == "L";
var replace$1 = before == after ? before ? "L" : "R" : outerType;
for (var j$1 = i$6; j$1 < end$1; ++j$1) types[j$1] = replace$1;
i$6 = end$1 - 1;
}
var order = [], m;
for (var i$7 = 0; i$7 < len;) if (countsAsLeft.test(types[i$7])) {
var start = i$7;
for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7);
order.push(new BidiSpan(0, start, i$7));
} else {
var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7);
for (var j$2 = pos; j$2 < i$7;) if (countsAsNum.test(types[j$2])) {
if (pos < j$2) {
order.splice(at, 0, new BidiSpan(1, pos, j$2));
at += isRTL;
}
var nstart = j$2;
for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2);
order.splice(at, 0, new BidiSpan(2, nstart, j$2));
at += isRTL;
pos = j$2;
} else ++j$2;
if (pos < i$7) order.splice(at, 0, new BidiSpan(1, pos, i$7));
}
if (direction == "ltr") {
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
order[0].from = m[0].length;
order.unshift(new BidiSpan(0, 0, m[0].length));
}
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
lst(order).to -= m[0].length;
order.push(new BidiSpan(0, len - m[0].length, len));
}
}
return direction == "rtl" ? order.reverse() : order;
};
}();
function getOrder(line, direction) {
var order = line.order;
if (order == null) order = line.order = bidiOrdering(line.text, direction);
return order;
}
var noHandlers = [];
var on = function(emitter, type, f) {
if (emitter.addEventListener) emitter.addEventListener(type, f, false);
else if (emitter.attachEvent) emitter.attachEvent("on" + type, f);
else {
var map$1 = emitter._handlers || (emitter._handlers = {});
map$1[type] = (map$1[type] || noHandlers).concat(f);
}
};
function getHandlers(emitter, type) {
return emitter._handlers && emitter._handlers[type] || noHandlers;
}
function off(emitter, type, f) {
if (emitter.removeEventListener) emitter.removeEventListener(type, f, false);
else if (emitter.detachEvent) emitter.detachEvent("on" + type, f);
else {
var map$1 = emitter._handlers, arr = map$1 && map$1[type];
if (arr) {
var index = indexOf(arr, f);
if (index > -1) map$1[type] = arr.slice(0, index).concat(arr.slice(index + 1));
}
}
}
function signal(emitter, type) {
var handlers = getHandlers(emitter, type);
if (!handlers.length) return;
var args = Array.prototype.slice.call(arguments, 2);
for (var i$3 = 0; i$3 < handlers.length; ++i$3) handlers[i$3].apply(null, args);
}
function signalDOMEvent(cm, e, override) {
if (typeof e == "string") e = {
type: e,
preventDefault: function() {
this.defaultPrevented = true;
}
};
signal(cm, override || e.type, cm, e);
return e_defaultPrevented(e) || e.codemirrorIgnore;
}
function signalCursorActivity(cm) {
var arr = cm._handlers && cm._handlers.cursorActivity;
if (!arr) return;
var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
for (var i$3 = 0; i$3 < arr.length; ++i$3) if (indexOf(set, arr[i$3]) == -1) set.push(arr[i$3]);
}
function hasHandler(emitter, type) {
return getHandlers(emitter, type).length > 0;
}
function eventMixin(ctor) {
ctor.prototype.on = function(type, f) {
on(this, type, f);
};
ctor.prototype.off = function(type, f) {
off(this, type, f);
};
}
function e_preventDefault(e) {
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
}
function e_stopPropagation(e) {
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
function e_defaultPrevented(e) {
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
}
function e_stop(e) {
e_preventDefault(e);
e_stopPropagation(e);
}
function e_target(e) {
return e.target || e.srcElement;
}
function e_button(e) {
var b = e.which;
if (b == null) {
if (e.button & 1) b = 1;
else if (e.button & 2) b = 3;
else if (e.button & 4) b = 2;
}
if (mac && e.ctrlKey && b == 1) b = 3;
return b;
}
var dragAndDrop = function() {
if (ie && ie_version < 9) return false;
var div = elt("div");
return "draggable" in div || "dragDrop" in div;
}();
var zwspSupported;
function zeroWidthElement(measure) {
if (zwspSupported == null) {
var test = elt("span", "");
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
if (measure.firstChild.offsetHeight != 0) zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
}
var node = zwspSupported ? elt("span", "") : elt("span", "\xA0", null, "display: inline-block; width: 1px; margin-right: -1px");
node.setAttribute("cm-text", "");
return node;
}
var badBidiRects;
function hasBadBidiRects(measure) {
if (badBidiRects != null) return badBidiRects;
var txt = removeChildrenAndAdd(measure, document.createTextNode("AخA"));
var r0 = range(txt, 0, 1).getBoundingClientRect();
var r1 = range(txt, 1, 2).getBoundingClientRect();
removeChildren(measure);
if (!r0 || r0.left == r0.right) return false;
return badBidiRects = r1.right - r0.right < 3;
}
var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function(string) {
var pos = 0, result = [], l = string.length;
while (pos <= l) {
var nl = string.indexOf("\n", pos);
if (nl == -1) nl = string.length;
var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
var rt = line.indexOf("\r");
if (rt != -1) {
result.push(line.slice(0, rt));
pos += rt + 1;
} else {
result.push(line);
pos = nl + 1;
}
}
return result;
} : function(string) {
return string.split(/\r\n?|\n/);
};
var hasSelection = window.getSelection ? function(te) {
try {
return te.selectionStart != te.selectionEnd;
} catch (e) {
return false;
}
} : function(te) {
var range$1;
try {
range$1 = te.ownerDocument.selection.createRange();
} catch (e) {}
if (!range$1 || range$1.parentElement() != te) return false;
return range$1.compareEndPoints("StartToEnd", range$1) != 0;
};
var hasCopyEvent = function() {
var e = elt("div");
if ("oncopy" in e) return true;
e.setAttribute("oncopy", "return;");
return typeof e.oncopy == "function";
}();
var badZoomedRects = null;
function hasBadZoomedRects(measure) {
if (badZoomedRects != null) return badZoomedRects;
var node = removeChildrenAndAdd(measure, elt("span", "x"));
var normal = node.getBoundingClientRect();
var fromRange = range(node, 0, 1).getBoundingClientRect();
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
}
var modes = {}, mimeModes = {};
function defineMode(name, mode) {
if (arguments.length > 2) mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
}
function defineMIME(mime, spec) {
mimeModes[mime] = spec;
}
function resolveMode(spec) {
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) spec = mimeModes[spec];
else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
var found = mimeModes[spec.name];
if (typeof found == "string") found = { name: found };
spec = createObj(found, spec);
spec.name = found.name;
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) return resolveMode("application/xml");
else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) return resolveMode("application/json");
if (typeof spec == "string") return { name: spec };
else return spec || { name: "null" };
}
function getMode(options, spec) {
spec = resolveMode(spec);
var mfactory = modes[spec.name];
if (!mfactory) return getMode(options, "text/plain");
var modeObj = mfactory(options, spec);
if (modeExtensions.hasOwnProperty(spec.name)) {
var exts = modeExtensions[spec.name];
for (var prop$1 in exts) {
if (!exts.hasOwnProperty(prop$1)) continue;
if (modeObj.hasOwnProperty(prop$1)) modeObj["_" + prop$1] = modeObj[prop$1];
modeObj[prop$1] = exts[prop$1];
}
}
modeObj.name = spec.name;
if (spec.helperType) modeObj.helperType = spec.helperType;
if (spec.modeProps) for (var prop$1$1 in spec.modeProps) modeObj[prop$1$1] = spec.modeProps[prop$1$1];
return modeObj;
}
var modeExtensions = {};
function extendMode(mode, properties) {
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : modeExtensions[mode] = {};
copyObj(properties, exts);
}
function copyState(mode, state) {
if (state === true) return state;
if (mode.copyState) return mode.copyState(state);
var nstate = {};
for (var n in state) {
var val = state[n];
if (val instanceof Array) val = val.concat([]);
nstate[n] = val;
}
return nstate;
}
function innerMode(mode, state) {
var info;
while (mode.innerMode) {
info = mode.innerMode(state);
if (!info || info.mode == mode) break;
state = info.state;
mode = info.mode;
}
return info || {
mode,
state
};
}
function startState(mode, a1, a2) {
return mode.startState ? mode.startState(a1, a2) : true;
}
var StringStream = function(string, tabSize, lineOracle) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
this.lineStart = 0;
this.lineOracle = lineOracle;
};
StringStream.prototype.eol = function() {
return this.pos >= this.string.length;
};
StringStream.prototype.sol = function() {
return this.pos == this.lineStart;
};
StringStream.prototype.peek = function() {
return this.string.charAt(this.pos) || void 0;
};
StringStream.prototype.next = function() {
if (this.pos < this.string.length) return this.string.charAt(this.pos++);
};
StringStream.prototype.eat = function(match) {
var ch = this.string.charAt(this.pos);
var ok;
if (typeof match == "string") ok = ch == match;
else ok = ch && (match.test ? match.test(ch) : match(ch));
if (ok) {
++this.pos;
return ch;
}
};
StringStream.prototype.eatWhile = function(match) {
var start = this.pos;
while (this.eat(match));
return this.pos > start;
};
StringStream.prototype.eatSpace = function() {
var start = this.pos;
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
return this.pos > start;
};
StringStream.prototype.skipToEnd = function() {
this.pos = this.string.length;
};
StringStream.prototype.skipTo = function(ch) {
var found = this.string.indexOf(ch, this.pos);
if (found > -1) {
this.pos = found;
return true;
}
};
StringStream.prototype.backUp = function(n) {
this.pos -= n;
};
StringStream.prototype.column = function() {
if (this.lastColumnPos < this.start) {
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
this.lastColumnPos = this.start;
}
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
};
StringStream.prototype.indentation = function() {
return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
};
StringStream.prototype.match = function(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
var cased = function(str) {
return caseInsensitive ? str.toLowerCase() : str;
};
var substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false) this.pos += pattern.length;
return true;
}
} else {
var match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0) return null;
if (match && consume !== false) this.pos += match[0].length;
return match;
}
};
StringStream.prototype.current = function() {
return this.string.slice(this.start, this.pos);
};
StringStream.prototype.hideFirstChars = function(n, inner) {
this.lineStart += n;
try {
return inner();
} finally {
this.lineStart -= n;
}
};
StringStream.prototype.lookAhead = function(n) {
var oracle = this.lineOracle;
return oracle && oracle.lookAhead(n);
};
StringStream.prototype.baseToken = function() {
var oracle = this.lineOracle;
return oracle && oracle.baseToken(this.pos);
};
function getLine(doc$1, n) {
n -= doc$1.first;
if (n < 0 || n >= doc$1.size) throw new Error("There is no line " + (n + doc$1.first) + " in the document.");
var chunk = doc$1;
while (!chunk.lines) for (var i$3 = 0;; ++i$3) {
var child = chunk.children[i$3], sz = child.chunkSize();
if (n < sz) {
chunk = child;
break;
}
n -= sz;
}
return chunk.lines[n];
}
function getBetween(doc$1, start, end) {
var out = [], n = start.line;
doc$1.iter(start.line, end.line + 1, function(line) {
var text = line.text;
if (n == end.line) text = text.slice(0, end.ch);
if (n == start.line) text = text.slice(start.ch);
out.push(text);
++n;
});
return out;
}
function getLines(doc$1, from, to) {
var out = [];
doc$1.iter(from, to, function(line) {
out.push(line.text);
});
return out;
}
function updateLineHeight(line, height) {
var diff = height - line.height;
if (diff) for (var n = line; n; n = n.parent) n.height += diff;
}
function lineNo(line) {
if (line.parent == null) return null;
var cur = line.parent, no = indexOf(cur.lines, line);
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) for (var i$3 = 0;; ++i$3) {
if (chunk.children[i$3] == cur) break;
no += chunk.children[i$3].chunkSize();
}
return no + cur.first;
}
function lineAtHeight(chunk, h$1) {
var n = chunk.first;
outer: do {
for (var i$1$1 = 0; i$1$1 < chunk.children.length; ++i$1$1) {
var child = chunk.children[i$1$1], ch = child.height;
if (h$1 < ch) {
chunk = child;
continue outer;
}
h$1 -= ch;
n += child.chunkSize();
}
return n;
} while (!chunk.lines);
var i$3 = 0;
for (; i$3 < chunk.lines.length; ++i$3) {
var line = chunk.lines[i$3], lh = line.height;
if (h$1 < lh) break;
h$1 -= lh;
}
return n + i$3;
}
function isLine(doc$1, l) {
return l >= doc$1.first && l < doc$1.first + doc$1.size;
}
function lineNumberFor(options, i$3) {
return String(options.lineNumberFormatter(i$3 + options.firstLineNumber));
}
function Pos(line, ch, sticky) {
if (sticky === void 0) sticky = null;
if (!(this instanceof Pos)) return new Pos(line, ch, sticky);
this.line = line;
this.ch = ch;
this.sticky = sticky;
}
function cmp(a, b) {
return a.line - b.line || a.ch - b.ch;
}
function equalCursorPos(a, b) {
return a.sticky == b.sticky && cmp(a, b) == 0;
}
function copyPos(x) {
return Pos(x.line, x.ch);
}
function maxPos(a, b) {
return cmp(a, b) < 0 ? b : a;
}
function minPos(a, b) {
return cmp(a, b) < 0 ? a : b;
}
function clipLine(doc$1, n) {
return Math.max(doc$1.first, Math.min(n, doc$1.first + doc$1.size - 1));
}
function clipPos(doc$1, pos) {
if (pos.line < doc$1.first) return Pos(doc$1.first, 0);
var last = doc$1.first + doc$1.size - 1;
if (pos.line > last) return Pos(last, getLine(doc$1, last).text.length);
return clipToLen(pos, getLine(doc$1, pos.line).text.length);
}
function clipToLen(pos, linelen) {
var ch = pos.ch;
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
else if (ch < 0) return Pos(pos.line, 0);
else return pos;
}
function clipPosArray(doc$1, array) {
var out = [];
for (var i$3 = 0; i$3 < array.length; i$3++) out[i$3] = clipPos(doc$1, array[i$3]);
return out;
}
var SavedContext = function(state, lookAhead) {
this.state = state;
this.lookAhead = lookAhead;
};
var Context = function(doc$1, state, line, lookAhead) {
this.state = state;
this.doc = doc$1;
this.line = line;
this.maxLookAhead = lookAhead || 0;
this.baseTokens = null;
this.baseTokenPos = 1;
};
Context.prototype.lookAhead = function(n) {
var line = this.doc.getLine(this.line + n);
if (line != null && n > this.maxLookAhead) this.maxLookAhead = n;
return line;
};
Context.prototype.baseToken = function(n) {
if (!this.baseTokens) return null;
while (this.baseTokens[this.baseTokenPos] <= n) this.baseTokenPos += 2;
var type = this.baseTokens[this.baseTokenPos + 1];
return {
type: type && type.replace(/( |^)overlay .*/, ""),
size: this.baseTokens[this.baseTokenPos] - n
};
};
Context.prototype.nextLine = function() {
this.line++;
if (this.maxLookAhead > 0) this.maxLookAhead--;
};
Context.fromSaved = function(doc$1, saved, line) {
if (saved instanceof SavedContext) return new Context(doc$1, copyState(doc$1.mode, saved.state), line, saved.lookAhead);
else return new Context(doc$1, copyState(doc$1.mode, saved), line);
};
Context.prototype.save = function(copy) {
var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state;
};
function highlightLine(cm, line, context, forceToEnd) {
var st = [cm.state.modeGen], lineClasses = {};
runMode(cm, line.text, cm.doc.mode, context, function(end, style) {
return st.push(end, style);
}, lineClasses, forceToEnd);
var state = context.state;
var loop = function(o$1) {
context.baseTokens = st;
var overlay = cm.state.overlays[o$1], i$3 = 1, at = 0;
context.state = true;
runMode(cm, line.text, overlay.mode, context, function(end, style) {
var start = i$3;
while (at < end) {
var i_end = st[i$3];
if (i_end > end) st.splice(i$3, 1, end, st[i$3 + 1], i_end);
i$3 += 2;
at = Math.min(end, i_end);
}
if (!style) return;
if (overlay.opaque) {
st.splice(start, i$3 - start, end, "overlay " + style);
i$3 = start + 2;
} else for (; start < i$3; start += 2) {
var cur = st[start + 1];
st[start + 1] = (cur ? cur + " " : "") + "overlay " + style;
}
}, lineClasses);
context.state = state;
context.baseTokens = null;
context.baseTokenPos = 1;
};
for (var o = 0; o < cm.state.overlays.length; ++o) loop(o);
return {
styles: st,
classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null
};
}
function getLineStyles(cm, line, updateFrontier) {
if (!line.styles || line.styles[0] != cm.state.modeGen) {
var context = getContextBefore(cm, lineNo(line));
var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
var result = highlightLine(cm, line, context);
if (resetState) context.state = resetState;
line.stateAfter = context.save(!resetState);
line.styles = result.styles;
if (result.classes) line.styleClasses = result.classes;
else if (line.styleClasses) line.styleClasses = null;
if (updateFrontier === cm.doc.highlightFrontier) cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier);
}
return line.styles;
}
function getContextBefore(cm, n, precise) {
var doc$1 = cm.doc, display = cm.display;
if (!doc$1.mode.startState) return new Context(doc$1, true, n);
var start = findStartLine(cm, n, precise);
var saved = start > doc$1.first && getLine(doc$1, start - 1).stateAfter;
var context = saved ? Context.fromSaved(doc$1, saved, start) : new Context(doc$1, startState(doc$1.mode), start);
doc$1.iter(start, n, function(line) {
processLine(cm, line.text, context);
var pos = context.line;
line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
context.nextLine();
});
if (precise) doc$1.modeFrontier = context.line;
return context;
}
function processLine(cm, text, context, startAt) {
var mode = cm.doc.mode;
var stream = new StringStream(text, cm.options.tabSize, context);
stream.start = stream.pos