市场夺宝奇兵
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18891 lines
630 KiB

  1. import { __commonJSMin, __toESM, getHot } from "./hot-D67q3Up2.js";
  2. 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";
  3. import { useRoute, useRouter, vShow } from "./vue-router-BxYGFXy-.js";
  4. import { guessMode, inspectSourcemaps, isStaticMode, onModuleUpdated, rpc, safeJsonParse, tryOnScopeDispose, usePayloadStore } from "./payload-BX9lTMvN.js";
  5. import "./_plugin-vue_export-helper-DfavQbjy.js";
  6. import { Badge_default, Container_default, NavBar_default, PluginName_default, QuerySelector_default } from "./QuerySelector-iLRAQoow.js";
  7. import { DurationDisplay_default, useOptionsStore } from "./options-D_MMddT_.js";
  8. import { ModuleId_default, ModuleList_default, kt } from "./ModuleList-ByxGSHde.js";
  9. const Pe = {
  10. __name: "splitpanes",
  11. props: {
  12. horizontal: {
  13. type: Boolean,
  14. default: !1
  15. },
  16. pushOtherPanes: {
  17. type: Boolean,
  18. default: !0
  19. },
  20. maximizePanes: {
  21. type: Boolean,
  22. default: !0
  23. },
  24. rtl: {
  25. type: Boolean,
  26. default: !1
  27. },
  28. firstSplitter: {
  29. type: Boolean,
  30. default: !1
  31. }
  32. },
  33. emits: [
  34. "ready",
  35. "resize",
  36. "resized",
  37. "pane-click",
  38. "pane-maximize",
  39. "pane-add",
  40. "pane-remove",
  41. "splitter-click",
  42. "splitter-dblclick"
  43. ],
  44. setup(D, { emit: h$1 }) {
  45. 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({
  46. mouseDown: !1,
  47. dragging: !1,
  48. activeSplitter: null,
  49. cursorOffset: 0
  50. }), f = ref({
  51. splitter: null,
  52. timeoutId: null
  53. }), _ = computed(() => ({
  54. [`splitpanes splitpanes--${u.horizontal ? "horizontal" : "vertical"}`]: !0,
  55. "splitpanes--dragging": c.value.dragging
  56. })), R = () => {
  57. document.addEventListener("mousemove", r, { passive: !1 }), document.addEventListener("mouseup", P), "ontouchstart" in window && (document.addEventListener("touchmove", r, { passive: !1 }), document.addEventListener("touchend", P));
  58. }, O = () => {
  59. document.removeEventListener("mousemove", r, { passive: !1 }), document.removeEventListener("mouseup", P), "ontouchstart" in window && (document.removeEventListener("touchmove", r, { passive: !1 }), document.removeEventListener("touchend", P));
  60. }, b = (e, n) => {
  61. const t = e.target.closest(".splitpanes__splitter");
  62. if (t) {
  63. const { left: i, top: a } = t.getBoundingClientRect(), { clientX: s, clientY: o } = "ontouchstart" in window && e.touches ? e.touches[0] : e;
  64. c.value.cursorOffset = u.horizontal ? o - a : s - i;
  65. }
  66. R(), c.value.mouseDown = !0, c.value.activeSplitter = n;
  67. }, r = (e) => {
  68. c.value.mouseDown && (e.preventDefault(), c.value.dragging = !0, requestAnimationFrame(() => {
  69. K(I(e)), d("resize", { event: e }, !0);
  70. }));
  71. }, P = (e) => {
  72. c.value.dragging && (window.getSelection().removeAllRanges(), d("resized", { event: e }, !0)), c.value.mouseDown = !1, c.value.activeSplitter = null, setTimeout(() => {
  73. c.value.dragging = !1, O();
  74. }, 100);
  75. }, A = (e, n) => {
  76. "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", {
  77. event: e,
  78. index: n
  79. }, !0);
  80. }, U = (e, n) => {
  81. if (d("splitter-dblclick", {
  82. event: e,
  83. index: n
  84. }, !0), u.maximizePanes) {
  85. let t = 0;
  86. 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", {
  87. event: e,
  88. index: n,
  89. pane: l.value[n]
  90. }), d("resized", {
  91. event: e,
  92. index: n
  93. }, !0);
  94. }
  95. }, W = (e, n) => {
  96. d("pane-click", {
  97. event: e,
  98. index: M.value[n].index,
  99. pane: M.value[n]
  100. });
  101. }, I = (e) => {
  102. const n = x.value.getBoundingClientRect(), { clientX: t, clientY: i } = "ontouchstart" in window && e.touches ? e.touches[0] : e;
  103. return {
  104. x: t - (u.horizontal ? 0 : c.value.cursorOffset) - n.left,
  105. y: i - (u.horizontal ? c.value.cursorOffset : 0) - n.top
  106. };
  107. }, J = (e) => {
  108. e = e[u.horizontal ? "y" : "x"];
  109. const n = x.value[u.horizontal ? "clientHeight" : "clientWidth"];
  110. return u.rtl && !u.horizontal && (e = n - e), e * 100 / n;
  111. }, K = (e) => {
  112. const n = c.value.activeSplitter;
  113. let t = {
  114. prevPanesSize: $(n),
  115. nextPanesSize: N(n),
  116. prevReachedMinPanes: 0,
  117. nextReachedMinPanes: 0
  118. };
  119. const i = 0 + (u.pushOtherPanes ? 0 : t.prevPanesSize), a = 100 - (u.pushOtherPanes ? 0 : t.nextPanesSize), s = Math.max(Math.min(J(e), a), i);
  120. let o = [n, n + 1], v = l.value[o[0]] || null, p = l.value[o[1]] || null;
  121. const H = v.max < 100 && s >= v.max + t.prevPanesSize, ue = p.max < 100 && s <= 100 - (p.max + N(n + 1));
  122. if (H || ue) {
  123. 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);
  124. return;
  125. }
  126. if (u.pushOtherPanes) {
  127. const j = Q(t, s);
  128. if (!j) return;
  129. ({sums: t, panesToResize: o} = j), v = l.value[o[0]] || null, p = l.value[o[1]] || null;
  130. }
  131. 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));
  132. }, Q = (e, n) => {
  133. const t = c.value.activeSplitter, i = [t, t + 1];
  134. 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) => {
  135. s > i[0] && s <= t && (a.size = a.min, e.prevReachedMinPanes += a.min);
  136. }), e.prevPanesSize = $(i[0]), i[0] === void 0) ? (e.prevReachedMinPanes = 0, l.value[0].size = l.value[0].min, l.value.forEach((a, s) => {
  137. s > 0 && s <= t && (a.size = a.min, e.prevReachedMinPanes += a.min);
  138. }), 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) => {
  139. s > t && s < i[1] && (a.size = a.min, e.nextReachedMinPanes += a.min);
  140. }), e.nextPanesSize = N(i[1] - 1), i[1] === void 0) ? (e.nextReachedMinPanes = 0, l.value.forEach((a, s) => {
  141. s < m.value - 1 && s >= t + 1 && (a.size = a.min, e.nextReachedMinPanes += a.min);
  142. }), l.value[i[0]].size = 100 - e.prevPanesSize - N(i[0] - 1), null) : {
  143. sums: e,
  144. panesToResize: i
  145. };
  146. }, $ = (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 = () => {
  147. var n;
  148. const e = Array.from(((n = x.value) == null ? void 0 : n.children) || []);
  149. for (const t of e) {
  150. const i = t.classList.contains("splitpanes__pane"), a = t.classList.contains("splitpanes__splitter");
  151. !i && !a && (t.remove(), console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."));
  152. }
  153. }, F = (e, n, t = !1) => {
  154. const i = e - 1, a = document.createElement("div");
  155. 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);
  156. }, ne = (e) => {
  157. e.onmousedown = void 0, e.onclick = void 0, e.ondblclick = void 0, e.remove();
  158. }, C = () => {
  159. var t;
  160. const e = Array.from(((t = x.value) == null ? void 0 : t.children) || []);
  161. for (const i of e) i.className.includes("splitpanes__splitter") && ne(i);
  162. let n = 0;
  163. for (const i of e) i.className.includes("splitpanes__pane") && (!n && u.firstSplitter ? F(n, i, !0) : n && F(n, i), n++);
  164. }, ie = ({ uid: e,...n }) => {
  165. const t = M.value[e];
  166. for (const [i, a] of Object.entries(n)) t[i] = a;
  167. }, te = (e) => {
  168. var t;
  169. let n = -1;
  170. 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, {
  171. ...e,
  172. index: n
  173. }), l.value.forEach((i, a) => i.index = a), S.value && nextTick(() => {
  174. C(), L({ addedPane: l.value[n] }), d("pane-add", { pane: l.value[n] });
  175. });
  176. }, ae = (e) => {
  177. const n = l.value.findIndex((i) => i.id === e);
  178. l.value[n].el = null;
  179. const t = l.value.splice(n, 1)[0];
  180. l.value.forEach((i, a) => i.index = a), nextTick(() => {
  181. C(), d("pane-remove", { pane: t }), L({ removedPane: { ...t } });
  182. });
  183. }, L = (e = {}) => {
  184. !e.addedPane && !e.removedPane ? le() : l.value.some((n) => n.givenSize !== null || n.min || n.max < 100) ? oe(e) : se(), S.value && d("resized");
  185. }, se = () => {
  186. const e = 100 / m.value;
  187. let n = 0;
  188. const t = [], i = [];
  189. 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);
  190. n > .1 && q(n, t, i);
  191. }, le = () => {
  192. let e = 100;
  193. const n = [], t = [];
  194. let i = 0;
  195. 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);
  196. let a = 100;
  197. if (e > .1) {
  198. 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;
  199. a > .1 && q(a, n, t);
  200. }
  201. }, oe = ({ addedPane: e, removedPane: n } = {}) => {
  202. let t = 100 / m.value, i = 0;
  203. const a = [], s = [];
  204. ((e == null ? void 0 : e.givenSize) ?? null) !== null && (t = (100 - e.givenSize) / (m.value - 1));
  205. 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);
  206. if (!(Math.abs(i) < .1)) {
  207. 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);
  208. i > .1 && q(i, a, s);
  209. }
  210. }, q = (e, n, t) => {
  211. let i;
  212. e > 0 ? i = e / (m.value - n.length) : i = e / (m.value - t.length), l.value.forEach((a, s) => {
  213. if (e > 0 && !n.includes(a.id)) {
  214. const o = Math.max(Math.min(a.size + i, a.max), a.min), v = o - a.size;
  215. e -= v, a.size = o;
  216. } else if (!t.includes(a.id)) {
  217. const o = Math.max(Math.min(a.size + i, a.max), a.min), v = o - a.size;
  218. e -= v, a.size = o;
  219. }
  220. }), Math.abs(e) > .1 && nextTick(() => {
  221. S.value && console.warn("Splitpanes: Could not resize panes correctly due to their constraints.");
  222. });
  223. }, d = (e, n = void 0, t = !1) => {
  224. const i = (n == null ? void 0 : n.index) ?? c.value.activeSplitter ?? null;
  225. y(e, {
  226. ...n,
  227. ...i !== null && { index: i },
  228. ...t && i !== null && {
  229. prevPane: l.value[i - (u.firstSplitter ? 1 : 0)],
  230. nextPane: l.value[i + (u.firstSplitter ? 0 : 1)]
  231. },
  232. panes: l.value.map((a) => ({
  233. min: a.min,
  234. max: a.max,
  235. size: a.size
  236. }))
  237. });
  238. };
  239. watch(() => u.firstSplitter, () => C()), onMounted(() => {
  240. ee(), C(), L(), d("ready"), S.value = !0;
  241. }), onBeforeUnmount(() => S.value = !1);
  242. const re = () => {
  243. var e;
  244. return h("div", {
  245. ref: x,
  246. class: _.value
  247. }, (e = E.default) == null ? void 0 : e.call(E));
  248. };
  249. 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)));
  250. }
  251. }, ge = {
  252. __name: "pane",
  253. props: {
  254. size: { type: [Number, String] },
  255. minSize: {
  256. type: [Number, String],
  257. default: 0
  258. },
  259. maxSize: {
  260. type: [Number, String],
  261. default: 100
  262. }
  263. },
  264. setup(D) {
  265. var b;
  266. 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(() => {
  267. const r = isNaN(h$1.size) || h$1.size === void 0 ? 0 : parseFloat(h$1.size);
  268. return Math.max(Math.min(r, R.value), _.value);
  269. }), _ = computed(() => {
  270. const r = parseFloat(h$1.minSize);
  271. return isNaN(r) ? 0 : r;
  272. }), R = computed(() => {
  273. const r = parseFloat(h$1.maxSize);
  274. return isNaN(r) ? 100 : r;
  275. }), O = computed(() => {
  276. var r;
  277. return `${E.value ? "height" : "width"}: ${(r = S.value) == null ? void 0 : r.size}%`;
  278. });
  279. return watch(() => f.value, (r) => y({
  280. uid: m,
  281. size: r
  282. })), watch(() => _.value, (r) => y({
  283. uid: m,
  284. min: r
  285. })), watch(() => R.value, (r) => y({
  286. uid: m,
  287. max: r
  288. })), onMounted(() => {
  289. u({
  290. id: m,
  291. el: c.value,
  292. min: _.value,
  293. max: R.value,
  294. givenSize: h$1.size === void 0 ? null : f.value,
  295. size: f.value
  296. });
  297. }), onBeforeUnmount(() => l(m)), (r, P) => (openBlock(), createElementBlock("div", {
  298. ref_key: "paneEl",
  299. ref: c,
  300. class: "splitpanes__pane",
  301. onClick: P[0] || (P[0] = (A) => unref(M)(A, r._.uid)),
  302. style: normalizeStyle(O.value)
  303. }, [renderSlot(r.$slots, "default")], 4));
  304. }
  305. };
  306. var require_codemirror = __commonJSMin((exports, module) => {
  307. (function(global, factory) {
  308. typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.CodeMirror = factory());
  309. })(exports, function() {
  310. "use strict";
  311. var userAgent = navigator.userAgent;
  312. var platform = navigator.platform;
  313. var gecko = /gecko\/\d/i.test(userAgent);
  314. var ie_upto10 = /MSIE \d/.test(userAgent);
  315. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  316. var edge = /Edge\/(\d+)/.exec(userAgent);
  317. var ie = ie_upto10 || ie_11up || edge;
  318. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  319. var webkit = !edge && /WebKit\//.test(userAgent);
  320. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  321. var chrome = !edge && /Chrome\/(\d+)/.exec(userAgent);
  322. var chrome_version = chrome && +chrome[1];
  323. var presto = /Opera\//.test(userAgent);
  324. var safari = /Apple Computer/.test(navigator.vendor);
  325. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  326. var phantom = /PhantomJS/.test(userAgent);
  327. var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
  328. var android = /Android/.test(userAgent);
  329. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  330. var mac = ios || /Mac/.test(platform);
  331. var chromeOS = /\bCrOS\b/.test(userAgent);
  332. var windows = /win/i.test(platform);
  333. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  334. if (presto_version) presto_version = Number(presto_version[1]);
  335. if (presto_version && presto_version >= 15) {
  336. presto = false;
  337. webkit = true;
  338. }
  339. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  340. var captureRightClick = gecko || ie && ie_version >= 9;
  341. function classTest(cls) {
  342. return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*");
  343. }
  344. var rmClass = function(node, cls) {
  345. var current = node.className;
  346. var match = classTest(cls).exec(current);
  347. if (match) {
  348. var after = current.slice(match.index + match[0].length);
  349. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  350. }
  351. };
  352. function removeChildren(e) {
  353. for (var count = e.childNodes.length; count > 0; --count) e.removeChild(e.firstChild);
  354. return e;
  355. }
  356. function removeChildrenAndAdd(parent, e) {
  357. return removeChildren(parent).appendChild(e);
  358. }
  359. function elt(tag, content, className, style) {
  360. var e = document.createElement(tag);
  361. if (className) e.className = className;
  362. if (style) e.style.cssText = style;
  363. if (typeof content == "string") e.appendChild(document.createTextNode(content));
  364. else if (content) for (var i$3 = 0; i$3 < content.length; ++i$3) e.appendChild(content[i$3]);
  365. return e;
  366. }
  367. function eltP(tag, content, className, style) {
  368. var e = elt(tag, content, className, style);
  369. e.setAttribute("role", "presentation");
  370. return e;
  371. }
  372. var range;
  373. if (document.createRange) range = function(node, start, end, endNode) {
  374. var r = document.createRange();
  375. r.setEnd(endNode || node, end);
  376. r.setStart(node, start);
  377. return r;
  378. };
  379. else range = function(node, start, end) {
  380. var r = document.body.createTextRange();
  381. try {
  382. r.moveToElementText(node.parentNode);
  383. } catch (e) {
  384. return r;
  385. }
  386. r.collapse(true);
  387. r.moveEnd("character", end);
  388. r.moveStart("character", start);
  389. return r;
  390. };
  391. function contains(parent, child) {
  392. if (child.nodeType == 3) child = child.parentNode;
  393. if (parent.contains) return parent.contains(child);
  394. do {
  395. if (child.nodeType == 11) child = child.host;
  396. if (child == parent) return true;
  397. } while (child = child.parentNode);
  398. }
  399. function activeElt(rootNode$1) {
  400. var doc$1 = rootNode$1.ownerDocument || rootNode$1;
  401. var activeElement;
  402. try {
  403. activeElement = rootNode$1.activeElement;
  404. } catch (e) {
  405. activeElement = doc$1.body || null;
  406. }
  407. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) activeElement = activeElement.shadowRoot.activeElement;
  408. return activeElement;
  409. }
  410. function addClass(node, cls) {
  411. var current = node.className;
  412. if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
  413. }
  414. function joinClasses(a, b) {
  415. var as = a.split(" ");
  416. 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];
  417. return b;
  418. }
  419. var selectInput = function(node) {
  420. node.select();
  421. };
  422. if (ios) selectInput = function(node) {
  423. node.selectionStart = 0;
  424. node.selectionEnd = node.value.length;
  425. };
  426. else if (ie) selectInput = function(node) {
  427. try {
  428. node.select();
  429. } catch (_e) {}
  430. };
  431. function doc(cm) {
  432. return cm.display.wrapper.ownerDocument;
  433. }
  434. function root(cm) {
  435. return rootNode(cm.display.wrapper);
  436. }
  437. function rootNode(element) {
  438. return element.getRootNode ? element.getRootNode() : element.ownerDocument;
  439. }
  440. function win(cm) {
  441. return doc(cm).defaultView;
  442. }
  443. function bind(f) {
  444. var args = Array.prototype.slice.call(arguments, 1);
  445. return function() {
  446. return f.apply(null, args);
  447. };
  448. }
  449. function copyObj(obj, target, overwrite) {
  450. if (!target) target = {};
  451. for (var prop$1 in obj) if (obj.hasOwnProperty(prop$1) && (overwrite !== false || !target.hasOwnProperty(prop$1))) target[prop$1] = obj[prop$1];
  452. return target;
  453. }
  454. function countColumn(string, end, tabSize, startIndex, startValue) {
  455. if (end == null) {
  456. end = string.search(/[^\s\u00a0]/);
  457. if (end == -1) end = string.length;
  458. }
  459. for (var i$3 = startIndex || 0, n = startValue || 0;;) {
  460. var nextTab = string.indexOf(" ", i$3);
  461. if (nextTab < 0 || nextTab >= end) return n + (end - i$3);
  462. n += nextTab - i$3;
  463. n += tabSize - n % tabSize;
  464. i$3 = nextTab + 1;
  465. }
  466. }
  467. var Delayed = function() {
  468. this.id = null;
  469. this.f = null;
  470. this.time = 0;
  471. this.handler = bind(this.onTimeout, this);
  472. };
  473. Delayed.prototype.onTimeout = function(self$1) {
  474. self$1.id = 0;
  475. if (self$1.time <= +new Date()) self$1.f();
  476. else setTimeout(self$1.handler, self$1.time - +new Date());
  477. };
  478. Delayed.prototype.set = function(ms, f) {
  479. this.f = f;
  480. var time = +new Date() + ms;
  481. if (!this.id || time < this.time) {
  482. clearTimeout(this.id);
  483. this.id = setTimeout(this.handler, ms);
  484. this.time = time;
  485. }
  486. };
  487. function indexOf(array, elt$1) {
  488. for (var i$3 = 0; i$3 < array.length; ++i$3) if (array[i$3] == elt$1) return i$3;
  489. return -1;
  490. }
  491. var scrollerGap = 50;
  492. var Pass = { toString: function() {
  493. return "CodeMirror.Pass";
  494. } };
  495. var sel_dontScroll = { scroll: false }, sel_mouse = { origin: "*mouse" }, sel_move = { origin: "+move" };
  496. function findColumn(string, goal, tabSize) {
  497. for (var pos = 0, col = 0;;) {
  498. var nextTab = string.indexOf(" ", pos);
  499. if (nextTab == -1) nextTab = string.length;
  500. var skipped = nextTab - pos;
  501. if (nextTab == string.length || col + skipped >= goal) return pos + Math.min(skipped, goal - col);
  502. col += nextTab - pos;
  503. col += tabSize - col % tabSize;
  504. pos = nextTab + 1;
  505. if (col >= goal) return pos;
  506. }
  507. }
  508. var spaceStrs = [""];
  509. function spaceStr(n) {
  510. while (spaceStrs.length <= n) spaceStrs.push(lst(spaceStrs) + " ");
  511. return spaceStrs[n];
  512. }
  513. function lst(arr) {
  514. return arr[arr.length - 1];
  515. }
  516. function map(array, f) {
  517. var out = [];
  518. for (var i$3 = 0; i$3 < array.length; i$3++) out[i$3] = f(array[i$3], i$3);
  519. return out;
  520. }
  521. function insertSorted(array, value, score) {
  522. var pos = 0, priority = score(value);
  523. while (pos < array.length && score(array[pos]) <= priority) pos++;
  524. array.splice(pos, 0, value);
  525. }
  526. function nothing() {}
  527. function createObj(base, props) {
  528. var inst;
  529. if (Object.create) inst = Object.create(base);
  530. else {
  531. nothing.prototype = base;
  532. inst = new nothing();
  533. }
  534. if (props) copyObj(props, inst);
  535. return inst;
  536. }
  537. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  538. function isWordCharBasic(ch) {
  539. return /\w/.test(ch) || ch > "€" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
  540. }
  541. function isWordChar(ch, helper) {
  542. if (!helper) return isWordCharBasic(ch);
  543. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
  544. return helper.test(ch);
  545. }
  546. function isEmpty(obj) {
  547. for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
  548. return true;
  549. }
  550. 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]/;
  551. function isExtendingChar(ch) {
  552. return ch.charCodeAt(0) >= 768 && extendingChars.test(ch);
  553. }
  554. function skipExtendingChars(str, pos, dir) {
  555. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) pos += dir;
  556. return pos;
  557. }
  558. function findFirst(pred, from, to) {
  559. var dir = from > to ? -1 : 1;
  560. for (;;) {
  561. if (from == to) return from;
  562. var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  563. if (mid == from) return pred(mid) ? from : to;
  564. if (pred(mid)) to = mid;
  565. else from = mid + dir;
  566. }
  567. }
  568. function iterateBidiSections(order, from, to, f) {
  569. if (!order) return f(from, to, "ltr", 0);
  570. var found = false;
  571. for (var i$3 = 0; i$3 < order.length; ++i$3) {
  572. var part = order[i$3];
  573. if (part.from < to && part.to > from || from == to && part.to == from) {
  574. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i$3);
  575. found = true;
  576. }
  577. }
  578. if (!found) f(from, to, "ltr");
  579. }
  580. var bidiOther = null;
  581. function getBidiPartAt(order, ch, sticky) {
  582. var found;
  583. bidiOther = null;
  584. for (var i$3 = 0; i$3 < order.length; ++i$3) {
  585. var cur = order[i$3];
  586. if (cur.from < ch && cur.to > ch) return i$3;
  587. if (cur.to == ch) if (cur.from != cur.to && sticky == "before") found = i$3;
  588. else bidiOther = i$3;
  589. if (cur.from == ch) if (cur.from != cur.to && sticky != "before") found = i$3;
  590. else bidiOther = i$3;
  591. }
  592. return found != null ? found : bidiOther;
  593. }
  594. var bidiOrdering = function() {
  595. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  596. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  597. function charType(code) {
  598. if (code <= 247) return lowTypes.charAt(code);
  599. else if (1424 <= code && code <= 1524) return "R";
  600. else if (1536 <= code && code <= 1785) return arabicTypes.charAt(code - 1536);
  601. else if (1774 <= code && code <= 2220) return "r";
  602. else if (8192 <= code && code <= 8203) return "w";
  603. else if (code == 8204) return "b";
  604. else return "L";
  605. }
  606. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  607. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
  608. function BidiSpan(level, from, to) {
  609. this.level = level;
  610. this.from = from;
  611. this.to = to;
  612. }
  613. return function(str, direction) {
  614. var outerType = direction == "ltr" ? "L" : "R";
  615. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) return false;
  616. var len = str.length, types = [];
  617. for (var i$3 = 0; i$3 < len; ++i$3) types.push(charType(str.charCodeAt(i$3)));
  618. for (var i$1$1 = 0, prev = outerType; i$1$1 < len; ++i$1$1) {
  619. var type = types[i$1$1];
  620. if (type == "m") types[i$1$1] = prev;
  621. else prev = type;
  622. }
  623. for (var i$2$1 = 0, cur = outerType; i$2$1 < len; ++i$2$1) {
  624. var type$1 = types[i$2$1];
  625. if (type$1 == "1" && cur == "r") types[i$2$1] = "n";
  626. else if (isStrong.test(type$1)) {
  627. cur = type$1;
  628. if (type$1 == "r") types[i$2$1] = "R";
  629. }
  630. }
  631. for (var i$3$1 = 1, prev$1 = types[0]; i$3$1 < len - 1; ++i$3$1) {
  632. var type$2 = types[i$3$1];
  633. if (type$2 == "+" && prev$1 == "1" && types[i$3$1 + 1] == "1") types[i$3$1] = "1";
  634. else if (type$2 == "," && prev$1 == types[i$3$1 + 1] && (prev$1 == "1" || prev$1 == "n")) types[i$3$1] = prev$1;
  635. prev$1 = type$2;
  636. }
  637. for (var i$4 = 0; i$4 < len; ++i$4) {
  638. var type$3 = types[i$4];
  639. if (type$3 == ",") types[i$4] = "N";
  640. else if (type$3 == "%") {
  641. var end = void 0;
  642. for (end = i$4 + 1; end < len && types[end] == "%"; ++end);
  643. var replace = i$4 && types[i$4 - 1] == "!" || end < len && types[end] == "1" ? "1" : "N";
  644. for (var j = i$4; j < end; ++j) types[j] = replace;
  645. i$4 = end - 1;
  646. }
  647. }
  648. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  649. var type$4 = types[i$5];
  650. if (cur$1 == "L" && type$4 == "1") types[i$5] = "L";
  651. else if (isStrong.test(type$4)) cur$1 = type$4;
  652. }
  653. for (var i$6 = 0; i$6 < len; ++i$6) if (isNeutral.test(types[i$6])) {
  654. var end$1 = void 0;
  655. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1);
  656. var before = (i$6 ? types[i$6 - 1] : outerType) == "L";
  657. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  658. var replace$1 = before == after ? before ? "L" : "R" : outerType;
  659. for (var j$1 = i$6; j$1 < end$1; ++j$1) types[j$1] = replace$1;
  660. i$6 = end$1 - 1;
  661. }
  662. var order = [], m;
  663. for (var i$7 = 0; i$7 < len;) if (countsAsLeft.test(types[i$7])) {
  664. var start = i$7;
  665. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7);
  666. order.push(new BidiSpan(0, start, i$7));
  667. } else {
  668. var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
  669. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7);
  670. for (var j$2 = pos; j$2 < i$7;) if (countsAsNum.test(types[j$2])) {
  671. if (pos < j$2) {
  672. order.splice(at, 0, new BidiSpan(1, pos, j$2));
  673. at += isRTL;
  674. }
  675. var nstart = j$2;
  676. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2);
  677. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  678. at += isRTL;
  679. pos = j$2;
  680. } else ++j$2;
  681. if (pos < i$7) order.splice(at, 0, new BidiSpan(1, pos, i$7));
  682. }
  683. if (direction == "ltr") {
  684. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  685. order[0].from = m[0].length;
  686. order.unshift(new BidiSpan(0, 0, m[0].length));
  687. }
  688. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  689. lst(order).to -= m[0].length;
  690. order.push(new BidiSpan(0, len - m[0].length, len));
  691. }
  692. }
  693. return direction == "rtl" ? order.reverse() : order;
  694. };
  695. }();
  696. function getOrder(line, direction) {
  697. var order = line.order;
  698. if (order == null) order = line.order = bidiOrdering(line.text, direction);
  699. return order;
  700. }
  701. var noHandlers = [];
  702. var on = function(emitter, type, f) {
  703. if (emitter.addEventListener) emitter.addEventListener(type, f, false);
  704. else if (emitter.attachEvent) emitter.attachEvent("on" + type, f);
  705. else {
  706. var map$1 = emitter._handlers || (emitter._handlers = {});
  707. map$1[type] = (map$1[type] || noHandlers).concat(f);
  708. }
  709. };
  710. function getHandlers(emitter, type) {
  711. return emitter._handlers && emitter._handlers[type] || noHandlers;
  712. }
  713. function off(emitter, type, f) {
  714. if (emitter.removeEventListener) emitter.removeEventListener(type, f, false);
  715. else if (emitter.detachEvent) emitter.detachEvent("on" + type, f);
  716. else {
  717. var map$1 = emitter._handlers, arr = map$1 && map$1[type];
  718. if (arr) {
  719. var index = indexOf(arr, f);
  720. if (index > -1) map$1[type] = arr.slice(0, index).concat(arr.slice(index + 1));
  721. }
  722. }
  723. }
  724. function signal(emitter, type) {
  725. var handlers = getHandlers(emitter, type);
  726. if (!handlers.length) return;
  727. var args = Array.prototype.slice.call(arguments, 2);
  728. for (var i$3 = 0; i$3 < handlers.length; ++i$3) handlers[i$3].apply(null, args);
  729. }
  730. function signalDOMEvent(cm, e, override) {
  731. if (typeof e == "string") e = {
  732. type: e,
  733. preventDefault: function() {
  734. this.defaultPrevented = true;
  735. }
  736. };
  737. signal(cm, override || e.type, cm, e);
  738. return e_defaultPrevented(e) || e.codemirrorIgnore;
  739. }
  740. function signalCursorActivity(cm) {
  741. var arr = cm._handlers && cm._handlers.cursorActivity;
  742. if (!arr) return;
  743. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  744. for (var i$3 = 0; i$3 < arr.length; ++i$3) if (indexOf(set, arr[i$3]) == -1) set.push(arr[i$3]);
  745. }
  746. function hasHandler(emitter, type) {
  747. return getHandlers(emitter, type).length > 0;
  748. }
  749. function eventMixin(ctor) {
  750. ctor.prototype.on = function(type, f) {
  751. on(this, type, f);
  752. };
  753. ctor.prototype.off = function(type, f) {
  754. off(this, type, f);
  755. };
  756. }
  757. function e_preventDefault(e) {
  758. if (e.preventDefault) e.preventDefault();
  759. else e.returnValue = false;
  760. }
  761. function e_stopPropagation(e) {
  762. if (e.stopPropagation) e.stopPropagation();
  763. else e.cancelBubble = true;
  764. }
  765. function e_defaultPrevented(e) {
  766. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
  767. }
  768. function e_stop(e) {
  769. e_preventDefault(e);
  770. e_stopPropagation(e);
  771. }
  772. function e_target(e) {
  773. return e.target || e.srcElement;
  774. }
  775. function e_button(e) {
  776. var b = e.which;
  777. if (b == null) {
  778. if (e.button & 1) b = 1;
  779. else if (e.button & 2) b = 3;
  780. else if (e.button & 4) b = 2;
  781. }
  782. if (mac && e.ctrlKey && b == 1) b = 3;
  783. return b;
  784. }
  785. var dragAndDrop = function() {
  786. if (ie && ie_version < 9) return false;
  787. var div = elt("div");
  788. return "draggable" in div || "dragDrop" in div;
  789. }();
  790. var zwspSupported;
  791. function zeroWidthElement(measure) {
  792. if (zwspSupported == null) {
  793. var test = elt("span", "​");
  794. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  795. if (measure.firstChild.offsetHeight != 0) zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
  796. }
  797. var node = zwspSupported ? elt("span", "​") : elt("span", "\xA0", null, "display: inline-block; width: 1px; margin-right: -1px");
  798. node.setAttribute("cm-text", "");
  799. return node;
  800. }
  801. var badBidiRects;
  802. function hasBadBidiRects(measure) {
  803. if (badBidiRects != null) return badBidiRects;
  804. var txt = removeChildrenAndAdd(measure, document.createTextNode("AخA"));
  805. var r0 = range(txt, 0, 1).getBoundingClientRect();
  806. var r1 = range(txt, 1, 2).getBoundingClientRect();
  807. removeChildren(measure);
  808. if (!r0 || r0.left == r0.right) return false;
  809. return badBidiRects = r1.right - r0.right < 3;
  810. }
  811. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function(string) {
  812. var pos = 0, result = [], l = string.length;
  813. while (pos <= l) {
  814. var nl = string.indexOf("\n", pos);
  815. if (nl == -1) nl = string.length;
  816. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  817. var rt = line.indexOf("\r");
  818. if (rt != -1) {
  819. result.push(line.slice(0, rt));
  820. pos += rt + 1;
  821. } else {
  822. result.push(line);
  823. pos = nl + 1;
  824. }
  825. }
  826. return result;
  827. } : function(string) {
  828. return string.split(/\r\n?|\n/);
  829. };
  830. var hasSelection = window.getSelection ? function(te) {
  831. try {
  832. return te.selectionStart != te.selectionEnd;
  833. } catch (e) {
  834. return false;
  835. }
  836. } : function(te) {
  837. var range$1;
  838. try {
  839. range$1 = te.ownerDocument.selection.createRange();
  840. } catch (e) {}
  841. if (!range$1 || range$1.parentElement() != te) return false;
  842. return range$1.compareEndPoints("StartToEnd", range$1) != 0;
  843. };
  844. var hasCopyEvent = function() {
  845. var e = elt("div");
  846. if ("oncopy" in e) return true;
  847. e.setAttribute("oncopy", "return;");
  848. return typeof e.oncopy == "function";
  849. }();
  850. var badZoomedRects = null;
  851. function hasBadZoomedRects(measure) {
  852. if (badZoomedRects != null) return badZoomedRects;
  853. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  854. var normal = node.getBoundingClientRect();
  855. var fromRange = range(node, 0, 1).getBoundingClientRect();
  856. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
  857. }
  858. var modes = {}, mimeModes = {};
  859. function defineMode(name, mode) {
  860. if (arguments.length > 2) mode.dependencies = Array.prototype.slice.call(arguments, 2);
  861. modes[name] = mode;
  862. }
  863. function defineMIME(mime, spec) {
  864. mimeModes[mime] = spec;
  865. }
  866. function resolveMode(spec) {
  867. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) spec = mimeModes[spec];
  868. else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  869. var found = mimeModes[spec.name];
  870. if (typeof found == "string") found = { name: found };
  871. spec = createObj(found, spec);
  872. spec.name = found.name;
  873. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) return resolveMode("application/xml");
  874. else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) return resolveMode("application/json");
  875. if (typeof spec == "string") return { name: spec };
  876. else return spec || { name: "null" };
  877. }
  878. function getMode(options, spec) {
  879. spec = resolveMode(spec);
  880. var mfactory = modes[spec.name];
  881. if (!mfactory) return getMode(options, "text/plain");
  882. var modeObj = mfactory(options, spec);
  883. if (modeExtensions.hasOwnProperty(spec.name)) {
  884. var exts = modeExtensions[spec.name];
  885. for (var prop$1 in exts) {
  886. if (!exts.hasOwnProperty(prop$1)) continue;
  887. if (modeObj.hasOwnProperty(prop$1)) modeObj["_" + prop$1] = modeObj[prop$1];
  888. modeObj[prop$1] = exts[prop$1];
  889. }
  890. }
  891. modeObj.name = spec.name;
  892. if (spec.helperType) modeObj.helperType = spec.helperType;
  893. if (spec.modeProps) for (var prop$1$1 in spec.modeProps) modeObj[prop$1$1] = spec.modeProps[prop$1$1];
  894. return modeObj;
  895. }
  896. var modeExtensions = {};
  897. function extendMode(mode, properties) {
  898. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : modeExtensions[mode] = {};
  899. copyObj(properties, exts);
  900. }
  901. function copyState(mode, state) {
  902. if (state === true) return state;
  903. if (mode.copyState) return mode.copyState(state);
  904. var nstate = {};
  905. for (var n in state) {
  906. var val = state[n];
  907. if (val instanceof Array) val = val.concat([]);
  908. nstate[n] = val;
  909. }
  910. return nstate;
  911. }
  912. function innerMode(mode, state) {
  913. var info;
  914. while (mode.innerMode) {
  915. info = mode.innerMode(state);
  916. if (!info || info.mode == mode) break;
  917. state = info.state;
  918. mode = info.mode;
  919. }
  920. return info || {
  921. mode,
  922. state
  923. };
  924. }
  925. function startState(mode, a1, a2) {
  926. return mode.startState ? mode.startState(a1, a2) : true;
  927. }
  928. var StringStream = function(string, tabSize, lineOracle) {
  929. this.pos = this.start = 0;
  930. this.string = string;
  931. this.tabSize = tabSize || 8;
  932. this.lastColumnPos = this.lastColumnValue = 0;
  933. this.lineStart = 0;
  934. this.lineOracle = lineOracle;
  935. };
  936. StringStream.prototype.eol = function() {
  937. return this.pos >= this.string.length;
  938. };
  939. StringStream.prototype.sol = function() {
  940. return this.pos == this.lineStart;
  941. };
  942. StringStream.prototype.peek = function() {
  943. return this.string.charAt(this.pos) || void 0;
  944. };
  945. StringStream.prototype.next = function() {
  946. if (this.pos < this.string.length) return this.string.charAt(this.pos++);
  947. };
  948. StringStream.prototype.eat = function(match) {
  949. var ch = this.string.charAt(this.pos);
  950. var ok;
  951. if (typeof match == "string") ok = ch == match;
  952. else ok = ch && (match.test ? match.test(ch) : match(ch));
  953. if (ok) {
  954. ++this.pos;
  955. return ch;
  956. }
  957. };
  958. StringStream.prototype.eatWhile = function(match) {
  959. var start = this.pos;
  960. while (this.eat(match));
  961. return this.pos > start;
  962. };
  963. StringStream.prototype.eatSpace = function() {
  964. var start = this.pos;
  965. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
  966. return this.pos > start;
  967. };
  968. StringStream.prototype.skipToEnd = function() {
  969. this.pos = this.string.length;
  970. };
  971. StringStream.prototype.skipTo = function(ch) {
  972. var found = this.string.indexOf(ch, this.pos);
  973. if (found > -1) {
  974. this.pos = found;
  975. return true;
  976. }
  977. };
  978. StringStream.prototype.backUp = function(n) {
  979. this.pos -= n;
  980. };
  981. StringStream.prototype.column = function() {
  982. if (this.lastColumnPos < this.start) {
  983. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  984. this.lastColumnPos = this.start;
  985. }
  986. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
  987. };
  988. StringStream.prototype.indentation = function() {
  989. return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
  990. };
  991. StringStream.prototype.match = function(pattern, consume, caseInsensitive) {
  992. if (typeof pattern == "string") {
  993. var cased = function(str) {
  994. return caseInsensitive ? str.toLowerCase() : str;
  995. };
  996. var substr = this.string.substr(this.pos, pattern.length);
  997. if (cased(substr) == cased(pattern)) {
  998. if (consume !== false) this.pos += pattern.length;
  999. return true;
  1000. }
  1001. } else {
  1002. var match = this.string.slice(this.pos).match(pattern);
  1003. if (match && match.index > 0) return null;
  1004. if (match && consume !== false) this.pos += match[0].length;
  1005. return match;
  1006. }
  1007. };
  1008. StringStream.prototype.current = function() {
  1009. return this.string.slice(this.start, this.pos);
  1010. };
  1011. StringStream.prototype.hideFirstChars = function(n, inner) {
  1012. this.lineStart += n;
  1013. try {
  1014. return inner();
  1015. } finally {
  1016. this.lineStart -= n;
  1017. }
  1018. };
  1019. StringStream.prototype.lookAhead = function(n) {
  1020. var oracle = this.lineOracle;
  1021. return oracle && oracle.lookAhead(n);
  1022. };
  1023. StringStream.prototype.baseToken = function() {
  1024. var oracle = this.lineOracle;
  1025. return oracle && oracle.baseToken(this.pos);
  1026. };
  1027. function getLine(doc$1, n) {
  1028. n -= doc$1.first;
  1029. if (n < 0 || n >= doc$1.size) throw new Error("There is no line " + (n + doc$1.first) + " in the document.");
  1030. var chunk = doc$1;
  1031. while (!chunk.lines) for (var i$3 = 0;; ++i$3) {
  1032. var child = chunk.children[i$3], sz = child.chunkSize();
  1033. if (n < sz) {
  1034. chunk = child;
  1035. break;
  1036. }
  1037. n -= sz;
  1038. }
  1039. return chunk.lines[n];
  1040. }
  1041. function getBetween(doc$1, start, end) {
  1042. var out = [], n = start.line;
  1043. doc$1.iter(start.line, end.line + 1, function(line) {
  1044. var text = line.text;
  1045. if (n == end.line) text = text.slice(0, end.ch);
  1046. if (n == start.line) text = text.slice(start.ch);
  1047. out.push(text);
  1048. ++n;
  1049. });
  1050. return out;
  1051. }
  1052. function getLines(doc$1, from, to) {
  1053. var out = [];
  1054. doc$1.iter(from, to, function(line) {
  1055. out.push(line.text);
  1056. });
  1057. return out;
  1058. }
  1059. function updateLineHeight(line, height) {
  1060. var diff = height - line.height;
  1061. if (diff) for (var n = line; n; n = n.parent) n.height += diff;
  1062. }
  1063. function lineNo(line) {
  1064. if (line.parent == null) return null;
  1065. var cur = line.parent, no = indexOf(cur.lines, line);
  1066. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) for (var i$3 = 0;; ++i$3) {
  1067. if (chunk.children[i$3] == cur) break;
  1068. no += chunk.children[i$3].chunkSize();
  1069. }
  1070. return no + cur.first;
  1071. }
  1072. function lineAtHeight(chunk, h$1) {
  1073. var n = chunk.first;
  1074. outer: do {
  1075. for (var i$1$1 = 0; i$1$1 < chunk.children.length; ++i$1$1) {
  1076. var child = chunk.children[i$1$1], ch = child.height;
  1077. if (h$1 < ch) {
  1078. chunk = child;
  1079. continue outer;
  1080. }
  1081. h$1 -= ch;
  1082. n += child.chunkSize();
  1083. }
  1084. return n;
  1085. } while (!chunk.lines);
  1086. var i$3 = 0;
  1087. for (; i$3 < chunk.lines.length; ++i$3) {
  1088. var line = chunk.lines[i$3], lh = line.height;
  1089. if (h$1 < lh) break;
  1090. h$1 -= lh;
  1091. }
  1092. return n + i$3;
  1093. }
  1094. function isLine(doc$1, l) {
  1095. return l >= doc$1.first && l < doc$1.first + doc$1.size;
  1096. }
  1097. function lineNumberFor(options, i$3) {
  1098. return String(options.lineNumberFormatter(i$3 + options.firstLineNumber));
  1099. }
  1100. function Pos(line, ch, sticky) {
  1101. if (sticky === void 0) sticky = null;
  1102. if (!(this instanceof Pos)) return new Pos(line, ch, sticky);
  1103. this.line = line;
  1104. this.ch = ch;
  1105. this.sticky = sticky;
  1106. }
  1107. function cmp(a, b) {
  1108. return a.line - b.line || a.ch - b.ch;
  1109. }
  1110. function equalCursorPos(a, b) {
  1111. return a.sticky == b.sticky && cmp(a, b) == 0;
  1112. }
  1113. function copyPos(x) {
  1114. return Pos(x.line, x.ch);
  1115. }
  1116. function maxPos(a, b) {
  1117. return cmp(a, b) < 0 ? b : a;
  1118. }
  1119. function minPos(a, b) {
  1120. return cmp(a, b) < 0 ? a : b;
  1121. }
  1122. function clipLine(doc$1, n) {
  1123. return Math.max(doc$1.first, Math.min(n, doc$1.first + doc$1.size - 1));
  1124. }
  1125. function clipPos(doc$1, pos) {
  1126. if (pos.line < doc$1.first) return Pos(doc$1.first, 0);
  1127. var last = doc$1.first + doc$1.size - 1;
  1128. if (pos.line > last) return Pos(last, getLine(doc$1, last).text.length);
  1129. return clipToLen(pos, getLine(doc$1, pos.line).text.length);
  1130. }
  1131. function clipToLen(pos, linelen) {
  1132. var ch = pos.ch;
  1133. if (ch == null || ch > linelen) return Pos(pos.line, linelen);
  1134. else if (ch < 0) return Pos(pos.line, 0);
  1135. else return pos;
  1136. }
  1137. function clipPosArray(doc$1, array) {
  1138. var out = [];
  1139. for (var i$3 = 0; i$3 < array.length; i$3++) out[i$3] = clipPos(doc$1, array[i$3]);
  1140. return out;
  1141. }
  1142. var SavedContext = function(state, lookAhead) {
  1143. this.state = state;
  1144. this.lookAhead = lookAhead;
  1145. };
  1146. var Context = function(doc$1, state, line, lookAhead) {
  1147. this.state = state;
  1148. this.doc = doc$1;
  1149. this.line = line;
  1150. this.maxLookAhead = lookAhead || 0;
  1151. this.baseTokens = null;
  1152. this.baseTokenPos = 1;
  1153. };
  1154. Context.prototype.lookAhead = function(n) {
  1155. var line = this.doc.getLine(this.line + n);
  1156. if (line != null && n > this.maxLookAhead) this.maxLookAhead = n;
  1157. return line;
  1158. };
  1159. Context.prototype.baseToken = function(n) {
  1160. if (!this.baseTokens) return null;
  1161. while (this.baseTokens[this.baseTokenPos] <= n) this.baseTokenPos += 2;
  1162. var type = this.baseTokens[this.baseTokenPos + 1];
  1163. return {
  1164. type: type && type.replace(/( |^)overlay .*/, ""),
  1165. size: this.baseTokens[this.baseTokenPos] - n
  1166. };
  1167. };
  1168. Context.prototype.nextLine = function() {
  1169. this.line++;
  1170. if (this.maxLookAhead > 0) this.maxLookAhead--;
  1171. };
  1172. Context.fromSaved = function(doc$1, saved, line) {
  1173. if (saved instanceof SavedContext) return new Context(doc$1, copyState(doc$1.mode, saved.state), line, saved.lookAhead);
  1174. else return new Context(doc$1, copyState(doc$1.mode, saved), line);
  1175. };
  1176. Context.prototype.save = function(copy) {
  1177. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  1178. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state;
  1179. };
  1180. function highlightLine(cm, line, context, forceToEnd) {
  1181. var st = [cm.state.modeGen], lineClasses = {};
  1182. runMode(cm, line.text, cm.doc.mode, context, function(end, style) {
  1183. return st.push(end, style);
  1184. }, lineClasses, forceToEnd);
  1185. var state = context.state;
  1186. var loop = function(o$1) {
  1187. context.baseTokens = st;
  1188. var overlay = cm.state.overlays[o$1], i$3 = 1, at = 0;
  1189. context.state = true;
  1190. runMode(cm, line.text, overlay.mode, context, function(end, style) {
  1191. var start = i$3;
  1192. while (at < end) {
  1193. var i_end = st[i$3];
  1194. if (i_end > end) st.splice(i$3, 1, end, st[i$3 + 1], i_end);
  1195. i$3 += 2;
  1196. at = Math.min(end, i_end);
  1197. }
  1198. if (!style) return;
  1199. if (overlay.opaque) {
  1200. st.splice(start, i$3 - start, end, "overlay " + style);
  1201. i$3 = start + 2;
  1202. } else for (; start < i$3; start += 2) {
  1203. var cur = st[start + 1];
  1204. st[start + 1] = (cur ? cur + " " : "") + "overlay " + style;
  1205. }
  1206. }, lineClasses);
  1207. context.state = state;
  1208. context.baseTokens = null;
  1209. context.baseTokenPos = 1;
  1210. };
  1211. for (var o = 0; o < cm.state.overlays.length; ++o) loop(o);
  1212. return {
  1213. styles: st,
  1214. classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null
  1215. };
  1216. }
  1217. function getLineStyles(cm, line, updateFrontier) {
  1218. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  1219. var context = getContextBefore(cm, lineNo(line));
  1220. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  1221. var result = highlightLine(cm, line, context);
  1222. if (resetState) context.state = resetState;
  1223. line.stateAfter = context.save(!resetState);
  1224. line.styles = result.styles;
  1225. if (result.classes) line.styleClasses = result.classes;
  1226. else if (line.styleClasses) line.styleClasses = null;
  1227. if (updateFrontier === cm.doc.highlightFrontier) cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier);
  1228. }
  1229. return line.styles;
  1230. }
  1231. function getContextBefore(cm, n, precise) {
  1232. var doc$1 = cm.doc, display = cm.display;
  1233. if (!doc$1.mode.startState) return new Context(doc$1, true, n);
  1234. var start = findStartLine(cm, n, precise);
  1235. var saved = start > doc$1.first && getLine(doc$1, start - 1).stateAfter;
  1236. var context = saved ? Context.fromSaved(doc$1, saved, start) : new Context(doc$1, startState(doc$1.mode), start);
  1237. doc$1.iter(start, n, function(line) {
  1238. processLine(cm, line.text, context);
  1239. var pos = context.line;
  1240. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  1241. context.nextLine();
  1242. });
  1243. if (precise) doc$1.modeFrontier = context.line;
  1244. return context;
  1245. }
  1246. function processLine(cm, text, context, startAt) {
  1247. var mode = cm.doc.mode;
  1248. var stream = new StringStream(text, cm.options.tabSize, context);
  1249. stream.start = stream.pos = startAt || 0;
  1250. if (text == "") callBlankLine(mode, context.state);
  1251. while (!stream.eol()) {
  1252. readToken(mode, stream, context.state);
  1253. stream.start = stream.pos;
  1254. }
  1255. }
  1256. function callBlankLine(mode, state) {
  1257. if (mode.blankLine) return mode.blankLine(state);
  1258. if (!mode.innerMode) return;
  1259. var inner = innerMode(mode, state);
  1260. if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
  1261. }
  1262. function readToken(mode, stream, state, inner) {
  1263. for (var i$3 = 0; i$3 < 10; i$3++) {
  1264. if (inner) inner[0] = innerMode(mode, state).mode;
  1265. var style = mode.token(stream, state);
  1266. if (stream.pos > stream.start) return style;
  1267. }
  1268. throw new Error("Mode " + mode.name + " failed to advance stream.");
  1269. }
  1270. var Token = function(stream, type, state) {
  1271. this.start = stream.start;
  1272. this.end = stream.pos;
  1273. this.string = stream.current();
  1274. this.type = type || null;
  1275. this.state = state;
  1276. };
  1277. function takeToken(cm, pos, precise, asArray) {
  1278. var doc$1 = cm.doc, mode = doc$1.mode, style;
  1279. pos = clipPos(doc$1, pos);
  1280. var line = getLine(doc$1, pos.line), context = getContextBefore(cm, pos.line, precise);
  1281. var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
  1282. if (asArray) tokens = [];
  1283. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  1284. stream.start = stream.pos;
  1285. style = readToken(mode, stream, context.state);
  1286. if (asArray) tokens.push(new Token(stream, style, copyState(doc$1.mode, context.state)));
  1287. }
  1288. return asArray ? tokens : new Token(stream, style, context.state);
  1289. }
  1290. function extractLineClasses(type, output) {
  1291. if (type) for (;;) {
  1292. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  1293. if (!lineClass) break;
  1294. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  1295. var prop$1 = lineClass[1] ? "bgClass" : "textClass";
  1296. if (output[prop$1] == null) output[prop$1] = lineClass[2];
  1297. else if (!new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)").test(output[prop$1])) output[prop$1] += " " + lineClass[2];
  1298. }
  1299. return type;
  1300. }
  1301. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  1302. var flattenSpans = mode.flattenSpans;
  1303. if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
  1304. var curStart = 0, curStyle = null;
  1305. var stream = new StringStream(text, cm.options.tabSize, context), style;
  1306. var inner = cm.options.addModeClass && [null];
  1307. if (text == "") extractLineClasses(callBlankLine(mode, context.state), lineClasses);
  1308. while (!stream.eol()) {
  1309. if (stream.pos > cm.options.maxHighlightLength) {
  1310. flattenSpans = false;
  1311. if (forceToEnd) processLine(cm, text, context, stream.pos);
  1312. stream.pos = text.length;
  1313. style = null;
  1314. } else style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  1315. if (inner) {
  1316. var mName = inner[0].name;
  1317. if (mName) style = "m-" + (style ? mName + " " + style : mName);
  1318. }
  1319. if (!flattenSpans || curStyle != style) {
  1320. while (curStart < stream.start) {
  1321. curStart = Math.min(stream.start, curStart + 5e3);
  1322. f(curStart, curStyle);
  1323. }
  1324. curStyle = style;
  1325. }
  1326. stream.start = stream.pos;
  1327. }
  1328. while (curStart < stream.pos) {
  1329. var pos = Math.min(stream.pos, curStart + 5e3);
  1330. f(pos, curStyle);
  1331. curStart = pos;
  1332. }
  1333. }
  1334. function findStartLine(cm, n, precise) {
  1335. var minindent, minline, doc$1 = cm.doc;
  1336. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1e3 : 100);
  1337. for (var search = n; search > lim; --search) {
  1338. if (search <= doc$1.first) return doc$1.first;
  1339. var line = getLine(doc$1, search - 1), after = line.stateAfter;
  1340. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc$1.modeFrontier)) return search;
  1341. var indented = countColumn(line.text, null, cm.options.tabSize);
  1342. if (minline == null || minindent > indented) {
  1343. minline = search - 1;
  1344. minindent = indented;
  1345. }
  1346. }
  1347. return minline;
  1348. }
  1349. function retreatFrontier(doc$1, n) {
  1350. doc$1.modeFrontier = Math.min(doc$1.modeFrontier, n);
  1351. if (doc$1.highlightFrontier < n - 10) return;
  1352. var start = doc$1.first;
  1353. for (var line = n - 1; line > start; line--) {
  1354. var saved = getLine(doc$1, line).stateAfter;
  1355. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  1356. start = line + 1;
  1357. break;
  1358. }
  1359. }
  1360. doc$1.highlightFrontier = Math.min(doc$1.highlightFrontier, start);
  1361. }
  1362. var sawReadOnlySpans = false, sawCollapsedSpans = false;
  1363. function seeReadOnlySpans() {
  1364. sawReadOnlySpans = true;
  1365. }
  1366. function seeCollapsedSpans() {
  1367. sawCollapsedSpans = true;
  1368. }
  1369. function MarkedSpan(marker, from, to) {
  1370. this.marker = marker;
  1371. this.from = from;
  1372. this.to = to;
  1373. }
  1374. function getMarkedSpanFor(spans, marker) {
  1375. if (spans) for (var i$3 = 0; i$3 < spans.length; ++i$3) {
  1376. var span = spans[i$3];
  1377. if (span.marker == marker) return span;
  1378. }
  1379. }
  1380. function removeMarkedSpan(spans, span) {
  1381. var r;
  1382. for (var i$3 = 0; i$3 < spans.length; ++i$3) if (spans[i$3] != span) (r || (r = [])).push(spans[i$3]);
  1383. return r;
  1384. }
  1385. function addMarkedSpan(line, span, op) {
  1386. var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet()));
  1387. if (inThisOp && line.markedSpans && inThisOp.has(line.markedSpans)) line.markedSpans.push(span);
  1388. else {
  1389. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  1390. if (inThisOp) inThisOp.add(line.markedSpans);
  1391. }
  1392. span.marker.attachLine(line);
  1393. }
  1394. function markedSpansBefore(old, startCh, isInsert) {
  1395. var nw;
  1396. if (old) for (var i$3 = 0; i$3 < old.length; ++i$3) {
  1397. var span = old[i$3], marker = span.marker;
  1398. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  1399. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  1400. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
  1401. (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  1402. }
  1403. }
  1404. return nw;
  1405. }
  1406. function markedSpansAfter(old, endCh, isInsert) {
  1407. var nw;
  1408. if (old) for (var i$3 = 0; i$3 < old.length; ++i$3) {
  1409. var span = old[i$3], marker = span.marker;
  1410. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  1411. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  1412. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
  1413. (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh));
  1414. }
  1415. }
  1416. return nw;
  1417. }
  1418. function stretchSpansOverChange(doc$1, change) {
  1419. if (change.full) return null;
  1420. var oldFirst = isLine(doc$1, change.from.line) && getLine(doc$1, change.from.line).markedSpans;
  1421. var oldLast = isLine(doc$1, change.to.line) && getLine(doc$1, change.to.line).markedSpans;
  1422. if (!oldFirst && !oldLast) return null;
  1423. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
  1424. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  1425. var last = markedSpansAfter(oldLast, endCh, isInsert);
  1426. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
  1427. if (first) for (var i$3 = 0; i$3 < first.length; ++i$3) {
  1428. var span = first[i$3];
  1429. if (span.to == null) {
  1430. var found = getMarkedSpanFor(last, span.marker);
  1431. if (!found) span.to = startCh;
  1432. else if (sameLine) span.to = found.to == null ? null : found.to + offset;
  1433. }
  1434. }
  1435. if (last) for (var i$1$1 = 0; i$1$1 < last.length; ++i$1$1) {
  1436. var span$1 = last[i$1$1];
  1437. if (span$1.to != null) span$1.to += offset;
  1438. if (span$1.from == null) {
  1439. var found$1 = getMarkedSpanFor(first, span$1.marker);
  1440. if (!found$1) {
  1441. span$1.from = offset;
  1442. if (sameLine) (first || (first = [])).push(span$1);
  1443. }
  1444. } else {
  1445. span$1.from += offset;
  1446. if (sameLine) (first || (first = [])).push(span$1);
  1447. }
  1448. }
  1449. if (first) first = clearEmptySpans(first);
  1450. if (last && last != first) last = clearEmptySpans(last);
  1451. var newMarkers = [first];
  1452. if (!sameLine) {
  1453. var gap = change.text.length - 2, gapMarkers;
  1454. if (gap > 0 && first) {
  1455. for (var i$2$1 = 0; i$2$1 < first.length; ++i$2$1) if (first[i$2$1].to == null) (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2$1].marker, null, null));
  1456. }
  1457. for (var i$3$1 = 0; i$3$1 < gap; ++i$3$1) newMarkers.push(gapMarkers);
  1458. newMarkers.push(last);
  1459. }
  1460. return newMarkers;
  1461. }
  1462. function clearEmptySpans(spans) {
  1463. for (var i$3 = 0; i$3 < spans.length; ++i$3) {
  1464. var span = spans[i$3];
  1465. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) spans.splice(i$3--, 1);
  1466. }
  1467. if (!spans.length) return null;
  1468. return spans;
  1469. }
  1470. function removeReadOnlyRanges(doc$1, from, to) {
  1471. var markers = null;
  1472. doc$1.iter(from.line, to.line + 1, function(line) {
  1473. if (line.markedSpans) for (var i$4 = 0; i$4 < line.markedSpans.length; ++i$4) {
  1474. var mark = line.markedSpans[i$4].marker;
  1475. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) (markers || (markers = [])).push(mark);
  1476. }
  1477. });
  1478. if (!markers) return null;
  1479. var parts = [{
  1480. from,
  1481. to
  1482. }];
  1483. for (var i$3 = 0; i$3 < markers.length; ++i$3) {
  1484. var mk = markers[i$3], m = mk.find(0);
  1485. for (var j = 0; j < parts.length; ++j) {
  1486. var p = parts[j];
  1487. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
  1488. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
  1489. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) newParts.push({
  1490. from: p.from,
  1491. to: m.from
  1492. });
  1493. if (dto > 0 || !mk.inclusiveRight && !dto) newParts.push({
  1494. from: m.to,
  1495. to: p.to
  1496. });
  1497. parts.splice.apply(parts, newParts);
  1498. j += newParts.length - 3;
  1499. }
  1500. }
  1501. return parts;
  1502. }
  1503. function detachMarkedSpans(line) {
  1504. var spans = line.markedSpans;
  1505. if (!spans) return;
  1506. for (var i$3 = 0; i$3 < spans.length; ++i$3) spans[i$3].marker.detachLine(line);
  1507. line.markedSpans = null;
  1508. }
  1509. function attachMarkedSpans(line, spans) {
  1510. if (!spans) return;
  1511. for (var i$3 = 0; i$3 < spans.length; ++i$3) spans[i$3].marker.attachLine(line);
  1512. line.markedSpans = spans;
  1513. }
  1514. function extraLeft(marker) {
  1515. return marker.inclusiveLeft ? -1 : 0;
  1516. }
  1517. function extraRight(marker) {
  1518. return marker.inclusiveRight ? 1 : 0;
  1519. }
  1520. function compareCollapsedMarkers(a, b) {
  1521. var lenDiff = a.lines.length - b.lines.length;
  1522. if (lenDiff != 0) return lenDiff;
  1523. var aPos = a.find(), bPos = b.find();
  1524. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  1525. if (fromCmp) return -fromCmp;
  1526. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  1527. if (toCmp) return toCmp;
  1528. return b.id - a.id;
  1529. }
  1530. function collapsedSpanAtSide(line, start) {
  1531. var sps = sawCollapsedSpans && line.markedSpans, found;
  1532. if (sps) for (var sp = void 0, i$3 = 0; i$3 < sps.length; ++i$3) {
  1533. sp = sps[i$3];
  1534. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) found = sp.marker;
  1535. }
  1536. return found;
  1537. }
  1538. function collapsedSpanAtStart(line) {
  1539. return collapsedSpanAtSide(line, true);
  1540. }
  1541. function collapsedSpanAtEnd(line) {
  1542. return collapsedSpanAtSide(line, false);
  1543. }
  1544. function collapsedSpanAround(line, ch) {
  1545. var sps = sawCollapsedSpans && line.markedSpans, found;
  1546. if (sps) for (var i$3 = 0; i$3 < sps.length; ++i$3) {
  1547. var sp = sps[i$3];
  1548. if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) found = sp.marker;
  1549. }
  1550. return found;
  1551. }
  1552. function conflictingCollapsedRange(doc$1, lineNo$1, from, to, marker) {
  1553. var line = getLine(doc$1, lineNo$1);
  1554. var sps = sawCollapsedSpans && line.markedSpans;
  1555. if (sps) for (var i$3 = 0; i$3 < sps.length; ++i$3) {
  1556. var sp = sps[i$3];
  1557. if (!sp.marker.collapsed) continue;
  1558. var found = sp.marker.find(0);
  1559. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  1560. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  1561. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
  1562. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) return true;
  1563. }
  1564. }
  1565. function visualLine(line) {
  1566. var merged;
  1567. while (merged = collapsedSpanAtStart(line)) line = merged.find(-1, true).line;
  1568. return line;
  1569. }
  1570. function visualLineEnd(line) {
  1571. var merged;
  1572. while (merged = collapsedSpanAtEnd(line)) line = merged.find(1, true).line;
  1573. return line;
  1574. }
  1575. function visualLineContinued(line) {
  1576. var merged, lines;
  1577. while (merged = collapsedSpanAtEnd(line)) {
  1578. line = merged.find(1, true).line;
  1579. (lines || (lines = [])).push(line);
  1580. }
  1581. return lines;
  1582. }
  1583. function visualLineNo(doc$1, lineN) {
  1584. var line = getLine(doc$1, lineN), vis = visualLine(line);
  1585. if (line == vis) return lineN;
  1586. return lineNo(vis);
  1587. }
  1588. function visualLineEndNo(doc$1, lineN) {
  1589. if (lineN > doc$1.lastLine()) return lineN;
  1590. var line = getLine(doc$1, lineN), merged;
  1591. if (!lineIsHidden(doc$1, line)) return lineN;
  1592. while (merged = collapsedSpanAtEnd(line)) line = merged.find(1, true).line;
  1593. return lineNo(line) + 1;
  1594. }
  1595. function lineIsHidden(doc$1, line) {
  1596. var sps = sawCollapsedSpans && line.markedSpans;
  1597. if (sps) for (var sp = void 0, i$3 = 0; i$3 < sps.length; ++i$3) {
  1598. sp = sps[i$3];
  1599. if (!sp.marker.collapsed) continue;
  1600. if (sp.from == null) return true;
  1601. if (sp.marker.widgetNode) continue;
  1602. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc$1, line, sp)) return true;
  1603. }
  1604. }
  1605. function lineIsHiddenInner(doc$1, line, span) {
  1606. if (span.to == null) {
  1607. var end = span.marker.find(1, true);
  1608. return lineIsHiddenInner(doc$1, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
  1609. }
  1610. if (span.marker.inclusiveRight && span.to == line.text.length) return true;
  1611. for (var sp = void 0, i$3 = 0; i$3 < line.markedSpans.length; ++i$3) {
  1612. sp = line.markedSpans[i$3];
  1613. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc$1, line, sp)) return true;
  1614. }
  1615. }
  1616. function heightAtLine(lineObj) {
  1617. lineObj = visualLine(lineObj);
  1618. var h$1 = 0, chunk = lineObj.parent;
  1619. for (var i$3 = 0; i$3 < chunk.lines.length; ++i$3) {
  1620. var line = chunk.lines[i$3];
  1621. if (line == lineObj) break;
  1622. else h$1 += line.height;
  1623. }
  1624. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) for (var i$1$1 = 0; i$1$1 < p.children.length; ++i$1$1) {
  1625. var cur = p.children[i$1$1];
  1626. if (cur == chunk) break;
  1627. else h$1 += cur.height;
  1628. }
  1629. return h$1;
  1630. }
  1631. function lineLength(line) {
  1632. if (line.height == 0) return 0;
  1633. var len = line.text.length, merged, cur = line;
  1634. while (merged = collapsedSpanAtStart(cur)) {
  1635. var found = merged.find(0, true);
  1636. cur = found.from.line;
  1637. len += found.from.ch - found.to.ch;
  1638. }
  1639. cur = line;
  1640. while (merged = collapsedSpanAtEnd(cur)) {
  1641. var found$1 = merged.find(0, true);
  1642. len -= cur.text.length - found$1.from.ch;
  1643. cur = found$1.to.line;
  1644. len += cur.text.length - found$1.to.ch;
  1645. }
  1646. return len;
  1647. }
  1648. function findMaxLine(cm) {
  1649. var d = cm.display, doc$1 = cm.doc;
  1650. d.maxLine = getLine(doc$1, doc$1.first);
  1651. d.maxLineLength = lineLength(d.maxLine);
  1652. d.maxLineChanged = true;
  1653. doc$1.iter(function(line) {
  1654. var len = lineLength(line);
  1655. if (len > d.maxLineLength) {
  1656. d.maxLineLength = len;
  1657. d.maxLine = line;
  1658. }
  1659. });
  1660. }
  1661. var Line = function(text, markedSpans, estimateHeight$1) {
  1662. this.text = text;
  1663. attachMarkedSpans(this, markedSpans);
  1664. this.height = estimateHeight$1 ? estimateHeight$1(this) : 1;
  1665. };
  1666. Line.prototype.lineNo = function() {
  1667. return lineNo(this);
  1668. };
  1669. eventMixin(Line);
  1670. function updateLine(line, text, markedSpans, estimateHeight$1) {
  1671. line.text = text;
  1672. if (line.stateAfter) line.stateAfter = null;
  1673. if (line.styles) line.styles = null;
  1674. if (line.order != null) line.order = null;
  1675. detachMarkedSpans(line);
  1676. attachMarkedSpans(line, markedSpans);
  1677. var estHeight = estimateHeight$1 ? estimateHeight$1(line) : 1;
  1678. if (estHeight != line.height) updateLineHeight(line, estHeight);
  1679. }
  1680. function cleanUpLine(line) {
  1681. line.parent = null;
  1682. detachMarkedSpans(line);
  1683. }
  1684. var styleToClassCache = {}, styleToClassCacheWithMode = {};
  1685. function interpretTokenStyle(style, options) {
  1686. if (!style || /^\s*$/.test(style)) return null;
  1687. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  1688. return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&"));
  1689. }
  1690. function buildLineContent(cm, lineView) {
  1691. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  1692. var builder = {
  1693. pre: eltP("pre", [content], "CodeMirror-line"),
  1694. content,
  1695. col: 0,
  1696. pos: 0,
  1697. cm,
  1698. trailingSpace: false,
  1699. splitSpaces: cm.getOption("lineWrapping")
  1700. };
  1701. lineView.measure = {};
  1702. for (var i$3 = 0; i$3 <= (lineView.rest ? lineView.rest.length : 0); i$3++) {
  1703. var line = i$3 ? lineView.rest[i$3 - 1] : lineView.line, order = void 0;
  1704. builder.pos = 0;
  1705. builder.addToken = buildToken;
  1706. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) builder.addToken = buildTokenBadBidi(builder.addToken, order);
  1707. builder.map = [];
  1708. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  1709. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  1710. if (line.styleClasses) {
  1711. if (line.styleClasses.bgClass) builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
  1712. if (line.styleClasses.textClass) builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
  1713. }
  1714. if (builder.map.length == 0) builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
  1715. if (i$3 == 0) {
  1716. lineView.measure.map = builder.map;
  1717. lineView.measure.cache = {};
  1718. } else {
  1719. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
  1720. (lineView.measure.caches || (lineView.measure.caches = [])).push({});
  1721. }
  1722. }
  1723. if (webkit) {
  1724. var last = builder.content.lastChild;
  1725. if (/\bcm-tab\b/.test(last.className) || last.querySelector && last.querySelector(".cm-tab")) builder.content.className = "cm-tab-wrap-hack";
  1726. }
  1727. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  1728. if (builder.pre.className) builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
  1729. return builder;
  1730. }
  1731. function defaultSpecialCharPlaceholder(ch) {
  1732. var token = elt("span", "•", "cm-invalidchar");
  1733. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  1734. token.setAttribute("aria-label", token.title);
  1735. return token;
  1736. }
  1737. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
  1738. if (!text) return;
  1739. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  1740. var special = builder.cm.state.specialChars, mustWrap = false;
  1741. var content;
  1742. if (!special.test(text)) {
  1743. builder.col += text.length;
  1744. content = document.createTextNode(displayText);
  1745. builder.map.push(builder.pos, builder.pos + text.length, content);
  1746. if (ie && ie_version < 9) mustWrap = true;
  1747. builder.pos += text.length;
  1748. } else {
  1749. content = document.createDocumentFragment();
  1750. var pos = 0;
  1751. while (true) {
  1752. special.lastIndex = pos;
  1753. var m = special.exec(text);
  1754. var skipped = m ? m.index - pos : text.length - pos;
  1755. if (skipped) {
  1756. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  1757. if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
  1758. else content.appendChild(txt);
  1759. builder.map.push(builder.pos, builder.pos + skipped, txt);
  1760. builder.col += skipped;
  1761. builder.pos += skipped;
  1762. }
  1763. if (!m) break;
  1764. pos += skipped + 1;
  1765. var txt$1 = void 0;
  1766. if (m[0] == " ") {
  1767. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
  1768. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  1769. txt$1.setAttribute("role", "presentation");
  1770. txt$1.setAttribute("cm-text", " ");
  1771. builder.col += tabWidth;
  1772. } else if (m[0] == "\r" || m[0] == "\n") {
  1773. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "␍" : "␤", "cm-invalidchar"));
  1774. txt$1.setAttribute("cm-text", m[0]);
  1775. builder.col += 1;
  1776. } else {
  1777. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  1778. txt$1.setAttribute("cm-text", m[0]);
  1779. if (ie && ie_version < 9) content.appendChild(elt("span", [txt$1]));
  1780. else content.appendChild(txt$1);
  1781. builder.col += 1;
  1782. }
  1783. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  1784. builder.pos++;
  1785. }
  1786. }
  1787. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  1788. if (style || startStyle || endStyle || mustWrap || css || attributes) {
  1789. var fullStyle = style || "";
  1790. if (startStyle) fullStyle += startStyle;
  1791. if (endStyle) fullStyle += endStyle;
  1792. var token = elt("span", [content], fullStyle, css);
  1793. if (attributes) {
  1794. for (var attr in attributes) if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") token.setAttribute(attr, attributes[attr]);
  1795. }
  1796. return builder.content.appendChild(token);
  1797. }
  1798. builder.content.appendChild(content);
  1799. }
  1800. function splitSpaces(text, trailingBefore) {
  1801. if (text.length > 1 && !/ /.test(text)) return text;
  1802. var spaceBefore = trailingBefore, result = "";
  1803. for (var i$3 = 0; i$3 < text.length; i$3++) {
  1804. var ch = text.charAt(i$3);
  1805. if (ch == " " && spaceBefore && (i$3 == text.length - 1 || text.charCodeAt(i$3 + 1) == 32)) ch = "\xA0";
  1806. result += ch;
  1807. spaceBefore = ch == " ";
  1808. }
  1809. return result;
  1810. }
  1811. function buildTokenBadBidi(inner, order) {
  1812. return function(builder, text, style, startStyle, endStyle, css, attributes) {
  1813. style = style ? style + " cm-force-border" : "cm-force-border";
  1814. var start = builder.pos, end = start + text.length;
  1815. for (;;) {
  1816. var part = void 0;
  1817. for (var i$3 = 0; i$3 < order.length; i$3++) {
  1818. part = order[i$3];
  1819. if (part.to > start && part.from <= start) break;
  1820. }
  1821. if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, css, attributes);
  1822. inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);
  1823. startStyle = null;
  1824. text = text.slice(part.to - start);
  1825. start = part.to;
  1826. }
  1827. };
  1828. }
  1829. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  1830. var widget = !ignoreWidget && marker.widgetNode;
  1831. if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
  1832. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  1833. if (!widget) widget = builder.content.appendChild(document.createElement("span"));
  1834. widget.setAttribute("cm-marker", marker.id);
  1835. }
  1836. if (widget) {
  1837. builder.cm.display.input.setUneditable(widget);
  1838. builder.content.appendChild(widget);
  1839. }
  1840. builder.pos += size;
  1841. builder.trailingSpace = false;
  1842. }
  1843. function insertLineContent(line, builder, styles) {
  1844. var spans = line.markedSpans, allText = line.text, at = 0;
  1845. if (!spans) {
  1846. for (var i$1$1 = 1; i$1$1 < styles.length; i$1$1 += 2) builder.addToken(builder, allText.slice(at, at = styles[i$1$1]), interpretTokenStyle(styles[i$1$1 + 1], builder.cm.options));
  1847. return;
  1848. }
  1849. var len = allText.length, pos = 0, i$3 = 1, text = "", style, css;
  1850. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes;
  1851. for (;;) {
  1852. if (nextChange == pos) {
  1853. spanStyle = spanEndStyle = spanStartStyle = css = "";
  1854. attributes = null;
  1855. collapsed = null;
  1856. nextChange = Infinity;
  1857. var foundBookmarks = [], endStyles = void 0;
  1858. for (var j = 0; j < spans.length; ++j) {
  1859. var sp = spans[j], m = sp.marker;
  1860. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
  1861. else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  1862. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  1863. nextChange = sp.to;
  1864. spanEndStyle = "";
  1865. }
  1866. if (m.className) spanStyle += " " + m.className;
  1867. if (m.css) css = (css ? css + ";" : "") + m.css;
  1868. if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
  1869. if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to);
  1870. if (m.title) (attributes || (attributes = {})).title = m.title;
  1871. if (m.attributes) for (var attr in m.attributes) (attributes || (attributes = {}))[attr] = m.attributes[attr];
  1872. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) collapsed = sp;
  1873. } else if (sp.from > pos && nextChange > sp.from) nextChange = sp.from;
  1874. }
  1875. if (endStyles) {
  1876. for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) if (endStyles[j$1 + 1] == nextChange) spanEndStyle += " " + endStyles[j$1];
  1877. }
  1878. if (!collapsed || collapsed.from == pos) for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) buildCollapsedSpan(builder, 0, foundBookmarks[j$2]);
  1879. if (collapsed && (collapsed.from || 0) == pos) {
  1880. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null);
  1881. if (collapsed.to == null) return;
  1882. if (collapsed.to == pos) collapsed = false;
  1883. }
  1884. }
  1885. if (pos >= len) break;
  1886. var upto = Math.min(len, nextChange);
  1887. while (true) {
  1888. if (text) {
  1889. var end = pos + text.length;
  1890. if (!collapsed) {
  1891. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  1892. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes);
  1893. }
  1894. if (end >= upto) {
  1895. text = text.slice(upto - pos);
  1896. pos = upto;
  1897. break;
  1898. }
  1899. pos = end;
  1900. spanStartStyle = "";
  1901. }
  1902. text = allText.slice(at, at = styles[i$3++]);
  1903. style = interpretTokenStyle(styles[i$3++], builder.cm.options);
  1904. }
  1905. }
  1906. }
  1907. function LineView(doc$1, line, lineN) {
  1908. this.line = line;
  1909. this.rest = visualLineContinued(line);
  1910. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  1911. this.node = this.text = null;
  1912. this.hidden = lineIsHidden(doc$1, line);
  1913. }
  1914. function buildViewArray(cm, from, to) {
  1915. var array = [], nextPos;
  1916. for (var pos = from; pos < to; pos = nextPos) {
  1917. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  1918. nextPos = pos + view.size;
  1919. array.push(view);
  1920. }
  1921. return array;
  1922. }
  1923. var operationGroup = null;
  1924. function pushOperation(op) {
  1925. if (operationGroup) operationGroup.ops.push(op);
  1926. else op.ownsGroup = operationGroup = {
  1927. ops: [op],
  1928. delayedCallbacks: []
  1929. };
  1930. }
  1931. function fireCallbacksForOps(group) {
  1932. var callbacks = group.delayedCallbacks, i$3 = 0;
  1933. do {
  1934. for (; i$3 < callbacks.length; i$3++) callbacks[i$3].call(null);
  1935. for (var j = 0; j < group.ops.length; j++) {
  1936. var op = group.ops[j];
  1937. if (op.cursorActivityHandlers) while (op.cursorActivityCalled < op.cursorActivityHandlers.length) op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
  1938. }
  1939. } while (i$3 < callbacks.length);
  1940. }
  1941. function finishOperation(op, endCb) {
  1942. var group = op.ownsGroup;
  1943. if (!group) return;
  1944. try {
  1945. fireCallbacksForOps(group);
  1946. } finally {
  1947. operationGroup = null;
  1948. endCb(group);
  1949. }
  1950. }
  1951. var orphanDelayedCallbacks = null;
  1952. function signalLater(emitter, type) {
  1953. var arr = getHandlers(emitter, type);
  1954. if (!arr.length) return;
  1955. var args = Array.prototype.slice.call(arguments, 2), list;
  1956. if (operationGroup) list = operationGroup.delayedCallbacks;
  1957. else if (orphanDelayedCallbacks) list = orphanDelayedCallbacks;
  1958. else {
  1959. list = orphanDelayedCallbacks = [];
  1960. setTimeout(fireOrphanDelayed, 0);
  1961. }
  1962. var loop = function(i$4) {
  1963. list.push(function() {
  1964. return arr[i$4].apply(null, args);
  1965. });
  1966. };
  1967. for (var i$3 = 0; i$3 < arr.length; ++i$3) loop(i$3);
  1968. }
  1969. function fireOrphanDelayed() {
  1970. var delayed = orphanDelayedCallbacks;
  1971. orphanDelayedCallbacks = null;
  1972. for (var i$3 = 0; i$3 < delayed.length; ++i$3) delayed[i$3]();
  1973. }
  1974. function updateLineForChanges(cm, lineView, lineN, dims) {
  1975. for (var j = 0; j < lineView.changes.length; j++) {
  1976. var type = lineView.changes[j];
  1977. if (type == "text") updateLineText(cm, lineView);
  1978. else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
  1979. else if (type == "class") updateLineClasses(cm, lineView);
  1980. else if (type == "widget") updateLineWidgets(cm, lineView, dims);
  1981. }
  1982. lineView.changes = null;
  1983. }
  1984. function ensureLineWrapped(lineView) {
  1985. if (lineView.node == lineView.text) {
  1986. lineView.node = elt("div", null, null, "position: relative");
  1987. if (lineView.text.parentNode) lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
  1988. lineView.node.appendChild(lineView.text);
  1989. if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
  1990. }
  1991. return lineView.node;
  1992. }
  1993. function updateLineBackground(cm, lineView) {
  1994. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  1995. if (cls) cls += " CodeMirror-linebackground";
  1996. if (lineView.background) if (cls) lineView.background.className = cls;
  1997. else {
  1998. lineView.background.parentNode.removeChild(lineView.background);
  1999. lineView.background = null;
  2000. }
  2001. else if (cls) {
  2002. var wrap$1 = ensureLineWrapped(lineView);
  2003. lineView.background = wrap$1.insertBefore(elt("div", null, cls), wrap$1.firstChild);
  2004. cm.display.input.setUneditable(lineView.background);
  2005. }
  2006. }
  2007. function getLineContent(cm, lineView) {
  2008. var ext = cm.display.externalMeasured;
  2009. if (ext && ext.line == lineView.line) {
  2010. cm.display.externalMeasured = null;
  2011. lineView.measure = ext.measure;
  2012. return ext.built;
  2013. }
  2014. return buildLineContent(cm, lineView);
  2015. }
  2016. function updateLineText(cm, lineView) {
  2017. var cls = lineView.text.className;
  2018. var built = getLineContent(cm, lineView);
  2019. if (lineView.text == lineView.node) lineView.node = built.pre;
  2020. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  2021. lineView.text = built.pre;
  2022. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  2023. lineView.bgClass = built.bgClass;
  2024. lineView.textClass = built.textClass;
  2025. updateLineClasses(cm, lineView);
  2026. } else if (cls) lineView.text.className = cls;
  2027. }
  2028. function updateLineClasses(cm, lineView) {
  2029. updateLineBackground(cm, lineView);
  2030. if (lineView.line.wrapClass) ensureLineWrapped(lineView).className = lineView.line.wrapClass;
  2031. else if (lineView.node != lineView.text) lineView.node.className = "";
  2032. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  2033. lineView.text.className = textClass || "";
  2034. }
  2035. function updateLineGutter(cm, lineView, lineN, dims) {
  2036. if (lineView.gutter) {
  2037. lineView.node.removeChild(lineView.gutter);
  2038. lineView.gutter = null;
  2039. }
  2040. if (lineView.gutterBackground) {
  2041. lineView.node.removeChild(lineView.gutterBackground);
  2042. lineView.gutterBackground = null;
  2043. }
  2044. if (lineView.line.gutterClass) {
  2045. var wrap$1 = ensureLineWrapped(lineView);
  2046. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + dims.gutterTotalWidth + "px");
  2047. cm.display.input.setUneditable(lineView.gutterBackground);
  2048. wrap$1.insertBefore(lineView.gutterBackground, lineView.text);
  2049. }
  2050. var markers = lineView.line.gutterMarkers;
  2051. if (cm.options.lineNumbers || markers) {
  2052. var wrap$1$1 = ensureLineWrapped(lineView);
  2053. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
  2054. gutterWrap.setAttribute("aria-hidden", "true");
  2055. cm.display.input.setUneditable(gutterWrap);
  2056. wrap$1$1.insertBefore(gutterWrap, lineView.text);
  2057. if (lineView.line.gutterClass) gutterWrap.className += " " + lineView.line.gutterClass;
  2058. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) lineView.lineNumber = gutterWrap.appendChild(elt("div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + cm.display.lineNumInnerWidth + "px"));
  2059. if (markers) for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {
  2060. var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id];
  2061. if (found) gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
  2062. }
  2063. }
  2064. }
  2065. function updateLineWidgets(cm, lineView, dims) {
  2066. if (lineView.alignable) lineView.alignable = null;
  2067. var isWidget = classTest("CodeMirror-linewidget");
  2068. for (var node = lineView.node.firstChild, next = void 0; node; node = next) {
  2069. next = node.nextSibling;
  2070. if (isWidget.test(node.className)) lineView.node.removeChild(node);
  2071. }
  2072. insertLineWidgets(cm, lineView, dims);
  2073. }
  2074. function buildLineElement(cm, lineView, lineN, dims) {
  2075. var built = getLineContent(cm, lineView);
  2076. lineView.text = lineView.node = built.pre;
  2077. if (built.bgClass) lineView.bgClass = built.bgClass;
  2078. if (built.textClass) lineView.textClass = built.textClass;
  2079. updateLineClasses(cm, lineView);
  2080. updateLineGutter(cm, lineView, lineN, dims);
  2081. insertLineWidgets(cm, lineView, dims);
  2082. return lineView.node;
  2083. }
  2084. function insertLineWidgets(cm, lineView, dims) {
  2085. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  2086. if (lineView.rest) for (var i$3 = 0; i$3 < lineView.rest.length; i$3++) insertLineWidgetsFor(cm, lineView.rest[i$3], lineView, dims, false);
  2087. }
  2088. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  2089. if (!line.widgets) return;
  2090. var wrap$1 = ensureLineWrapped(lineView);
  2091. for (var i$3 = 0, ws = line.widgets; i$3 < ws.length; ++i$3) {
  2092. var widget = ws[i$3], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : ""));
  2093. if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
  2094. positionLineWidget(widget, node, lineView, dims);
  2095. cm.display.input.setUneditable(node);
  2096. if (allowAbove && widget.above) wrap$1.insertBefore(node, lineView.gutter || lineView.text);
  2097. else wrap$1.appendChild(node);
  2098. signalLater(widget, "redraw");
  2099. }
  2100. }
  2101. function positionLineWidget(widget, node, lineView, dims) {
  2102. if (widget.noHScroll) {
  2103. (lineView.alignable || (lineView.alignable = [])).push(node);
  2104. var width = dims.wrapperWidth;
  2105. node.style.left = dims.fixedPos + "px";
  2106. if (!widget.coverGutter) {
  2107. width -= dims.gutterTotalWidth;
  2108. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  2109. }
  2110. node.style.width = width + "px";
  2111. }
  2112. if (widget.coverGutter) {
  2113. node.style.zIndex = 5;
  2114. node.style.position = "relative";
  2115. if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
  2116. }
  2117. }
  2118. function widgetHeight(widget) {
  2119. if (widget.height != null) return widget.height;
  2120. var cm = widget.doc.cm;
  2121. if (!cm) return 0;
  2122. if (!contains(document.body, widget.node)) {
  2123. var parentStyle = "position: relative;";
  2124. if (widget.coverGutter) parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
  2125. if (widget.noHScroll) parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
  2126. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  2127. }
  2128. return widget.height = widget.node.parentNode.offsetHeight;
  2129. }
  2130. function eventInWidget(display, e) {
  2131. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) if (!n || n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true" || n.parentNode == display.sizer && n != display.mover) return true;
  2132. }
  2133. function paddingTop(display) {
  2134. return display.lineSpace.offsetTop;
  2135. }
  2136. function paddingVert(display) {
  2137. return display.mover.offsetHeight - display.lineSpace.offsetHeight;
  2138. }
  2139. function paddingH(display) {
  2140. if (display.cachedPaddingH) return display.cachedPaddingH;
  2141. var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like"));
  2142. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  2143. var data = {
  2144. left: parseInt(style.paddingLeft),
  2145. right: parseInt(style.paddingRight)
  2146. };
  2147. if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
  2148. return data;
  2149. }
  2150. function scrollGap(cm) {
  2151. return scrollerGap - cm.display.nativeBarWidth;
  2152. }
  2153. function displayWidth(cm) {
  2154. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
  2155. }
  2156. function displayHeight(cm) {
  2157. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
  2158. }
  2159. function ensureLineHeights(cm, lineView, rect) {
  2160. var wrapping = cm.options.lineWrapping;
  2161. var curWidth = wrapping && displayWidth(cm);
  2162. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  2163. var heights = lineView.measure.heights = [];
  2164. if (wrapping) {
  2165. lineView.measure.width = curWidth;
  2166. var rects = lineView.text.firstChild.getClientRects();
  2167. for (var i$3 = 0; i$3 < rects.length - 1; i$3++) {
  2168. var cur = rects[i$3], next = rects[i$3 + 1];
  2169. if (Math.abs(cur.bottom - next.bottom) > 2) heights.push((cur.bottom + next.top) / 2 - rect.top);
  2170. }
  2171. }
  2172. heights.push(rect.bottom - rect.top);
  2173. }
  2174. }
  2175. function mapFromLineView(lineView, line, lineN) {
  2176. if (lineView.line == line) return {
  2177. map: lineView.measure.map,
  2178. cache: lineView.measure.cache
  2179. };
  2180. if (lineView.rest) {
  2181. for (var i$3 = 0; i$3 < lineView.rest.length; i$3++) if (lineView.rest[i$3] == line) return {
  2182. map: lineView.measure.maps[i$3],
  2183. cache: lineView.measure.caches[i$3]
  2184. };
  2185. for (var i$1$1 = 0; i$1$1 < lineView.rest.length; i$1$1++) if (lineNo(lineView.rest[i$1$1]) > lineN) return {
  2186. map: lineView.measure.maps[i$1$1],
  2187. cache: lineView.measure.caches[i$1$1],
  2188. before: true
  2189. };
  2190. }
  2191. }
  2192. function updateExternalMeasurement(cm, line) {
  2193. line = visualLine(line);
  2194. var lineN = lineNo(line);
  2195. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  2196. view.lineN = lineN;
  2197. var built = view.built = buildLineContent(cm, view);
  2198. view.text = built.pre;
  2199. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  2200. return view;
  2201. }
  2202. function measureChar(cm, line, ch, bias) {
  2203. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
  2204. }
  2205. function findViewForLine(cm, lineN) {
  2206. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) return cm.display.view[findViewIndex(cm, lineN)];
  2207. var ext = cm.display.externalMeasured;
  2208. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) return ext;
  2209. }
  2210. function prepareMeasureForLine(cm, line) {
  2211. var lineN = lineNo(line);
  2212. var view = findViewForLine(cm, lineN);
  2213. if (view && !view.text) view = null;
  2214. else if (view && view.changes) {
  2215. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  2216. cm.curOp.forceUpdate = true;
  2217. }
  2218. if (!view) view = updateExternalMeasurement(cm, line);
  2219. var info = mapFromLineView(view, line, lineN);
  2220. return {
  2221. line,
  2222. view,
  2223. rect: null,
  2224. map: info.map,
  2225. cache: info.cache,
  2226. before: info.before,
  2227. hasHeights: false
  2228. };
  2229. }
  2230. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  2231. if (prepared.before) ch = -1;
  2232. var key = ch + (bias || ""), found;
  2233. if (prepared.cache.hasOwnProperty(key)) found = prepared.cache[key];
  2234. else {
  2235. if (!prepared.rect) prepared.rect = prepared.view.text.getBoundingClientRect();
  2236. if (!prepared.hasHeights) {
  2237. ensureLineHeights(cm, prepared.view, prepared.rect);
  2238. prepared.hasHeights = true;
  2239. }
  2240. found = measureCharInner(cm, prepared, ch, bias);
  2241. if (!found.bogus) prepared.cache[key] = found;
  2242. }
  2243. return {
  2244. left: found.left,
  2245. right: found.right,
  2246. top: varHeight ? found.rtop : found.top,
  2247. bottom: varHeight ? found.rbottom : found.bottom
  2248. };
  2249. }
  2250. var nullRect = {
  2251. left: 0,
  2252. right: 0,
  2253. top: 0,
  2254. bottom: 0
  2255. };
  2256. function nodeAndOffsetInLineMap(map$1, ch, bias) {
  2257. var node, start, end, collapse, mStart, mEnd;
  2258. for (var i$3 = 0; i$3 < map$1.length; i$3 += 3) {
  2259. mStart = map$1[i$3];
  2260. mEnd = map$1[i$3 + 1];
  2261. if (ch < mStart) {
  2262. start = 0;
  2263. end = 1;
  2264. collapse = "left";
  2265. } else if (ch < mEnd) {
  2266. start = ch - mStart;
  2267. end = start + 1;
  2268. } else if (i$3 == map$1.length - 3 || ch == mEnd && map$1[i$3 + 3] > ch) {
  2269. end = mEnd - mStart;
  2270. start = end - 1;
  2271. if (ch >= mEnd) collapse = "right";
  2272. }
  2273. if (start != null) {
  2274. node = map$1[i$3 + 2];
  2275. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) collapse = bias;
  2276. if (bias == "left" && start == 0) while (i$3 && map$1[i$3 - 2] == map$1[i$3 - 3] && map$1[i$3 - 1].insertLeft) {
  2277. node = map$1[(i$3 -= 3) + 2];
  2278. collapse = "left";
  2279. }
  2280. if (bias == "right" && start == mEnd - mStart) while (i$3 < map$1.length - 3 && map$1[i$3 + 3] == map$1[i$3 + 4] && !map$1[i$3 + 5].insertLeft) {
  2281. node = map$1[(i$3 += 3) + 2];
  2282. collapse = "right";
  2283. }
  2284. break;
  2285. }
  2286. }
  2287. return {
  2288. node,
  2289. start,
  2290. end,
  2291. collapse,
  2292. coverStart: mStart,
  2293. coverEnd: mEnd
  2294. };
  2295. }
  2296. function getUsefulRect(rects, bias) {
  2297. var rect = nullRect;
  2298. if (bias == "left") {
  2299. for (var i$3 = 0; i$3 < rects.length; i$3++) if ((rect = rects[i$3]).left != rect.right) break;
  2300. } else for (var i$1$1 = rects.length - 1; i$1$1 >= 0; i$1$1--) if ((rect = rects[i$1$1]).left != rect.right) break;
  2301. return rect;
  2302. }
  2303. function measureCharInner(cm, prepared, ch, bias) {
  2304. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  2305. var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
  2306. var rect;
  2307. if (node.nodeType == 3) {
  2308. for (var i$1$1 = 0; i$1$1 < 4; i$1$1++) {
  2309. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
  2310. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
  2311. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) rect = node.parentNode.getBoundingClientRect();
  2312. else rect = getUsefulRect(range(node, start, end).getClientRects(), bias);
  2313. if (rect.left || rect.right || start == 0) break;
  2314. end = start;
  2315. start = start - 1;
  2316. collapse = "right";
  2317. }
  2318. if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
  2319. } else {
  2320. if (start > 0) collapse = bias = "right";
  2321. var rects;
  2322. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) rect = rects[bias == "right" ? rects.length - 1 : 0];
  2323. else rect = node.getBoundingClientRect();
  2324. }
  2325. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  2326. var rSpan = node.parentNode.getClientRects()[0];
  2327. if (rSpan) rect = {
  2328. left: rSpan.left,
  2329. right: rSpan.left + charWidth(cm.display),
  2330. top: rSpan.top,
  2331. bottom: rSpan.bottom
  2332. };
  2333. else rect = nullRect;
  2334. }
  2335. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
  2336. var mid = (rtop + rbot) / 2;
  2337. var heights = prepared.view.measure.heights;
  2338. var i$3 = 0;
  2339. for (; i$3 < heights.length - 1; i$3++) if (mid < heights[i$3]) break;
  2340. var top = i$3 ? heights[i$3 - 1] : 0, bot = heights[i$3];
  2341. var result = {
  2342. left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  2343. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  2344. top,
  2345. bottom: bot
  2346. };
  2347. if (!rect.left && !rect.right) result.bogus = true;
  2348. if (!cm.options.singleCursorHeightPerLine) {
  2349. result.rtop = rtop;
  2350. result.rbottom = rbot;
  2351. }
  2352. return result;
  2353. }
  2354. function maybeUpdateRectForZooming(measure, rect) {
  2355. if (!window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) return rect;
  2356. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  2357. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  2358. return {
  2359. left: rect.left * scaleX,
  2360. right: rect.right * scaleX,
  2361. top: rect.top * scaleY,
  2362. bottom: rect.bottom * scaleY
  2363. };
  2364. }
  2365. function clearLineMeasurementCacheFor(lineView) {
  2366. if (lineView.measure) {
  2367. lineView.measure.cache = {};
  2368. lineView.measure.heights = null;
  2369. if (lineView.rest) for (var i$3 = 0; i$3 < lineView.rest.length; i$3++) lineView.measure.caches[i$3] = {};
  2370. }
  2371. }
  2372. function clearLineMeasurementCache(cm) {
  2373. cm.display.externalMeasure = null;
  2374. removeChildren(cm.display.lineMeasure);
  2375. for (var i$3 = 0; i$3 < cm.display.view.length; i$3++) clearLineMeasurementCacheFor(cm.display.view[i$3]);
  2376. }
  2377. function clearCaches(cm) {
  2378. clearLineMeasurementCache(cm);
  2379. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  2380. if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
  2381. cm.display.lineNumChars = null;
  2382. }
  2383. function pageScrollX(doc$1) {
  2384. if (chrome && android) return -(doc$1.body.getBoundingClientRect().left - parseInt(getComputedStyle(doc$1.body).marginLeft));
  2385. return doc$1.defaultView.pageXOffset || (doc$1.documentElement || doc$1.body).scrollLeft;
  2386. }
  2387. function pageScrollY(doc$1) {
  2388. if (chrome && android) return -(doc$1.body.getBoundingClientRect().top - parseInt(getComputedStyle(doc$1.body).marginTop));
  2389. return doc$1.defaultView.pageYOffset || (doc$1.documentElement || doc$1.body).scrollTop;
  2390. }
  2391. function widgetTopHeight(lineObj) {
  2392. var ref$1 = visualLine(lineObj);
  2393. var widgets = ref$1.widgets;
  2394. var height = 0;
  2395. if (widgets) {
  2396. for (var i$3 = 0; i$3 < widgets.length; ++i$3) if (widgets[i$3].above) height += widgetHeight(widgets[i$3]);
  2397. }
  2398. return height;
  2399. }
  2400. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  2401. if (!includeWidgets) {
  2402. var height = widgetTopHeight(lineObj);
  2403. rect.top += height;
  2404. rect.bottom += height;
  2405. }
  2406. if (context == "line") return rect;
  2407. if (!context) context = "local";
  2408. var yOff = heightAtLine(lineObj);
  2409. if (context == "local") yOff += paddingTop(cm.display);
  2410. else yOff -= cm.display.viewOffset;
  2411. if (context == "page" || context == "window") {
  2412. var lOff = cm.display.lineSpace.getBoundingClientRect();
  2413. yOff += lOff.top + (context == "window" ? 0 : pageScrollY(doc(cm)));
  2414. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX(doc(cm)));
  2415. rect.left += xOff;
  2416. rect.right += xOff;
  2417. }
  2418. rect.top += yOff;
  2419. rect.bottom += yOff;
  2420. return rect;
  2421. }
  2422. function fromCoordSystem(cm, coords, context) {
  2423. if (context == "div") return coords;
  2424. var left = coords.left, top = coords.top;
  2425. if (context == "page") {
  2426. left -= pageScrollX(doc(cm));
  2427. top -= pageScrollY(doc(cm));
  2428. } else if (context == "local" || !context) {
  2429. var localBox = cm.display.sizer.getBoundingClientRect();
  2430. left += localBox.left;
  2431. top += localBox.top;
  2432. }
  2433. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  2434. return {
  2435. left: left - lineSpaceBox.left,
  2436. top: top - lineSpaceBox.top
  2437. };
  2438. }
  2439. function charCoords(cm, pos, context, lineObj, bias) {
  2440. if (!lineObj) lineObj = getLine(cm.doc, pos.line);
  2441. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
  2442. }
  2443. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  2444. lineObj = lineObj || getLine(cm.doc, pos.line);
  2445. if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
  2446. function get(ch$1, right) {
  2447. var m = measureCharPrepared(cm, preparedMeasure, ch$1, right ? "right" : "left", varHeight);
  2448. if (right) m.left = m.right;
  2449. else m.right = m.left;
  2450. return intoCoordSystem(cm, lineObj, m, context);
  2451. }
  2452. var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
  2453. if (ch >= lineObj.text.length) {
  2454. ch = lineObj.text.length;
  2455. sticky = "before";
  2456. } else if (ch <= 0) {
  2457. ch = 0;
  2458. sticky = "after";
  2459. }
  2460. if (!order) return get(sticky == "before" ? ch - 1 : ch, sticky == "before");
  2461. function getBidi(ch$1, partPos$1, invert) {
  2462. var part = order[partPos$1], right = part.level == 1;
  2463. return get(invert ? ch$1 - 1 : ch$1, right != invert);
  2464. }
  2465. var partPos = getBidiPartAt(order, ch, sticky);
  2466. var other = bidiOther;
  2467. var val = getBidi(ch, partPos, sticky == "before");
  2468. if (other != null) val.other = getBidi(ch, other, sticky != "before");
  2469. return val;
  2470. }
  2471. function estimateCoords(cm, pos) {
  2472. var left = 0;
  2473. pos = clipPos(cm.doc, pos);
  2474. if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
  2475. var lineObj = getLine(cm.doc, pos.line);
  2476. var top = heightAtLine(lineObj) + paddingTop(cm.display);
  2477. return {
  2478. left,
  2479. right: left,
  2480. top,
  2481. bottom: top + lineObj.height
  2482. };
  2483. }
  2484. function PosWithInfo(line, ch, sticky, outside, xRel) {
  2485. var pos = Pos(line, ch, sticky);
  2486. pos.xRel = xRel;
  2487. if (outside) pos.outside = outside;
  2488. return pos;
  2489. }
  2490. function coordsChar(cm, x, y) {
  2491. var doc$1 = cm.doc;
  2492. y += cm.display.viewOffset;
  2493. if (y < 0) return PosWithInfo(doc$1.first, 0, null, -1, -1);
  2494. var lineN = lineAtHeight(doc$1, y), last = doc$1.first + doc$1.size - 1;
  2495. if (lineN > last) return PosWithInfo(doc$1.first + doc$1.size - 1, getLine(doc$1, last).text.length, null, 1, 1);
  2496. if (x < 0) x = 0;
  2497. var lineObj = getLine(doc$1, lineN);
  2498. for (;;) {
  2499. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  2500. var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
  2501. if (!collapsed) return found;
  2502. var rangeEnd = collapsed.find(1);
  2503. if (rangeEnd.line == lineN) return rangeEnd;
  2504. lineObj = getLine(doc$1, lineN = rangeEnd.line);
  2505. }
  2506. }
  2507. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  2508. y -= widgetTopHeight(lineObj);
  2509. var end = lineObj.text.length;
  2510. var begin = findFirst(function(ch) {
  2511. return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y;
  2512. }, end, 0);
  2513. end = findFirst(function(ch) {
  2514. return measureCharPrepared(cm, preparedMeasure, ch).top > y;
  2515. }, begin, end);
  2516. return {
  2517. begin,
  2518. end
  2519. };
  2520. }
  2521. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  2522. if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
  2523. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  2524. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop);
  2525. }
  2526. function boxIsAfter(box, x, y, left) {
  2527. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x;
  2528. }
  2529. function coordsCharInner(cm, lineObj, lineNo$1, x, y) {
  2530. y -= heightAtLine(lineObj);
  2531. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  2532. var widgetHeight$1 = widgetTopHeight(lineObj);
  2533. var begin = 0, end = lineObj.text.length, ltr = true;
  2534. var order = getOrder(lineObj, cm.doc.direction);
  2535. if (order) {
  2536. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)(cm, lineObj, lineNo$1, preparedMeasure, order, x, y);
  2537. ltr = part.level != 1;
  2538. begin = ltr ? part.from : part.to - 1;
  2539. end = ltr ? part.to : part.from - 1;
  2540. }
  2541. var chAround = null, boxAround = null;
  2542. var ch = findFirst(function(ch$1) {
  2543. var box = measureCharPrepared(cm, preparedMeasure, ch$1);
  2544. box.top += widgetHeight$1;
  2545. box.bottom += widgetHeight$1;
  2546. if (!boxIsAfter(box, x, y, false)) return false;
  2547. if (box.top <= y && box.left <= x) {
  2548. chAround = ch$1;
  2549. boxAround = box;
  2550. }
  2551. return true;
  2552. }, begin, end);
  2553. var baseX, sticky, outside = false;
  2554. if (boxAround) {
  2555. var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
  2556. ch = chAround + (atStart ? 0 : 1);
  2557. sticky = atStart ? "after" : "before";
  2558. baseX = atLeft ? boxAround.left : boxAround.right;
  2559. } else {
  2560. if (!ltr && (ch == end || ch == begin)) ch++;
  2561. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$1 <= y == ltr ? "after" : "before";
  2562. var coords = cursorCoords(cm, Pos(lineNo$1, ch, sticky), "line", lineObj, preparedMeasure);
  2563. baseX = coords.left;
  2564. outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;
  2565. }
  2566. ch = skipExtendingChars(lineObj.text, ch, 1);
  2567. return PosWithInfo(lineNo$1, ch, sticky, outside, x - baseX);
  2568. }
  2569. function coordsBidiPart(cm, lineObj, lineNo$1, preparedMeasure, order, x, y) {
  2570. var index = findFirst(function(i$3) {
  2571. var part$1 = order[i$3], ltr$1 = part$1.level != 1;
  2572. return boxIsAfter(cursorCoords(cm, Pos(lineNo$1, ltr$1 ? part$1.to : part$1.from, ltr$1 ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, true);
  2573. }, 0, order.length - 1);
  2574. var part = order[index];
  2575. if (index > 0) {
  2576. var ltr = part.level != 1;
  2577. var start = cursorCoords(cm, Pos(lineNo$1, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure);
  2578. if (boxIsAfter(start, x, y, true) && start.top > y) part = order[index - 1];
  2579. }
  2580. return part;
  2581. }
  2582. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  2583. var ref$1 = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  2584. var begin = ref$1.begin;
  2585. var end = ref$1.end;
  2586. if (/\s/.test(lineObj.text.charAt(end - 1))) end--;
  2587. var part = null, closestDist = null;
  2588. for (var i$3 = 0; i$3 < order.length; i$3++) {
  2589. var p = order[i$3];
  2590. if (p.from >= end || p.to <= begin) continue;
  2591. var ltr = p.level != 1;
  2592. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  2593. var dist = endX < x ? x - endX + 1e9 : endX - x;
  2594. if (!part || closestDist > dist) {
  2595. part = p;
  2596. closestDist = dist;
  2597. }
  2598. }
  2599. if (!part) part = order[order.length - 1];
  2600. if (part.from < begin) part = {
  2601. from: begin,
  2602. to: part.to,
  2603. level: part.level
  2604. };
  2605. if (part.to > end) part = {
  2606. from: part.from,
  2607. to: end,
  2608. level: part.level
  2609. };
  2610. return part;
  2611. }
  2612. var measureText;
  2613. function textHeight(display) {
  2614. if (display.cachedTextHeight != null) return display.cachedTextHeight;
  2615. if (measureText == null) {
  2616. measureText = elt("pre", null, "CodeMirror-line-like");
  2617. for (var i$3 = 0; i$3 < 49; ++i$3) {
  2618. measureText.appendChild(document.createTextNode("x"));
  2619. measureText.appendChild(elt("br"));
  2620. }
  2621. measureText.appendChild(document.createTextNode("x"));
  2622. }
  2623. removeChildrenAndAdd(display.measure, measureText);
  2624. var height = measureText.offsetHeight / 50;
  2625. if (height > 3) display.cachedTextHeight = height;
  2626. removeChildren(display.measure);
  2627. return height || 1;
  2628. }
  2629. function charWidth(display) {
  2630. if (display.cachedCharWidth != null) return display.cachedCharWidth;
  2631. var anchor = elt("span", "xxxxxxxxxx");
  2632. var pre = elt("pre", [anchor], "CodeMirror-line-like");
  2633. removeChildrenAndAdd(display.measure, pre);
  2634. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
  2635. if (width > 2) display.cachedCharWidth = width;
  2636. return width || 10;
  2637. }
  2638. function getDimensions(cm) {
  2639. var d = cm.display, left = {}, width = {};
  2640. var gutterLeft = d.gutters.clientLeft;
  2641. for (var n = d.gutters.firstChild, i$3 = 0; n; n = n.nextSibling, ++i$3) {
  2642. var id = cm.display.gutterSpecs[i$3].className;
  2643. left[id] = n.offsetLeft + n.clientLeft + gutterLeft;
  2644. width[id] = n.clientWidth;
  2645. }
  2646. return {
  2647. fixedPos: compensateForHScroll(d),
  2648. gutterTotalWidth: d.gutters.offsetWidth,
  2649. gutterLeft: left,
  2650. gutterWidth: width,
  2651. wrapperWidth: d.wrapper.clientWidth
  2652. };
  2653. }
  2654. function compensateForHScroll(display) {
  2655. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
  2656. }
  2657. function estimateHeight(cm) {
  2658. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
  2659. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  2660. return function(line) {
  2661. if (lineIsHidden(cm.doc, line)) return 0;
  2662. var widgetsHeight = 0;
  2663. if (line.widgets) {
  2664. for (var i$3 = 0; i$3 < line.widgets.length; i$3++) if (line.widgets[i$3].height) widgetsHeight += line.widgets[i$3].height;
  2665. }
  2666. if (wrapping) return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
  2667. else return widgetsHeight + th;
  2668. };
  2669. }
  2670. function estimateLineHeights(cm) {
  2671. var doc$1 = cm.doc, est = estimateHeight(cm);
  2672. doc$1.iter(function(line) {
  2673. var estHeight = est(line);
  2674. if (estHeight != line.height) updateLineHeight(line, estHeight);
  2675. });
  2676. }
  2677. function posFromMouse(cm, e, liberal, forRect) {
  2678. var display = cm.display;
  2679. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
  2680. var x, y, space = display.lineSpace.getBoundingClientRect();
  2681. try {
  2682. x = e.clientX - space.left;
  2683. y = e.clientY - space.top;
  2684. } catch (e$1) {
  2685. return null;
  2686. }
  2687. var coords = coordsChar(cm, x, y), line;
  2688. if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  2689. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  2690. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  2691. }
  2692. return coords;
  2693. }
  2694. function findViewIndex(cm, n) {
  2695. if (n >= cm.display.viewTo) return null;
  2696. n -= cm.display.viewFrom;
  2697. if (n < 0) return null;
  2698. var view = cm.display.view;
  2699. for (var i$3 = 0; i$3 < view.length; i$3++) {
  2700. n -= view[i$3].size;
  2701. if (n < 0) return i$3;
  2702. }
  2703. }
  2704. function regChange(cm, from, to, lendiff) {
  2705. if (from == null) from = cm.doc.first;
  2706. if (to == null) to = cm.doc.first + cm.doc.size;
  2707. if (!lendiff) lendiff = 0;
  2708. var display = cm.display;
  2709. if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) display.updateLineNumbers = from;
  2710. cm.curOp.viewChanged = true;
  2711. if (from >= display.viewTo) {
  2712. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) resetView(cm);
  2713. } else if (to <= display.viewFrom) if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) resetView(cm);
  2714. else {
  2715. display.viewFrom += lendiff;
  2716. display.viewTo += lendiff;
  2717. }
  2718. else if (from <= display.viewFrom && to >= display.viewTo) resetView(cm);
  2719. else if (from <= display.viewFrom) {
  2720. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  2721. if (cut) {
  2722. display.view = display.view.slice(cut.index);
  2723. display.viewFrom = cut.lineN;
  2724. display.viewTo += lendiff;
  2725. } else resetView(cm);
  2726. } else if (to >= display.viewTo) {
  2727. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  2728. if (cut$1) {
  2729. display.view = display.view.slice(0, cut$1.index);
  2730. display.viewTo = cut$1.lineN;
  2731. } else resetView(cm);
  2732. } else {
  2733. var cutTop = viewCuttingPoint(cm, from, from, -1);
  2734. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  2735. if (cutTop && cutBot) {
  2736. display.view = display.view.slice(0, cutTop.index).concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)).concat(display.view.slice(cutBot.index));
  2737. display.viewTo += lendiff;
  2738. } else resetView(cm);
  2739. }
  2740. var ext = display.externalMeasured;
  2741. if (ext) {
  2742. if (to < ext.lineN) ext.lineN += lendiff;
  2743. else if (from < ext.lineN + ext.size) display.externalMeasured = null;
  2744. }
  2745. }
  2746. function regLineChange(cm, line, type) {
  2747. cm.curOp.viewChanged = true;
  2748. var display = cm.display, ext = cm.display.externalMeasured;
  2749. if (ext && line >= ext.lineN && line < ext.lineN + ext.size) display.externalMeasured = null;
  2750. if (line < display.viewFrom || line >= display.viewTo) return;
  2751. var lineView = display.view[findViewIndex(cm, line)];
  2752. if (lineView.node == null) return;
  2753. var arr = lineView.changes || (lineView.changes = []);
  2754. if (indexOf(arr, type) == -1) arr.push(type);
  2755. }
  2756. function resetView(cm) {
  2757. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  2758. cm.display.view = [];
  2759. cm.display.viewOffset = 0;
  2760. }
  2761. function viewCuttingPoint(cm, oldN, newN, dir) {
  2762. var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
  2763. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) return {
  2764. index,
  2765. lineN: newN
  2766. };
  2767. var n = cm.display.viewFrom;
  2768. for (var i$3 = 0; i$3 < index; i$3++) n += view[i$3].size;
  2769. if (n != oldN) {
  2770. if (dir > 0) {
  2771. if (index == view.length - 1) return null;
  2772. diff = n + view[index].size - oldN;
  2773. index++;
  2774. } else diff = n - oldN;
  2775. oldN += diff;
  2776. newN += diff;
  2777. }
  2778. while (visualLineNo(cm.doc, newN) != newN) {
  2779. if (index == (dir < 0 ? 0 : view.length - 1)) return null;
  2780. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  2781. index += dir;
  2782. }
  2783. return {
  2784. index,
  2785. lineN: newN
  2786. };
  2787. }
  2788. function adjustView(cm, from, to) {
  2789. var display = cm.display, view = display.view;
  2790. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  2791. display.view = buildViewArray(cm, from, to);
  2792. display.viewFrom = from;
  2793. } else {
  2794. if (display.viewFrom > from) display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
  2795. else if (display.viewFrom < from) display.view = display.view.slice(findViewIndex(cm, from));
  2796. display.viewFrom = from;
  2797. if (display.viewTo < to) display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
  2798. else if (display.viewTo > to) display.view = display.view.slice(0, findViewIndex(cm, to));
  2799. }
  2800. display.viewTo = to;
  2801. }
  2802. function countDirtyView(cm) {
  2803. var view = cm.display.view, dirty = 0;
  2804. for (var i$3 = 0; i$3 < view.length; i$3++) {
  2805. var lineView = view[i$3];
  2806. if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
  2807. }
  2808. return dirty;
  2809. }
  2810. function updateSelection(cm) {
  2811. cm.display.input.showSelection(cm.display.input.prepareSelection());
  2812. }
  2813. function prepareSelection(cm, primary) {
  2814. if (primary === void 0) primary = true;
  2815. var doc$1 = cm.doc, result = {};
  2816. var curFragment = result.cursors = document.createDocumentFragment();
  2817. var selFragment = result.selection = document.createDocumentFragment();
  2818. var customCursor = cm.options.$customCursor;
  2819. if (customCursor) primary = true;
  2820. for (var i$3 = 0; i$3 < doc$1.sel.ranges.length; i$3++) {
  2821. if (!primary && i$3 == doc$1.sel.primIndex) continue;
  2822. var range$1 = doc$1.sel.ranges[i$3];
  2823. if (range$1.from().line >= cm.display.viewTo || range$1.to().line < cm.display.viewFrom) continue;
  2824. var collapsed = range$1.empty();
  2825. if (customCursor) {
  2826. var head = customCursor(cm, range$1);
  2827. if (head) drawSelectionCursor(cm, head, curFragment);
  2828. } else if (collapsed || cm.options.showCursorWhenSelecting) drawSelectionCursor(cm, range$1.head, curFragment);
  2829. if (!collapsed) drawSelectionRange(cm, range$1, selFragment);
  2830. }
  2831. return result;
  2832. }
  2833. function drawSelectionCursor(cm, head, output) {
  2834. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  2835. var cursor = output.appendChild(elt("div", "\xA0", "CodeMirror-cursor"));
  2836. cursor.style.left = pos.left + "px";
  2837. cursor.style.top = pos.top + "px";
  2838. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  2839. if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) {
  2840. var charPos = charCoords(cm, head, "div", null, null);
  2841. var width = charPos.right - charPos.left;
  2842. cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px";
  2843. }
  2844. if (pos.other) {
  2845. var otherCursor = output.appendChild(elt("div", "\xA0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  2846. otherCursor.style.display = "";
  2847. otherCursor.style.left = pos.other.left + "px";
  2848. otherCursor.style.top = pos.other.top + "px";
  2849. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  2850. }
  2851. }
  2852. function cmpCoords(a, b) {
  2853. return a.top - b.top || a.left - b.left;
  2854. }
  2855. function drawSelectionRange(cm, range$1, output) {
  2856. var display = cm.display, doc$1 = cm.doc;
  2857. var fragment = document.createDocumentFragment();
  2858. var padding = paddingH(cm.display), leftSide = padding.left;
  2859. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  2860. var docLTR = doc$1.direction == "ltr";
  2861. function add(left, top, width, bottom) {
  2862. if (top < 0) top = 0;
  2863. top = Math.round(top);
  2864. bottom = Math.round(bottom);
  2865. fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"));
  2866. }
  2867. function drawForLine(line, fromArg, toArg) {
  2868. var lineObj = getLine(doc$1, line);
  2869. var lineLen = lineObj.text.length;
  2870. var start, end;
  2871. function coords(ch, bias) {
  2872. return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
  2873. }
  2874. function wrapX(pos, dir, side) {
  2875. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  2876. var prop$1 = dir == "ltr" == (side == "after") ? "left" : "right";
  2877. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  2878. return coords(ch, prop$1)[prop$1];
  2879. }
  2880. var order = getOrder(lineObj, doc$1.direction);
  2881. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir, i$3) {
  2882. var ltr = dir == "ltr";
  2883. var fromPos = coords(from, ltr ? "left" : "right");
  2884. var toPos = coords(to - 1, ltr ? "right" : "left");
  2885. var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
  2886. var first = i$3 == 0, last = !order || i$3 == order.length - 1;
  2887. if (toPos.top - fromPos.top <= 3) {
  2888. var openLeft = (docLTR ? openStart : openEnd) && first;
  2889. var openRight = (docLTR ? openEnd : openStart) && last;
  2890. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  2891. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  2892. add(left, fromPos.top, right - left, fromPos.bottom);
  2893. } else {
  2894. var topLeft, topRight, botLeft, botRight;
  2895. if (ltr) {
  2896. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  2897. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  2898. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  2899. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  2900. } else {
  2901. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  2902. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  2903. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  2904. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  2905. }
  2906. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  2907. if (fromPos.bottom < toPos.top) add(leftSide, fromPos.bottom, null, toPos.top);
  2908. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  2909. }
  2910. if (!start || cmpCoords(fromPos, start) < 0) start = fromPos;
  2911. if (cmpCoords(toPos, start) < 0) start = toPos;
  2912. if (!end || cmpCoords(fromPos, end) < 0) end = fromPos;
  2913. if (cmpCoords(toPos, end) < 0) end = toPos;
  2914. });
  2915. return {
  2916. start,
  2917. end
  2918. };
  2919. }
  2920. var sFrom = range$1.from(), sTo = range$1.to();
  2921. if (sFrom.line == sTo.line) drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  2922. else {
  2923. var fromLine = getLine(doc$1, sFrom.line), toLine = getLine(doc$1, sTo.line);
  2924. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  2925. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  2926. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  2927. if (singleVLine) if (leftEnd.top < rightStart.top - 2) {
  2928. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  2929. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  2930. } else add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  2931. if (leftEnd.bottom < rightStart.top) add(leftSide, leftEnd.bottom, null, rightStart.top);
  2932. }
  2933. output.appendChild(fragment);
  2934. }
  2935. function restartBlink(cm) {
  2936. if (!cm.state.focused) return;
  2937. var display = cm.display;
  2938. clearInterval(display.blinker);
  2939. var on$1 = true;
  2940. display.cursorDiv.style.visibility = "";
  2941. if (cm.options.cursorBlinkRate > 0) display.blinker = setInterval(function() {
  2942. if (!cm.hasFocus()) onBlur(cm);
  2943. display.cursorDiv.style.visibility = (on$1 = !on$1) ? "" : "hidden";
  2944. }, cm.options.cursorBlinkRate);
  2945. else if (cm.options.cursorBlinkRate < 0) display.cursorDiv.style.visibility = "hidden";
  2946. }
  2947. function ensureFocus(cm) {
  2948. if (!cm.hasFocus()) {
  2949. cm.display.input.focus();
  2950. if (!cm.state.focused) onFocus(cm);
  2951. }
  2952. }
  2953. function delayBlurEvent(cm) {
  2954. cm.state.delayingBlurEvent = true;
  2955. setTimeout(function() {
  2956. if (cm.state.delayingBlurEvent) {
  2957. cm.state.delayingBlurEvent = false;
  2958. if (cm.state.focused) onBlur(cm);
  2959. }
  2960. }, 100);
  2961. }
  2962. function onFocus(cm, e) {
  2963. if (cm.state.delayingBlurEvent && !cm.state.draggingText) cm.state.delayingBlurEvent = false;
  2964. if (cm.options.readOnly == "nocursor") return;
  2965. if (!cm.state.focused) {
  2966. signal(cm, "focus", cm, e);
  2967. cm.state.focused = true;
  2968. addClass(cm.display.wrapper, "CodeMirror-focused");
  2969. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  2970. cm.display.input.reset();
  2971. if (webkit) setTimeout(function() {
  2972. return cm.display.input.reset(true);
  2973. }, 20);
  2974. }
  2975. cm.display.input.receivedFocus();
  2976. }
  2977. restartBlink(cm);
  2978. }
  2979. function onBlur(cm, e) {
  2980. if (cm.state.delayingBlurEvent) return;
  2981. if (cm.state.focused) {
  2982. signal(cm, "blur", cm, e);
  2983. cm.state.focused = false;
  2984. rmClass(cm.display.wrapper, "CodeMirror-focused");
  2985. }
  2986. clearInterval(cm.display.blinker);
  2987. setTimeout(function() {
  2988. if (!cm.state.focused) cm.display.shift = false;
  2989. }, 150);
  2990. }
  2991. function updateHeightsInViewport(cm) {
  2992. var display = cm.display;
  2993. var prevBottom = display.lineDiv.offsetTop;
  2994. var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top);
  2995. var oldHeight = display.lineDiv.getBoundingClientRect().top;
  2996. var mustScroll = 0;
  2997. for (var i$3 = 0; i$3 < display.view.length; i$3++) {
  2998. var cur = display.view[i$3], wrapping = cm.options.lineWrapping;
  2999. var height = void 0, width = 0;
  3000. if (cur.hidden) continue;
  3001. oldHeight += cur.line.height;
  3002. if (ie && ie_version < 8) {
  3003. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  3004. height = bot - prevBottom;
  3005. prevBottom = bot;
  3006. } else {
  3007. var box = cur.node.getBoundingClientRect();
  3008. height = box.bottom - box.top;
  3009. if (!wrapping && cur.text.firstChild) width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1;
  3010. }
  3011. var diff = cur.line.height - height;
  3012. if (diff > .005 || diff < -.005) {
  3013. if (oldHeight < viewTop) mustScroll -= diff;
  3014. updateLineHeight(cur.line, height);
  3015. updateWidgetHeight(cur.line);
  3016. if (cur.rest) for (var j = 0; j < cur.rest.length; j++) updateWidgetHeight(cur.rest[j]);
  3017. }
  3018. if (width > cm.display.sizerWidth) {
  3019. var chWidth = Math.ceil(width / charWidth(cm.display));
  3020. if (chWidth > cm.display.maxLineLength) {
  3021. cm.display.maxLineLength = chWidth;
  3022. cm.display.maxLine = cur.line;
  3023. cm.display.maxLineChanged = true;
  3024. }
  3025. }
  3026. }
  3027. if (Math.abs(mustScroll) > 2) display.scroller.scrollTop += mustScroll;
  3028. }
  3029. function updateWidgetHeight(line) {
  3030. if (line.widgets) for (var i$3 = 0; i$3 < line.widgets.length; ++i$3) {
  3031. var w = line.widgets[i$3], parent = w.node.parentNode;
  3032. if (parent) w.height = parent.offsetHeight;
  3033. }
  3034. }
  3035. function visibleLines(display, doc$1, viewport) {
  3036. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  3037. top = Math.floor(top - paddingTop(display));
  3038. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  3039. var from = lineAtHeight(doc$1, top), to = lineAtHeight(doc$1, bottom);
  3040. if (viewport && viewport.ensure) {
  3041. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
  3042. if (ensureFrom < from) {
  3043. from = ensureFrom;
  3044. to = lineAtHeight(doc$1, heightAtLine(getLine(doc$1, ensureFrom)) + display.wrapper.clientHeight);
  3045. } else if (Math.min(ensureTo, doc$1.lastLine()) >= to) {
  3046. from = lineAtHeight(doc$1, heightAtLine(getLine(doc$1, ensureTo)) - display.wrapper.clientHeight);
  3047. to = ensureTo;
  3048. }
  3049. }
  3050. return {
  3051. from,
  3052. to: Math.max(to, from + 1)
  3053. };
  3054. }
  3055. function maybeScrollWindow(cm, rect) {
  3056. if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
  3057. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
  3058. var doc$1 = display.wrapper.ownerDocument;
  3059. if (rect.top + box.top < 0) doScroll = true;
  3060. else if (rect.bottom + box.top > (doc$1.defaultView.innerHeight || doc$1.documentElement.clientHeight)) doScroll = false;
  3061. if (doScroll != null && !phantom) {
  3062. var scrollNode = elt("div", "​", null, "position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + rect.left + "px; width: " + Math.max(2, rect.right - rect.left) + "px;");
  3063. cm.display.lineSpace.appendChild(scrollNode);
  3064. scrollNode.scrollIntoView(doScroll);
  3065. cm.display.lineSpace.removeChild(scrollNode);
  3066. }
  3067. }
  3068. function scrollPosIntoView(cm, pos, end, margin) {
  3069. if (margin == null) margin = 0;
  3070. var rect;
  3071. if (!cm.options.lineWrapping && pos == end) {
  3072. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  3073. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  3074. }
  3075. for (var limit = 0; limit < 5; limit++) {
  3076. var changed = false;
  3077. var coords = cursorCoords(cm, pos);
  3078. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
  3079. rect = {
  3080. left: Math.min(coords.left, endCoords.left),
  3081. top: Math.min(coords.top, endCoords.top) - margin,
  3082. right: Math.max(coords.left, endCoords.left),
  3083. bottom: Math.max(coords.bottom, endCoords.bottom) + margin
  3084. };
  3085. var scrollPos = calculateScrollPos(cm, rect);
  3086. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
  3087. if (scrollPos.scrollTop != null) {
  3088. updateScrollTop(cm, scrollPos.scrollTop);
  3089. if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
  3090. }
  3091. if (scrollPos.scrollLeft != null) {
  3092. setScrollLeft(cm, scrollPos.scrollLeft);
  3093. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
  3094. }
  3095. if (!changed) break;
  3096. }
  3097. return rect;
  3098. }
  3099. function scrollIntoView(cm, rect) {
  3100. var scrollPos = calculateScrollPos(cm, rect);
  3101. if (scrollPos.scrollTop != null) updateScrollTop(cm, scrollPos.scrollTop);
  3102. if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
  3103. }
  3104. function calculateScrollPos(cm, rect) {
  3105. var display = cm.display, snapMargin = textHeight(cm.display);
  3106. if (rect.top < 0) rect.top = 0;
  3107. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  3108. var screen$1 = displayHeight(cm), result = {};
  3109. if (rect.bottom - rect.top > screen$1) rect.bottom = rect.top + screen$1;
  3110. var docBottom = cm.doc.height + paddingVert(display);
  3111. var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
  3112. if (rect.top < screentop) result.scrollTop = atTop ? 0 : rect.top;
  3113. else if (rect.bottom > screentop + screen$1) {
  3114. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen$1);
  3115. if (newTop != screentop) result.scrollTop = newTop;
  3116. }
  3117. var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth;
  3118. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace;
  3119. var screenw = displayWidth(cm) - display.gutters.offsetWidth;
  3120. var tooWide = rect.right - rect.left > screenw;
  3121. if (tooWide) rect.right = rect.left + screenw;
  3122. if (rect.left < 10) result.scrollLeft = 0;
  3123. else if (rect.left < screenleft) result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10));
  3124. else if (rect.right > screenw + screenleft - 3) result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw;
  3125. return result;
  3126. }
  3127. function addToScrollTop(cm, top) {
  3128. if (top == null) return;
  3129. resolveScrollToPos(cm);
  3130. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  3131. }
  3132. function ensureCursorVisible(cm) {
  3133. resolveScrollToPos(cm);
  3134. var cur = cm.getCursor();
  3135. cm.curOp.scrollToPos = {
  3136. from: cur,
  3137. to: cur,
  3138. margin: cm.options.cursorScrollMargin
  3139. };
  3140. }
  3141. function scrollToCoords(cm, x, y) {
  3142. if (x != null || y != null) resolveScrollToPos(cm);
  3143. if (x != null) cm.curOp.scrollLeft = x;
  3144. if (y != null) cm.curOp.scrollTop = y;
  3145. }
  3146. function scrollToRange(cm, range$1) {
  3147. resolveScrollToPos(cm);
  3148. cm.curOp.scrollToPos = range$1;
  3149. }
  3150. function resolveScrollToPos(cm) {
  3151. var range$1 = cm.curOp.scrollToPos;
  3152. if (range$1) {
  3153. cm.curOp.scrollToPos = null;
  3154. var from = estimateCoords(cm, range$1.from), to = estimateCoords(cm, range$1.to);
  3155. scrollToCoordsRange(cm, from, to, range$1.margin);
  3156. }
  3157. }
  3158. function scrollToCoordsRange(cm, from, to, margin) {
  3159. var sPos = calculateScrollPos(cm, {
  3160. left: Math.min(from.left, to.left),
  3161. top: Math.min(from.top, to.top) - margin,
  3162. right: Math.max(from.right, to.right),
  3163. bottom: Math.max(from.bottom, to.bottom) + margin
  3164. });
  3165. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  3166. }
  3167. function updateScrollTop(cm, val) {
  3168. if (Math.abs(cm.doc.scrollTop - val) < 2) return;
  3169. if (!gecko) updateDisplaySimple(cm, { top: val });
  3170. setScrollTop(cm, val, true);
  3171. if (gecko) updateDisplaySimple(cm);
  3172. startWorker(cm, 100);
  3173. }
  3174. function setScrollTop(cm, val, forceScroll) {
  3175. val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val));
  3176. if (cm.display.scroller.scrollTop == val && !forceScroll) return;
  3177. cm.doc.scrollTop = val;
  3178. cm.display.scrollbars.setScrollTop(val);
  3179. if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
  3180. }
  3181. function setScrollLeft(cm, val, isScroller, forceScroll) {
  3182. val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth));
  3183. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) return;
  3184. cm.doc.scrollLeft = val;
  3185. alignHorizontally(cm);
  3186. if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
  3187. cm.display.scrollbars.setScrollLeft(val);
  3188. }
  3189. function measureForScrollbars(cm) {
  3190. var d = cm.display, gutterW = d.gutters.offsetWidth;
  3191. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  3192. return {
  3193. clientHeight: d.scroller.clientHeight,
  3194. viewHeight: d.wrapper.clientHeight,
  3195. scrollWidth: d.scroller.scrollWidth,
  3196. clientWidth: d.scroller.clientWidth,
  3197. viewWidth: d.wrapper.clientWidth,
  3198. barLeft: cm.options.fixedGutter ? gutterW : 0,
  3199. docHeight: docH,
  3200. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  3201. nativeBarWidth: d.nativeBarWidth,
  3202. gutterWidth: gutterW
  3203. };
  3204. }
  3205. var NativeScrollbars = function(place, scroll, cm) {
  3206. this.cm = cm;
  3207. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  3208. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  3209. vert.tabIndex = horiz.tabIndex = -1;
  3210. place(vert);
  3211. place(horiz);
  3212. on(vert, "scroll", function() {
  3213. if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
  3214. });
  3215. on(horiz, "scroll", function() {
  3216. if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
  3217. });
  3218. this.checkedZeroWidth = false;
  3219. if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
  3220. };
  3221. NativeScrollbars.prototype.update = function(measure) {
  3222. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  3223. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  3224. var sWidth = measure.nativeBarWidth;
  3225. if (needsV) {
  3226. this.vert.style.display = "block";
  3227. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  3228. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  3229. this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  3230. } else {
  3231. this.vert.scrollTop = 0;
  3232. this.vert.style.display = "";
  3233. this.vert.firstChild.style.height = "0";
  3234. }
  3235. if (needsH) {
  3236. this.horiz.style.display = "block";
  3237. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  3238. this.horiz.style.left = measure.barLeft + "px";
  3239. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  3240. this.horiz.firstChild.style.width = Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  3241. } else {
  3242. this.horiz.style.display = "";
  3243. this.horiz.firstChild.style.width = "0";
  3244. }
  3245. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  3246. if (sWidth == 0) this.zeroWidthHack();
  3247. this.checkedZeroWidth = true;
  3248. }
  3249. return {
  3250. right: needsV ? sWidth : 0,
  3251. bottom: needsH ? sWidth : 0
  3252. };
  3253. };
  3254. NativeScrollbars.prototype.setScrollLeft = function(pos) {
  3255. if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
  3256. if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz");
  3257. };
  3258. NativeScrollbars.prototype.setScrollTop = function(pos) {
  3259. if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
  3260. if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert, "vert");
  3261. };
  3262. NativeScrollbars.prototype.zeroWidthHack = function() {
  3263. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  3264. this.horiz.style.height = this.vert.style.width = w;
  3265. this.horiz.style.visibility = this.vert.style.visibility = "hidden";
  3266. this.disableHoriz = new Delayed();
  3267. this.disableVert = new Delayed();
  3268. };
  3269. NativeScrollbars.prototype.enableZeroWidthBar = function(bar, delay, type) {
  3270. bar.style.visibility = "";
  3271. function maybeDisable() {
  3272. var box = bar.getBoundingClientRect();
  3273. var elt$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  3274. if (elt$1 != bar) bar.style.visibility = "hidden";
  3275. else delay.set(1e3, maybeDisable);
  3276. }
  3277. delay.set(1e3, maybeDisable);
  3278. };
  3279. NativeScrollbars.prototype.clear = function() {
  3280. var parent = this.horiz.parentNode;
  3281. parent.removeChild(this.horiz);
  3282. parent.removeChild(this.vert);
  3283. };
  3284. var NullScrollbars = function() {};
  3285. NullScrollbars.prototype.update = function() {
  3286. return {
  3287. bottom: 0,
  3288. right: 0
  3289. };
  3290. };
  3291. NullScrollbars.prototype.setScrollLeft = function() {};
  3292. NullScrollbars.prototype.setScrollTop = function() {};
  3293. NullScrollbars.prototype.clear = function() {};
  3294. function updateScrollbars(cm, measure) {
  3295. if (!measure) measure = measureForScrollbars(cm);
  3296. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
  3297. updateScrollbarsInner(cm, measure);
  3298. for (var i$3 = 0; i$3 < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i$3++) {
  3299. if (startWidth != cm.display.barWidth && cm.options.lineWrapping) updateHeightsInViewport(cm);
  3300. updateScrollbarsInner(cm, measureForScrollbars(cm));
  3301. startWidth = cm.display.barWidth;
  3302. startHeight = cm.display.barHeight;
  3303. }
  3304. }
  3305. function updateScrollbarsInner(cm, measure) {
  3306. var d = cm.display;
  3307. var sizes = d.scrollbars.update(measure);
  3308. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  3309. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  3310. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  3311. if (sizes.right && sizes.bottom) {
  3312. d.scrollbarFiller.style.display = "block";
  3313. d.scrollbarFiller.style.height = sizes.bottom + "px";
  3314. d.scrollbarFiller.style.width = sizes.right + "px";
  3315. } else d.scrollbarFiller.style.display = "";
  3316. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  3317. d.gutterFiller.style.display = "block";
  3318. d.gutterFiller.style.height = sizes.bottom + "px";
  3319. d.gutterFiller.style.width = measure.gutterWidth + "px";
  3320. } else d.gutterFiller.style.display = "";
  3321. }
  3322. var scrollbarModel = {
  3323. "native": NativeScrollbars,
  3324. "null": NullScrollbars
  3325. };
  3326. function initScrollbars(cm) {
  3327. if (cm.display.scrollbars) {
  3328. cm.display.scrollbars.clear();
  3329. if (cm.display.scrollbars.addClass) rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
  3330. }
  3331. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function(node) {
  3332. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  3333. on(node, "mousedown", function() {
  3334. if (cm.state.focused) setTimeout(function() {
  3335. return cm.display.input.focus();
  3336. }, 0);
  3337. });
  3338. node.setAttribute("cm-not-content", "true");
  3339. }, function(pos, axis) {
  3340. if (axis == "horizontal") setScrollLeft(cm, pos);
  3341. else updateScrollTop(cm, pos);
  3342. }, cm);
  3343. if (cm.display.scrollbars.addClass) addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
  3344. }
  3345. var nextOpId = 0;
  3346. function startOperation(cm) {
  3347. cm.curOp = {
  3348. cm,
  3349. viewChanged: false,
  3350. startHeight: cm.doc.height,
  3351. forceUpdate: false,
  3352. updateInput: 0,
  3353. typing: false,
  3354. changeObjs: null,
  3355. cursorActivityHandlers: null,
  3356. cursorActivityCalled: 0,
  3357. selectionChanged: false,
  3358. updateMaxLine: false,
  3359. scrollLeft: null,
  3360. scrollTop: null,
  3361. scrollToPos: null,
  3362. focus: false,
  3363. id: ++nextOpId,
  3364. markArrays: null
  3365. };
  3366. pushOperation(cm.curOp);
  3367. }
  3368. function endOperation(cm) {
  3369. var op = cm.curOp;
  3370. if (op) finishOperation(op, function(group) {
  3371. for (var i$3 = 0; i$3 < group.ops.length; i$3++) group.ops[i$3].cm.curOp = null;
  3372. endOperations(group);
  3373. });
  3374. }
  3375. function endOperations(group) {
  3376. var ops = group.ops;
  3377. for (var i$3 = 0; i$3 < ops.length; i$3++) endOperation_R1(ops[i$3]);
  3378. for (var i$1$1 = 0; i$1$1 < ops.length; i$1$1++) endOperation_W1(ops[i$1$1]);
  3379. for (var i$2$1 = 0; i$2$1 < ops.length; i$2$1++) endOperation_R2(ops[i$2$1]);
  3380. for (var i$3$1 = 0; i$3$1 < ops.length; i$3$1++) endOperation_W2(ops[i$3$1]);
  3381. for (var i$4 = 0; i$4 < ops.length; i$4++) endOperation_finish(ops[i$4]);
  3382. }
  3383. function endOperation_R1(op) {
  3384. var cm = op.cm, display = cm.display;
  3385. maybeClipScrollbars(cm);
  3386. if (op.updateMaxLine) findMaxLine(cm);
  3387. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping;
  3388. op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && {
  3389. top: op.scrollTop,
  3390. ensure: op.scrollToPos
  3391. }, op.forceUpdate);
  3392. }
  3393. function endOperation_W1(op) {
  3394. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  3395. }
  3396. function endOperation_R2(op) {
  3397. var cm = op.cm, display = cm.display;
  3398. if (op.updatedDisplay) updateHeightsInViewport(cm);
  3399. op.barMeasure = measureForScrollbars(cm);
  3400. if (display.maxLineChanged && !cm.options.lineWrapping) {
  3401. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  3402. cm.display.sizerWidth = op.adjustWidthTo;
  3403. op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  3404. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  3405. }
  3406. if (op.updatedDisplay || op.selectionChanged) op.preparedSelection = display.input.prepareSelection();
  3407. }
  3408. function endOperation_W2(op) {
  3409. var cm = op.cm;
  3410. if (op.adjustWidthTo != null) {
  3411. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  3412. if (op.maxScrollLeft < cm.doc.scrollLeft) setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
  3413. cm.display.maxLineChanged = false;
  3414. }
  3415. var takeFocus = op.focus && op.focus == activeElt(root(cm));
  3416. if (op.preparedSelection) cm.display.input.showSelection(op.preparedSelection, takeFocus);
  3417. if (op.updatedDisplay || op.startHeight != cm.doc.height) updateScrollbars(cm, op.barMeasure);
  3418. if (op.updatedDisplay) setDocumentHeight(cm, op.barMeasure);
  3419. if (op.selectionChanged) restartBlink(cm);
  3420. if (cm.state.focused && op.updateInput) cm.display.input.reset(op.typing);
  3421. if (takeFocus) ensureFocus(op.cm);
  3422. }
  3423. function endOperation_finish(op) {
  3424. var cm = op.cm, display = cm.display, doc$1 = cm.doc;
  3425. if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
  3426. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) display.wheelStartX = display.wheelStartY = null;
  3427. if (op.scrollTop != null) setScrollTop(cm, op.scrollTop, op.forceScroll);
  3428. if (op.scrollLeft != null) setScrollLeft(cm, op.scrollLeft, true, true);
  3429. if (op.scrollToPos) {
  3430. var rect = scrollPosIntoView(cm, clipPos(doc$1, op.scrollToPos.from), clipPos(doc$1, op.scrollToPos.to), op.scrollToPos.margin);
  3431. maybeScrollWindow(cm, rect);
  3432. }
  3433. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
  3434. if (hidden) {
  3435. for (var i$3 = 0; i$3 < hidden.length; ++i$3) if (!hidden[i$3].lines.length) signal(hidden[i$3], "hide");
  3436. }
  3437. if (unhidden) {
  3438. for (var i$1$1 = 0; i$1$1 < unhidden.length; ++i$1$1) if (unhidden[i$1$1].lines.length) signal(unhidden[i$1$1], "unhide");
  3439. }
  3440. if (display.wrapper.offsetHeight) doc$1.scrollTop = cm.display.scroller.scrollTop;
  3441. if (op.changeObjs) signal(cm, "changes", cm, op.changeObjs);
  3442. if (op.update) op.update.finish();
  3443. }
  3444. function runInOp(cm, f) {
  3445. if (cm.curOp) return f();
  3446. startOperation(cm);
  3447. try {
  3448. return f();
  3449. } finally {
  3450. endOperation(cm);
  3451. }
  3452. }
  3453. function operation(cm, f) {
  3454. return function() {
  3455. if (cm.curOp) return f.apply(cm, arguments);
  3456. startOperation(cm);
  3457. try {
  3458. return f.apply(cm, arguments);
  3459. } finally {
  3460. endOperation(cm);
  3461. }
  3462. };
  3463. }
  3464. function methodOp(f) {
  3465. return function() {
  3466. if (this.curOp) return f.apply(this, arguments);
  3467. startOperation(this);
  3468. try {
  3469. return f.apply(this, arguments);
  3470. } finally {
  3471. endOperation(this);
  3472. }
  3473. };
  3474. }
  3475. function docMethodOp(f) {
  3476. return function() {
  3477. var cm = this.cm;
  3478. if (!cm || cm.curOp) return f.apply(this, arguments);
  3479. startOperation(cm);
  3480. try {
  3481. return f.apply(this, arguments);
  3482. } finally {
  3483. endOperation(cm);
  3484. }
  3485. };
  3486. }
  3487. function startWorker(cm, time) {
  3488. if (cm.doc.highlightFrontier < cm.display.viewTo) cm.state.highlight.set(time, bind(highlightWorker, cm));
  3489. }
  3490. function highlightWorker(cm) {
  3491. var doc$1 = cm.doc;
  3492. if (doc$1.highlightFrontier >= cm.display.viewTo) return;
  3493. var end = +new Date() + cm.options.workTime;
  3494. var context = getContextBefore(cm, doc$1.highlightFrontier);
  3495. var changedLines = [];
  3496. doc$1.iter(context.line, Math.min(doc$1.first + doc$1.size, cm.display.viewTo + 500), function(line) {
  3497. if (context.line >= cm.display.viewFrom) {
  3498. var oldStyles = line.styles;
  3499. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc$1.mode, context.state) : null;
  3500. var highlighted = highlightLine(cm, line, context, true);
  3501. if (resetState) context.state = resetState;
  3502. line.styles = highlighted.styles;
  3503. var oldCls = line.styleClasses, newCls = highlighted.classes;
  3504. if (newCls) line.styleClasses = newCls;
  3505. else if (oldCls) line.styleClasses = null;
  3506. var ischange = !oldStyles || oldStyles.length != line.styles.length || oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  3507. for (var i$3 = 0; !ischange && i$3 < oldStyles.length; ++i$3) ischange = oldStyles[i$3] != line.styles[i$3];
  3508. if (ischange) changedLines.push(context.line);
  3509. line.stateAfter = context.save();
  3510. context.nextLine();
  3511. } else {
  3512. if (line.text.length <= cm.options.maxHighlightLength) processLine(cm, line.text, context);
  3513. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  3514. context.nextLine();
  3515. }
  3516. if (+new Date() > end) {
  3517. startWorker(cm, cm.options.workDelay);
  3518. return true;
  3519. }
  3520. });
  3521. doc$1.highlightFrontier = context.line;
  3522. doc$1.modeFrontier = Math.max(doc$1.modeFrontier, context.line);
  3523. if (changedLines.length) runInOp(cm, function() {
  3524. for (var i$3 = 0; i$3 < changedLines.length; i$3++) regLineChange(cm, changedLines[i$3], "text");
  3525. });
  3526. }
  3527. var DisplayUpdate = function(cm, viewport, force) {
  3528. var display = cm.display;
  3529. this.viewport = viewport;
  3530. this.visible = visibleLines(display, cm.doc, viewport);
  3531. this.editorIsHidden = !display.wrapper.offsetWidth;
  3532. this.wrapperHeight = display.wrapper.clientHeight;
  3533. this.wrapperWidth = display.wrapper.clientWidth;
  3534. this.oldDisplayWidth = displayWidth(cm);
  3535. this.force = force;
  3536. this.dims = getDimensions(cm);
  3537. this.events = [];
  3538. };
  3539. DisplayUpdate.prototype.signal = function(emitter, type) {
  3540. if (hasHandler(emitter, type)) this.events.push(arguments);
  3541. };
  3542. DisplayUpdate.prototype.finish = function() {
  3543. for (var i$3 = 0; i$3 < this.events.length; i$3++) signal.apply(null, this.events[i$3]);
  3544. };
  3545. function maybeClipScrollbars(cm) {
  3546. var display = cm.display;
  3547. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  3548. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  3549. display.heightForcer.style.height = scrollGap(cm) + "px";
  3550. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  3551. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  3552. display.scrollbarsClipped = true;
  3553. }
  3554. }
  3555. function selectionSnapshot(cm) {
  3556. if (cm.hasFocus()) return null;
  3557. var active = activeElt(root(cm));
  3558. if (!active || !contains(cm.display.lineDiv, active)) return null;
  3559. var result = { activeElt: active };
  3560. if (window.getSelection) {
  3561. var sel = win(cm).getSelection();
  3562. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  3563. result.anchorNode = sel.anchorNode;
  3564. result.anchorOffset = sel.anchorOffset;
  3565. result.focusNode = sel.focusNode;
  3566. result.focusOffset = sel.focusOffset;
  3567. }
  3568. }
  3569. return result;
  3570. }
  3571. function restoreSelection(snapshot) {
  3572. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) return;
  3573. snapshot.activeElt.focus();
  3574. if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  3575. var doc$1 = snapshot.activeElt.ownerDocument;
  3576. var sel = doc$1.defaultView.getSelection(), range$1 = doc$1.createRange();
  3577. range$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  3578. range$1.collapse(false);
  3579. sel.removeAllRanges();
  3580. sel.addRange(range$1);
  3581. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  3582. }
  3583. }
  3584. function updateDisplayIfNeeded(cm, update) {
  3585. var display = cm.display, doc$1 = cm.doc;
  3586. if (update.editorIsHidden) {
  3587. resetView(cm);
  3588. return false;
  3589. }
  3590. if (!update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0) return false;
  3591. if (maybeUpdateLineNumberWidth(cm)) {
  3592. resetView(cm);
  3593. update.dims = getDimensions(cm);
  3594. }
  3595. var end = doc$1.first + doc$1.size;
  3596. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc$1.first);
  3597. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  3598. if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc$1.first, display.viewFrom);
  3599. if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
  3600. if (sawCollapsedSpans) {
  3601. from = visualLineNo(cm.doc, from);
  3602. to = visualLineEndNo(cm.doc, to);
  3603. }
  3604. var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  3605. adjustView(cm, from, to);
  3606. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
  3607. cm.display.mover.style.top = display.viewOffset + "px";
  3608. var toUpdate = countDirtyView(cm);
  3609. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) return false;
  3610. var selSnapshot = selectionSnapshot(cm);
  3611. if (toUpdate > 4) display.lineDiv.style.display = "none";
  3612. patchDisplay(cm, display.updateLineNumbers, update.dims);
  3613. if (toUpdate > 4) display.lineDiv.style.display = "";
  3614. display.renderedView = display.view;
  3615. restoreSelection(selSnapshot);
  3616. removeChildren(display.cursorDiv);
  3617. removeChildren(display.selectionDiv);
  3618. display.gutters.style.height = display.sizer.style.minHeight = 0;
  3619. if (different) {
  3620. display.lastWrapHeight = update.wrapperHeight;
  3621. display.lastWrapWidth = update.wrapperWidth;
  3622. startWorker(cm, 400);
  3623. }
  3624. display.updateLineNumbers = null;
  3625. return true;
  3626. }
  3627. function postUpdateDisplay(cm, update) {
  3628. var viewport = update.viewport;
  3629. for (var first = true;; first = false) {
  3630. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  3631. if (viewport && viewport.top != null) viewport = { top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top) };
  3632. update.visible = visibleLines(cm.display, cm.doc, viewport);
  3633. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) break;
  3634. } else if (first) update.visible = visibleLines(cm.display, cm.doc, viewport);
  3635. if (!updateDisplayIfNeeded(cm, update)) break;
  3636. updateHeightsInViewport(cm);
  3637. var barMeasure = measureForScrollbars(cm);
  3638. updateSelection(cm);
  3639. updateScrollbars(cm, barMeasure);
  3640. setDocumentHeight(cm, barMeasure);
  3641. update.force = false;
  3642. }
  3643. update.signal(cm, "update", cm);
  3644. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  3645. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  3646. cm.display.reportedViewFrom = cm.display.viewFrom;
  3647. cm.display.reportedViewTo = cm.display.viewTo;
  3648. }
  3649. }
  3650. function updateDisplaySimple(cm, viewport) {
  3651. var update = new DisplayUpdate(cm, viewport);
  3652. if (updateDisplayIfNeeded(cm, update)) {
  3653. updateHeightsInViewport(cm);
  3654. postUpdateDisplay(cm, update);
  3655. var barMeasure = measureForScrollbars(cm);
  3656. updateSelection(cm);
  3657. updateScrollbars(cm, barMeasure);
  3658. setDocumentHeight(cm, barMeasure);
  3659. update.finish();
  3660. }
  3661. }
  3662. function patchDisplay(cm, updateNumbersFrom, dims) {
  3663. var display = cm.display, lineNumbers = cm.options.lineNumbers;
  3664. var container = display.lineDiv, cur = container.firstChild;
  3665. function rm(node$1) {
  3666. var next = node$1.nextSibling;
  3667. if (webkit && mac && cm.display.currentWheelTarget == node$1) node$1.style.display = "none";
  3668. else node$1.parentNode.removeChild(node$1);
  3669. return next;
  3670. }
  3671. var view = display.view, lineN = display.viewFrom;
  3672. for (var i$3 = 0; i$3 < view.length; i$3++) {
  3673. var lineView = view[i$3];
  3674. if (lineView.hidden);
  3675. else if (!lineView.node || lineView.node.parentNode != container) {
  3676. var node = buildLineElement(cm, lineView, lineN, dims);
  3677. container.insertBefore(node, cur);
  3678. } else {
  3679. while (cur != lineView.node) cur = rm(cur);
  3680. var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber;
  3681. if (lineView.changes) {
  3682. if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
  3683. updateLineForChanges(cm, lineView, lineN, dims);
  3684. }
  3685. if (updateNumber) {
  3686. removeChildren(lineView.lineNumber);
  3687. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  3688. }
  3689. cur = lineView.node.nextSibling;
  3690. }
  3691. lineN += lineView.size;
  3692. }
  3693. while (cur) cur = rm(cur);
  3694. }
  3695. function updateGutterSpace(display) {
  3696. var width = display.gutters.offsetWidth;
  3697. display.sizer.style.marginLeft = width + "px";
  3698. signalLater(display, "gutterChanged", display);
  3699. }
  3700. function setDocumentHeight(cm, measure) {
  3701. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  3702. cm.display.heightForcer.style.top = measure.docHeight + "px";
  3703. cm.display.gutters.style.height = measure.docHeight + cm.display.barHeight + scrollGap(cm) + "px";
  3704. }
  3705. function alignHorizontally(cm) {
  3706. var display = cm.display, view = display.view;
  3707. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
  3708. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  3709. var gutterW = display.gutters.offsetWidth, left = comp + "px";
  3710. for (var i$3 = 0; i$3 < view.length; i$3++) if (!view[i$3].hidden) {
  3711. if (cm.options.fixedGutter) {
  3712. if (view[i$3].gutter) view[i$3].gutter.style.left = left;
  3713. if (view[i$3].gutterBackground) view[i$3].gutterBackground.style.left = left;
  3714. }
  3715. var align = view[i$3].alignable;
  3716. if (align) for (var j = 0; j < align.length; j++) align[j].style.left = left;
  3717. }
  3718. if (cm.options.fixedGutter) display.gutters.style.left = comp + gutterW + "px";
  3719. }
  3720. function maybeUpdateLineNumberWidth(cm) {
  3721. if (!cm.options.lineNumbers) return false;
  3722. var doc$1 = cm.doc, last = lineNumberFor(cm.options, doc$1.first + doc$1.size - 1), display = cm.display;
  3723. if (last.length != display.lineNumChars) {
  3724. var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt"));
  3725. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
  3726. display.lineGutter.style.width = "";
  3727. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  3728. display.lineNumWidth = display.lineNumInnerWidth + padding;
  3729. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  3730. display.lineGutter.style.width = display.lineNumWidth + "px";
  3731. updateGutterSpace(cm.display);
  3732. return true;
  3733. }
  3734. return false;
  3735. }
  3736. function getGutters(gutters, lineNumbers) {
  3737. var result = [], sawLineNumbers = false;
  3738. for (var i$3 = 0; i$3 < gutters.length; i$3++) {
  3739. var name = gutters[i$3], style = null;
  3740. if (typeof name != "string") {
  3741. style = name.style;
  3742. name = name.className;
  3743. }
  3744. if (name == "CodeMirror-linenumbers") if (!lineNumbers) continue;
  3745. else sawLineNumbers = true;
  3746. result.push({
  3747. className: name,
  3748. style
  3749. });
  3750. }
  3751. if (lineNumbers && !sawLineNumbers) result.push({
  3752. className: "CodeMirror-linenumbers",
  3753. style: null
  3754. });
  3755. return result;
  3756. }
  3757. function renderGutters(display) {
  3758. var gutters = display.gutters, specs = display.gutterSpecs;
  3759. removeChildren(gutters);
  3760. display.lineGutter = null;
  3761. for (var i$3 = 0; i$3 < specs.length; ++i$3) {
  3762. var ref$1 = specs[i$3];
  3763. var className = ref$1.className;
  3764. var style = ref$1.style;
  3765. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className));
  3766. if (style) gElt.style.cssText = style;
  3767. if (className == "CodeMirror-linenumbers") {
  3768. display.lineGutter = gElt;
  3769. gElt.style.width = (display.lineNumWidth || 1) + "px";
  3770. }
  3771. }
  3772. gutters.style.display = specs.length ? "" : "none";
  3773. updateGutterSpace(display);
  3774. }
  3775. function updateGutters(cm) {
  3776. renderGutters(cm.display);
  3777. regChange(cm);
  3778. alignHorizontally(cm);
  3779. }
  3780. function Display(place, doc$1, input, options) {
  3781. var d = this;
  3782. this.input = input;
  3783. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  3784. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  3785. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  3786. d.gutterFiller.setAttribute("cm-not-content", "true");
  3787. d.lineDiv = eltP("div", null, "CodeMirror-code");
  3788. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  3789. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  3790. d.measure = elt("div", null, "CodeMirror-measure");
  3791. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  3792. d.lineSpace = eltP("div", [
  3793. d.measure,
  3794. d.lineMeasure,
  3795. d.selectionDiv,
  3796. d.cursorDiv,
  3797. d.lineDiv
  3798. ], null, "position: relative; outline: none");
  3799. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  3800. d.mover = elt("div", [lines], null, "position: relative");
  3801. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  3802. d.sizerWidth = null;
  3803. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  3804. d.gutters = elt("div", null, "CodeMirror-gutters");
  3805. d.lineGutter = null;
  3806. d.scroller = elt("div", [
  3807. d.sizer,
  3808. d.heightForcer,
  3809. d.gutters
  3810. ], "CodeMirror-scroll");
  3811. d.scroller.setAttribute("tabIndex", "-1");
  3812. d.wrapper = elt("div", [
  3813. d.scrollbarFiller,
  3814. d.gutterFiller,
  3815. d.scroller
  3816. ], "CodeMirror");
  3817. if (chrome && chrome_version >= 105) d.wrapper.style.clipPath = "inset(0px)";
  3818. d.wrapper.setAttribute("translate", "no");
  3819. if (ie && ie_version < 8) {
  3820. d.gutters.style.zIndex = -1;
  3821. d.scroller.style.paddingRight = 0;
  3822. }
  3823. if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
  3824. if (place) if (place.appendChild) place.appendChild(d.wrapper);
  3825. else place(d.wrapper);
  3826. d.viewFrom = d.viewTo = doc$1.first;
  3827. d.reportedViewFrom = d.reportedViewTo = doc$1.first;
  3828. d.view = [];
  3829. d.renderedView = null;
  3830. d.externalMeasured = null;
  3831. d.viewOffset = 0;
  3832. d.lastWrapHeight = d.lastWrapWidth = 0;
  3833. d.updateLineNumbers = null;
  3834. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  3835. d.scrollbarsClipped = false;
  3836. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  3837. d.alignWidgets = false;
  3838. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  3839. d.maxLine = null;
  3840. d.maxLineLength = 0;
  3841. d.maxLineChanged = false;
  3842. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  3843. d.shift = false;
  3844. d.selForContextMenu = null;
  3845. d.activeTouch = null;
  3846. d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);
  3847. renderGutters(d);
  3848. input.init(d);
  3849. }
  3850. var wheelSamples = 0, wheelPixelsPerUnit = null;
  3851. if (ie) wheelPixelsPerUnit = -.53;
  3852. else if (gecko) wheelPixelsPerUnit = 15;
  3853. else if (chrome) wheelPixelsPerUnit = -.7;
  3854. else if (safari) wheelPixelsPerUnit = -1 / 3;
  3855. function wheelEventDelta(e) {
  3856. var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
  3857. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
  3858. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
  3859. else if (dy == null) dy = e.wheelDelta;
  3860. return {
  3861. x: dx,
  3862. y: dy
  3863. };
  3864. }
  3865. function wheelEventPixels(e) {
  3866. var delta = wheelEventDelta(e);
  3867. delta.x *= wheelPixelsPerUnit;
  3868. delta.y *= wheelPixelsPerUnit;
  3869. return delta;
  3870. }
  3871. function onScrollWheel(cm, e) {
  3872. if (chrome && chrome_version == 102) {
  3873. if (cm.display.chromeScrollHack == null) cm.display.sizer.style.pointerEvents = "none";
  3874. else clearTimeout(cm.display.chromeScrollHack);
  3875. cm.display.chromeScrollHack = setTimeout(function() {
  3876. cm.display.chromeScrollHack = null;
  3877. cm.display.sizer.style.pointerEvents = "";
  3878. }, 100);
  3879. }
  3880. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
  3881. var pixelsPerUnit = wheelPixelsPerUnit;
  3882. if (e.deltaMode === 0) {
  3883. dx = e.deltaX;
  3884. dy = e.deltaY;
  3885. pixelsPerUnit = 1;
  3886. }
  3887. var display = cm.display, scroll = display.scroller;
  3888. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  3889. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  3890. if (!(dx && canScrollX || dy && canScrollY)) return;
  3891. if (dy && mac && webkit) {
  3892. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) for (var i$3 = 0; i$3 < view.length; i$3++) if (view[i$3].node == cur) {
  3893. cm.display.currentWheelTarget = cur;
  3894. break outer;
  3895. }
  3896. }
  3897. if (dx && !gecko && !presto && pixelsPerUnit != null) {
  3898. if (dy && canScrollY) updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit));
  3899. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit));
  3900. if (!dy || dy && canScrollY) e_preventDefault(e);
  3901. display.wheelStartX = null;
  3902. return;
  3903. }
  3904. if (dy && pixelsPerUnit != null) {
  3905. var pixels = dy * pixelsPerUnit;
  3906. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
  3907. if (pixels < 0) top = Math.max(0, top + pixels - 50);
  3908. else bot = Math.min(cm.doc.height, bot + pixels + 50);
  3909. updateDisplaySimple(cm, {
  3910. top,
  3911. bottom: bot
  3912. });
  3913. }
  3914. if (wheelSamples < 20 && e.deltaMode !== 0) if (display.wheelStartX == null) {
  3915. display.wheelStartX = scroll.scrollLeft;
  3916. display.wheelStartY = scroll.scrollTop;
  3917. display.wheelDX = dx;
  3918. display.wheelDY = dy;
  3919. setTimeout(function() {
  3920. if (display.wheelStartX == null) return;
  3921. var movedX = scroll.scrollLeft - display.wheelStartX;
  3922. var movedY = scroll.scrollTop - display.wheelStartY;
  3923. var sample = movedY && display.wheelDY && movedY / display.wheelDY || movedX && display.wheelDX && movedX / display.wheelDX;
  3924. display.wheelStartX = display.wheelStartY = null;
  3925. if (!sample) return;
  3926. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  3927. ++wheelSamples;
  3928. }, 200);
  3929. } else {
  3930. display.wheelDX += dx;
  3931. display.wheelDY += dy;
  3932. }
  3933. }
  3934. var Selection = function(ranges, primIndex) {
  3935. this.ranges = ranges;
  3936. this.primIndex = primIndex;
  3937. };
  3938. Selection.prototype.primary = function() {
  3939. return this.ranges[this.primIndex];
  3940. };
  3941. Selection.prototype.equals = function(other) {
  3942. if (other == this) return true;
  3943. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
  3944. for (var i$3 = 0; i$3 < this.ranges.length; i$3++) {
  3945. var here = this.ranges[i$3], there = other.ranges[i$3];
  3946. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) return false;
  3947. }
  3948. return true;
  3949. };
  3950. Selection.prototype.deepCopy = function() {
  3951. var out = [];
  3952. for (var i$3 = 0; i$3 < this.ranges.length; i$3++) out[i$3] = new Range(copyPos(this.ranges[i$3].anchor), copyPos(this.ranges[i$3].head));
  3953. return new Selection(out, this.primIndex);
  3954. };
  3955. Selection.prototype.somethingSelected = function() {
  3956. for (var i$3 = 0; i$3 < this.ranges.length; i$3++) if (!this.ranges[i$3].empty()) return true;
  3957. return false;
  3958. };
  3959. Selection.prototype.contains = function(pos, end) {
  3960. if (!end) end = pos;
  3961. for (var i$3 = 0; i$3 < this.ranges.length; i$3++) {
  3962. var range$1 = this.ranges[i$3];
  3963. if (cmp(end, range$1.from()) >= 0 && cmp(pos, range$1.to()) <= 0) return i$3;
  3964. }
  3965. return -1;
  3966. };
  3967. var Range = function(anchor, head) {
  3968. this.anchor = anchor;
  3969. this.head = head;
  3970. };
  3971. Range.prototype.from = function() {
  3972. return minPos(this.anchor, this.head);
  3973. };
  3974. Range.prototype.to = function() {
  3975. return maxPos(this.anchor, this.head);
  3976. };
  3977. Range.prototype.empty = function() {
  3978. return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
  3979. };
  3980. function normalizeSelection(cm, ranges, primIndex) {
  3981. var mayTouch = cm && cm.options.selectionsMayTouch;
  3982. var prim = ranges[primIndex];
  3983. ranges.sort(function(a, b) {
  3984. return cmp(a.from(), b.from());
  3985. });
  3986. primIndex = indexOf(ranges, prim);
  3987. for (var i$3 = 1; i$3 < ranges.length; i$3++) {
  3988. var cur = ranges[i$3], prev = ranges[i$3 - 1];
  3989. var diff = cmp(prev.to(), cur.from());
  3990. if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {
  3991. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
  3992. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  3993. if (i$3 <= primIndex) --primIndex;
  3994. ranges.splice(--i$3, 2, new Range(inv ? to : from, inv ? from : to));
  3995. }
  3996. }
  3997. return new Selection(ranges, primIndex);
  3998. }
  3999. function simpleSelection(anchor, head) {
  4000. return new Selection([new Range(anchor, head || anchor)], 0);
  4001. }
  4002. function changeEnd(change) {
  4003. if (!change.text) return change.to;
  4004. return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
  4005. }
  4006. function adjustForChange(pos, change) {
  4007. if (cmp(pos, change.from) < 0) return pos;
  4008. if (cmp(pos, change.to) <= 0) return changeEnd(change);
  4009. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
  4010. if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
  4011. return Pos(line, ch);
  4012. }
  4013. function computeSelAfterChange(doc$1, change) {
  4014. var out = [];
  4015. for (var i$3 = 0; i$3 < doc$1.sel.ranges.length; i$3++) {
  4016. var range$1 = doc$1.sel.ranges[i$3];
  4017. out.push(new Range(adjustForChange(range$1.anchor, change), adjustForChange(range$1.head, change)));
  4018. }
  4019. return normalizeSelection(doc$1.cm, out, doc$1.sel.primIndex);
  4020. }
  4021. function offsetPos(pos, old, nw) {
  4022. if (pos.line == old.line) return Pos(nw.line, pos.ch - old.ch + nw.ch);
  4023. else return Pos(nw.line + (pos.line - old.line), pos.ch);
  4024. }
  4025. function computeReplacedSel(doc$1, changes, hint) {
  4026. var out = [];
  4027. var oldPrev = Pos(doc$1.first, 0), newPrev = oldPrev;
  4028. for (var i$3 = 0; i$3 < changes.length; i$3++) {
  4029. var change = changes[i$3];
  4030. var from = offsetPos(change.from, oldPrev, newPrev);
  4031. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  4032. oldPrev = change.to;
  4033. newPrev = to;
  4034. if (hint == "around") {
  4035. var range$1 = doc$1.sel.ranges[i$3], inv = cmp(range$1.head, range$1.anchor) < 0;
  4036. out[i$3] = new Range(inv ? to : from, inv ? from : to);
  4037. } else out[i$3] = new Range(from, from);
  4038. }
  4039. return new Selection(out, doc$1.sel.primIndex);
  4040. }
  4041. function loadMode(cm) {
  4042. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  4043. resetModeState(cm);
  4044. }
  4045. function resetModeState(cm) {
  4046. cm.doc.iter(function(line) {
  4047. if (line.stateAfter) line.stateAfter = null;
  4048. if (line.styles) line.styles = null;
  4049. });
  4050. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  4051. startWorker(cm, 100);
  4052. cm.state.modeGen++;
  4053. if (cm.curOp) regChange(cm);
  4054. }
  4055. function isWholeLineUpdate(doc$1, change) {
  4056. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc$1.cm || doc$1.cm.options.wholeLineUpdateBefore);
  4057. }
  4058. function updateDoc(doc$1, change, markedSpans, estimateHeight$1) {
  4059. function spansFor(n) {
  4060. return markedSpans ? markedSpans[n] : null;
  4061. }
  4062. function update(line, text$1, spans) {
  4063. updateLine(line, text$1, spans, estimateHeight$1);
  4064. signalLater(line, "change", line, change);
  4065. }
  4066. function linesFor(start, end) {
  4067. var result = [];
  4068. for (var i$3 = start; i$3 < end; ++i$3) result.push(new Line(text[i$3], spansFor(i$3), estimateHeight$1));
  4069. return result;
  4070. }
  4071. var from = change.from, to = change.to, text = change.text;
  4072. var firstLine = getLine(doc$1, from.line), lastLine = getLine(doc$1, to.line);
  4073. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
  4074. if (change.full) {
  4075. doc$1.insert(0, linesFor(0, text.length));
  4076. doc$1.remove(text.length, doc$1.size - text.length);
  4077. } else if (isWholeLineUpdate(doc$1, change)) {
  4078. var added = linesFor(0, text.length - 1);
  4079. update(lastLine, lastLine.text, lastSpans);
  4080. if (nlines) doc$1.remove(from.line, nlines);
  4081. if (added.length) doc$1.insert(from.line, added);
  4082. } else if (firstLine == lastLine) if (text.length == 1) update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  4083. else {
  4084. var added$1 = linesFor(1, text.length - 1);
  4085. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$1));
  4086. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  4087. doc$1.insert(from.line + 1, added$1);
  4088. }
  4089. else if (text.length == 1) {
  4090. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  4091. doc$1.remove(from.line + 1, nlines);
  4092. } else {
  4093. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  4094. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  4095. var added$2 = linesFor(1, text.length - 1);
  4096. if (nlines > 1) doc$1.remove(from.line + 1, nlines - 1);
  4097. doc$1.insert(from.line + 1, added$2);
  4098. }
  4099. signalLater(doc$1, "change", doc$1, change);
  4100. }
  4101. function linkedDocs(doc$1, f, sharedHistOnly) {
  4102. function propagate(doc$2, skip, sharedHist) {
  4103. if (doc$2.linked) for (var i$3 = 0; i$3 < doc$2.linked.length; ++i$3) {
  4104. var rel = doc$2.linked[i$3];
  4105. if (rel.doc == skip) continue;
  4106. var shared = sharedHist && rel.sharedHist;
  4107. if (sharedHistOnly && !shared) continue;
  4108. f(rel.doc, shared);
  4109. propagate(rel.doc, doc$2, shared);
  4110. }
  4111. }
  4112. propagate(doc$1, null, true);
  4113. }
  4114. function attachDoc(cm, doc$1) {
  4115. if (doc$1.cm) throw new Error("This document is already in use.");
  4116. cm.doc = doc$1;
  4117. doc$1.cm = cm;
  4118. estimateLineHeights(cm);
  4119. loadMode(cm);
  4120. setDirectionClass(cm);
  4121. cm.options.direction = doc$1.direction;
  4122. if (!cm.options.lineWrapping) findMaxLine(cm);
  4123. cm.options.mode = doc$1.modeOption;
  4124. regChange(cm);
  4125. }
  4126. function setDirectionClass(cm) {
  4127. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  4128. }
  4129. function directionChanged(cm) {
  4130. runInOp(cm, function() {
  4131. setDirectionClass(cm);
  4132. regChange(cm);
  4133. });
  4134. }
  4135. function History(prev) {
  4136. this.done = [];
  4137. this.undone = [];
  4138. this.undoDepth = prev ? prev.undoDepth : Infinity;
  4139. this.lastModTime = this.lastSelTime = 0;
  4140. this.lastOp = this.lastSelOp = null;
  4141. this.lastOrigin = this.lastSelOrigin = null;
  4142. this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1;
  4143. }
  4144. function historyChangeFromChange(doc$1, change) {
  4145. var histChange = {
  4146. from: copyPos(change.from),
  4147. to: changeEnd(change),
  4148. text: getBetween(doc$1, change.from, change.to)
  4149. };
  4150. attachLocalSpans(doc$1, histChange, change.from.line, change.to.line + 1);
  4151. linkedDocs(doc$1, function(doc$2) {
  4152. return attachLocalSpans(doc$2, histChange, change.from.line, change.to.line + 1);
  4153. }, true);
  4154. return histChange;
  4155. }
  4156. function clearSelectionEvents(array) {
  4157. while (array.length) {
  4158. var last = lst(array);
  4159. if (last.ranges) array.pop();
  4160. else break;
  4161. }
  4162. }
  4163. function lastChangeEvent(hist, force) {
  4164. if (force) {
  4165. clearSelectionEvents(hist.done);
  4166. return lst(hist.done);
  4167. } else if (hist.done.length && !lst(hist.done).ranges) return lst(hist.done);
  4168. else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  4169. hist.done.pop();
  4170. return lst(hist.done);
  4171. }
  4172. }
  4173. function addChangeToHistory(doc$1, change, selAfter, opId) {
  4174. var hist = doc$1.history;
  4175. hist.undone.length = 0;
  4176. var time = +new Date(), cur;
  4177. var last;
  4178. if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && (change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc$1.cm ? doc$1.cm.options.historyEventDelay : 500) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  4179. last = lst(cur.changes);
  4180. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) last.to = changeEnd(change);
  4181. else cur.changes.push(historyChangeFromChange(doc$1, change));
  4182. } else {
  4183. var before = lst(hist.done);
  4184. if (!before || !before.ranges) pushSelectionToHistory(doc$1.sel, hist.done);
  4185. cur = {
  4186. changes: [historyChangeFromChange(doc$1, change)],
  4187. generation: hist.generation
  4188. };
  4189. hist.done.push(cur);
  4190. while (hist.done.length > hist.undoDepth) {
  4191. hist.done.shift();
  4192. if (!hist.done[0].ranges) hist.done.shift();
  4193. }
  4194. }
  4195. hist.done.push(selAfter);
  4196. hist.generation = ++hist.maxGeneration;
  4197. hist.lastModTime = hist.lastSelTime = time;
  4198. hist.lastOp = hist.lastSelOp = opId;
  4199. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  4200. if (!last) signal(doc$1, "historyAdded");
  4201. }
  4202. function selectionEventCanBeMerged(doc$1, origin, prev, sel) {
  4203. var ch = origin.charAt(0);
  4204. return ch == "*" || ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date() - doc$1.history.lastSelTime <= (doc$1.cm ? doc$1.cm.options.historyEventDelay : 500);
  4205. }
  4206. function addSelectionToHistory(doc$1, sel, opId, options) {
  4207. var hist = doc$1.history, origin = options && options.origin;
  4208. if (opId == hist.lastSelOp || origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc$1, origin, lst(hist.done), sel))) hist.done[hist.done.length - 1] = sel;
  4209. else pushSelectionToHistory(sel, hist.done);
  4210. hist.lastSelTime = +new Date();
  4211. hist.lastSelOrigin = origin;
  4212. hist.lastSelOp = opId;
  4213. if (options && options.clearRedo !== false) clearSelectionEvents(hist.undone);
  4214. }
  4215. function pushSelectionToHistory(sel, dest) {
  4216. var top = lst(dest);
  4217. if (!(top && top.ranges && top.equals(sel))) dest.push(sel);
  4218. }
  4219. function attachLocalSpans(doc$1, change, from, to) {
  4220. var existing = change["spans_" + doc$1.id], n = 0;
  4221. doc$1.iter(Math.max(doc$1.first, from), Math.min(doc$1.first + doc$1.size, to), function(line) {
  4222. if (line.markedSpans) (existing || (existing = change["spans_" + doc$1.id] = {}))[n] = line.markedSpans;
  4223. ++n;
  4224. });
  4225. }
  4226. function removeClearedSpans(spans) {
  4227. if (!spans) return null;
  4228. var out;
  4229. for (var i$3 = 0; i$3 < spans.length; ++i$3) if (spans[i$3].marker.explicitlyCleared) {
  4230. if (!out) out = spans.slice(0, i$3);
  4231. } else if (out) out.push(spans[i$3]);
  4232. return !out ? spans : out.length ? out : null;
  4233. }
  4234. function getOldSpans(doc$1, change) {
  4235. var found = change["spans_" + doc$1.id];
  4236. if (!found) return null;
  4237. var nw = [];
  4238. for (var i$3 = 0; i$3 < change.text.length; ++i$3) nw.push(removeClearedSpans(found[i$3]));
  4239. return nw;
  4240. }
  4241. function mergeOldSpans(doc$1, change) {
  4242. var old = getOldSpans(doc$1, change);
  4243. var stretched = stretchSpansOverChange(doc$1, change);
  4244. if (!old) return stretched;
  4245. if (!stretched) return old;
  4246. for (var i$3 = 0; i$3 < old.length; ++i$3) {
  4247. var oldCur = old[i$3], stretchCur = stretched[i$3];
  4248. if (oldCur && stretchCur) spans: for (var j = 0; j < stretchCur.length; ++j) {
  4249. var span = stretchCur[j];
  4250. for (var k = 0; k < oldCur.length; ++k) if (oldCur[k].marker == span.marker) continue spans;
  4251. oldCur.push(span);
  4252. }
  4253. else if (stretchCur) old[i$3] = stretchCur;
  4254. }
  4255. return old;
  4256. }
  4257. function copyHistoryArray(events, newGroup, instantiateSel) {
  4258. var copy = [];
  4259. for (var i$3 = 0; i$3 < events.length; ++i$3) {
  4260. var event = events[i$3];
  4261. if (event.ranges) {
  4262. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  4263. continue;
  4264. }
  4265. var changes = event.changes, newChanges = [];
  4266. copy.push({ changes: newChanges });
  4267. for (var j = 0; j < changes.length; ++j) {
  4268. var change = changes[j], m = void 0;
  4269. newChanges.push({
  4270. from: change.from,
  4271. to: change.to,
  4272. text: change.text
  4273. });
  4274. if (newGroup) {
  4275. for (var prop$1 in change) if (m = prop$1.match(/^spans_(\d+)$/)) {
  4276. if (indexOf(newGroup, Number(m[1])) > -1) {
  4277. lst(newChanges)[prop$1] = change[prop$1];
  4278. delete change[prop$1];
  4279. }
  4280. }
  4281. }
  4282. }
  4283. }
  4284. return copy;
  4285. }
  4286. function extendRange(range$1, head, other, extend) {
  4287. if (extend) {
  4288. var anchor = range$1.anchor;
  4289. if (other) {
  4290. var posBefore = cmp(head, anchor) < 0;
  4291. if (posBefore != cmp(other, anchor) < 0) {
  4292. anchor = head;
  4293. head = other;
  4294. } else if (posBefore != cmp(head, other) < 0) head = other;
  4295. }
  4296. return new Range(anchor, head);
  4297. } else return new Range(other || head, head);
  4298. }
  4299. function extendSelection(doc$1, head, other, options, extend) {
  4300. if (extend == null) extend = doc$1.cm && (doc$1.cm.display.shift || doc$1.extend);
  4301. setSelection(doc$1, new Selection([extendRange(doc$1.sel.primary(), head, other, extend)], 0), options);
  4302. }
  4303. function extendSelections(doc$1, heads, options) {
  4304. var out = [];
  4305. var extend = doc$1.cm && (doc$1.cm.display.shift || doc$1.extend);
  4306. for (var i$3 = 0; i$3 < doc$1.sel.ranges.length; i$3++) out[i$3] = extendRange(doc$1.sel.ranges[i$3], heads[i$3], null, extend);
  4307. var newSel = normalizeSelection(doc$1.cm, out, doc$1.sel.primIndex);
  4308. setSelection(doc$1, newSel, options);
  4309. }
  4310. function replaceOneSelection(doc$1, i$3, range$1, options) {
  4311. var ranges = doc$1.sel.ranges.slice(0);
  4312. ranges[i$3] = range$1;
  4313. setSelection(doc$1, normalizeSelection(doc$1.cm, ranges, doc$1.sel.primIndex), options);
  4314. }
  4315. function setSimpleSelection(doc$1, anchor, head, options) {
  4316. setSelection(doc$1, simpleSelection(anchor, head), options);
  4317. }
  4318. function filterSelectionChange(doc$1, sel, options) {
  4319. var obj = {
  4320. ranges: sel.ranges,
  4321. update: function(ranges) {
  4322. this.ranges = [];
  4323. for (var i$3 = 0; i$3 < ranges.length; i$3++) this.ranges[i$3] = new Range(clipPos(doc$1, ranges[i$3].anchor), clipPos(doc$1, ranges[i$3].head));
  4324. },
  4325. origin: options && options.origin
  4326. };
  4327. signal(doc$1, "beforeSelectionChange", doc$1, obj);
  4328. if (doc$1.cm) signal(doc$1.cm, "beforeSelectionChange", doc$1.cm, obj);
  4329. if (obj.ranges != sel.ranges) return normalizeSelection(doc$1.cm, obj.ranges, obj.ranges.length - 1);
  4330. else return sel;
  4331. }
  4332. function setSelectionReplaceHistory(doc$1, sel, options) {
  4333. var done = doc$1.history.done, last = lst(done);
  4334. if (last && last.ranges) {
  4335. done[done.length - 1] = sel;
  4336. setSelectionNoUndo(doc$1, sel, options);
  4337. } else setSelection(doc$1, sel, options);
  4338. }
  4339. function setSelection(doc$1, sel, options) {
  4340. setSelectionNoUndo(doc$1, sel, options);
  4341. addSelectionToHistory(doc$1, doc$1.sel, doc$1.cm ? doc$1.cm.curOp.id : NaN, options);
  4342. }
  4343. function setSelectionNoUndo(doc$1, sel, options) {
  4344. if (hasHandler(doc$1, "beforeSelectionChange") || doc$1.cm && hasHandler(doc$1.cm, "beforeSelectionChange")) sel = filterSelectionChange(doc$1, sel, options);
  4345. var bias = options && options.bias || (cmp(sel.primary().head, doc$1.sel.primary().head) < 0 ? -1 : 1);
  4346. setSelectionInner(doc$1, skipAtomicInSelection(doc$1, sel, bias, true));
  4347. if (!(options && options.scroll === false) && doc$1.cm && doc$1.cm.getOption("readOnly") != "nocursor") ensureCursorVisible(doc$1.cm);
  4348. }
  4349. function setSelectionInner(doc$1, sel) {
  4350. if (sel.equals(doc$1.sel)) return;
  4351. doc$1.sel = sel;
  4352. if (doc$1.cm) {
  4353. doc$1.cm.curOp.updateInput = 1;
  4354. doc$1.cm.curOp.selectionChanged = true;
  4355. signalCursorActivity(doc$1.cm);
  4356. }
  4357. signalLater(doc$1, "cursorActivity", doc$1);
  4358. }
  4359. function reCheckSelection(doc$1) {
  4360. setSelectionInner(doc$1, skipAtomicInSelection(doc$1, doc$1.sel, null, false));
  4361. }
  4362. function skipAtomicInSelection(doc$1, sel, bias, mayClear) {
  4363. var out;
  4364. for (var i$3 = 0; i$3 < sel.ranges.length; i$3++) {
  4365. var range$1 = sel.ranges[i$3];
  4366. var old = sel.ranges.length == doc$1.sel.ranges.length && doc$1.sel.ranges[i$3];
  4367. var newAnchor = skipAtomic(doc$1, range$1.anchor, old && old.anchor, bias, mayClear);
  4368. var newHead = range$1.head == range$1.anchor ? newAnchor : skipAtomic(doc$1, range$1.head, old && old.head, bias, mayClear);
  4369. if (out || newAnchor != range$1.anchor || newHead != range$1.head) {
  4370. if (!out) out = sel.ranges.slice(0, i$3);
  4371. out[i$3] = new Range(newAnchor, newHead);
  4372. }
  4373. }
  4374. return out ? normalizeSelection(doc$1.cm, out, sel.primIndex) : sel;
  4375. }
  4376. function skipAtomicInner(doc$1, pos, oldPos, dir, mayClear) {
  4377. var line = getLine(doc$1, pos.line);
  4378. if (line.markedSpans) for (var i$3 = 0; i$3 < line.markedSpans.length; ++i$3) {
  4379. var sp = line.markedSpans[i$3], m = sp.marker;
  4380. var preventCursorLeft = "selectLeft" in m ? !m.selectLeft : m.inclusiveLeft;
  4381. var preventCursorRight = "selectRight" in m ? !m.selectRight : m.inclusiveRight;
  4382. if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  4383. if (mayClear) {
  4384. signal(m, "beforeCursorEnter");
  4385. if (m.explicitlyCleared) if (!line.markedSpans) break;
  4386. else {
  4387. --i$3;
  4388. continue;
  4389. }
  4390. }
  4391. if (!m.atomic) continue;
  4392. if (oldPos) {
  4393. var near = m.find(dir < 0 ? 1 : -1), diff = void 0;
  4394. if (dir < 0 ? preventCursorRight : preventCursorLeft) near = movePos(doc$1, near, -dir, near && near.line == pos.line ? line : null);
  4395. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) return skipAtomicInner(doc$1, near, pos, dir, mayClear);
  4396. }
  4397. var far = m.find(dir < 0 ? -1 : 1);
  4398. if (dir < 0 ? preventCursorLeft : preventCursorRight) far = movePos(doc$1, far, dir, far.line == pos.line ? line : null);
  4399. return far ? skipAtomicInner(doc$1, far, pos, dir, mayClear) : null;
  4400. }
  4401. }
  4402. return pos;
  4403. }
  4404. function skipAtomic(doc$1, pos, oldPos, bias, mayClear) {
  4405. var dir = bias || 1;
  4406. var found = skipAtomicInner(doc$1, pos, oldPos, dir, mayClear) || !mayClear && skipAtomicInner(doc$1, pos, oldPos, dir, true) || skipAtomicInner(doc$1, pos, oldPos, -dir, mayClear) || !mayClear && skipAtomicInner(doc$1, pos, oldPos, -dir, true);
  4407. if (!found) {
  4408. doc$1.cantEdit = true;
  4409. return Pos(doc$1.first, 0);
  4410. }
  4411. return found;
  4412. }
  4413. function movePos(doc$1, pos, dir, line) {
  4414. if (dir < 0 && pos.ch == 0) if (pos.line > doc$1.first) return clipPos(doc$1, Pos(pos.line - 1));
  4415. else return null;
  4416. else if (dir > 0 && pos.ch == (line || getLine(doc$1, pos.line)).text.length) if (pos.line < doc$1.first + doc$1.size - 1) return Pos(pos.line + 1, 0);
  4417. else return null;
  4418. else return new Pos(pos.line, pos.ch + dir);
  4419. }
  4420. function selectAll(cm) {
  4421. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  4422. }
  4423. function filterChange(doc$1, change, update) {
  4424. var obj = {
  4425. canceled: false,
  4426. from: change.from,
  4427. to: change.to,
  4428. text: change.text,
  4429. origin: change.origin,
  4430. cancel: function() {
  4431. return obj.canceled = true;
  4432. }
  4433. };
  4434. if (update) obj.update = function(from, to, text, origin) {
  4435. if (from) obj.from = clipPos(doc$1, from);
  4436. if (to) obj.to = clipPos(doc$1, to);
  4437. if (text) obj.text = text;
  4438. if (origin !== void 0) obj.origin = origin;
  4439. };
  4440. signal(doc$1, "beforeChange", doc$1, obj);
  4441. if (doc$1.cm) signal(doc$1.cm, "beforeChange", doc$1.cm, obj);
  4442. if (obj.canceled) {
  4443. if (doc$1.cm) doc$1.cm.curOp.updateInput = 2;
  4444. return null;
  4445. }
  4446. return {
  4447. from: obj.from,
  4448. to: obj.to,
  4449. text: obj.text,
  4450. origin: obj.origin
  4451. };
  4452. }
  4453. function makeChange(doc$1, change, ignoreReadOnly) {
  4454. if (doc$1.cm) {
  4455. if (!doc$1.cm.curOp) return operation(doc$1.cm, makeChange)(doc$1, change, ignoreReadOnly);
  4456. if (doc$1.cm.state.suppressEdits) return;
  4457. }
  4458. if (hasHandler(doc$1, "beforeChange") || doc$1.cm && hasHandler(doc$1.cm, "beforeChange")) {
  4459. change = filterChange(doc$1, change, true);
  4460. if (!change) return;
  4461. }
  4462. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc$1, change.from, change.to);
  4463. if (split) for (var i$3 = split.length - 1; i$3 >= 0; --i$3) makeChangeInner(doc$1, {
  4464. from: split[i$3].from,
  4465. to: split[i$3].to,
  4466. text: i$3 ? [""] : change.text,
  4467. origin: change.origin
  4468. });
  4469. else makeChangeInner(doc$1, change);
  4470. }
  4471. function makeChangeInner(doc$1, change) {
  4472. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
  4473. var selAfter = computeSelAfterChange(doc$1, change);
  4474. addChangeToHistory(doc$1, change, selAfter, doc$1.cm ? doc$1.cm.curOp.id : NaN);
  4475. makeChangeSingleDoc(doc$1, change, selAfter, stretchSpansOverChange(doc$1, change));
  4476. var rebased = [];
  4477. linkedDocs(doc$1, function(doc$2, sharedHist) {
  4478. if (!sharedHist && indexOf(rebased, doc$2.history) == -1) {
  4479. rebaseHist(doc$2.history, change);
  4480. rebased.push(doc$2.history);
  4481. }
  4482. makeChangeSingleDoc(doc$2, change, null, stretchSpansOverChange(doc$2, change));
  4483. });
  4484. }
  4485. function makeChangeFromHistory(doc$1, type, allowSelectionOnly) {
  4486. var suppress = doc$1.cm && doc$1.cm.state.suppressEdits;
  4487. if (suppress && !allowSelectionOnly) return;
  4488. var hist = doc$1.history, event, selAfter = doc$1.sel;
  4489. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
  4490. var i$3 = 0;
  4491. for (; i$3 < source.length; i$3++) {
  4492. event = source[i$3];
  4493. if (allowSelectionOnly ? event.ranges && !event.equals(doc$1.sel) : !event.ranges) break;
  4494. }
  4495. if (i$3 == source.length) return;
  4496. hist.lastOrigin = hist.lastSelOrigin = null;
  4497. for (;;) {
  4498. event = source.pop();
  4499. if (event.ranges) {
  4500. pushSelectionToHistory(event, dest);
  4501. if (allowSelectionOnly && !event.equals(doc$1.sel)) {
  4502. setSelection(doc$1, event, { clearRedo: false });
  4503. return;
  4504. }
  4505. selAfter = event;
  4506. } else if (suppress) {
  4507. source.push(event);
  4508. return;
  4509. } else break;
  4510. }
  4511. var antiChanges = [];
  4512. pushSelectionToHistory(selAfter, dest);
  4513. dest.push({
  4514. changes: antiChanges,
  4515. generation: hist.generation
  4516. });
  4517. hist.generation = event.generation || ++hist.maxGeneration;
  4518. var filter = hasHandler(doc$1, "beforeChange") || doc$1.cm && hasHandler(doc$1.cm, "beforeChange");
  4519. var loop = function(i$4) {
  4520. var change = event.changes[i$4];
  4521. change.origin = type;
  4522. if (filter && !filterChange(doc$1, change, false)) {
  4523. source.length = 0;
  4524. return {};
  4525. }
  4526. antiChanges.push(historyChangeFromChange(doc$1, change));
  4527. var after = i$4 ? computeSelAfterChange(doc$1, change) : lst(source);
  4528. makeChangeSingleDoc(doc$1, change, after, mergeOldSpans(doc$1, change));
  4529. if (!i$4 && doc$1.cm) doc$1.cm.scrollIntoView({
  4530. from: change.from,
  4531. to: changeEnd(change)
  4532. });
  4533. var rebased = [];
  4534. linkedDocs(doc$1, function(doc$2, sharedHist) {
  4535. if (!sharedHist && indexOf(rebased, doc$2.history) == -1) {
  4536. rebaseHist(doc$2.history, change);
  4537. rebased.push(doc$2.history);
  4538. }
  4539. makeChangeSingleDoc(doc$2, change, null, mergeOldSpans(doc$2, change));
  4540. });
  4541. };
  4542. for (var i$1$1 = event.changes.length - 1; i$1$1 >= 0; --i$1$1) {
  4543. var returned = loop(i$1$1);
  4544. if (returned) return returned.v;
  4545. }
  4546. }
  4547. function shiftDoc(doc$1, distance) {
  4548. if (distance == 0) return;
  4549. doc$1.first += distance;
  4550. doc$1.sel = new Selection(map(doc$1.sel.ranges, function(range$1) {
  4551. return new Range(Pos(range$1.anchor.line + distance, range$1.anchor.ch), Pos(range$1.head.line + distance, range$1.head.ch));
  4552. }), doc$1.sel.primIndex);
  4553. if (doc$1.cm) {
  4554. regChange(doc$1.cm, doc$1.first, doc$1.first - distance, distance);
  4555. for (var d = doc$1.cm.display, l = d.viewFrom; l < d.viewTo; l++) regLineChange(doc$1.cm, l, "gutter");
  4556. }
  4557. }
  4558. function makeChangeSingleDoc(doc$1, change, selAfter, spans) {
  4559. if (doc$1.cm && !doc$1.cm.curOp) return operation(doc$1.cm, makeChangeSingleDoc)(doc$1, change, selAfter, spans);
  4560. if (change.to.line < doc$1.first) {
  4561. shiftDoc(doc$1, change.text.length - 1 - (change.to.line - change.from.line));
  4562. return;
  4563. }
  4564. if (change.from.line > doc$1.lastLine()) return;
  4565. if (change.from.line < doc$1.first) {
  4566. var shift = change.text.length - 1 - (doc$1.first - change.from.line);
  4567. shiftDoc(doc$1, shift);
  4568. change = {
  4569. from: Pos(doc$1.first, 0),
  4570. to: Pos(change.to.line + shift, change.to.ch),
  4571. text: [lst(change.text)],
  4572. origin: change.origin
  4573. };
  4574. }
  4575. var last = doc$1.lastLine();
  4576. if (change.to.line > last) change = {
  4577. from: change.from,
  4578. to: Pos(last, getLine(doc$1, last).text.length),
  4579. text: [change.text[0]],
  4580. origin: change.origin
  4581. };
  4582. change.removed = getBetween(doc$1, change.from, change.to);
  4583. if (!selAfter) selAfter = computeSelAfterChange(doc$1, change);
  4584. if (doc$1.cm) makeChangeSingleDocInEditor(doc$1.cm, change, spans);
  4585. else updateDoc(doc$1, change, spans);
  4586. setSelectionNoUndo(doc$1, selAfter, sel_dontScroll);
  4587. if (doc$1.cantEdit && skipAtomic(doc$1, Pos(doc$1.firstLine(), 0))) doc$1.cantEdit = false;
  4588. }
  4589. function makeChangeSingleDocInEditor(cm, change, spans) {
  4590. var doc$1 = cm.doc, display = cm.display, from = change.from, to = change.to;
  4591. var recomputeMaxLength = false, checkWidthStart = from.line;
  4592. if (!cm.options.lineWrapping) {
  4593. checkWidthStart = lineNo(visualLine(getLine(doc$1, from.line)));
  4594. doc$1.iter(checkWidthStart, to.line + 1, function(line) {
  4595. if (line == display.maxLine) {
  4596. recomputeMaxLength = true;
  4597. return true;
  4598. }
  4599. });
  4600. }
  4601. if (doc$1.sel.contains(change.from, change.to) > -1) signalCursorActivity(cm);
  4602. updateDoc(doc$1, change, spans, estimateHeight(cm));
  4603. if (!cm.options.lineWrapping) {
  4604. doc$1.iter(checkWidthStart, from.line + change.text.length, function(line) {
  4605. var len = lineLength(line);
  4606. if (len > display.maxLineLength) {
  4607. display.maxLine = line;
  4608. display.maxLineLength = len;
  4609. display.maxLineChanged = true;
  4610. recomputeMaxLength = false;
  4611. }
  4612. });
  4613. if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
  4614. }
  4615. retreatFrontier(doc$1, from.line);
  4616. startWorker(cm, 400);
  4617. var lendiff = change.text.length - (to.line - from.line) - 1;
  4618. if (change.full) regChange(cm);
  4619. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) regLineChange(cm, from.line, "text");
  4620. else regChange(cm, from.line, to.line + 1, lendiff);
  4621. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
  4622. if (changeHandler || changesHandler) {
  4623. var obj = {
  4624. from,
  4625. to,
  4626. text: change.text,
  4627. removed: change.removed,
  4628. origin: change.origin
  4629. };
  4630. if (changeHandler) signalLater(cm, "change", cm, obj);
  4631. if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
  4632. }
  4633. cm.display.selForContextMenu = null;
  4634. }
  4635. function replaceRange(doc$1, code, from, to, origin) {
  4636. var assign;
  4637. if (!to) to = from;
  4638. if (cmp(to, from) < 0) assign = [to, from], from = assign[0], to = assign[1];
  4639. if (typeof code == "string") code = doc$1.splitLines(code);
  4640. makeChange(doc$1, {
  4641. from,
  4642. to,
  4643. text: code,
  4644. origin
  4645. });
  4646. }
  4647. function rebaseHistSelSingle(pos, from, to, diff) {
  4648. if (to < pos.line) pos.line += diff;
  4649. else if (from < pos.line) {
  4650. pos.line = from;
  4651. pos.ch = 0;
  4652. }
  4653. }
  4654. function rebaseHistArray(array, from, to, diff) {
  4655. for (var i$3 = 0; i$3 < array.length; ++i$3) {
  4656. var sub = array[i$3], ok = true;
  4657. if (sub.ranges) {
  4658. if (!sub.copied) {
  4659. sub = array[i$3] = sub.deepCopy();
  4660. sub.copied = true;
  4661. }
  4662. for (var j = 0; j < sub.ranges.length; j++) {
  4663. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  4664. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  4665. }
  4666. continue;
  4667. }
  4668. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  4669. var cur = sub.changes[j$1];
  4670. if (to < cur.from.line) {
  4671. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  4672. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  4673. } else if (from <= cur.to.line) {
  4674. ok = false;
  4675. break;
  4676. }
  4677. }
  4678. if (!ok) {
  4679. array.splice(0, i$3 + 1);
  4680. i$3 = 0;
  4681. }
  4682. }
  4683. }
  4684. function rebaseHist(hist, change) {
  4685. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
  4686. rebaseHistArray(hist.done, from, to, diff);
  4687. rebaseHistArray(hist.undone, from, to, diff);
  4688. }
  4689. function changeLine(doc$1, handle, changeType, op) {
  4690. var no = handle, line = handle;
  4691. if (typeof handle == "number") line = getLine(doc$1, clipLine(doc$1, handle));
  4692. else no = lineNo(handle);
  4693. if (no == null) return null;
  4694. if (op(line, no) && doc$1.cm) regLineChange(doc$1.cm, no, changeType);
  4695. return line;
  4696. }
  4697. function LeafChunk(lines) {
  4698. this.lines = lines;
  4699. this.parent = null;
  4700. var height = 0;
  4701. for (var i$3 = 0; i$3 < lines.length; ++i$3) {
  4702. lines[i$3].parent = this;
  4703. height += lines[i$3].height;
  4704. }
  4705. this.height = height;
  4706. }
  4707. LeafChunk.prototype = {
  4708. chunkSize: function() {
  4709. return this.lines.length;
  4710. },
  4711. removeInner: function(at, n) {
  4712. for (var i$3 = at, e = at + n; i$3 < e; ++i$3) {
  4713. var line = this.lines[i$3];
  4714. this.height -= line.height;
  4715. cleanUpLine(line);
  4716. signalLater(line, "delete");
  4717. }
  4718. this.lines.splice(at, n);
  4719. },
  4720. collapse: function(lines) {
  4721. lines.push.apply(lines, this.lines);
  4722. },
  4723. insertInner: function(at, lines, height) {
  4724. this.height += height;
  4725. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  4726. for (var i$3 = 0; i$3 < lines.length; ++i$3) lines[i$3].parent = this;
  4727. },
  4728. iterN: function(at, n, op) {
  4729. for (var e = at + n; at < e; ++at) if (op(this.lines[at])) return true;
  4730. }
  4731. };
  4732. function BranchChunk(children) {
  4733. this.children = children;
  4734. var size = 0, height = 0;
  4735. for (var i$3 = 0; i$3 < children.length; ++i$3) {
  4736. var ch = children[i$3];
  4737. size += ch.chunkSize();
  4738. height += ch.height;
  4739. ch.parent = this;
  4740. }
  4741. this.size = size;
  4742. this.height = height;
  4743. this.parent = null;
  4744. }
  4745. BranchChunk.prototype = {
  4746. chunkSize: function() {
  4747. return this.size;
  4748. },
  4749. removeInner: function(at, n) {
  4750. this.size -= n;
  4751. for (var i$3 = 0; i$3 < this.children.length; ++i$3) {
  4752. var child = this.children[i$3], sz = child.chunkSize();
  4753. if (at < sz) {
  4754. var rm = Math.min(n, sz - at), oldHeight = child.height;
  4755. child.removeInner(at, rm);
  4756. this.height -= oldHeight - child.height;
  4757. if (sz == rm) {
  4758. this.children.splice(i$3--, 1);
  4759. child.parent = null;
  4760. }
  4761. if ((n -= rm) == 0) break;
  4762. at = 0;
  4763. } else at -= sz;
  4764. }
  4765. if (this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  4766. var lines = [];
  4767. this.collapse(lines);
  4768. this.children = [new LeafChunk(lines)];
  4769. this.children[0].parent = this;
  4770. }
  4771. },
  4772. collapse: function(lines) {
  4773. for (var i$3 = 0; i$3 < this.children.length; ++i$3) this.children[i$3].collapse(lines);
  4774. },
  4775. insertInner: function(at, lines, height) {
  4776. this.size += lines.length;
  4777. this.height += height;
  4778. for (var i$3 = 0; i$3 < this.children.length; ++i$3) {
  4779. var child = this.children[i$3], sz = child.chunkSize();
  4780. if (at <= sz) {
  4781. child.insertInner(at, lines, height);
  4782. if (child.lines && child.lines.length > 50) {
  4783. var remaining = child.lines.length % 25 + 25;
  4784. for (var pos = remaining; pos < child.lines.length;) {
  4785. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  4786. child.height -= leaf.height;
  4787. this.children.splice(++i$3, 0, leaf);
  4788. leaf.parent = this;
  4789. }
  4790. child.lines = child.lines.slice(0, remaining);
  4791. this.maybeSpill();
  4792. }
  4793. break;
  4794. }
  4795. at -= sz;
  4796. }
  4797. },
  4798. maybeSpill: function() {
  4799. if (this.children.length <= 10) return;
  4800. var me = this;
  4801. do {
  4802. var spilled = me.children.splice(me.children.length - 5, 5);
  4803. var sibling = new BranchChunk(spilled);
  4804. if (!me.parent) {
  4805. var copy = new BranchChunk(me.children);
  4806. copy.parent = me;
  4807. me.children = [copy, sibling];
  4808. me = copy;
  4809. } else {
  4810. me.size -= sibling.size;
  4811. me.height -= sibling.height;
  4812. var myIndex = indexOf(me.parent.children, me);
  4813. me.parent.children.splice(myIndex + 1, 0, sibling);
  4814. }
  4815. sibling.parent = me.parent;
  4816. } while (me.children.length > 10);
  4817. me.parent.maybeSpill();
  4818. },
  4819. iterN: function(at, n, op) {
  4820. for (var i$3 = 0; i$3 < this.children.length; ++i$3) {
  4821. var child = this.children[i$3], sz = child.chunkSize();
  4822. if (at < sz) {
  4823. var used = Math.min(n, sz - at);
  4824. if (child.iterN(at, used, op)) return true;
  4825. if ((n -= used) == 0) break;
  4826. at = 0;
  4827. } else at -= sz;
  4828. }
  4829. }
  4830. };
  4831. var LineWidget = function(doc$1, node, options) {
  4832. if (options) {
  4833. for (var opt in options) if (options.hasOwnProperty(opt)) this[opt] = options[opt];
  4834. }
  4835. this.doc = doc$1;
  4836. this.node = node;
  4837. };
  4838. LineWidget.prototype.clear = function() {
  4839. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
  4840. if (no == null || !ws) return;
  4841. for (var i$3 = 0; i$3 < ws.length; ++i$3) if (ws[i$3] == this) ws.splice(i$3--, 1);
  4842. if (!ws.length) line.widgets = null;
  4843. var height = widgetHeight(this);
  4844. updateLineHeight(line, Math.max(0, line.height - height));
  4845. if (cm) {
  4846. runInOp(cm, function() {
  4847. adjustScrollWhenAboveVisible(cm, line, -height);
  4848. regLineChange(cm, no, "widget");
  4849. });
  4850. signalLater(cm, "lineWidgetCleared", cm, this, no);
  4851. }
  4852. };
  4853. LineWidget.prototype.changed = function() {
  4854. var this$1 = this;
  4855. var oldH = this.height, cm = this.doc.cm, line = this.line;
  4856. this.height = null;
  4857. var diff = widgetHeight(this) - oldH;
  4858. if (!diff) return;
  4859. if (!lineIsHidden(this.doc, line)) updateLineHeight(line, line.height + diff);
  4860. if (cm) runInOp(cm, function() {
  4861. cm.curOp.forceUpdate = true;
  4862. adjustScrollWhenAboveVisible(cm, line, diff);
  4863. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  4864. });
  4865. };
  4866. eventMixin(LineWidget);
  4867. function adjustScrollWhenAboveVisible(cm, line, diff) {
  4868. if (heightAtLine(line) < (cm.curOp && cm.curOp.scrollTop || cm.doc.scrollTop)) addToScrollTop(cm, diff);
  4869. }
  4870. function addLineWidget(doc$1, handle, node, options) {
  4871. var widget = new LineWidget(doc$1, node, options);
  4872. var cm = doc$1.cm;
  4873. if (cm && widget.noHScroll) cm.display.alignWidgets = true;
  4874. changeLine(doc$1, handle, "widget", function(line) {
  4875. var widgets = line.widgets || (line.widgets = []);
  4876. if (widget.insertAt == null) widgets.push(widget);
  4877. else widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget);
  4878. widget.line = line;
  4879. if (cm && !lineIsHidden(doc$1, line)) {
  4880. var aboveVisible = heightAtLine(line) < doc$1.scrollTop;
  4881. updateLineHeight(line, line.height + widgetHeight(widget));
  4882. if (aboveVisible) addToScrollTop(cm, widget.height);
  4883. cm.curOp.forceUpdate = true;
  4884. }
  4885. return true;
  4886. });
  4887. if (cm) signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle));
  4888. return widget;
  4889. }
  4890. var nextMarkerId = 0;
  4891. var TextMarker = function(doc$1, type) {
  4892. this.lines = [];
  4893. this.type = type;
  4894. this.doc = doc$1;
  4895. this.id = ++nextMarkerId;
  4896. };
  4897. TextMarker.prototype.clear = function() {
  4898. if (this.explicitlyCleared) return;
  4899. var cm = this.doc.cm, withOp = cm && !cm.curOp;
  4900. if (withOp) startOperation(cm);
  4901. if (hasHandler(this, "clear")) {
  4902. var found = this.find();
  4903. if (found) signalLater(this, "clear", found.from, found.to);
  4904. }
  4905. var min = null, max = null;
  4906. for (var i$3 = 0; i$3 < this.lines.length; ++i$3) {
  4907. var line = this.lines[i$3];
  4908. var span = getMarkedSpanFor(line.markedSpans, this);
  4909. if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
  4910. else if (cm) {
  4911. if (span.to != null) max = lineNo(line);
  4912. if (span.from != null) min = lineNo(line);
  4913. }
  4914. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  4915. if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) updateLineHeight(line, textHeight(cm.display));
  4916. }
  4917. if (cm && this.collapsed && !cm.options.lineWrapping) for (var i$1$1 = 0; i$1$1 < this.lines.length; ++i$1$1) {
  4918. var visual = visualLine(this.lines[i$1$1]), len = lineLength(visual);
  4919. if (len > cm.display.maxLineLength) {
  4920. cm.display.maxLine = visual;
  4921. cm.display.maxLineLength = len;
  4922. cm.display.maxLineChanged = true;
  4923. }
  4924. }
  4925. if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
  4926. this.lines.length = 0;
  4927. this.explicitlyCleared = true;
  4928. if (this.atomic && this.doc.cantEdit) {
  4929. this.doc.cantEdit = false;
  4930. if (cm) reCheckSelection(cm.doc);
  4931. }
  4932. if (cm) signalLater(cm, "markerCleared", cm, this, min, max);
  4933. if (withOp) endOperation(cm);
  4934. if (this.parent) this.parent.clear();
  4935. };
  4936. TextMarker.prototype.find = function(side, lineObj) {
  4937. if (side == null && this.type == "bookmark") side = 1;
  4938. var from, to;
  4939. for (var i$3 = 0; i$3 < this.lines.length; ++i$3) {
  4940. var line = this.lines[i$3];
  4941. var span = getMarkedSpanFor(line.markedSpans, this);
  4942. if (span.from != null) {
  4943. from = Pos(lineObj ? line : lineNo(line), span.from);
  4944. if (side == -1) return from;
  4945. }
  4946. if (span.to != null) {
  4947. to = Pos(lineObj ? line : lineNo(line), span.to);
  4948. if (side == 1) return to;
  4949. }
  4950. }
  4951. return from && {
  4952. from,
  4953. to
  4954. };
  4955. };
  4956. TextMarker.prototype.changed = function() {
  4957. var this$1 = this;
  4958. var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
  4959. if (!pos || !cm) return;
  4960. runInOp(cm, function() {
  4961. var line = pos.line, lineN = lineNo(pos.line);
  4962. var view = findViewForLine(cm, lineN);
  4963. if (view) {
  4964. clearLineMeasurementCacheFor(view);
  4965. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  4966. }
  4967. cm.curOp.updateMaxLine = true;
  4968. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  4969. var oldHeight = widget.height;
  4970. widget.height = null;
  4971. var dHeight = widgetHeight(widget) - oldHeight;
  4972. if (dHeight) updateLineHeight(line, line.height + dHeight);
  4973. }
  4974. signalLater(cm, "markerChanged", cm, this$1);
  4975. });
  4976. };
  4977. TextMarker.prototype.attachLine = function(line) {
  4978. if (!this.lines.length && this.doc.cm) {
  4979. var op = this.doc.cm.curOp;
  4980. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
  4981. }
  4982. this.lines.push(line);
  4983. };
  4984. TextMarker.prototype.detachLine = function(line) {
  4985. this.lines.splice(indexOf(this.lines, line), 1);
  4986. if (!this.lines.length && this.doc.cm) {
  4987. var op = this.doc.cm.curOp;
  4988. (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  4989. }
  4990. };
  4991. eventMixin(TextMarker);
  4992. function markText(doc$1, from, to, options, type) {
  4993. if (options && options.shared) return markTextShared(doc$1, from, to, options, type);
  4994. if (doc$1.cm && !doc$1.cm.curOp) return operation(doc$1.cm, markText)(doc$1, from, to, options, type);
  4995. var marker = new TextMarker(doc$1, type), diff = cmp(from, to);
  4996. if (options) copyObj(options, marker, false);
  4997. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) return marker;
  4998. if (marker.replacedWith) {
  4999. marker.collapsed = true;
  5000. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  5001. if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
  5002. if (options.insertLeft) marker.widgetNode.insertLeft = true;
  5003. }
  5004. if (marker.collapsed) {
  5005. if (conflictingCollapsedRange(doc$1, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc$1, to.line, from, to, marker)) throw new Error("Inserting collapsed marker partially overlapping an existing one");
  5006. seeCollapsedSpans();
  5007. }
  5008. if (marker.addToHistory) addChangeToHistory(doc$1, {
  5009. from,
  5010. to,
  5011. origin: "markText"
  5012. }, doc$1.sel, NaN);
  5013. var curLine = from.line, cm = doc$1.cm, updateMaxLine;
  5014. doc$1.iter(curLine, to.line + 1, function(line) {
  5015. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) updateMaxLine = true;
  5016. if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
  5017. addMarkedSpan(line, new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null), doc$1.cm && doc$1.cm.curOp);
  5018. ++curLine;
  5019. });
  5020. if (marker.collapsed) doc$1.iter(from.line, to.line + 1, function(line) {
  5021. if (lineIsHidden(doc$1, line)) updateLineHeight(line, 0);
  5022. });
  5023. if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() {
  5024. return marker.clear();
  5025. });
  5026. if (marker.readOnly) {
  5027. seeReadOnlySpans();
  5028. if (doc$1.history.done.length || doc$1.history.undone.length) doc$1.clearHistory();
  5029. }
  5030. if (marker.collapsed) {
  5031. marker.id = ++nextMarkerId;
  5032. marker.atomic = true;
  5033. }
  5034. if (cm) {
  5035. if (updateMaxLine) cm.curOp.updateMaxLine = true;
  5036. if (marker.collapsed) regChange(cm, from.line, to.line + 1);
  5037. else if (marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title) for (var i$3 = from.line; i$3 <= to.line; i$3++) regLineChange(cm, i$3, "text");
  5038. if (marker.atomic) reCheckSelection(cm.doc);
  5039. signalLater(cm, "markerAdded", cm, marker);
  5040. }
  5041. return marker;
  5042. }
  5043. var SharedTextMarker = function(markers, primary) {
  5044. this.markers = markers;
  5045. this.primary = primary;
  5046. for (var i$3 = 0; i$3 < markers.length; ++i$3) markers[i$3].parent = this;
  5047. };
  5048. SharedTextMarker.prototype.clear = function() {
  5049. if (this.explicitlyCleared) return;
  5050. this.explicitlyCleared = true;
  5051. for (var i$3 = 0; i$3 < this.markers.length; ++i$3) this.markers[i$3].clear();
  5052. signalLater(this, "clear");
  5053. };
  5054. SharedTextMarker.prototype.find = function(side, lineObj) {
  5055. return this.primary.find(side, lineObj);
  5056. };
  5057. eventMixin(SharedTextMarker);
  5058. function markTextShared(doc$1, from, to, options, type) {
  5059. options = copyObj(options);
  5060. options.shared = false;
  5061. var markers = [markText(doc$1, from, to, options, type)], primary = markers[0];
  5062. var widget = options.widgetNode;
  5063. linkedDocs(doc$1, function(doc$2) {
  5064. if (widget) options.widgetNode = widget.cloneNode(true);
  5065. markers.push(markText(doc$2, clipPos(doc$2, from), clipPos(doc$2, to), options, type));
  5066. for (var i$3 = 0; i$3 < doc$2.linked.length; ++i$3) if (doc$2.linked[i$3].isParent) return;
  5067. primary = lst(markers);
  5068. });
  5069. return new SharedTextMarker(markers, primary);
  5070. }
  5071. function findSharedMarkers(doc$1) {
  5072. return doc$1.findMarks(Pos(doc$1.first, 0), doc$1.clipPos(Pos(doc$1.lastLine())), function(m) {
  5073. return m.parent;
  5074. });
  5075. }
  5076. function copySharedMarkers(doc$1, markers) {
  5077. for (var i$3 = 0; i$3 < markers.length; i$3++) {
  5078. var marker = markers[i$3], pos = marker.find();
  5079. var mFrom = doc$1.clipPos(pos.from), mTo = doc$1.clipPos(pos.to);
  5080. if (cmp(mFrom, mTo)) {
  5081. var subMark = markText(doc$1, mFrom, mTo, marker.primary, marker.primary.type);
  5082. marker.markers.push(subMark);
  5083. subMark.parent = marker;
  5084. }
  5085. }
  5086. }
  5087. function detachSharedMarkers(markers) {
  5088. var loop = function(i$4) {
  5089. var marker = markers[i$4], linked = [marker.primary.doc];
  5090. linkedDocs(marker.primary.doc, function(d) {
  5091. return linked.push(d);
  5092. });
  5093. for (var j = 0; j < marker.markers.length; j++) {
  5094. var subMarker = marker.markers[j];
  5095. if (indexOf(linked, subMarker.doc) == -1) {
  5096. subMarker.parent = null;
  5097. marker.markers.splice(j--, 1);
  5098. }
  5099. }
  5100. };
  5101. for (var i$3 = 0; i$3 < markers.length; i$3++) loop(i$3);
  5102. }
  5103. var nextDocId = 0;
  5104. var Doc = function(text, mode, firstLine, lineSep, direction) {
  5105. if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep, direction);
  5106. if (firstLine == null) firstLine = 0;
  5107. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  5108. this.first = firstLine;
  5109. this.scrollTop = this.scrollLeft = 0;
  5110. this.cantEdit = false;
  5111. this.cleanGeneration = 1;
  5112. this.modeFrontier = this.highlightFrontier = firstLine;
  5113. var start = Pos(firstLine, 0);
  5114. this.sel = simpleSelection(start);
  5115. this.history = new History(null);
  5116. this.id = ++nextDocId;
  5117. this.modeOption = mode;
  5118. this.lineSep = lineSep;
  5119. this.direction = direction == "rtl" ? "rtl" : "ltr";
  5120. this.extend = false;
  5121. if (typeof text == "string") text = this.splitLines(text);
  5122. updateDoc(this, {
  5123. from: start,
  5124. to: start,
  5125. text
  5126. });
  5127. setSelection(this, simpleSelection(start), sel_dontScroll);
  5128. };
  5129. Doc.prototype = createObj(BranchChunk.prototype, {
  5130. constructor: Doc,
  5131. iter: function(from, to, op) {
  5132. if (op) this.iterN(from - this.first, to - from, op);
  5133. else this.iterN(this.first, this.first + this.size, from);
  5134. },
  5135. insert: function(at, lines) {
  5136. var height = 0;
  5137. for (var i$3 = 0; i$3 < lines.length; ++i$3) height += lines[i$3].height;
  5138. this.insertInner(at - this.first, lines, height);
  5139. },
  5140. remove: function(at, n) {
  5141. this.removeInner(at - this.first, n);
  5142. },
  5143. getValue: function(lineSep) {
  5144. var lines = getLines(this, this.first, this.first + this.size);
  5145. if (lineSep === false) return lines;
  5146. return lines.join(lineSep || this.lineSeparator());
  5147. },
  5148. setValue: docMethodOp(function(code) {
  5149. var top = Pos(this.first, 0), last = this.first + this.size - 1;
  5150. makeChange(this, {
  5151. from: top,
  5152. to: Pos(last, getLine(this, last).text.length),
  5153. text: this.splitLines(code),
  5154. origin: "setValue",
  5155. full: true
  5156. }, true);
  5157. if (this.cm) scrollToCoords(this.cm, 0, 0);
  5158. setSelection(this, simpleSelection(top), sel_dontScroll);
  5159. }),
  5160. replaceRange: function(code, from, to, origin) {
  5161. from = clipPos(this, from);
  5162. to = to ? clipPos(this, to) : from;
  5163. replaceRange(this, code, from, to, origin);
  5164. },
  5165. getRange: function(from, to, lineSep) {
  5166. var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
  5167. if (lineSep === false) return lines;
  5168. if (lineSep === "") return lines.join("");
  5169. return lines.join(lineSep || this.lineSeparator());
  5170. },
  5171. getLine: function(line) {
  5172. var l = this.getLineHandle(line);
  5173. return l && l.text;
  5174. },
  5175. getLineHandle: function(line) {
  5176. if (isLine(this, line)) return getLine(this, line);
  5177. },
  5178. getLineNumber: function(line) {
  5179. return lineNo(line);
  5180. },
  5181. getLineHandleVisualStart: function(line) {
  5182. if (typeof line == "number") line = getLine(this, line);
  5183. return visualLine(line);
  5184. },
  5185. lineCount: function() {
  5186. return this.size;
  5187. },
  5188. firstLine: function() {
  5189. return this.first;
  5190. },
  5191. lastLine: function() {
  5192. return this.first + this.size - 1;
  5193. },
  5194. clipPos: function(pos) {
  5195. return clipPos(this, pos);
  5196. },
  5197. getCursor: function(start) {
  5198. var range$1 = this.sel.primary(), pos;
  5199. if (start == null || start == "head") pos = range$1.head;
  5200. else if (start == "anchor") pos = range$1.anchor;
  5201. else if (start == "end" || start == "to" || start === false) pos = range$1.to();
  5202. else pos = range$1.from();
  5203. return pos;
  5204. },
  5205. listSelections: function() {
  5206. return this.sel.ranges;
  5207. },
  5208. somethingSelected: function() {
  5209. return this.sel.somethingSelected();
  5210. },
  5211. setCursor: docMethodOp(function(line, ch, options) {
  5212. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  5213. }),
  5214. setSelection: docMethodOp(function(anchor, head, options) {
  5215. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
  5216. }),
  5217. extendSelection: docMethodOp(function(head, other, options) {
  5218. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
  5219. }),
  5220. extendSelections: docMethodOp(function(heads, options) {
  5221. extendSelections(this, clipPosArray(this, heads), options);
  5222. }),
  5223. extendSelectionsBy: docMethodOp(function(f, options) {
  5224. var heads = map(this.sel.ranges, f);
  5225. extendSelections(this, clipPosArray(this, heads), options);
  5226. }),
  5227. setSelections: docMethodOp(function(ranges, primary, options) {
  5228. if (!ranges.length) return;
  5229. var out = [];
  5230. for (var i$3 = 0; i$3 < ranges.length; i$3++) out[i$3] = new Range(clipPos(this, ranges[i$3].anchor), clipPos(this, ranges[i$3].head || ranges[i$3].anchor));
  5231. if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
  5232. setSelection(this, normalizeSelection(this.cm, out, primary), options);
  5233. }),
  5234. addSelection: docMethodOp(function(anchor, head, options) {
  5235. var ranges = this.sel.ranges.slice(0);
  5236. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
  5237. setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);
  5238. }),
  5239. getSelection: function(lineSep) {
  5240. var ranges = this.sel.ranges, lines;
  5241. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  5242. var sel = getBetween(this, ranges[i$3].from(), ranges[i$3].to());
  5243. lines = lines ? lines.concat(sel) : sel;
  5244. }
  5245. if (lineSep === false) return lines;
  5246. else return lines.join(lineSep || this.lineSeparator());
  5247. },
  5248. getSelections: function(lineSep) {
  5249. var parts = [], ranges = this.sel.ranges;
  5250. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  5251. var sel = getBetween(this, ranges[i$3].from(), ranges[i$3].to());
  5252. if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
  5253. parts[i$3] = sel;
  5254. }
  5255. return parts;
  5256. },
  5257. replaceSelection: function(code, collapse, origin) {
  5258. var dup = [];
  5259. for (var i$3 = 0; i$3 < this.sel.ranges.length; i$3++) dup[i$3] = code;
  5260. this.replaceSelections(dup, collapse, origin || "+input");
  5261. },
  5262. replaceSelections: docMethodOp(function(code, collapse, origin) {
  5263. var changes = [], sel = this.sel;
  5264. for (var i$3 = 0; i$3 < sel.ranges.length; i$3++) {
  5265. var range$1 = sel.ranges[i$3];
  5266. changes[i$3] = {
  5267. from: range$1.from(),
  5268. to: range$1.to(),
  5269. text: this.splitLines(code[i$3]),
  5270. origin
  5271. };
  5272. }
  5273. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  5274. for (var i$1$1 = changes.length - 1; i$1$1 >= 0; i$1$1--) makeChange(this, changes[i$1$1]);
  5275. if (newSel) setSelectionReplaceHistory(this, newSel);
  5276. else if (this.cm) ensureCursorVisible(this.cm);
  5277. }),
  5278. undo: docMethodOp(function() {
  5279. makeChangeFromHistory(this, "undo");
  5280. }),
  5281. redo: docMethodOp(function() {
  5282. makeChangeFromHistory(this, "redo");
  5283. }),
  5284. undoSelection: docMethodOp(function() {
  5285. makeChangeFromHistory(this, "undo", true);
  5286. }),
  5287. redoSelection: docMethodOp(function() {
  5288. makeChangeFromHistory(this, "redo", true);
  5289. }),
  5290. setExtending: function(val) {
  5291. this.extend = val;
  5292. },
  5293. getExtending: function() {
  5294. return this.extend;
  5295. },
  5296. historySize: function() {
  5297. var hist = this.history, done = 0, undone = 0;
  5298. for (var i$3 = 0; i$3 < hist.done.length; i$3++) if (!hist.done[i$3].ranges) ++done;
  5299. for (var i$1$1 = 0; i$1$1 < hist.undone.length; i$1$1++) if (!hist.undone[i$1$1].ranges) ++undone;
  5300. return {
  5301. undo: done,
  5302. redo: undone
  5303. };
  5304. },
  5305. clearHistory: function() {
  5306. var this$1 = this;
  5307. this.history = new History(this.history);
  5308. linkedDocs(this, function(doc$1) {
  5309. return doc$1.history = this$1.history;
  5310. }, true);
  5311. },
  5312. markClean: function() {
  5313. this.cleanGeneration = this.changeGeneration(true);
  5314. },
  5315. changeGeneration: function(forceSplit) {
  5316. if (forceSplit) this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
  5317. return this.history.generation;
  5318. },
  5319. isClean: function(gen) {
  5320. return this.history.generation == (gen || this.cleanGeneration);
  5321. },
  5322. getHistory: function() {
  5323. return {
  5324. done: copyHistoryArray(this.history.done),
  5325. undone: copyHistoryArray(this.history.undone)
  5326. };
  5327. },
  5328. setHistory: function(histData) {
  5329. var hist = this.history = new History(this.history);
  5330. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  5331. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  5332. },
  5333. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  5334. return changeLine(this, line, "gutter", function(line$1) {
  5335. var markers = line$1.gutterMarkers || (line$1.gutterMarkers = {});
  5336. markers[gutterID] = value;
  5337. if (!value && isEmpty(markers)) line$1.gutterMarkers = null;
  5338. return true;
  5339. });
  5340. }),
  5341. clearGutter: docMethodOp(function(gutterID) {
  5342. var this$1 = this;
  5343. this.iter(function(line) {
  5344. if (line.gutterMarkers && line.gutterMarkers[gutterID]) changeLine(this$1, line, "gutter", function() {
  5345. line.gutterMarkers[gutterID] = null;
  5346. if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
  5347. return true;
  5348. });
  5349. });
  5350. }),
  5351. lineInfo: function(line) {
  5352. var n;
  5353. if (typeof line == "number") {
  5354. if (!isLine(this, line)) return null;
  5355. n = line;
  5356. line = getLine(this, line);
  5357. if (!line) return null;
  5358. } else {
  5359. n = lineNo(line);
  5360. if (n == null) return null;
  5361. }
  5362. return {
  5363. line: n,
  5364. handle: line,
  5365. text: line.text,
  5366. gutterMarkers: line.gutterMarkers,
  5367. textClass: line.textClass,
  5368. bgClass: line.bgClass,
  5369. wrapClass: line.wrapClass,
  5370. widgets: line.widgets
  5371. };
  5372. },
  5373. addLineClass: docMethodOp(function(handle, where, cls) {
  5374. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
  5375. var prop$1 = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass";
  5376. if (!line[prop$1]) line[prop$1] = cls;
  5377. else if (classTest(cls).test(line[prop$1])) return false;
  5378. else line[prop$1] += " " + cls;
  5379. return true;
  5380. });
  5381. }),
  5382. removeLineClass: docMethodOp(function(handle, where, cls) {
  5383. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
  5384. var prop$1 = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass";
  5385. var cur = line[prop$1];
  5386. if (!cur) return false;
  5387. else if (cls == null) line[prop$1] = null;
  5388. else {
  5389. var found = cur.match(classTest(cls));
  5390. if (!found) return false;
  5391. var end = found.index + found[0].length;
  5392. line[prop$1] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  5393. }
  5394. return true;
  5395. });
  5396. }),
  5397. addLineWidget: docMethodOp(function(handle, node, options) {
  5398. return addLineWidget(this, handle, node, options);
  5399. }),
  5400. removeLineWidget: function(widget) {
  5401. widget.clear();
  5402. },
  5403. markText: function(from, to, options) {
  5404. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
  5405. },
  5406. setBookmark: function(pos, options) {
  5407. var realOpts = {
  5408. replacedWith: options && (options.nodeType == null ? options.widget : options),
  5409. insertLeft: options && options.insertLeft,
  5410. clearWhenEmpty: false,
  5411. shared: options && options.shared,
  5412. handleMouseEvents: options && options.handleMouseEvents
  5413. };
  5414. pos = clipPos(this, pos);
  5415. return markText(this, pos, pos, realOpts, "bookmark");
  5416. },
  5417. findMarksAt: function(pos) {
  5418. pos = clipPos(this, pos);
  5419. var markers = [], spans = getLine(this, pos.line).markedSpans;
  5420. if (spans) for (var i$3 = 0; i$3 < spans.length; ++i$3) {
  5421. var span = spans[i$3];
  5422. if ((span.from == null || span.from <= pos.ch) && (span.to == null || span.to >= pos.ch)) markers.push(span.marker.parent || span.marker);
  5423. }
  5424. return markers;
  5425. },
  5426. findMarks: function(from, to, filter) {
  5427. from = clipPos(this, from);
  5428. to = clipPos(this, to);
  5429. var found = [], lineNo$1 = from.line;
  5430. this.iter(from.line, to.line + 1, function(line) {
  5431. var spans = line.markedSpans;
  5432. if (spans) for (var i$3 = 0; i$3 < spans.length; i$3++) {
  5433. var span = spans[i$3];
  5434. if (!(span.to != null && lineNo$1 == from.line && from.ch >= span.to || span.from == null && lineNo$1 != from.line || span.from != null && lineNo$1 == to.line && span.from >= to.ch) && (!filter || filter(span.marker))) found.push(span.marker.parent || span.marker);
  5435. }
  5436. ++lineNo$1;
  5437. });
  5438. return found;
  5439. },
  5440. getAllMarks: function() {
  5441. var markers = [];
  5442. this.iter(function(line) {
  5443. var sps = line.markedSpans;
  5444. if (sps) {
  5445. for (var i$3 = 0; i$3 < sps.length; ++i$3) if (sps[i$3].from != null) markers.push(sps[i$3].marker);
  5446. }
  5447. });
  5448. return markers;
  5449. },
  5450. posFromIndex: function(off$1) {
  5451. var ch, lineNo$1 = this.first, sepSize = this.lineSeparator().length;
  5452. this.iter(function(line) {
  5453. var sz = line.text.length + sepSize;
  5454. if (sz > off$1) {
  5455. ch = off$1;
  5456. return true;
  5457. }
  5458. off$1 -= sz;
  5459. ++lineNo$1;
  5460. });
  5461. return clipPos(this, Pos(lineNo$1, ch));
  5462. },
  5463. indexFromPos: function(coords) {
  5464. coords = clipPos(this, coords);
  5465. var index = coords.ch;
  5466. if (coords.line < this.first || coords.ch < 0) return 0;
  5467. var sepSize = this.lineSeparator().length;
  5468. this.iter(this.first, coords.line, function(line) {
  5469. index += line.text.length + sepSize;
  5470. });
  5471. return index;
  5472. },
  5473. copy: function(copyHistory) {
  5474. var doc$1 = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction);
  5475. doc$1.scrollTop = this.scrollTop;
  5476. doc$1.scrollLeft = this.scrollLeft;
  5477. doc$1.sel = this.sel;
  5478. doc$1.extend = false;
  5479. if (copyHistory) {
  5480. doc$1.history.undoDepth = this.history.undoDepth;
  5481. doc$1.setHistory(this.getHistory());
  5482. }
  5483. return doc$1;
  5484. },
  5485. linkedDoc: function(options) {
  5486. if (!options) options = {};
  5487. var from = this.first, to = this.first + this.size;
  5488. if (options.from != null && options.from > from) from = options.from;
  5489. if (options.to != null && options.to < to) to = options.to;
  5490. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  5491. if (options.sharedHist) copy.history = this.history;
  5492. (this.linked || (this.linked = [])).push({
  5493. doc: copy,
  5494. sharedHist: options.sharedHist
  5495. });
  5496. copy.linked = [{
  5497. doc: this,
  5498. isParent: true,
  5499. sharedHist: options.sharedHist
  5500. }];
  5501. copySharedMarkers(copy, findSharedMarkers(this));
  5502. return copy;
  5503. },
  5504. unlinkDoc: function(other) {
  5505. if (other instanceof CodeMirror$1) other = other.doc;
  5506. if (this.linked) for (var i$3 = 0; i$3 < this.linked.length; ++i$3) {
  5507. var link = this.linked[i$3];
  5508. if (link.doc != other) continue;
  5509. this.linked.splice(i$3, 1);
  5510. other.unlinkDoc(this);
  5511. detachSharedMarkers(findSharedMarkers(this));
  5512. break;
  5513. }
  5514. if (other.history == this.history) {
  5515. var splitIds = [other.id];
  5516. linkedDocs(other, function(doc$1) {
  5517. return splitIds.push(doc$1.id);
  5518. }, true);
  5519. other.history = new History(null);
  5520. other.history.done = copyHistoryArray(this.history.done, splitIds);
  5521. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  5522. }
  5523. },
  5524. iterLinkedDocs: function(f) {
  5525. linkedDocs(this, f);
  5526. },
  5527. getMode: function() {
  5528. return this.mode;
  5529. },
  5530. getEditor: function() {
  5531. return this.cm;
  5532. },
  5533. splitLines: function(str) {
  5534. if (this.lineSep) return str.split(this.lineSep);
  5535. return splitLinesAuto(str);
  5536. },
  5537. lineSeparator: function() {
  5538. return this.lineSep || "\n";
  5539. },
  5540. setDirection: docMethodOp(function(dir) {
  5541. if (dir != "rtl") dir = "ltr";
  5542. if (dir == this.direction) return;
  5543. this.direction = dir;
  5544. this.iter(function(line) {
  5545. return line.order = null;
  5546. });
  5547. if (this.cm) directionChanged(this.cm);
  5548. })
  5549. });
  5550. Doc.prototype.eachLine = Doc.prototype.iter;
  5551. var lastDrop = 0;
  5552. function onDrop(e) {
  5553. var cm = this;
  5554. clearDragCursor(cm);
  5555. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
  5556. e_preventDefault(e);
  5557. if (ie) lastDrop = +new Date();
  5558. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
  5559. if (!pos || cm.isReadOnly()) return;
  5560. if (files && files.length && window.FileReader && window.File) {
  5561. var n = files.length, text = Array(n), read = 0;
  5562. var markAsReadAndPasteIfAllFilesAreRead = function() {
  5563. if (++read == n) operation(cm, function() {
  5564. pos = clipPos(cm.doc, pos);
  5565. var change = {
  5566. from: pos,
  5567. to: pos,
  5568. text: cm.doc.splitLines(text.filter(function(t) {
  5569. return t != null;
  5570. }).join(cm.doc.lineSeparator())),
  5571. origin: "paste"
  5572. };
  5573. makeChange(cm.doc, change);
  5574. setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change))));
  5575. })();
  5576. };
  5577. var readTextFromFile = function(file, i$4) {
  5578. if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
  5579. markAsReadAndPasteIfAllFilesAreRead();
  5580. return;
  5581. }
  5582. var reader = new FileReader();
  5583. reader.onerror = function() {
  5584. return markAsReadAndPasteIfAllFilesAreRead();
  5585. };
  5586. reader.onload = function() {
  5587. var content = reader.result;
  5588. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
  5589. markAsReadAndPasteIfAllFilesAreRead();
  5590. return;
  5591. }
  5592. text[i$4] = content;
  5593. markAsReadAndPasteIfAllFilesAreRead();
  5594. };
  5595. reader.readAsText(file);
  5596. };
  5597. for (var i$3 = 0; i$3 < files.length; i$3++) readTextFromFile(files[i$3], i$3);
  5598. } else {
  5599. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  5600. cm.state.draggingText(e);
  5601. setTimeout(function() {
  5602. return cm.display.input.focus();
  5603. }, 20);
  5604. return;
  5605. }
  5606. try {
  5607. var text$1 = e.dataTransfer.getData("Text");
  5608. if (text$1) {
  5609. var selected;
  5610. if (cm.state.draggingText && !cm.state.draggingText.copy) selected = cm.listSelections();
  5611. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  5612. if (selected) for (var i$1$1 = 0; i$1$1 < selected.length; ++i$1$1) replaceRange(cm.doc, "", selected[i$1$1].anchor, selected[i$1$1].head, "drag");
  5613. cm.replaceSelection(text$1, "around", "paste");
  5614. cm.display.input.focus();
  5615. }
  5616. } catch (e$1) {}
  5617. }
  5618. }
  5619. function onDragStart(cm, e) {
  5620. if (ie && (!cm.state.draggingText || +new Date() - lastDrop < 100)) {
  5621. e_stop(e);
  5622. return;
  5623. }
  5624. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
  5625. e.dataTransfer.setData("Text", cm.getSelection());
  5626. e.dataTransfer.effectAllowed = "copyMove";
  5627. if (e.dataTransfer.setDragImage && !safari) {
  5628. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  5629. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  5630. if (presto) {
  5631. img.width = img.height = 1;
  5632. cm.display.wrapper.appendChild(img);
  5633. img._top = img.offsetTop;
  5634. }
  5635. e.dataTransfer.setDragImage(img, 0, 0);
  5636. if (presto) img.parentNode.removeChild(img);
  5637. }
  5638. }
  5639. function onDragOver(cm, e) {
  5640. var pos = posFromMouse(cm, e);
  5641. if (!pos) return;
  5642. var frag = document.createDocumentFragment();
  5643. drawSelectionCursor(cm, pos, frag);
  5644. if (!cm.display.dragCursor) {
  5645. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  5646. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  5647. }
  5648. removeChildrenAndAdd(cm.display.dragCursor, frag);
  5649. }
  5650. function clearDragCursor(cm) {
  5651. if (cm.display.dragCursor) {
  5652. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  5653. cm.display.dragCursor = null;
  5654. }
  5655. }
  5656. function forEachCodeMirror(f) {
  5657. if (!document.getElementsByClassName) return;
  5658. var byClass = document.getElementsByClassName("CodeMirror"), editors = [];
  5659. for (var i$3 = 0; i$3 < byClass.length; i$3++) {
  5660. var cm = byClass[i$3].CodeMirror;
  5661. if (cm) editors.push(cm);
  5662. }
  5663. if (editors.length) editors[0].operation(function() {
  5664. for (var i$4 = 0; i$4 < editors.length; i$4++) f(editors[i$4]);
  5665. });
  5666. }
  5667. var globalsRegistered = false;
  5668. function ensureGlobalHandlers() {
  5669. if (globalsRegistered) return;
  5670. registerGlobalHandlers();
  5671. globalsRegistered = true;
  5672. }
  5673. function registerGlobalHandlers() {
  5674. var resizeTimer;
  5675. on(window, "resize", function() {
  5676. if (resizeTimer == null) resizeTimer = setTimeout(function() {
  5677. resizeTimer = null;
  5678. forEachCodeMirror(onResize);
  5679. }, 100);
  5680. });
  5681. on(window, "blur", function() {
  5682. return forEachCodeMirror(onBlur);
  5683. });
  5684. }
  5685. function onResize(cm) {
  5686. var d = cm.display;
  5687. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  5688. d.scrollbarsClipped = false;
  5689. cm.setSize();
  5690. }
  5691. var keyNames = {
  5692. 3: "Pause",
  5693. 8: "Backspace",
  5694. 9: "Tab",
  5695. 13: "Enter",
  5696. 16: "Shift",
  5697. 17: "Ctrl",
  5698. 18: "Alt",
  5699. 19: "Pause",
  5700. 20: "CapsLock",
  5701. 27: "Esc",
  5702. 32: "Space",
  5703. 33: "PageUp",
  5704. 34: "PageDown",
  5705. 35: "End",
  5706. 36: "Home",
  5707. 37: "Left",
  5708. 38: "Up",
  5709. 39: "Right",
  5710. 40: "Down",
  5711. 44: "PrintScrn",
  5712. 45: "Insert",
  5713. 46: "Delete",
  5714. 59: ";",
  5715. 61: "=",
  5716. 91: "Mod",
  5717. 92: "Mod",
  5718. 93: "Mod",
  5719. 106: "*",
  5720. 107: "=",
  5721. 109: "-",
  5722. 110: ".",
  5723. 111: "/",
  5724. 145: "ScrollLock",
  5725. 173: "-",
  5726. 186: ";",
  5727. 187: "=",
  5728. 188: ",",
  5729. 189: "-",
  5730. 190: ".",
  5731. 191: "/",
  5732. 192: "`",
  5733. 219: "[",
  5734. 220: "\\",
  5735. 221: "]",
  5736. 222: "'",
  5737. 224: "Mod",
  5738. 63232: "Up",
  5739. 63233: "Down",
  5740. 63234: "Left",
  5741. 63235: "Right",
  5742. 63272: "Delete",
  5743. 63273: "Home",
  5744. 63275: "End",
  5745. 63276: "PageUp",
  5746. 63277: "PageDown",
  5747. 63302: "Insert"
  5748. };
  5749. for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
  5750. for (var i$1 = 65; i$1 <= 90; i$1++) keyNames[i$1] = String.fromCharCode(i$1);
  5751. for (var i$2 = 1; i$2 <= 12; i$2++) keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2;
  5752. var keyMap = {};
  5753. keyMap.basic = {
  5754. "Left": "goCharLeft",
  5755. "Right": "goCharRight",
  5756. "Up": "goLineUp",
  5757. "Down": "goLineDown",
  5758. "End": "goLineEnd",
  5759. "Home": "goLineStartSmart",
  5760. "PageUp": "goPageUp",
  5761. "PageDown": "goPageDown",
  5762. "Delete": "delCharAfter",
  5763. "Backspace": "delCharBefore",
  5764. "Shift-Backspace": "delCharBefore",
  5765. "Tab": "defaultTab",
  5766. "Shift-Tab": "indentAuto",
  5767. "Enter": "newlineAndIndent",
  5768. "Insert": "toggleOverwrite",
  5769. "Esc": "singleSelection"
  5770. };
  5771. keyMap.pcDefault = {
  5772. "Ctrl-A": "selectAll",
  5773. "Ctrl-D": "deleteLine",
  5774. "Ctrl-Z": "undo",
  5775. "Shift-Ctrl-Z": "redo",
  5776. "Ctrl-Y": "redo",
  5777. "Ctrl-Home": "goDocStart",
  5778. "Ctrl-End": "goDocEnd",
  5779. "Ctrl-Up": "goLineUp",
  5780. "Ctrl-Down": "goLineDown",
  5781. "Ctrl-Left": "goGroupLeft",
  5782. "Ctrl-Right": "goGroupRight",
  5783. "Alt-Left": "goLineStart",
  5784. "Alt-Right": "goLineEnd",
  5785. "Ctrl-Backspace": "delGroupBefore",
  5786. "Ctrl-Delete": "delGroupAfter",
  5787. "Ctrl-S": "save",
  5788. "Ctrl-F": "find",
  5789. "Ctrl-G": "findNext",
  5790. "Shift-Ctrl-G": "findPrev",
  5791. "Shift-Ctrl-F": "replace",
  5792. "Shift-Ctrl-R": "replaceAll",
  5793. "Ctrl-[": "indentLess",
  5794. "Ctrl-]": "indentMore",
  5795. "Ctrl-U": "undoSelection",
  5796. "Shift-Ctrl-U": "redoSelection",
  5797. "Alt-U": "redoSelection",
  5798. "fallthrough": "basic"
  5799. };
  5800. keyMap.emacsy = {
  5801. "Ctrl-F": "goCharRight",
  5802. "Ctrl-B": "goCharLeft",
  5803. "Ctrl-P": "goLineUp",
  5804. "Ctrl-N": "goLineDown",
  5805. "Ctrl-A": "goLineStart",
  5806. "Ctrl-E": "goLineEnd",
  5807. "Ctrl-V": "goPageDown",
  5808. "Shift-Ctrl-V": "goPageUp",
  5809. "Ctrl-D": "delCharAfter",
  5810. "Ctrl-H": "delCharBefore",
  5811. "Alt-Backspace": "delWordBefore",
  5812. "Ctrl-K": "killLine",
  5813. "Ctrl-T": "transposeChars",
  5814. "Ctrl-O": "openLine"
  5815. };
  5816. keyMap.macDefault = {
  5817. "Cmd-A": "selectAll",
  5818. "Cmd-D": "deleteLine",
  5819. "Cmd-Z": "undo",
  5820. "Shift-Cmd-Z": "redo",
  5821. "Cmd-Y": "redo",
  5822. "Cmd-Home": "goDocStart",
  5823. "Cmd-Up": "goDocStart",
  5824. "Cmd-End": "goDocEnd",
  5825. "Cmd-Down": "goDocEnd",
  5826. "Alt-Left": "goGroupLeft",
  5827. "Alt-Right": "goGroupRight",
  5828. "Cmd-Left": "goLineLeft",
  5829. "Cmd-Right": "goLineRight",
  5830. "Alt-Backspace": "delGroupBefore",
  5831. "Ctrl-Alt-Backspace": "delGroupAfter",
  5832. "Alt-Delete": "delGroupAfter",
  5833. "Cmd-S": "save",
  5834. "Cmd-F": "find",
  5835. "Cmd-G": "findNext",
  5836. "Shift-Cmd-G": "findPrev",
  5837. "Cmd-Alt-F": "replace",
  5838. "Shift-Cmd-Alt-F": "replaceAll",
  5839. "Cmd-[": "indentLess",
  5840. "Cmd-]": "indentMore",
  5841. "Cmd-Backspace": "delWrappedLineLeft",
  5842. "Cmd-Delete": "delWrappedLineRight",
  5843. "Cmd-U": "undoSelection",
  5844. "Shift-Cmd-U": "redoSelection",
  5845. "Ctrl-Up": "goDocStart",
  5846. "Ctrl-Down": "goDocEnd",
  5847. "fallthrough": ["basic", "emacsy"]
  5848. };
  5849. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  5850. function normalizeKeyName(name) {
  5851. var parts = name.split(/-(?!$)/);
  5852. name = parts[parts.length - 1];
  5853. var alt, ctrl, shift, cmd;
  5854. for (var i$3 = 0; i$3 < parts.length - 1; i$3++) {
  5855. var mod = parts[i$3];
  5856. if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
  5857. else if (/^a(lt)?$/i.test(mod)) alt = true;
  5858. else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
  5859. else if (/^s(hift)?$/i.test(mod)) shift = true;
  5860. else throw new Error("Unrecognized modifier name: " + mod);
  5861. }
  5862. if (alt) name = "Alt-" + name;
  5863. if (ctrl) name = "Ctrl-" + name;
  5864. if (cmd) name = "Cmd-" + name;
  5865. if (shift) name = "Shift-" + name;
  5866. return name;
  5867. }
  5868. function normalizeKeyMap(keymap) {
  5869. var copy = {};
  5870. for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
  5871. var value = keymap[keyname];
  5872. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
  5873. if (value == "...") {
  5874. delete keymap[keyname];
  5875. continue;
  5876. }
  5877. var keys = map(keyname.split(" "), normalizeKeyName);
  5878. for (var i$3 = 0; i$3 < keys.length; i$3++) {
  5879. var val = void 0, name = void 0;
  5880. if (i$3 == keys.length - 1) {
  5881. name = keys.join(" ");
  5882. val = value;
  5883. } else {
  5884. name = keys.slice(0, i$3 + 1).join(" ");
  5885. val = "...";
  5886. }
  5887. var prev = copy[name];
  5888. if (!prev) copy[name] = val;
  5889. else if (prev != val) throw new Error("Inconsistent bindings for " + name);
  5890. }
  5891. delete keymap[keyname];
  5892. }
  5893. for (var prop$1 in copy) keymap[prop$1] = copy[prop$1];
  5894. return keymap;
  5895. }
  5896. function lookupKey(key, map$1, handle, context) {
  5897. map$1 = getKeyMap(map$1);
  5898. var found = map$1.call ? map$1.call(key, context) : map$1[key];
  5899. if (found === false) return "nothing";
  5900. if (found === "...") return "multi";
  5901. if (found != null && handle(found)) return "handled";
  5902. if (map$1.fallthrough) {
  5903. if (Object.prototype.toString.call(map$1.fallthrough) != "[object Array]") return lookupKey(key, map$1.fallthrough, handle, context);
  5904. for (var i$3 = 0; i$3 < map$1.fallthrough.length; i$3++) {
  5905. var result = lookupKey(key, map$1.fallthrough[i$3], handle, context);
  5906. if (result) return result;
  5907. }
  5908. }
  5909. }
  5910. function isModifierKey(value) {
  5911. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  5912. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
  5913. }
  5914. function addModifierNames(name, event, noShift) {
  5915. var base = name;
  5916. if (event.altKey && base != "Alt") name = "Alt-" + name;
  5917. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
  5918. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") name = "Cmd-" + name;
  5919. if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
  5920. return name;
  5921. }
  5922. function keyName(event, noShift) {
  5923. if (presto && event.keyCode == 34 && event["char"]) return false;
  5924. var name = keyNames[event.keyCode];
  5925. if (name == null || event.altGraphKey) return false;
  5926. if (event.keyCode == 3 && event.code) name = event.code;
  5927. return addModifierNames(name, event, noShift);
  5928. }
  5929. function getKeyMap(val) {
  5930. return typeof val == "string" ? keyMap[val] : val;
  5931. }
  5932. function deleteNearSelection(cm, compute) {
  5933. var ranges = cm.doc.sel.ranges, kill = [];
  5934. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  5935. var toKill = compute(ranges[i$3]);
  5936. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  5937. var replaced = kill.pop();
  5938. if (cmp(replaced.from, toKill.from) < 0) {
  5939. toKill.from = replaced.from;
  5940. break;
  5941. }
  5942. }
  5943. kill.push(toKill);
  5944. }
  5945. runInOp(cm, function() {
  5946. for (var i$4 = kill.length - 1; i$4 >= 0; i$4--) replaceRange(cm.doc, "", kill[i$4].from, kill[i$4].to, "+delete");
  5947. ensureCursorVisible(cm);
  5948. });
  5949. }
  5950. function moveCharLogically(line, ch, dir) {
  5951. var target = skipExtendingChars(line.text, ch + dir, dir);
  5952. return target < 0 || target > line.text.length ? null : target;
  5953. }
  5954. function moveLogically(line, start, dir) {
  5955. var ch = moveCharLogically(line, start.ch, dir);
  5956. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before");
  5957. }
  5958. function endOfLine(visually, cm, lineObj, lineNo$1, dir) {
  5959. if (visually) {
  5960. if (cm.doc.direction == "rtl") dir = -dir;
  5961. var order = getOrder(lineObj, cm.doc.direction);
  5962. if (order) {
  5963. var part = dir < 0 ? lst(order) : order[0];
  5964. var moveInStorageOrder = dir < 0 == (part.level == 1);
  5965. var sticky = moveInStorageOrder ? "after" : "before";
  5966. var ch;
  5967. if (part.level > 0 || cm.doc.direction == "rtl") {
  5968. var prep = prepareMeasureForLine(cm, lineObj);
  5969. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  5970. var targetTop = measureCharPrepared(cm, prep, ch).top;
  5971. ch = findFirst(function(ch$1) {
  5972. return measureCharPrepared(cm, prep, ch$1).top == targetTop;
  5973. }, dir < 0 == (part.level == 1) ? part.from : part.to - 1, ch);
  5974. if (sticky == "before") ch = moveCharLogically(lineObj, ch, 1);
  5975. } else ch = dir < 0 ? part.to : part.from;
  5976. return new Pos(lineNo$1, ch, sticky);
  5977. }
  5978. }
  5979. return new Pos(lineNo$1, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after");
  5980. }
  5981. function moveVisually(cm, line, start, dir) {
  5982. var bidi = getOrder(line, cm.doc.direction);
  5983. if (!bidi) return moveLogically(line, start, dir);
  5984. if (start.ch >= line.text.length) {
  5985. start.ch = line.text.length;
  5986. start.sticky = "before";
  5987. } else if (start.ch <= 0) {
  5988. start.ch = 0;
  5989. start.sticky = "after";
  5990. }
  5991. var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
  5992. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) return moveLogically(line, start, dir);
  5993. var mv = function(pos, dir$1) {
  5994. return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir$1);
  5995. };
  5996. var prep;
  5997. var getWrappedLineExtent = function(ch$1) {
  5998. if (!cm.options.lineWrapping) return {
  5999. begin: 0,
  6000. end: line.text.length
  6001. };
  6002. prep = prep || prepareMeasureForLine(cm, line);
  6003. return wrappedLineExtentChar(cm, line, prep, ch$1);
  6004. };
  6005. var wrappedLineExtent$1 = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  6006. if (cm.doc.direction == "rtl" || part.level == 1) {
  6007. var moveInStorageOrder = part.level == 1 == dir < 0;
  6008. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  6009. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent$1.begin : ch <= part.to && ch <= wrappedLineExtent$1.end)) {
  6010. var sticky = moveInStorageOrder ? "before" : "after";
  6011. return new Pos(start.line, ch, sticky);
  6012. }
  6013. }
  6014. var searchInVisualLine = function(partPos$1, dir$1, wrappedLineExtent$2) {
  6015. var getRes = function(ch$2, moveInStorageOrder$2) {
  6016. return moveInStorageOrder$2 ? new Pos(start.line, mv(ch$2, 1), "before") : new Pos(start.line, ch$2, "after");
  6017. };
  6018. for (; partPos$1 >= 0 && partPos$1 < bidi.length; partPos$1 += dir$1) {
  6019. var part$1 = bidi[partPos$1];
  6020. var moveInStorageOrder$1 = dir$1 > 0 == (part$1.level != 1);
  6021. var ch$1 = moveInStorageOrder$1 ? wrappedLineExtent$2.begin : mv(wrappedLineExtent$2.end, -1);
  6022. if (part$1.from <= ch$1 && ch$1 < part$1.to) return getRes(ch$1, moveInStorageOrder$1);
  6023. ch$1 = moveInStorageOrder$1 ? part$1.from : mv(part$1.to, -1);
  6024. if (wrappedLineExtent$2.begin <= ch$1 && ch$1 < wrappedLineExtent$2.end) return getRes(ch$1, moveInStorageOrder$1);
  6025. }
  6026. };
  6027. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent$1);
  6028. if (res) return res;
  6029. var nextCh = dir > 0 ? wrappedLineExtent$1.end : mv(wrappedLineExtent$1.begin, -1);
  6030. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  6031. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  6032. if (res) return res;
  6033. }
  6034. return null;
  6035. }
  6036. var commands = {
  6037. selectAll,
  6038. singleSelection: function(cm) {
  6039. return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
  6040. },
  6041. killLine: function(cm) {
  6042. return deleteNearSelection(cm, function(range$1) {
  6043. if (range$1.empty()) {
  6044. var len = getLine(cm.doc, range$1.head.line).text.length;
  6045. if (range$1.head.ch == len && range$1.head.line < cm.lastLine()) return {
  6046. from: range$1.head,
  6047. to: Pos(range$1.head.line + 1, 0)
  6048. };
  6049. else return {
  6050. from: range$1.head,
  6051. to: Pos(range$1.head.line, len)
  6052. };
  6053. } else return {
  6054. from: range$1.from(),
  6055. to: range$1.to()
  6056. };
  6057. });
  6058. },
  6059. deleteLine: function(cm) {
  6060. return deleteNearSelection(cm, function(range$1) {
  6061. return {
  6062. from: Pos(range$1.from().line, 0),
  6063. to: clipPos(cm.doc, Pos(range$1.to().line + 1, 0))
  6064. };
  6065. });
  6066. },
  6067. delLineLeft: function(cm) {
  6068. return deleteNearSelection(cm, function(range$1) {
  6069. return {
  6070. from: Pos(range$1.from().line, 0),
  6071. to: range$1.from()
  6072. };
  6073. });
  6074. },
  6075. delWrappedLineLeft: function(cm) {
  6076. return deleteNearSelection(cm, function(range$1) {
  6077. var top = cm.charCoords(range$1.head, "div").top + 5;
  6078. var leftPos = cm.coordsChar({
  6079. left: 0,
  6080. top
  6081. }, "div");
  6082. return {
  6083. from: leftPos,
  6084. to: range$1.from()
  6085. };
  6086. });
  6087. },
  6088. delWrappedLineRight: function(cm) {
  6089. return deleteNearSelection(cm, function(range$1) {
  6090. var top = cm.charCoords(range$1.head, "div").top + 5;
  6091. var rightPos = cm.coordsChar({
  6092. left: cm.display.lineDiv.offsetWidth + 100,
  6093. top
  6094. }, "div");
  6095. return {
  6096. from: range$1.from(),
  6097. to: rightPos
  6098. };
  6099. });
  6100. },
  6101. undo: function(cm) {
  6102. return cm.undo();
  6103. },
  6104. redo: function(cm) {
  6105. return cm.redo();
  6106. },
  6107. undoSelection: function(cm) {
  6108. return cm.undoSelection();
  6109. },
  6110. redoSelection: function(cm) {
  6111. return cm.redoSelection();
  6112. },
  6113. goDocStart: function(cm) {
  6114. return cm.extendSelection(Pos(cm.firstLine(), 0));
  6115. },
  6116. goDocEnd: function(cm) {
  6117. return cm.extendSelection(Pos(cm.lastLine()));
  6118. },
  6119. goLineStart: function(cm) {
  6120. return cm.extendSelectionsBy(function(range$1) {
  6121. return lineStart(cm, range$1.head.line);
  6122. }, {
  6123. origin: "+move",
  6124. bias: 1
  6125. });
  6126. },
  6127. goLineStartSmart: function(cm) {
  6128. return cm.extendSelectionsBy(function(range$1) {
  6129. return lineStartSmart(cm, range$1.head);
  6130. }, {
  6131. origin: "+move",
  6132. bias: 1
  6133. });
  6134. },
  6135. goLineEnd: function(cm) {
  6136. return cm.extendSelectionsBy(function(range$1) {
  6137. return lineEnd(cm, range$1.head.line);
  6138. }, {
  6139. origin: "+move",
  6140. bias: -1
  6141. });
  6142. },
  6143. goLineRight: function(cm) {
  6144. return cm.extendSelectionsBy(function(range$1) {
  6145. var top = cm.cursorCoords(range$1.head, "div").top + 5;
  6146. return cm.coordsChar({
  6147. left: cm.display.lineDiv.offsetWidth + 100,
  6148. top
  6149. }, "div");
  6150. }, sel_move);
  6151. },
  6152. goLineLeft: function(cm) {
  6153. return cm.extendSelectionsBy(function(range$1) {
  6154. var top = cm.cursorCoords(range$1.head, "div").top + 5;
  6155. return cm.coordsChar({
  6156. left: 0,
  6157. top
  6158. }, "div");
  6159. }, sel_move);
  6160. },
  6161. goLineLeftSmart: function(cm) {
  6162. return cm.extendSelectionsBy(function(range$1) {
  6163. var top = cm.cursorCoords(range$1.head, "div").top + 5;
  6164. var pos = cm.coordsChar({
  6165. left: 0,
  6166. top
  6167. }, "div");
  6168. if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range$1.head);
  6169. return pos;
  6170. }, sel_move);
  6171. },
  6172. goLineUp: function(cm) {
  6173. return cm.moveV(-1, "line");
  6174. },
  6175. goLineDown: function(cm) {
  6176. return cm.moveV(1, "line");
  6177. },
  6178. goPageUp: function(cm) {
  6179. return cm.moveV(-1, "page");
  6180. },
  6181. goPageDown: function(cm) {
  6182. return cm.moveV(1, "page");
  6183. },
  6184. goCharLeft: function(cm) {
  6185. return cm.moveH(-1, "char");
  6186. },
  6187. goCharRight: function(cm) {
  6188. return cm.moveH(1, "char");
  6189. },
  6190. goColumnLeft: function(cm) {
  6191. return cm.moveH(-1, "column");
  6192. },
  6193. goColumnRight: function(cm) {
  6194. return cm.moveH(1, "column");
  6195. },
  6196. goWordLeft: function(cm) {
  6197. return cm.moveH(-1, "word");
  6198. },
  6199. goGroupRight: function(cm) {
  6200. return cm.moveH(1, "group");
  6201. },
  6202. goGroupLeft: function(cm) {
  6203. return cm.moveH(-1, "group");
  6204. },
  6205. goWordRight: function(cm) {
  6206. return cm.moveH(1, "word");
  6207. },
  6208. delCharBefore: function(cm) {
  6209. return cm.deleteH(-1, "codepoint");
  6210. },
  6211. delCharAfter: function(cm) {
  6212. return cm.deleteH(1, "char");
  6213. },
  6214. delWordBefore: function(cm) {
  6215. return cm.deleteH(-1, "word");
  6216. },
  6217. delWordAfter: function(cm) {
  6218. return cm.deleteH(1, "word");
  6219. },
  6220. delGroupBefore: function(cm) {
  6221. return cm.deleteH(-1, "group");
  6222. },
  6223. delGroupAfter: function(cm) {
  6224. return cm.deleteH(1, "group");
  6225. },
  6226. indentAuto: function(cm) {
  6227. return cm.indentSelection("smart");
  6228. },
  6229. indentMore: function(cm) {
  6230. return cm.indentSelection("add");
  6231. },
  6232. indentLess: function(cm) {
  6233. return cm.indentSelection("subtract");
  6234. },
  6235. insertTab: function(cm) {
  6236. return cm.replaceSelection(" ");
  6237. },
  6238. insertSoftTab: function(cm) {
  6239. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
  6240. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  6241. var pos = ranges[i$3].from();
  6242. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  6243. spaces.push(spaceStr(tabSize - col % tabSize));
  6244. }
  6245. cm.replaceSelections(spaces);
  6246. },
  6247. defaultTab: function(cm) {
  6248. if (cm.somethingSelected()) cm.indentSelection("add");
  6249. else cm.execCommand("insertTab");
  6250. },
  6251. transposeChars: function(cm) {
  6252. return runInOp(cm, function() {
  6253. var ranges = cm.listSelections(), newSel = [];
  6254. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  6255. if (!ranges[i$3].empty()) continue;
  6256. var cur = ranges[i$3].head, line = getLine(cm.doc, cur.line).text;
  6257. if (line) {
  6258. if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
  6259. if (cur.ch > 0) {
  6260. cur = new Pos(cur.line, cur.ch + 1);
  6261. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose");
  6262. } else if (cur.line > cm.doc.first) {
  6263. var prev = getLine(cm.doc, cur.line - 1).text;
  6264. if (prev) {
  6265. cur = new Pos(cur.line, 1);
  6266. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  6267. }
  6268. }
  6269. }
  6270. newSel.push(new Range(cur, cur));
  6271. }
  6272. cm.setSelections(newSel);
  6273. });
  6274. },
  6275. newlineAndIndent: function(cm) {
  6276. return runInOp(cm, function() {
  6277. var sels = cm.listSelections();
  6278. for (var i$3 = sels.length - 1; i$3 >= 0; i$3--) cm.replaceRange(cm.doc.lineSeparator(), sels[i$3].anchor, sels[i$3].head, "+input");
  6279. sels = cm.listSelections();
  6280. for (var i$1$1 = 0; i$1$1 < sels.length; i$1$1++) cm.indentLine(sels[i$1$1].from().line, null, true);
  6281. ensureCursorVisible(cm);
  6282. });
  6283. },
  6284. openLine: function(cm) {
  6285. return cm.replaceSelection("\n", "start");
  6286. },
  6287. toggleOverwrite: function(cm) {
  6288. return cm.toggleOverwrite();
  6289. }
  6290. };
  6291. function lineStart(cm, lineN) {
  6292. var line = getLine(cm.doc, lineN);
  6293. var visual = visualLine(line);
  6294. if (visual != line) lineN = lineNo(visual);
  6295. return endOfLine(true, cm, visual, lineN, 1);
  6296. }
  6297. function lineEnd(cm, lineN) {
  6298. var line = getLine(cm.doc, lineN);
  6299. var visual = visualLineEnd(line);
  6300. if (visual != line) lineN = lineNo(visual);
  6301. return endOfLine(true, cm, line, lineN, -1);
  6302. }
  6303. function lineStartSmart(cm, pos) {
  6304. var start = lineStart(cm, pos.line);
  6305. var line = getLine(cm.doc, start.line);
  6306. var order = getOrder(line, cm.doc.direction);
  6307. if (!order || order[0].level == 0) {
  6308. var firstNonWS = Math.max(start.ch, line.text.search(/\S/));
  6309. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  6310. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky);
  6311. }
  6312. return start;
  6313. }
  6314. function doHandleBinding(cm, bound, dropShift) {
  6315. if (typeof bound == "string") {
  6316. bound = commands[bound];
  6317. if (!bound) return false;
  6318. }
  6319. cm.display.input.ensurePolled();
  6320. var prevShift = cm.display.shift, done = false;
  6321. try {
  6322. if (cm.isReadOnly()) cm.state.suppressEdits = true;
  6323. if (dropShift) cm.display.shift = false;
  6324. done = bound(cm) != Pass;
  6325. } finally {
  6326. cm.display.shift = prevShift;
  6327. cm.state.suppressEdits = false;
  6328. }
  6329. return done;
  6330. }
  6331. function lookupKeyForEditor(cm, name, handle) {
  6332. for (var i$3 = 0; i$3 < cm.state.keyMaps.length; i$3++) {
  6333. var result = lookupKey(name, cm.state.keyMaps[i$3], handle, cm);
  6334. if (result) return result;
  6335. }
  6336. return cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm) || lookupKey(name, cm.options.keyMap, handle, cm);
  6337. }
  6338. var stopSeq = new Delayed();
  6339. function dispatchKey(cm, name, e, handle) {
  6340. var seq = cm.state.keySeq;
  6341. if (seq) {
  6342. if (isModifierKey(name)) return "handled";
  6343. if (/\'$/.test(name)) cm.state.keySeq = null;
  6344. else stopSeq.set(50, function() {
  6345. if (cm.state.keySeq == seq) {
  6346. cm.state.keySeq = null;
  6347. cm.display.input.reset();
  6348. }
  6349. });
  6350. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) return true;
  6351. }
  6352. return dispatchKeyInner(cm, name, e, handle);
  6353. }
  6354. function dispatchKeyInner(cm, name, e, handle) {
  6355. var result = lookupKeyForEditor(cm, name, handle);
  6356. if (result == "multi") cm.state.keySeq = name;
  6357. if (result == "handled") signalLater(cm, "keyHandled", cm, name, e);
  6358. if (result == "handled" || result == "multi") {
  6359. e_preventDefault(e);
  6360. restartBlink(cm);
  6361. }
  6362. return !!result;
  6363. }
  6364. function handleKeyBinding(cm, e) {
  6365. var name = keyName(e, true);
  6366. if (!name) return false;
  6367. if (e.shiftKey && !cm.state.keySeq) return dispatchKey(cm, "Shift-" + name, e, function(b) {
  6368. return doHandleBinding(cm, b, true);
  6369. }) || dispatchKey(cm, name, e, function(b) {
  6370. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) return doHandleBinding(cm, b);
  6371. });
  6372. else return dispatchKey(cm, name, e, function(b) {
  6373. return doHandleBinding(cm, b);
  6374. });
  6375. }
  6376. function handleCharBinding(cm, e, ch) {
  6377. return dispatchKey(cm, "'" + ch + "'", e, function(b) {
  6378. return doHandleBinding(cm, b, true);
  6379. });
  6380. }
  6381. var lastStoppedKey = null;
  6382. function onKeyDown(e) {
  6383. var cm = this;
  6384. if (e.target && e.target != cm.display.input.getField()) return;
  6385. cm.curOp.focus = activeElt(root(cm));
  6386. if (signalDOMEvent(cm, e)) return;
  6387. if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
  6388. var code = e.keyCode;
  6389. cm.display.shift = code == 16 || e.shiftKey;
  6390. var handled = handleKeyBinding(cm, e);
  6391. if (presto) {
  6392. lastStoppedKey = handled ? code : null;
  6393. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) cm.replaceSelection("", null, "cut");
  6394. }
  6395. if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand) document.execCommand("cut");
  6396. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) showCrossHair(cm);
  6397. }
  6398. function showCrossHair(cm) {
  6399. var lineDiv = cm.display.lineDiv;
  6400. addClass(lineDiv, "CodeMirror-crosshair");
  6401. function up(e) {
  6402. if (e.keyCode == 18 || !e.altKey) {
  6403. rmClass(lineDiv, "CodeMirror-crosshair");
  6404. off(document, "keyup", up);
  6405. off(document, "mouseover", up);
  6406. }
  6407. }
  6408. on(document, "keyup", up);
  6409. on(document, "mouseover", up);
  6410. }
  6411. function onKeyUp(e) {
  6412. if (e.keyCode == 16) this.doc.sel.shift = false;
  6413. signalDOMEvent(this, e);
  6414. }
  6415. function onKeyPress(e) {
  6416. var cm = this;
  6417. if (e.target && e.target != cm.display.input.getField()) return;
  6418. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
  6419. var keyCode = e.keyCode, charCode = e.charCode;
  6420. if (presto && keyCode == lastStoppedKey) {
  6421. lastStoppedKey = null;
  6422. e_preventDefault(e);
  6423. return;
  6424. }
  6425. if (presto && (!e.which || e.which < 10) && handleKeyBinding(cm, e)) return;
  6426. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  6427. if (ch == "\b") return;
  6428. if (handleCharBinding(cm, e, ch)) return;
  6429. cm.display.input.onKeyPress(e);
  6430. }
  6431. var DOUBLECLICK_DELAY = 400;
  6432. var PastClick = function(time, pos, button) {
  6433. this.time = time;
  6434. this.pos = pos;
  6435. this.button = button;
  6436. };
  6437. PastClick.prototype.compare = function(time, pos, button) {
  6438. return this.time + DOUBLECLICK_DELAY > time && cmp(pos, this.pos) == 0 && button == this.button;
  6439. };
  6440. var lastClick, lastDoubleClick;
  6441. function clickRepeat(pos, button) {
  6442. var now = +new Date();
  6443. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  6444. lastClick = lastDoubleClick = null;
  6445. return "triple";
  6446. } else if (lastClick && lastClick.compare(now, pos, button)) {
  6447. lastDoubleClick = new PastClick(now, pos, button);
  6448. lastClick = null;
  6449. return "double";
  6450. } else {
  6451. lastClick = new PastClick(now, pos, button);
  6452. lastDoubleClick = null;
  6453. return "single";
  6454. }
  6455. }
  6456. function onMouseDown(e) {
  6457. var cm = this, display = cm.display;
  6458. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return;
  6459. display.input.ensurePolled();
  6460. display.shift = e.shiftKey;
  6461. if (eventInWidget(display, e)) {
  6462. if (!webkit) {
  6463. display.scroller.draggable = false;
  6464. setTimeout(function() {
  6465. return display.scroller.draggable = true;
  6466. }, 100);
  6467. }
  6468. return;
  6469. }
  6470. if (clickInGutter(cm, e)) return;
  6471. var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
  6472. win(cm).focus();
  6473. if (button == 1 && cm.state.selectingText) cm.state.selectingText(e);
  6474. if (pos && handleMappedButton(cm, button, pos, repeat, e)) return;
  6475. if (button == 1) {
  6476. if (pos) leftButtonDown(cm, pos, repeat, e);
  6477. else if (e_target(e) == display.scroller) e_preventDefault(e);
  6478. } else if (button == 2) {
  6479. if (pos) extendSelection(cm.doc, pos);
  6480. setTimeout(function() {
  6481. return display.input.focus();
  6482. }, 20);
  6483. } else if (button == 3) if (captureRightClick) cm.display.input.onContextMenu(e);
  6484. else delayBlurEvent(cm);
  6485. }
  6486. function handleMappedButton(cm, button, pos, repeat, event) {
  6487. var name = "Click";
  6488. if (repeat == "double") name = "Double" + name;
  6489. else if (repeat == "triple") name = "Triple" + name;
  6490. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  6491. return dispatchKey(cm, addModifierNames(name, event), event, function(bound) {
  6492. if (typeof bound == "string") bound = commands[bound];
  6493. if (!bound) return false;
  6494. var done = false;
  6495. try {
  6496. if (cm.isReadOnly()) cm.state.suppressEdits = true;
  6497. done = bound(cm, pos) != Pass;
  6498. } finally {
  6499. cm.state.suppressEdits = false;
  6500. }
  6501. return done;
  6502. });
  6503. }
  6504. function configureMouse(cm, repeat, event) {
  6505. var option = cm.getOption("configureMouse");
  6506. var value = option ? option(cm, repeat, event) : {};
  6507. if (value.unit == null) {
  6508. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  6509. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  6510. }
  6511. if (value.extend == null || cm.doc.extend) value.extend = cm.doc.extend || event.shiftKey;
  6512. if (value.addNew == null) value.addNew = mac ? event.metaKey : event.ctrlKey;
  6513. if (value.moveOnDrag == null) value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey);
  6514. return value;
  6515. }
  6516. function leftButtonDown(cm, pos, repeat, event) {
  6517. if (ie) setTimeout(bind(ensureFocus, cm), 0);
  6518. else cm.curOp.focus = activeElt(root(cm));
  6519. var behavior = configureMouse(cm, repeat, event);
  6520. var sel = cm.doc.sel, contained;
  6521. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && repeat == "single" && (contained = sel.contains(pos)) > -1 && (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0)) leftButtonStartDrag(cm, event, pos, behavior);
  6522. else leftButtonSelect(cm, event, pos, behavior);
  6523. }
  6524. function leftButtonStartDrag(cm, event, pos, behavior) {
  6525. var display = cm.display, moved = false;
  6526. var dragEnd = operation(cm, function(e) {
  6527. if (webkit) display.scroller.draggable = false;
  6528. cm.state.draggingText = false;
  6529. if (cm.state.delayingBlurEvent) if (cm.hasFocus()) cm.state.delayingBlurEvent = false;
  6530. else delayBlurEvent(cm);
  6531. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  6532. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  6533. off(display.scroller, "dragstart", dragStart);
  6534. off(display.scroller, "drop", dragEnd);
  6535. if (!moved) {
  6536. e_preventDefault(e);
  6537. if (!behavior.addNew) extendSelection(cm.doc, pos, null, null, behavior.extend);
  6538. if (webkit && !safari || ie && ie_version == 9) setTimeout(function() {
  6539. display.wrapper.ownerDocument.body.focus({ preventScroll: true });
  6540. display.input.focus();
  6541. }, 20);
  6542. else display.input.focus();
  6543. }
  6544. });
  6545. var mouseMove = function(e2) {
  6546. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  6547. };
  6548. var dragStart = function() {
  6549. return moved = true;
  6550. };
  6551. if (webkit) display.scroller.draggable = true;
  6552. cm.state.draggingText = dragEnd;
  6553. dragEnd.copy = !behavior.moveOnDrag;
  6554. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  6555. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  6556. on(display.scroller, "dragstart", dragStart);
  6557. on(display.scroller, "drop", dragEnd);
  6558. cm.state.delayingBlurEvent = true;
  6559. setTimeout(function() {
  6560. return display.input.focus();
  6561. }, 20);
  6562. if (display.scroller.dragDrop) display.scroller.dragDrop();
  6563. }
  6564. function rangeForUnit(cm, pos, unit) {
  6565. if (unit == "char") return new Range(pos, pos);
  6566. if (unit == "word") return cm.findWordAt(pos);
  6567. if (unit == "line") return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
  6568. var result = unit(cm, pos);
  6569. return new Range(result.from, result.to);
  6570. }
  6571. function leftButtonSelect(cm, event, start, behavior) {
  6572. if (ie) delayBlurEvent(cm);
  6573. var display = cm.display, doc$1 = cm.doc;
  6574. e_preventDefault(event);
  6575. var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
  6576. if (behavior.addNew && !behavior.extend) {
  6577. ourIndex = doc$1.sel.contains(start);
  6578. if (ourIndex > -1) ourRange = ranges[ourIndex];
  6579. else ourRange = new Range(start, start);
  6580. } else {
  6581. ourRange = doc$1.sel.primary();
  6582. ourIndex = doc$1.sel.primIndex;
  6583. }
  6584. if (behavior.unit == "rectangle") {
  6585. if (!behavior.addNew) ourRange = new Range(start, start);
  6586. start = posFromMouse(cm, event, true, true);
  6587. ourIndex = -1;
  6588. } else {
  6589. var range$1 = rangeForUnit(cm, start, behavior.unit);
  6590. if (behavior.extend) ourRange = extendRange(ourRange, range$1.anchor, range$1.head, behavior.extend);
  6591. else ourRange = range$1;
  6592. }
  6593. if (!behavior.addNew) {
  6594. ourIndex = 0;
  6595. setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
  6596. startSel = doc$1.sel;
  6597. } else if (ourIndex == -1) {
  6598. ourIndex = ranges.length;
  6599. setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), {
  6600. scroll: false,
  6601. origin: "*mouse"
  6602. });
  6603. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  6604. setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), {
  6605. scroll: false,
  6606. origin: "*mouse"
  6607. });
  6608. startSel = doc$1.sel;
  6609. } else replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
  6610. var lastPos = start;
  6611. function extendTo(pos) {
  6612. if (cmp(lastPos, pos) == 0) return;
  6613. lastPos = pos;
  6614. if (behavior.unit == "rectangle") {
  6615. var ranges$1 = [], tabSize = cm.options.tabSize;
  6616. var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
  6617. var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
  6618. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
  6619. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) {
  6620. var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
  6621. if (left == right) ranges$1.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
  6622. else if (text.length > leftPos) ranges$1.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
  6623. }
  6624. if (!ranges$1.length) ranges$1.push(new Range(start, start));
  6625. setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges$1), ourIndex), {
  6626. origin: "*mouse",
  6627. scroll: false
  6628. });
  6629. cm.scrollIntoView(pos);
  6630. } else {
  6631. var oldRange = ourRange;
  6632. var range$2 = rangeForUnit(cm, pos, behavior.unit);
  6633. var anchor = oldRange.anchor, head;
  6634. if (cmp(range$2.anchor, anchor) > 0) {
  6635. head = range$2.head;
  6636. anchor = minPos(oldRange.from(), range$2.anchor);
  6637. } else {
  6638. head = range$2.anchor;
  6639. anchor = maxPos(oldRange.to(), range$2.head);
  6640. }
  6641. var ranges$1$1 = startSel.ranges.slice(0);
  6642. ranges$1$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
  6643. setSelection(doc$1, normalizeSelection(cm, ranges$1$1, ourIndex), sel_mouse);
  6644. }
  6645. }
  6646. var editorSize = display.wrapper.getBoundingClientRect();
  6647. var counter = 0;
  6648. function extend(e) {
  6649. var curCount = ++counter;
  6650. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  6651. if (!cur) return;
  6652. if (cmp(cur, lastPos) != 0) {
  6653. cm.curOp.focus = activeElt(root(cm));
  6654. extendTo(cur);
  6655. var visible = visibleLines(display, doc$1);
  6656. if (cur.line >= visible.to || cur.line < visible.from) setTimeout(operation(cm, function() {
  6657. if (counter == curCount) extend(e);
  6658. }), 150);
  6659. } else {
  6660. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  6661. if (outside) setTimeout(operation(cm, function() {
  6662. if (counter != curCount) return;
  6663. display.scroller.scrollTop += outside;
  6664. extend(e);
  6665. }), 50);
  6666. }
  6667. }
  6668. function done(e) {
  6669. cm.state.selectingText = false;
  6670. counter = Infinity;
  6671. if (e) {
  6672. e_preventDefault(e);
  6673. display.input.focus();
  6674. }
  6675. off(display.wrapper.ownerDocument, "mousemove", move);
  6676. off(display.wrapper.ownerDocument, "mouseup", up);
  6677. doc$1.history.lastSelOrigin = null;
  6678. }
  6679. var move = operation(cm, function(e) {
  6680. if (e.buttons === 0 || !e_button(e)) done(e);
  6681. else extend(e);
  6682. });
  6683. var up = operation(cm, done);
  6684. cm.state.selectingText = up;
  6685. on(display.wrapper.ownerDocument, "mousemove", move);
  6686. on(display.wrapper.ownerDocument, "mouseup", up);
  6687. }
  6688. function bidiSimplify(cm, range$1) {
  6689. var anchor = range$1.anchor;
  6690. var head = range$1.head;
  6691. var anchorLine = getLine(cm.doc, anchor.line);
  6692. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) return range$1;
  6693. var order = getOrder(anchorLine);
  6694. if (!order) return range$1;
  6695. var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
  6696. if (part.from != anchor.ch && part.to != anchor.ch) return range$1;
  6697. var boundary = index + (part.from == anchor.ch == (part.level != 1) ? 0 : 1);
  6698. if (boundary == 0 || boundary == order.length) return range$1;
  6699. var leftSide;
  6700. if (head.line != anchor.line) leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  6701. else {
  6702. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  6703. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  6704. if (headIndex == boundary - 1 || headIndex == boundary) leftSide = dir < 0;
  6705. else leftSide = dir > 0;
  6706. }
  6707. var usePart = order[boundary + (leftSide ? -1 : 0)];
  6708. var from = leftSide == (usePart.level == 1);
  6709. var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
  6710. return anchor.ch == ch && anchor.sticky == sticky ? range$1 : new Range(new Pos(anchor.line, ch, sticky), head);
  6711. }
  6712. function gutterEvent(cm, e, type, prevent) {
  6713. var mX, mY;
  6714. if (e.touches) {
  6715. mX = e.touches[0].clientX;
  6716. mY = e.touches[0].clientY;
  6717. } else try {
  6718. mX = e.clientX;
  6719. mY = e.clientY;
  6720. } catch (e$1) {
  6721. return false;
  6722. }
  6723. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
  6724. if (prevent) e_preventDefault(e);
  6725. var display = cm.display;
  6726. var lineBox = display.lineDiv.getBoundingClientRect();
  6727. if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
  6728. mY -= lineBox.top - display.viewOffset;
  6729. for (var i$3 = 0; i$3 < cm.display.gutterSpecs.length; ++i$3) {
  6730. var g = display.gutters.childNodes[i$3];
  6731. if (g && g.getBoundingClientRect().right >= mX) {
  6732. var line = lineAtHeight(cm.doc, mY);
  6733. var gutter = cm.display.gutterSpecs[i$3];
  6734. signal(cm, type, cm, line, gutter.className, e);
  6735. return e_defaultPrevented(e);
  6736. }
  6737. }
  6738. }
  6739. function clickInGutter(cm, e) {
  6740. return gutterEvent(cm, e, "gutterClick", true);
  6741. }
  6742. function onContextMenu(cm, e) {
  6743. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
  6744. if (signalDOMEvent(cm, e, "contextmenu")) return;
  6745. if (!captureRightClick) cm.display.input.onContextMenu(e);
  6746. }
  6747. function contextMenuInGutter(cm, e) {
  6748. if (!hasHandler(cm, "gutterContextMenu")) return false;
  6749. return gutterEvent(cm, e, "gutterContextMenu", false);
  6750. }
  6751. function themeChanged(cm) {
  6752. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  6753. clearCaches(cm);
  6754. }
  6755. var Init = { toString: function() {
  6756. return "CodeMirror.Init";
  6757. } };
  6758. var defaults = {};
  6759. var optionHandlers = {};
  6760. function defineOptions(CodeMirror$2) {
  6761. var optionHandlers$1 = CodeMirror$2.optionHandlers;
  6762. function option(name, deflt, handle, notOnInit) {
  6763. CodeMirror$2.defaults[name] = deflt;
  6764. if (handle) optionHandlers$1[name] = notOnInit ? function(cm, val, old) {
  6765. if (old != Init) handle(cm, val, old);
  6766. } : handle;
  6767. }
  6768. CodeMirror$2.defineOption = option;
  6769. CodeMirror$2.Init = Init;
  6770. option("value", "", function(cm, val) {
  6771. return cm.setValue(val);
  6772. }, true);
  6773. option("mode", null, function(cm, val) {
  6774. cm.doc.modeOption = val;
  6775. loadMode(cm);
  6776. }, true);
  6777. option("indentUnit", 2, loadMode, true);
  6778. option("indentWithTabs", false);
  6779. option("smartIndent", true);
  6780. option("tabSize", 4, function(cm) {
  6781. resetModeState(cm);
  6782. clearCaches(cm);
  6783. regChange(cm);
  6784. }, true);
  6785. option("lineSeparator", null, function(cm, val) {
  6786. cm.doc.lineSep = val;
  6787. if (!val) return;
  6788. var newBreaks = [], lineNo$1 = cm.doc.first;
  6789. cm.doc.iter(function(line) {
  6790. for (var pos = 0;;) {
  6791. var found = line.text.indexOf(val, pos);
  6792. if (found == -1) break;
  6793. pos = found + val.length;
  6794. newBreaks.push(Pos(lineNo$1, found));
  6795. }
  6796. lineNo$1++;
  6797. });
  6798. for (var i$3 = newBreaks.length - 1; i$3 >= 0; i$3--) replaceRange(cm.doc, val, newBreaks[i$3], Pos(newBreaks[i$3].line, newBreaks[i$3].ch + val.length));
  6799. });
  6800. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g, function(cm, val, old) {
  6801. cm.state.specialChars = new RegExp(val.source + (val.test(" ") ? "" : "| "), "g");
  6802. if (old != Init) cm.refresh();
  6803. });
  6804. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {
  6805. return cm.refresh();
  6806. }, true);
  6807. option("electricChars", true);
  6808. option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
  6809. throw new Error("inputStyle can not (yet) be changed in a running editor");
  6810. }, true);
  6811. option("spellcheck", false, function(cm, val) {
  6812. return cm.getInputField().spellcheck = val;
  6813. }, true);
  6814. option("autocorrect", false, function(cm, val) {
  6815. return cm.getInputField().autocorrect = val;
  6816. }, true);
  6817. option("autocapitalize", false, function(cm, val) {
  6818. return cm.getInputField().autocapitalize = val;
  6819. }, true);
  6820. option("rtlMoveVisually", !windows);
  6821. option("wholeLineUpdateBefore", true);
  6822. option("theme", "default", function(cm) {
  6823. themeChanged(cm);
  6824. updateGutters(cm);
  6825. }, true);
  6826. option("keyMap", "default", function(cm, val, old) {
  6827. var next = getKeyMap(val);
  6828. var prev = old != Init && getKeyMap(old);
  6829. if (prev && prev.detach) prev.detach(cm, next);
  6830. if (next.attach) next.attach(cm, prev || null);
  6831. });
  6832. option("extraKeys", null);
  6833. option("configureMouse", null);
  6834. option("lineWrapping", false, wrappingChanged, true);
  6835. option("gutters", [], function(cm, val) {
  6836. cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);
  6837. updateGutters(cm);
  6838. }, true);
  6839. option("fixedGutter", true, function(cm, val) {
  6840. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  6841. cm.refresh();
  6842. }, true);
  6843. option("coverGutterNextToScrollbar", false, function(cm) {
  6844. return updateScrollbars(cm);
  6845. }, true);
  6846. option("scrollbarStyle", "native", function(cm) {
  6847. initScrollbars(cm);
  6848. updateScrollbars(cm);
  6849. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  6850. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  6851. }, true);
  6852. option("lineNumbers", false, function(cm, val) {
  6853. cm.display.gutterSpecs = getGutters(cm.options.gutters, val);
  6854. updateGutters(cm);
  6855. }, true);
  6856. option("firstLineNumber", 1, updateGutters, true);
  6857. option("lineNumberFormatter", function(integer) {
  6858. return integer;
  6859. }, updateGutters, true);
  6860. option("showCursorWhenSelecting", false, updateSelection, true);
  6861. option("resetSelectionOnContextMenu", true);
  6862. option("lineWiseCopyCut", true);
  6863. option("pasteLinesPerSelection", true);
  6864. option("selectionsMayTouch", false);
  6865. option("readOnly", false, function(cm, val) {
  6866. if (val == "nocursor") {
  6867. onBlur(cm);
  6868. cm.display.input.blur();
  6869. }
  6870. cm.display.input.readOnlyChanged(val);
  6871. });
  6872. option("screenReaderLabel", null, function(cm, val) {
  6873. val = val === "" ? null : val;
  6874. cm.display.input.screenReaderLabelChanged(val);
  6875. });
  6876. option("disableInput", false, function(cm, val) {
  6877. if (!val) cm.display.input.reset();
  6878. }, true);
  6879. option("dragDrop", true, dragDropChanged);
  6880. option("allowDropFileTypes", null);
  6881. option("cursorBlinkRate", 530);
  6882. option("cursorScrollMargin", 0);
  6883. option("cursorHeight", 1, updateSelection, true);
  6884. option("singleCursorHeightPerLine", true, updateSelection, true);
  6885. option("workTime", 100);
  6886. option("workDelay", 100);
  6887. option("flattenSpans", true, resetModeState, true);
  6888. option("addModeClass", false, resetModeState, true);
  6889. option("pollInterval", 100);
  6890. option("undoDepth", 200, function(cm, val) {
  6891. return cm.doc.history.undoDepth = val;
  6892. });
  6893. option("historyEventDelay", 1250);
  6894. option("viewportMargin", 10, function(cm) {
  6895. return cm.refresh();
  6896. }, true);
  6897. option("maxHighlightLength", 1e4, resetModeState, true);
  6898. option("moveInputWithCursor", true, function(cm, val) {
  6899. if (!val) cm.display.input.resetPosition();
  6900. });
  6901. option("tabindex", null, function(cm, val) {
  6902. return cm.display.input.getField().tabIndex = val || "";
  6903. });
  6904. option("autofocus", null);
  6905. option("direction", "ltr", function(cm, val) {
  6906. return cm.doc.setDirection(val);
  6907. }, true);
  6908. option("phrases", null);
  6909. }
  6910. function dragDropChanged(cm, value, old) {
  6911. var wasOn = old && old != Init;
  6912. if (!value != !wasOn) {
  6913. var funcs = cm.display.dragFunctions;
  6914. var toggle = value ? on : off;
  6915. toggle(cm.display.scroller, "dragstart", funcs.start);
  6916. toggle(cm.display.scroller, "dragenter", funcs.enter);
  6917. toggle(cm.display.scroller, "dragover", funcs.over);
  6918. toggle(cm.display.scroller, "dragleave", funcs.leave);
  6919. toggle(cm.display.scroller, "drop", funcs.drop);
  6920. }
  6921. }
  6922. function wrappingChanged(cm) {
  6923. if (cm.options.lineWrapping) {
  6924. addClass(cm.display.wrapper, "CodeMirror-wrap");
  6925. cm.display.sizer.style.minWidth = "";
  6926. cm.display.sizerWidth = null;
  6927. } else {
  6928. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  6929. findMaxLine(cm);
  6930. }
  6931. estimateLineHeights(cm);
  6932. regChange(cm);
  6933. clearCaches(cm);
  6934. setTimeout(function() {
  6935. return updateScrollbars(cm);
  6936. }, 100);
  6937. }
  6938. function CodeMirror$1(place, options) {
  6939. var this$1 = this;
  6940. if (!(this instanceof CodeMirror$1)) return new CodeMirror$1(place, options);
  6941. this.options = options = options ? copyObj(options) : {};
  6942. copyObj(defaults, options, false);
  6943. var doc$1 = options.value;
  6944. if (typeof doc$1 == "string") doc$1 = new Doc(doc$1, options.mode, null, options.lineSeparator, options.direction);
  6945. else if (options.mode) doc$1.modeOption = options.mode;
  6946. this.doc = doc$1;
  6947. var input = new CodeMirror$1.inputStyles[options.inputStyle](this);
  6948. var display = this.display = new Display(place, doc$1, input, options);
  6949. display.wrapper.CodeMirror = this;
  6950. themeChanged(this);
  6951. if (options.lineWrapping) this.display.wrapper.className += " CodeMirror-wrap";
  6952. initScrollbars(this);
  6953. this.state = {
  6954. keyMaps: [],
  6955. overlays: [],
  6956. modeGen: 0,
  6957. overwrite: false,
  6958. delayingBlurEvent: false,
  6959. focused: false,
  6960. suppressEdits: false,
  6961. pasteIncoming: -1,
  6962. cutIncoming: -1,
  6963. selectingText: false,
  6964. draggingText: false,
  6965. highlight: new Delayed(),
  6966. keySeq: null,
  6967. specialChars: null
  6968. };
  6969. if (options.autofocus && !mobile) display.input.focus();
  6970. if (ie && ie_version < 11) setTimeout(function() {
  6971. return this$1.display.input.reset(true);
  6972. }, 20);
  6973. registerEventHandlers(this);
  6974. ensureGlobalHandlers();
  6975. startOperation(this);
  6976. this.curOp.forceUpdate = true;
  6977. attachDoc(this, doc$1);
  6978. if (options.autofocus && !mobile || this.hasFocus()) setTimeout(function() {
  6979. if (this$1.hasFocus() && !this$1.state.focused) onFocus(this$1);
  6980. }, 20);
  6981. else onBlur(this);
  6982. for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt)) optionHandlers[opt](this, options[opt], Init);
  6983. maybeUpdateLineNumberWidth(this);
  6984. if (options.finishInit) options.finishInit(this);
  6985. for (var i$3 = 0; i$3 < initHooks.length; ++i$3) initHooks[i$3](this);
  6986. endOperation(this);
  6987. if (webkit && options.lineWrapping && getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") display.lineDiv.style.textRendering = "auto";
  6988. }
  6989. CodeMirror$1.defaults = defaults;
  6990. CodeMirror$1.optionHandlers = optionHandlers;
  6991. function registerEventHandlers(cm) {
  6992. var d = cm.display;
  6993. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  6994. if (ie && ie_version < 11) on(d.scroller, "dblclick", operation(cm, function(e) {
  6995. if (signalDOMEvent(cm, e)) return;
  6996. var pos = posFromMouse(cm, e);
  6997. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
  6998. e_preventDefault(e);
  6999. var word = cm.findWordAt(pos);
  7000. extendSelection(cm.doc, word.anchor, word.head);
  7001. }));
  7002. else on(d.scroller, "dblclick", function(e) {
  7003. return signalDOMEvent(cm, e) || e_preventDefault(e);
  7004. });
  7005. on(d.scroller, "contextmenu", function(e) {
  7006. return onContextMenu(cm, e);
  7007. });
  7008. on(d.input.getField(), "contextmenu", function(e) {
  7009. if (!d.scroller.contains(e.target)) onContextMenu(cm, e);
  7010. });
  7011. var touchFinished, prevTouch = { end: 0 };
  7012. function finishTouch() {
  7013. if (d.activeTouch) {
  7014. touchFinished = setTimeout(function() {
  7015. return d.activeTouch = null;
  7016. }, 1e3);
  7017. prevTouch = d.activeTouch;
  7018. prevTouch.end = +new Date();
  7019. }
  7020. }
  7021. function isMouseLikeTouchEvent(e) {
  7022. if (e.touches.length != 1) return false;
  7023. var touch = e.touches[0];
  7024. return touch.radiusX <= 1 && touch.radiusY <= 1;
  7025. }
  7026. function farAway(touch, other) {
  7027. if (other.left == null) return true;
  7028. var dx = other.left - touch.left, dy = other.top - touch.top;
  7029. return dx * dx + dy * dy > 20 * 20;
  7030. }
  7031. on(d.scroller, "touchstart", function(e) {
  7032. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  7033. d.input.ensurePolled();
  7034. clearTimeout(touchFinished);
  7035. var now = +new Date();
  7036. d.activeTouch = {
  7037. start: now,
  7038. moved: false,
  7039. prev: now - prevTouch.end <= 300 ? prevTouch : null
  7040. };
  7041. if (e.touches.length == 1) {
  7042. d.activeTouch.left = e.touches[0].pageX;
  7043. d.activeTouch.top = e.touches[0].pageY;
  7044. }
  7045. }
  7046. });
  7047. on(d.scroller, "touchmove", function() {
  7048. if (d.activeTouch) d.activeTouch.moved = true;
  7049. });
  7050. on(d.scroller, "touchend", function(e) {
  7051. var touch = d.activeTouch;
  7052. if (touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date() - touch.start < 300) {
  7053. var pos = cm.coordsChar(d.activeTouch, "page"), range$1;
  7054. if (!touch.prev || farAway(touch, touch.prev)) range$1 = new Range(pos, pos);
  7055. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) range$1 = cm.findWordAt(pos);
  7056. else range$1 = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
  7057. cm.setSelection(range$1.anchor, range$1.head);
  7058. cm.focus();
  7059. e_preventDefault(e);
  7060. }
  7061. finishTouch();
  7062. });
  7063. on(d.scroller, "touchcancel", finishTouch);
  7064. on(d.scroller, "scroll", function() {
  7065. if (d.scroller.clientHeight) {
  7066. updateScrollTop(cm, d.scroller.scrollTop);
  7067. setScrollLeft(cm, d.scroller.scrollLeft, true);
  7068. signal(cm, "scroll", cm);
  7069. }
  7070. });
  7071. on(d.scroller, "mousewheel", function(e) {
  7072. return onScrollWheel(cm, e);
  7073. });
  7074. on(d.scroller, "DOMMouseScroll", function(e) {
  7075. return onScrollWheel(cm, e);
  7076. });
  7077. on(d.wrapper, "scroll", function() {
  7078. return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0;
  7079. });
  7080. d.dragFunctions = {
  7081. enter: function(e) {
  7082. if (!signalDOMEvent(cm, e)) e_stop(e);
  7083. },
  7084. over: function(e) {
  7085. if (!signalDOMEvent(cm, e)) {
  7086. onDragOver(cm, e);
  7087. e_stop(e);
  7088. }
  7089. },
  7090. start: function(e) {
  7091. return onDragStart(cm, e);
  7092. },
  7093. drop: operation(cm, onDrop),
  7094. leave: function(e) {
  7095. if (!signalDOMEvent(cm, e)) clearDragCursor(cm);
  7096. }
  7097. };
  7098. var inp = d.input.getField();
  7099. on(inp, "keyup", function(e) {
  7100. return onKeyUp.call(cm, e);
  7101. });
  7102. on(inp, "keydown", operation(cm, onKeyDown));
  7103. on(inp, "keypress", operation(cm, onKeyPress));
  7104. on(inp, "focus", function(e) {
  7105. return onFocus(cm, e);
  7106. });
  7107. on(inp, "blur", function(e) {
  7108. return onBlur(cm, e);
  7109. });
  7110. }
  7111. var initHooks = [];
  7112. CodeMirror$1.defineInitHook = function(f) {
  7113. return initHooks.push(f);
  7114. };
  7115. function indentLine(cm, n, how, aggressive) {
  7116. var doc$1 = cm.doc, state;
  7117. if (how == null) how = "add";
  7118. if (how == "smart") if (!doc$1.mode.indent) how = "prev";
  7119. else state = getContextBefore(cm, n).state;
  7120. var tabSize = cm.options.tabSize;
  7121. var line = getLine(doc$1, n), curSpace = countColumn(line.text, null, tabSize);
  7122. if (line.stateAfter) line.stateAfter = null;
  7123. var curSpaceString = line.text.match(/^\s*/)[0], indentation;
  7124. if (!aggressive && !/\S/.test(line.text)) {
  7125. indentation = 0;
  7126. how = "not";
  7127. } else if (how == "smart") {
  7128. indentation = doc$1.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  7129. if (indentation == Pass || indentation > 150) {
  7130. if (!aggressive) return;
  7131. how = "prev";
  7132. }
  7133. }
  7134. if (how == "prev") if (n > doc$1.first) indentation = countColumn(getLine(doc$1, n - 1).text, null, tabSize);
  7135. else indentation = 0;
  7136. else if (how == "add") indentation = curSpace + cm.options.indentUnit;
  7137. else if (how == "subtract") indentation = curSpace - cm.options.indentUnit;
  7138. else if (typeof how == "number") indentation = curSpace + how;
  7139. indentation = Math.max(0, indentation);
  7140. var indentString = "", pos = 0;
  7141. if (cm.options.indentWithTabs) for (var i$3 = Math.floor(indentation / tabSize); i$3; --i$3) {
  7142. pos += tabSize;
  7143. indentString += " ";
  7144. }
  7145. if (pos < indentation) indentString += spaceStr(indentation - pos);
  7146. if (indentString != curSpaceString) {
  7147. replaceRange(doc$1, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  7148. line.stateAfter = null;
  7149. return true;
  7150. } else for (var i$1$1 = 0; i$1$1 < doc$1.sel.ranges.length; i$1$1++) {
  7151. var range$1 = doc$1.sel.ranges[i$1$1];
  7152. if (range$1.head.line == n && range$1.head.ch < curSpaceString.length) {
  7153. var pos$1 = Pos(n, curSpaceString.length);
  7154. replaceOneSelection(doc$1, i$1$1, new Range(pos$1, pos$1));
  7155. break;
  7156. }
  7157. }
  7158. }
  7159. var lastCopied = null;
  7160. function setLastCopied(newLastCopied) {
  7161. lastCopied = newLastCopied;
  7162. }
  7163. function applyTextInput(cm, inserted, deleted, sel, origin) {
  7164. var doc$1 = cm.doc;
  7165. cm.display.shift = false;
  7166. if (!sel) sel = doc$1.sel;
  7167. var recent = +new Date() - 200;
  7168. var paste = origin == "paste" || cm.state.pasteIncoming > recent;
  7169. var textLines = splitLinesAuto(inserted), multiPaste = null;
  7170. if (paste && sel.ranges.length > 1) {
  7171. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  7172. if (sel.ranges.length % lastCopied.text.length == 0) {
  7173. multiPaste = [];
  7174. for (var i$3 = 0; i$3 < lastCopied.text.length; i$3++) multiPaste.push(doc$1.splitLines(lastCopied.text[i$3]));
  7175. }
  7176. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) multiPaste = map(textLines, function(l) {
  7177. return [l];
  7178. });
  7179. }
  7180. var updateInput = cm.curOp.updateInput;
  7181. for (var i$1$1 = sel.ranges.length - 1; i$1$1 >= 0; i$1$1--) {
  7182. var range$1 = sel.ranges[i$1$1];
  7183. var from = range$1.from(), to = range$1.to();
  7184. if (range$1.empty()) {
  7185. if (deleted && deleted > 0) from = Pos(from.line, from.ch - deleted);
  7186. else if (cm.state.overwrite && !paste) to = Pos(to.line, Math.min(getLine(doc$1, to.line).text.length, to.ch + lst(textLines).length));
  7187. else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n")) from = to = Pos(from.line, 0);
  7188. }
  7189. var changeEvent = {
  7190. from,
  7191. to,
  7192. text: multiPaste ? multiPaste[i$1$1 % multiPaste.length] : textLines,
  7193. origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")
  7194. };
  7195. makeChange(cm.doc, changeEvent);
  7196. signalLater(cm, "inputRead", cm, changeEvent);
  7197. }
  7198. if (inserted && !paste) triggerElectric(cm, inserted);
  7199. ensureCursorVisible(cm);
  7200. if (cm.curOp.updateInput < 2) cm.curOp.updateInput = updateInput;
  7201. cm.curOp.typing = true;
  7202. cm.state.pasteIncoming = cm.state.cutIncoming = -1;
  7203. }
  7204. function handlePaste(e, cm) {
  7205. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  7206. if (pasted) {
  7207. e.preventDefault();
  7208. if (!cm.isReadOnly() && !cm.options.disableInput && cm.hasFocus()) runInOp(cm, function() {
  7209. return applyTextInput(cm, pasted, 0, null, "paste");
  7210. });
  7211. return true;
  7212. }
  7213. }
  7214. function triggerElectric(cm, inserted) {
  7215. if (!cm.options.electricChars || !cm.options.smartIndent) return;
  7216. var sel = cm.doc.sel;
  7217. for (var i$3 = sel.ranges.length - 1; i$3 >= 0; i$3--) {
  7218. var range$1 = sel.ranges[i$3];
  7219. if (range$1.head.ch > 100 || i$3 && sel.ranges[i$3 - 1].head.line == range$1.head.line) continue;
  7220. var mode = cm.getModeAt(range$1.head);
  7221. var indented = false;
  7222. if (mode.electricChars) {
  7223. for (var j = 0; j < mode.electricChars.length; j++) if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  7224. indented = indentLine(cm, range$1.head.line, "smart");
  7225. break;
  7226. }
  7227. } else if (mode.electricInput) {
  7228. if (mode.electricInput.test(getLine(cm.doc, range$1.head.line).text.slice(0, range$1.head.ch))) indented = indentLine(cm, range$1.head.line, "smart");
  7229. }
  7230. if (indented) signalLater(cm, "electricInput", cm, range$1.head.line);
  7231. }
  7232. }
  7233. function copyableRanges(cm) {
  7234. var text = [], ranges = [];
  7235. for (var i$3 = 0; i$3 < cm.doc.sel.ranges.length; i$3++) {
  7236. var line = cm.doc.sel.ranges[i$3].head.line;
  7237. var lineRange = {
  7238. anchor: Pos(line, 0),
  7239. head: Pos(line + 1, 0)
  7240. };
  7241. ranges.push(lineRange);
  7242. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  7243. }
  7244. return {
  7245. text,
  7246. ranges
  7247. };
  7248. }
  7249. function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
  7250. field.setAttribute("autocorrect", autocorrect ? "on" : "off");
  7251. field.setAttribute("autocapitalize", autocapitalize ? "on" : "off");
  7252. field.setAttribute("spellcheck", !!spellcheck);
  7253. }
  7254. function hiddenTextarea() {
  7255. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none");
  7256. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  7257. if (webkit) te.style.width = "1000px";
  7258. else te.setAttribute("wrap", "off");
  7259. if (ios) te.style.border = "1px solid black";
  7260. return div;
  7261. }
  7262. function addEditorMethods(CodeMirror$2) {
  7263. var optionHandlers$1 = CodeMirror$2.optionHandlers;
  7264. var helpers = CodeMirror$2.helpers = {};
  7265. CodeMirror$2.prototype = {
  7266. constructor: CodeMirror$2,
  7267. focus: function() {
  7268. win(this).focus();
  7269. this.display.input.focus();
  7270. },
  7271. setOption: function(option, value) {
  7272. var options = this.options, old = options[option];
  7273. if (options[option] == value && option != "mode") return;
  7274. options[option] = value;
  7275. if (optionHandlers$1.hasOwnProperty(option)) operation(this, optionHandlers$1[option])(this, value, old);
  7276. signal(this, "optionChange", this, option);
  7277. },
  7278. getOption: function(option) {
  7279. return this.options[option];
  7280. },
  7281. getDoc: function() {
  7282. return this.doc;
  7283. },
  7284. addKeyMap: function(map$1, bottom) {
  7285. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$1));
  7286. },
  7287. removeKeyMap: function(map$1) {
  7288. var maps = this.state.keyMaps;
  7289. for (var i$3 = 0; i$3 < maps.length; ++i$3) if (maps[i$3] == map$1 || maps[i$3].name == map$1) {
  7290. maps.splice(i$3, 1);
  7291. return true;
  7292. }
  7293. },
  7294. addOverlay: methodOp(function(spec, options) {
  7295. var mode = spec.token ? spec : CodeMirror$2.getMode(this.options, spec);
  7296. if (mode.startState) throw new Error("Overlays may not be stateful.");
  7297. insertSorted(this.state.overlays, {
  7298. mode,
  7299. modeSpec: spec,
  7300. opaque: options && options.opaque,
  7301. priority: options && options.priority || 0
  7302. }, function(overlay) {
  7303. return overlay.priority;
  7304. });
  7305. this.state.modeGen++;
  7306. regChange(this);
  7307. }),
  7308. removeOverlay: methodOp(function(spec) {
  7309. var overlays = this.state.overlays;
  7310. for (var i$3 = 0; i$3 < overlays.length; ++i$3) {
  7311. var cur = overlays[i$3].modeSpec;
  7312. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  7313. overlays.splice(i$3, 1);
  7314. this.state.modeGen++;
  7315. regChange(this);
  7316. return;
  7317. }
  7318. }
  7319. }),
  7320. indentLine: methodOp(function(n, dir, aggressive) {
  7321. if (typeof dir != "string" && typeof dir != "number") if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
  7322. else dir = dir ? "add" : "subtract";
  7323. if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
  7324. }),
  7325. indentSelection: methodOp(function(how) {
  7326. var ranges = this.doc.sel.ranges, end = -1;
  7327. for (var i$3 = 0; i$3 < ranges.length; i$3++) {
  7328. var range$1 = ranges[i$3];
  7329. if (!range$1.empty()) {
  7330. var from = range$1.from(), to = range$1.to();
  7331. var start = Math.max(end, from.line);
  7332. end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  7333. for (var j = start; j < end; ++j) indentLine(this, j, how);
  7334. var newRanges = this.doc.sel.ranges;
  7335. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i$3].from().ch > 0) replaceOneSelection(this.doc, i$3, new Range(from, newRanges[i$3].to()), sel_dontScroll);
  7336. } else if (range$1.head.line > end) {
  7337. indentLine(this, range$1.head.line, how, true);
  7338. end = range$1.head.line;
  7339. if (i$3 == this.doc.sel.primIndex) ensureCursorVisible(this);
  7340. }
  7341. }
  7342. }),
  7343. getTokenAt: function(pos, precise) {
  7344. return takeToken(this, pos, precise);
  7345. },
  7346. getLineTokens: function(line, precise) {
  7347. return takeToken(this, Pos(line), precise, true);
  7348. },
  7349. getTokenTypeAt: function(pos) {
  7350. pos = clipPos(this.doc, pos);
  7351. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  7352. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
  7353. var type;
  7354. if (ch == 0) type = styles[2];
  7355. else for (;;) {
  7356. var mid = before + after >> 1;
  7357. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
  7358. else if (styles[mid * 2 + 1] < ch) before = mid + 1;
  7359. else {
  7360. type = styles[mid * 2 + 2];
  7361. break;
  7362. }
  7363. }
  7364. var cut = type ? type.indexOf("overlay ") : -1;
  7365. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
  7366. },
  7367. getModeAt: function(pos) {
  7368. var mode = this.doc.mode;
  7369. if (!mode.innerMode) return mode;
  7370. return CodeMirror$2.innerMode(mode, this.getTokenAt(pos).state).mode;
  7371. },
  7372. getHelper: function(pos, type) {
  7373. return this.getHelpers(pos, type)[0];
  7374. },
  7375. getHelpers: function(pos, type) {
  7376. var found = [];
  7377. if (!helpers.hasOwnProperty(type)) return found;
  7378. var help = helpers[type], mode = this.getModeAt(pos);
  7379. if (typeof mode[type] == "string") {
  7380. if (help[mode[type]]) found.push(help[mode[type]]);
  7381. } else if (mode[type]) for (var i$3 = 0; i$3 < mode[type].length; i$3++) {
  7382. var val = help[mode[type][i$3]];
  7383. if (val) found.push(val);
  7384. }
  7385. else if (mode.helperType && help[mode.helperType]) found.push(help[mode.helperType]);
  7386. else if (help[mode.name]) found.push(help[mode.name]);
  7387. for (var i$1$1 = 0; i$1$1 < help._global.length; i$1$1++) {
  7388. var cur = help._global[i$1$1];
  7389. if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) found.push(cur.val);
  7390. }
  7391. return found;
  7392. },
  7393. getStateAfter: function(line, precise) {
  7394. var doc$1 = this.doc;
  7395. line = clipLine(doc$1, line == null ? doc$1.first + doc$1.size - 1 : line);
  7396. return getContextBefore(this, line + 1, precise).state;
  7397. },
  7398. cursorCoords: function(start, mode) {
  7399. var pos, range$1 = this.doc.sel.primary();
  7400. if (start == null) pos = range$1.head;
  7401. else if (typeof start == "object") pos = clipPos(this.doc, start);
  7402. else pos = start ? range$1.from() : range$1.to();
  7403. return cursorCoords(this, pos, mode || "page");
  7404. },
  7405. charCoords: function(pos, mode) {
  7406. return charCoords(this, clipPos(this.doc, pos), mode || "page");
  7407. },
  7408. coordsChar: function(coords, mode) {
  7409. coords = fromCoordSystem(this, coords, mode || "page");
  7410. return coordsChar(this, coords.left, coords.top);
  7411. },
  7412. lineAtHeight: function(height, mode) {
  7413. height = fromCoordSystem(this, {
  7414. top: height,
  7415. left: 0
  7416. }, mode || "page").top;
  7417. return lineAtHeight(this.doc, height + this.display.viewOffset);
  7418. },
  7419. heightAtLine: function(line, mode, includeWidgets) {
  7420. var end = false, lineObj;
  7421. if (typeof line == "number") {
  7422. var last = this.doc.first + this.doc.size - 1;
  7423. if (line < this.doc.first) line = this.doc.first;
  7424. else if (line > last) {
  7425. line = last;
  7426. end = true;
  7427. }
  7428. lineObj = getLine(this.doc, line);
  7429. } else lineObj = line;
  7430. return intoCoordSystem(this, lineObj, {
  7431. top: 0,
  7432. left: 0
  7433. }, mode || "page", includeWidgets || end).top + (end ? this.doc.height - heightAtLine(lineObj) : 0);
  7434. },
  7435. defaultTextHeight: function() {
  7436. return textHeight(this.display);
  7437. },
  7438. defaultCharWidth: function() {
  7439. return charWidth(this.display);
  7440. },
  7441. getViewport: function() {
  7442. return {
  7443. from: this.display.viewFrom,
  7444. to: this.display.viewTo
  7445. };
  7446. },
  7447. addWidget: function(pos, node, scroll, vert, horiz) {
  7448. var display = this.display;
  7449. pos = cursorCoords(this, clipPos(this.doc, pos));
  7450. var top = pos.bottom, left = pos.left;
  7451. node.style.position = "absolute";
  7452. node.setAttribute("cm-ignore-events", "true");
  7453. this.display.input.setUneditable(node);
  7454. display.sizer.appendChild(node);
  7455. if (vert == "over") top = pos.top;
  7456. else if (vert == "above" || vert == "near") {
  7457. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  7458. if ((vert == "above" || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) top = pos.top - node.offsetHeight;
  7459. else if (pos.bottom + node.offsetHeight <= vspace) top = pos.bottom;
  7460. if (left + node.offsetWidth > hspace) left = hspace - node.offsetWidth;
  7461. }
  7462. node.style.top = top + "px";
  7463. node.style.left = node.style.right = "";
  7464. if (horiz == "right") {
  7465. left = display.sizer.clientWidth - node.offsetWidth;
  7466. node.style.right = "0px";
  7467. } else {
  7468. if (horiz == "left") left = 0;
  7469. else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
  7470. node.style.left = left + "px";
  7471. }
  7472. if (scroll) scrollIntoView(this, {
  7473. left,
  7474. top,
  7475. right: left + node.offsetWidth,
  7476. bottom: top + node.offsetHeight
  7477. });
  7478. },
  7479. triggerOnKeyDown: methodOp(onKeyDown),
  7480. triggerOnKeyPress: methodOp(onKeyPress),
  7481. triggerOnKeyUp: onKeyUp,
  7482. triggerOnMouseDown: methodOp(onMouseDown),
  7483. execCommand: function(cmd) {
  7484. if (commands.hasOwnProperty(cmd)) return commands[cmd].call(null, this);
  7485. },
  7486. triggerElectric: methodOp(function(text) {
  7487. triggerElectric(this, text);
  7488. }),
  7489. findPosH: function(from, amount, unit, visually) {
  7490. var dir = 1;
  7491. if (amount < 0) {
  7492. dir = -1;
  7493. amount = -amount;
  7494. }
  7495. var cur = clipPos(this.doc, from);
  7496. for (var i$3 = 0; i$3 < amount; ++i$3) {
  7497. cur = findPosH(this.doc, cur, dir, unit, visually);
  7498. if (cur.hitSide) break;
  7499. }
  7500. return cur;
  7501. },
  7502. moveH: methodOp(function(dir, unit) {
  7503. var this$1 = this;
  7504. this.extendSelectionsBy(function(range$1) {
  7505. if (this$1.display.shift || this$1.doc.extend || range$1.empty()) return findPosH(this$1.doc, range$1.head, dir, unit, this$1.options.rtlMoveVisually);
  7506. else return dir < 0 ? range$1.from() : range$1.to();
  7507. }, sel_move);
  7508. }),
  7509. deleteH: methodOp(function(dir, unit) {
  7510. var sel = this.doc.sel, doc$1 = this.doc;
  7511. if (sel.somethingSelected()) doc$1.replaceSelection("", null, "+delete");
  7512. else deleteNearSelection(this, function(range$1) {
  7513. var other = findPosH(doc$1, range$1.head, dir, unit, false);
  7514. return dir < 0 ? {
  7515. from: other,
  7516. to: range$1.head
  7517. } : {
  7518. from: range$1.head,
  7519. to: other
  7520. };
  7521. });
  7522. }),
  7523. findPosV: function(from, amount, unit, goalColumn) {
  7524. var dir = 1, x = goalColumn;
  7525. if (amount < 0) {
  7526. dir = -1;
  7527. amount = -amount;
  7528. }
  7529. var cur = clipPos(this.doc, from);
  7530. for (var i$3 = 0; i$3 < amount; ++i$3) {
  7531. var coords = cursorCoords(this, cur, "div");
  7532. if (x == null) x = coords.left;
  7533. else coords.left = x;
  7534. cur = findPosV(this, coords, dir, unit);
  7535. if (cur.hitSide) break;
  7536. }
  7537. return cur;
  7538. },
  7539. moveV: methodOp(function(dir, unit) {
  7540. var this$1 = this;
  7541. var doc$1 = this.doc, goals = [];
  7542. var collapse = !this.display.shift && !doc$1.extend && doc$1.sel.somethingSelected();
  7543. doc$1.extendSelectionsBy(function(range$1) {
  7544. if (collapse) return dir < 0 ? range$1.from() : range$1.to();
  7545. var headPos = cursorCoords(this$1, range$1.head, "div");
  7546. if (range$1.goalColumn != null) headPos.left = range$1.goalColumn;
  7547. goals.push(headPos.left);
  7548. var pos = findPosV(this$1, headPos, dir, unit);
  7549. if (unit == "page" && range$1 == doc$1.sel.primary()) addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top);
  7550. return pos;
  7551. }, sel_move);
  7552. if (goals.length) for (var i$3 = 0; i$3 < doc$1.sel.ranges.length; i$3++) doc$1.sel.ranges[i$3].goalColumn = goals[i$3];
  7553. }),
  7554. findWordAt: function(pos) {
  7555. var doc$1 = this.doc, line = getLine(doc$1, pos.line).text;
  7556. var start = pos.ch, end = pos.ch;
  7557. if (line) {
  7558. var helper = this.getHelper(pos, "wordChars");
  7559. if ((pos.sticky == "before" || end == line.length) && start) --start;
  7560. else ++end;
  7561. var startChar = line.charAt(start);
  7562. var check = isWordChar(startChar, helper) ? function(ch) {
  7563. return isWordChar(ch, helper);
  7564. } : /\s/.test(startChar) ? function(ch) {
  7565. return /\s/.test(ch);
  7566. } : function(ch) {
  7567. return !/\s/.test(ch) && !isWordChar(ch);
  7568. };
  7569. while (start > 0 && check(line.charAt(start - 1))) --start;
  7570. while (end < line.length && check(line.charAt(end))) ++end;
  7571. }
  7572. return new Range(Pos(pos.line, start), Pos(pos.line, end));
  7573. },
  7574. toggleOverwrite: function(value) {
  7575. if (value != null && value == this.state.overwrite) return;
  7576. if (this.state.overwrite = !this.state.overwrite) addClass(this.display.cursorDiv, "CodeMirror-overwrite");
  7577. else rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
  7578. signal(this, "overwriteToggle", this, this.state.overwrite);
  7579. },
  7580. hasFocus: function() {
  7581. return this.display.input.getField() == activeElt(root(this));
  7582. },
  7583. isReadOnly: function() {
  7584. return !!(this.options.readOnly || this.doc.cantEdit);
  7585. },
  7586. scrollTo: methodOp(function(x, y) {
  7587. scrollToCoords(this, x, y);
  7588. }),
  7589. getScrollInfo: function() {
  7590. var scroller = this.display.scroller;
  7591. return {
  7592. left: scroller.scrollLeft,
  7593. top: scroller.scrollTop,
  7594. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  7595. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  7596. clientHeight: displayHeight(this),
  7597. clientWidth: displayWidth(this)
  7598. };
  7599. },
  7600. scrollIntoView: methodOp(function(range$1, margin) {
  7601. if (range$1 == null) {
  7602. range$1 = {
  7603. from: this.doc.sel.primary().head,
  7604. to: null
  7605. };
  7606. if (margin == null) margin = this.options.cursorScrollMargin;
  7607. } else if (typeof range$1 == "number") range$1 = {
  7608. from: Pos(range$1, 0),
  7609. to: null
  7610. };
  7611. else if (range$1.from == null) range$1 = {
  7612. from: range$1,
  7613. to: null
  7614. };
  7615. if (!range$1.to) range$1.to = range$1.from;
  7616. range$1.margin = margin || 0;
  7617. if (range$1.from.line != null) scrollToRange(this, range$1);
  7618. else scrollToCoordsRange(this, range$1.from, range$1.to, range$1.margin);
  7619. }),
  7620. setSize: methodOp(function(width, height) {
  7621. var this$1 = this;
  7622. var interpret = function(val) {
  7623. return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
  7624. };
  7625. if (width != null) this.display.wrapper.style.width = interpret(width);
  7626. if (height != null) this.display.wrapper.style.height = interpret(height);
  7627. if (this.options.lineWrapping) clearLineMeasurementCache(this);
  7628. var lineNo$1 = this.display.viewFrom;
  7629. this.doc.iter(lineNo$1, this.display.viewTo, function(line) {
  7630. if (line.widgets) {
  7631. for (var i$3 = 0; i$3 < line.widgets.length; i$3++) if (line.widgets[i$3].noHScroll) {
  7632. regLineChange(this$1, lineNo$1, "widget");
  7633. break;
  7634. }
  7635. }
  7636. ++lineNo$1;
  7637. });
  7638. this.curOp.forceUpdate = true;
  7639. signal(this, "refresh", this);
  7640. }),
  7641. operation: function(f) {
  7642. return runInOp(this, f);
  7643. },
  7644. startOperation: function() {
  7645. return startOperation(this);
  7646. },
  7647. endOperation: function() {
  7648. return endOperation(this);
  7649. },
  7650. refresh: methodOp(function() {
  7651. var oldHeight = this.display.cachedTextHeight;
  7652. regChange(this);
  7653. this.curOp.forceUpdate = true;
  7654. clearCaches(this);
  7655. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  7656. updateGutterSpace(this.display);
  7657. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping) estimateLineHeights(this);
  7658. signal(this, "refresh", this);
  7659. }),
  7660. swapDoc: methodOp(function(doc$1) {
  7661. var old = this.doc;
  7662. old.cm = null;
  7663. if (this.state.selectingText) this.state.selectingText();
  7664. attachDoc(this, doc$1);
  7665. clearCaches(this);
  7666. this.display.input.reset();
  7667. scrollToCoords(this, doc$1.scrollLeft, doc$1.scrollTop);
  7668. this.curOp.forceScroll = true;
  7669. signalLater(this, "swapDoc", this, old);
  7670. return old;
  7671. }),
  7672. phrase: function(phraseText) {
  7673. var phrases = this.options.phrases;
  7674. return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText;
  7675. },
  7676. getInputField: function() {
  7677. return this.display.input.getField();
  7678. },
  7679. getWrapperElement: function() {
  7680. return this.display.wrapper;
  7681. },
  7682. getScrollerElement: function() {
  7683. return this.display.scroller;
  7684. },
  7685. getGutterElement: function() {
  7686. return this.display.gutters;
  7687. }
  7688. };
  7689. eventMixin(CodeMirror$2);
  7690. CodeMirror$2.registerHelper = function(type, name, value) {
  7691. if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror$2[type] = { _global: [] };
  7692. helpers[type][name] = value;
  7693. };
  7694. CodeMirror$2.registerGlobalHelper = function(type, name, predicate, value) {
  7695. CodeMirror$2.registerHelper(type, name, value);
  7696. helpers[type]._global.push({
  7697. pred: predicate,
  7698. val: value
  7699. });
  7700. };
  7701. }
  7702. function findPosH(doc$1, pos, dir, unit, visually) {
  7703. var oldPos = pos;
  7704. var origDir = dir;
  7705. var lineObj = getLine(doc$1, pos.line);
  7706. var lineDir = visually && doc$1.direction == "rtl" ? -dir : dir;
  7707. function findNextLine() {
  7708. var l = pos.line + lineDir;
  7709. if (l < doc$1.first || l >= doc$1.first + doc$1.size) return false;
  7710. pos = new Pos(l, pos.ch, pos.sticky);
  7711. return lineObj = getLine(doc$1, l);
  7712. }
  7713. function moveOnce(boundToLine) {
  7714. var next;
  7715. if (unit == "codepoint") {
  7716. var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1));
  7717. if (isNaN(ch)) next = null;
  7718. else {
  7719. var astral = dir > 0 ? ch >= 55296 && ch < 56320 : ch >= 56320 && ch < 57343;
  7720. next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir);
  7721. }
  7722. } else if (visually) next = moveVisually(doc$1.cm, lineObj, pos, dir);
  7723. else next = moveLogically(lineObj, pos, dir);
  7724. if (next == null) if (!boundToLine && findNextLine()) pos = endOfLine(visually, doc$1.cm, lineObj, pos.line, lineDir);
  7725. else return false;
  7726. else pos = next;
  7727. return true;
  7728. }
  7729. if (unit == "char" || unit == "codepoint") moveOnce();
  7730. else if (unit == "column") moveOnce(true);
  7731. else if (unit == "word" || unit == "group") {
  7732. var sawType = null, group = unit == "group";
  7733. var helper = doc$1.cm && doc$1.cm.getHelper(pos, "wordChars");
  7734. for (var first = true;; first = false) {
  7735. if (dir < 0 && !moveOnce(!first)) break;
  7736. var cur = lineObj.text.charAt(pos.ch) || "\n";
  7737. var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p";
  7738. if (group && !first && !type) type = "s";
  7739. if (sawType && sawType != type) {
  7740. if (dir < 0) {
  7741. dir = 1;
  7742. moveOnce();
  7743. pos.sticky = "after";
  7744. }
  7745. break;
  7746. }
  7747. if (type) sawType = type;
  7748. if (dir > 0 && !moveOnce(!first)) break;
  7749. }
  7750. }
  7751. var result = skipAtomic(doc$1, pos, oldPos, origDir, true);
  7752. if (equalCursorPos(oldPos, result)) result.hitSide = true;
  7753. return result;
  7754. }
  7755. function findPosV(cm, pos, dir, unit) {
  7756. var doc$1 = cm.doc, x = pos.left, y;
  7757. if (unit == "page") {
  7758. var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc$1(cm).documentElement.clientHeight);
  7759. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  7760. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  7761. } else if (unit == "line") y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  7762. var target;
  7763. for (;;) {
  7764. target = coordsChar(cm, x, y);
  7765. if (!target.outside) break;
  7766. if (dir < 0 ? y <= 0 : y >= doc$1.height) {
  7767. target.hitSide = true;
  7768. break;
  7769. }
  7770. y += dir * 5;
  7771. }
  7772. return target;
  7773. }
  7774. var ContentEditableInput = function(cm) {
  7775. this.cm = cm;
  7776. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  7777. this.polling = new Delayed();
  7778. this.composing = null;
  7779. this.gracePeriod = false;
  7780. this.readDOMTimeout = null;
  7781. };
  7782. ContentEditableInput.prototype.init = function(display) {
  7783. var this$1 = this;
  7784. var input = this, cm = input.cm;
  7785. var div = input.div = display.lineDiv;
  7786. div.contentEditable = true;
  7787. disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
  7788. function belongsToInput(e) {
  7789. for (var t = e.target; t; t = t.parentNode) {
  7790. if (t == div) return true;
  7791. if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) break;
  7792. }
  7793. return false;
  7794. }
  7795. on(div, "paste", function(e) {
  7796. if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) return;
  7797. if (ie_version <= 11) setTimeout(operation(cm, function() {
  7798. return this$1.updateFromDOM();
  7799. }), 20);
  7800. });
  7801. on(div, "compositionstart", function(e) {
  7802. this$1.composing = {
  7803. data: e.data,
  7804. done: false
  7805. };
  7806. });
  7807. on(div, "compositionupdate", function(e) {
  7808. if (!this$1.composing) this$1.composing = {
  7809. data: e.data,
  7810. done: false
  7811. };
  7812. });
  7813. on(div, "compositionend", function(e) {
  7814. if (this$1.composing) {
  7815. if (e.data != this$1.composing.data) this$1.readFromDOMSoon();
  7816. this$1.composing.done = true;
  7817. }
  7818. });
  7819. on(div, "touchstart", function() {
  7820. return input.forceCompositionEnd();
  7821. });
  7822. on(div, "input", function() {
  7823. if (!this$1.composing) this$1.readFromDOMSoon();
  7824. });
  7825. function onCopyCut(e) {
  7826. if (!belongsToInput(e) || signalDOMEvent(cm, e)) return;
  7827. if (cm.somethingSelected()) {
  7828. setLastCopied({
  7829. lineWise: false,
  7830. text: cm.getSelections()
  7831. });
  7832. if (e.type == "cut") cm.replaceSelection("", null, "cut");
  7833. } else if (!cm.options.lineWiseCopyCut) return;
  7834. else {
  7835. var ranges = copyableRanges(cm);
  7836. setLastCopied({
  7837. lineWise: true,
  7838. text: ranges.text
  7839. });
  7840. if (e.type == "cut") cm.operation(function() {
  7841. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  7842. cm.replaceSelection("", null, "cut");
  7843. });
  7844. }
  7845. if (e.clipboardData) {
  7846. e.clipboardData.clearData();
  7847. var content = lastCopied.text.join("\n");
  7848. e.clipboardData.setData("Text", content);
  7849. if (e.clipboardData.getData("Text") == content) {
  7850. e.preventDefault();
  7851. return;
  7852. }
  7853. }
  7854. var kludge = hiddenTextarea(), te = kludge.firstChild;
  7855. disableBrowserMagic(te);
  7856. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  7857. te.value = lastCopied.text.join("\n");
  7858. var hadFocus = activeElt(rootNode(div));
  7859. selectInput(te);
  7860. setTimeout(function() {
  7861. cm.display.lineSpace.removeChild(kludge);
  7862. hadFocus.focus();
  7863. if (hadFocus == div) input.showPrimarySelection();
  7864. }, 50);
  7865. }
  7866. on(div, "copy", onCopyCut);
  7867. on(div, "cut", onCopyCut);
  7868. };
  7869. ContentEditableInput.prototype.screenReaderLabelChanged = function(label) {
  7870. if (label) this.div.setAttribute("aria-label", label);
  7871. else this.div.removeAttribute("aria-label");
  7872. };
  7873. ContentEditableInput.prototype.prepareSelection = function() {
  7874. var result = prepareSelection(this.cm, false);
  7875. result.focus = activeElt(rootNode(this.div)) == this.div;
  7876. return result;
  7877. };
  7878. ContentEditableInput.prototype.showSelection = function(info, takeFocus) {
  7879. if (!info || !this.cm.display.view.length) return;
  7880. if (info.focus || takeFocus) this.showPrimarySelection();
  7881. this.showMultipleSelections(info);
  7882. };
  7883. ContentEditableInput.prototype.getSelection = function() {
  7884. return this.cm.display.wrapper.ownerDocument.getSelection();
  7885. };
  7886. ContentEditableInput.prototype.showPrimarySelection = function() {
  7887. var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
  7888. var from = prim.from(), to = prim.to();
  7889. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  7890. sel.removeAllRanges();
  7891. return;
  7892. }
  7893. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  7894. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  7895. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && cmp(minPos(curAnchor, curFocus), from) == 0 && cmp(maxPos(curAnchor, curFocus), to) == 0) return;
  7896. var view = cm.display.view;
  7897. var start = from.line >= cm.display.viewFrom && posToDOM(cm, from) || {
  7898. node: view[0].measure.map[2],
  7899. offset: 0
  7900. };
  7901. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  7902. if (!end) {
  7903. var measure = view[view.length - 1].measure;
  7904. var map$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  7905. end = {
  7906. node: map$1[map$1.length - 1],
  7907. offset: map$1[map$1.length - 2] - map$1[map$1.length - 3]
  7908. };
  7909. }
  7910. if (!start || !end) {
  7911. sel.removeAllRanges();
  7912. return;
  7913. }
  7914. var old = sel.rangeCount && sel.getRangeAt(0), rng;
  7915. try {
  7916. rng = range(start.node, start.offset, end.offset, end.node);
  7917. } catch (e) {}
  7918. if (rng) {
  7919. if (!gecko && cm.state.focused) {
  7920. sel.collapse(start.node, start.offset);
  7921. if (!rng.collapsed) {
  7922. sel.removeAllRanges();
  7923. sel.addRange(rng);
  7924. }
  7925. } else {
  7926. sel.removeAllRanges();
  7927. sel.addRange(rng);
  7928. }
  7929. if (old && sel.anchorNode == null) sel.addRange(old);
  7930. else if (gecko) this.startGracePeriod();
  7931. }
  7932. this.rememberSelection();
  7933. };
  7934. ContentEditableInput.prototype.startGracePeriod = function() {
  7935. var this$1 = this;
  7936. clearTimeout(this.gracePeriod);
  7937. this.gracePeriod = setTimeout(function() {
  7938. this$1.gracePeriod = false;
  7939. if (this$1.selectionChanged()) this$1.cm.operation(function() {
  7940. return this$1.cm.curOp.selectionChanged = true;
  7941. });
  7942. }, 20);
  7943. };
  7944. ContentEditableInput.prototype.showMultipleSelections = function(info) {
  7945. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  7946. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  7947. };
  7948. ContentEditableInput.prototype.rememberSelection = function() {
  7949. var sel = this.getSelection();
  7950. this.lastAnchorNode = sel.anchorNode;
  7951. this.lastAnchorOffset = sel.anchorOffset;
  7952. this.lastFocusNode = sel.focusNode;
  7953. this.lastFocusOffset = sel.focusOffset;
  7954. };
  7955. ContentEditableInput.prototype.selectionInEditor = function() {
  7956. var sel = this.getSelection();
  7957. if (!sel.rangeCount) return false;
  7958. var node = sel.getRangeAt(0).commonAncestorContainer;
  7959. return contains(this.div, node);
  7960. };
  7961. ContentEditableInput.prototype.focus = function() {
  7962. if (this.cm.options.readOnly != "nocursor") {
  7963. if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div) this.showSelection(this.prepareSelection(), true);
  7964. this.div.focus();
  7965. }
  7966. };
  7967. ContentEditableInput.prototype.blur = function() {
  7968. this.div.blur();
  7969. };
  7970. ContentEditableInput.prototype.getField = function() {
  7971. return this.div;
  7972. };
  7973. ContentEditableInput.prototype.supportsTouch = function() {
  7974. return true;
  7975. };
  7976. ContentEditableInput.prototype.receivedFocus = function() {
  7977. var this$1 = this;
  7978. var input = this;
  7979. if (this.selectionInEditor()) setTimeout(function() {
  7980. return this$1.pollSelection();
  7981. }, 20);
  7982. else runInOp(this.cm, function() {
  7983. return input.cm.curOp.selectionChanged = true;
  7984. });
  7985. function poll() {
  7986. if (input.cm.state.focused) {
  7987. input.pollSelection();
  7988. input.polling.set(input.cm.options.pollInterval, poll);
  7989. }
  7990. }
  7991. this.polling.set(this.cm.options.pollInterval, poll);
  7992. };
  7993. ContentEditableInput.prototype.selectionChanged = function() {
  7994. var sel = this.getSelection();
  7995. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
  7996. };
  7997. ContentEditableInput.prototype.pollSelection = function() {
  7998. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) return;
  7999. var sel = this.getSelection(), cm = this.cm;
  8000. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {
  8001. this.cm.triggerOnKeyDown({
  8002. type: "keydown",
  8003. keyCode: 8,
  8004. preventDefault: Math.abs
  8005. });
  8006. this.blur();
  8007. this.focus();
  8008. return;
  8009. }
  8010. if (this.composing) return;
  8011. this.rememberSelection();
  8012. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  8013. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  8014. if (anchor && head) runInOp(cm, function() {
  8015. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  8016. if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
  8017. });
  8018. };
  8019. ContentEditableInput.prototype.pollContent = function() {
  8020. if (this.readDOMTimeout != null) {
  8021. clearTimeout(this.readDOMTimeout);
  8022. this.readDOMTimeout = null;
  8023. }
  8024. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
  8025. var from = sel.from(), to = sel.to();
  8026. if (from.ch == 0 && from.line > cm.firstLine()) from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length);
  8027. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) to = Pos(to.line + 1, 0);
  8028. if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
  8029. var fromIndex, fromLine, fromNode;
  8030. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  8031. fromLine = lineNo(display.view[0].line);
  8032. fromNode = display.view[0].node;
  8033. } else {
  8034. fromLine = lineNo(display.view[fromIndex].line);
  8035. fromNode = display.view[fromIndex - 1].node.nextSibling;
  8036. }
  8037. var toIndex = findViewIndex(cm, to.line);
  8038. var toLine, toNode;
  8039. if (toIndex == display.view.length - 1) {
  8040. toLine = display.viewTo - 1;
  8041. toNode = display.lineDiv.lastChild;
  8042. } else {
  8043. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  8044. toNode = display.view[toIndex + 1].node.previousSibling;
  8045. }
  8046. if (!fromNode) return false;
  8047. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  8048. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  8049. while (newText.length > 1 && oldText.length > 1) if (lst(newText) == lst(oldText)) {
  8050. newText.pop();
  8051. oldText.pop();
  8052. toLine--;
  8053. } else if (newText[0] == oldText[0]) {
  8054. newText.shift();
  8055. oldText.shift();
  8056. fromLine++;
  8057. } else break;
  8058. var cutFront = 0, cutEnd = 0;
  8059. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
  8060. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) ++cutFront;
  8061. var newBot = lst(newText), oldBot = lst(oldText);
  8062. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), oldBot.length - (oldText.length == 1 ? cutFront : 0));
  8063. while (cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) ++cutEnd;
  8064. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) while (cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  8065. cutFront--;
  8066. cutEnd++;
  8067. }
  8068. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  8069. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  8070. var chFrom = Pos(fromLine, cutFront);
  8071. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  8072. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  8073. replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  8074. return true;
  8075. }
  8076. };
  8077. ContentEditableInput.prototype.ensurePolled = function() {
  8078. this.forceCompositionEnd();
  8079. };
  8080. ContentEditableInput.prototype.reset = function() {
  8081. this.forceCompositionEnd();
  8082. };
  8083. ContentEditableInput.prototype.forceCompositionEnd = function() {
  8084. if (!this.composing) return;
  8085. clearTimeout(this.readDOMTimeout);
  8086. this.composing = null;
  8087. this.updateFromDOM();
  8088. this.div.blur();
  8089. this.div.focus();
  8090. };
  8091. ContentEditableInput.prototype.readFromDOMSoon = function() {
  8092. var this$1 = this;
  8093. if (this.readDOMTimeout != null) return;
  8094. this.readDOMTimeout = setTimeout(function() {
  8095. this$1.readDOMTimeout = null;
  8096. if (this$1.composing) if (this$1.composing.done) this$1.composing = null;
  8097. else return;
  8098. this$1.updateFromDOM();
  8099. }, 80);
  8100. };
  8101. ContentEditableInput.prototype.updateFromDOM = function() {
  8102. var this$1 = this;
  8103. if (this.cm.isReadOnly() || !this.pollContent()) runInOp(this.cm, function() {
  8104. return regChange(this$1.cm);
  8105. });
  8106. };
  8107. ContentEditableInput.prototype.setUneditable = function(node) {
  8108. node.contentEditable = "false";
  8109. };
  8110. ContentEditableInput.prototype.onKeyPress = function(e) {
  8111. if (e.charCode == 0 || this.composing) return;
  8112. e.preventDefault();
  8113. if (!this.cm.isReadOnly()) operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
  8114. };
  8115. ContentEditableInput.prototype.readOnlyChanged = function(val) {
  8116. this.div.contentEditable = String(val != "nocursor");
  8117. };
  8118. ContentEditableInput.prototype.onContextMenu = function() {};
  8119. ContentEditableInput.prototype.resetPosition = function() {};
  8120. ContentEditableInput.prototype.needsContentAttribute = true;
  8121. function posToDOM(cm, pos) {
  8122. var view = findViewForLine(cm, pos.line);
  8123. if (!view || view.hidden) return null;
  8124. var line = getLine(cm.doc, pos.line);
  8125. var info = mapFromLineView(view, line, pos.line);
  8126. var order = getOrder(line, cm.doc.direction), side = "left";
  8127. if (order) {
  8128. var partPos = getBidiPartAt(order, pos.ch);
  8129. side = partPos % 2 ? "right" : "left";
  8130. }
  8131. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  8132. result.offset = result.collapse == "right" ? result.end : result.start;
  8133. return result;
  8134. }
  8135. function isInGutter(node) {
  8136. for (var scan = node; scan; scan = scan.parentNode) if (/CodeMirror-gutter-wrapper/.test(scan.className)) return true;
  8137. return false;
  8138. }
  8139. function badPos(pos, bad) {
  8140. if (bad) pos.bad = true;
  8141. return pos;
  8142. }
  8143. function domTextBetween(cm, from, to, fromLine, toLine) {
  8144. var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false;
  8145. function recognizeMarker(id) {
  8146. return function(marker) {
  8147. return marker.id == id;
  8148. };
  8149. }
  8150. function close() {
  8151. if (closing) {
  8152. text += lineSep;
  8153. if (extraLinebreak) text += lineSep;
  8154. closing = extraLinebreak = false;
  8155. }
  8156. }
  8157. function addText(str) {
  8158. if (str) {
  8159. close();
  8160. text += str;
  8161. }
  8162. }
  8163. function walk(node) {
  8164. if (node.nodeType == 1) {
  8165. var cmText = node.getAttribute("cm-text");
  8166. if (cmText) {
  8167. addText(cmText);
  8168. return;
  8169. }
  8170. var markerID = node.getAttribute("cm-marker"), range$1;
  8171. if (markerID) {
  8172. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  8173. if (found.length && (range$1 = found[0].find(0))) addText(getBetween(cm.doc, range$1.from, range$1.to).join(lineSep));
  8174. return;
  8175. }
  8176. if (node.getAttribute("contenteditable") == "false") return;
  8177. var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);
  8178. if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) return;
  8179. if (isBlock) close();
  8180. for (var i$3 = 0; i$3 < node.childNodes.length; i$3++) walk(node.childNodes[i$3]);
  8181. if (/^(pre|p)$/i.test(node.nodeName)) extraLinebreak = true;
  8182. if (isBlock) closing = true;
  8183. } else if (node.nodeType == 3) addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
  8184. }
  8185. for (;;) {
  8186. walk(from);
  8187. if (from == to) break;
  8188. from = from.nextSibling;
  8189. extraLinebreak = false;
  8190. }
  8191. return text;
  8192. }
  8193. function domToPos(cm, node, offset) {
  8194. var lineNode;
  8195. if (node == cm.display.lineDiv) {
  8196. lineNode = cm.display.lineDiv.childNodes[offset];
  8197. if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
  8198. node = null;
  8199. offset = 0;
  8200. } else for (lineNode = node;; lineNode = lineNode.parentNode) {
  8201. if (!lineNode || lineNode == cm.display.lineDiv) return null;
  8202. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
  8203. }
  8204. for (var i$3 = 0; i$3 < cm.display.view.length; i$3++) {
  8205. var lineView = cm.display.view[i$3];
  8206. if (lineView.node == lineNode) return locateNodeInLineView(lineView, node, offset);
  8207. }
  8208. }
  8209. function locateNodeInLineView(lineView, node, offset) {
  8210. var wrapper = lineView.text.firstChild, bad = false;
  8211. if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
  8212. if (node == wrapper) {
  8213. bad = true;
  8214. node = wrapper.childNodes[offset];
  8215. offset = 0;
  8216. if (!node) {
  8217. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  8218. return badPos(Pos(lineNo(line), line.text.length), bad);
  8219. }
  8220. }
  8221. var textNode = node.nodeType == 3 ? node : null, topNode = node;
  8222. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  8223. textNode = node.firstChild;
  8224. if (offset) offset = textNode.nodeValue.length;
  8225. }
  8226. while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
  8227. var measure = lineView.measure, maps = measure.maps;
  8228. function find(textNode$1, topNode$1, offset$1) {
  8229. for (var i$3 = -1; i$3 < (maps ? maps.length : 0); i$3++) {
  8230. var map$1 = i$3 < 0 ? measure.map : maps[i$3];
  8231. for (var j = 0; j < map$1.length; j += 3) {
  8232. var curNode = map$1[j + 2];
  8233. if (curNode == textNode$1 || curNode == topNode$1) {
  8234. var line$1 = lineNo(i$3 < 0 ? lineView.line : lineView.rest[i$3]);
  8235. var ch = map$1[j] + offset$1;
  8236. if (offset$1 < 0 || curNode != textNode$1) ch = map$1[j + (offset$1 ? 1 : 0)];
  8237. return Pos(line$1, ch);
  8238. }
  8239. }
  8240. }
  8241. }
  8242. var found = find(textNode, topNode, offset);
  8243. if (found) return badPos(found, bad);
  8244. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  8245. found = find(after, after.firstChild, 0);
  8246. if (found) return badPos(Pos(found.line, found.ch - dist), bad);
  8247. else dist += after.textContent.length;
  8248. }
  8249. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  8250. found = find(before, before.firstChild, -1);
  8251. if (found) return badPos(Pos(found.line, found.ch + dist$1), bad);
  8252. else dist$1 += before.textContent.length;
  8253. }
  8254. }
  8255. var TextareaInput = function(cm) {
  8256. this.cm = cm;
  8257. this.prevInput = "";
  8258. this.pollingFast = false;
  8259. this.polling = new Delayed();
  8260. this.hasSelection = false;
  8261. this.composing = null;
  8262. this.resetting = false;
  8263. };
  8264. TextareaInput.prototype.init = function(display) {
  8265. var this$1 = this;
  8266. var input = this, cm = this.cm;
  8267. this.createField(display);
  8268. var te = this.textarea;
  8269. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  8270. if (ios) te.style.width = "0px";
  8271. on(te, "input", function() {
  8272. if (ie && ie_version >= 9 && this$1.hasSelection) this$1.hasSelection = null;
  8273. input.poll();
  8274. });
  8275. on(te, "paste", function(e) {
  8276. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return;
  8277. cm.state.pasteIncoming = +new Date();
  8278. input.fastPoll();
  8279. });
  8280. function prepareCopyCut(e) {
  8281. if (signalDOMEvent(cm, e)) return;
  8282. if (cm.somethingSelected()) setLastCopied({
  8283. lineWise: false,
  8284. text: cm.getSelections()
  8285. });
  8286. else if (!cm.options.lineWiseCopyCut) return;
  8287. else {
  8288. var ranges = copyableRanges(cm);
  8289. setLastCopied({
  8290. lineWise: true,
  8291. text: ranges.text
  8292. });
  8293. if (e.type == "cut") cm.setSelections(ranges.ranges, null, sel_dontScroll);
  8294. else {
  8295. input.prevInput = "";
  8296. te.value = ranges.text.join("\n");
  8297. selectInput(te);
  8298. }
  8299. }
  8300. if (e.type == "cut") cm.state.cutIncoming = +new Date();
  8301. }
  8302. on(te, "cut", prepareCopyCut);
  8303. on(te, "copy", prepareCopyCut);
  8304. on(display.scroller, "paste", function(e) {
  8305. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
  8306. if (!te.dispatchEvent) {
  8307. cm.state.pasteIncoming = +new Date();
  8308. input.focus();
  8309. return;
  8310. }
  8311. var event = new Event("paste");
  8312. event.clipboardData = e.clipboardData;
  8313. te.dispatchEvent(event);
  8314. });
  8315. on(display.lineSpace, "selectstart", function(e) {
  8316. if (!eventInWidget(display, e)) e_preventDefault(e);
  8317. });
  8318. on(te, "compositionstart", function() {
  8319. var start = cm.getCursor("from");
  8320. if (input.composing) input.composing.range.clear();
  8321. input.composing = {
  8322. start,
  8323. range: cm.markText(start, cm.getCursor("to"), { className: "CodeMirror-composing" })
  8324. };
  8325. });
  8326. on(te, "compositionend", function() {
  8327. if (input.composing) {
  8328. input.poll();
  8329. input.composing.range.clear();
  8330. input.composing = null;
  8331. }
  8332. });
  8333. };
  8334. TextareaInput.prototype.createField = function(_display) {
  8335. this.wrapper = hiddenTextarea();
  8336. this.textarea = this.wrapper.firstChild;
  8337. var opts = this.cm.options;
  8338. disableBrowserMagic(this.textarea, opts.spellcheck, opts.autocorrect, opts.autocapitalize);
  8339. };
  8340. TextareaInput.prototype.screenReaderLabelChanged = function(label) {
  8341. if (label) this.textarea.setAttribute("aria-label", label);
  8342. else this.textarea.removeAttribute("aria-label");
  8343. };
  8344. TextareaInput.prototype.prepareSelection = function() {
  8345. var cm = this.cm, display = cm.display, doc$1 = cm.doc;
  8346. var result = prepareSelection(cm);
  8347. if (cm.options.moveInputWithCursor) {
  8348. var headPos = cursorCoords(cm, doc$1.sel.primary().head, "div");
  8349. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
  8350. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top));
  8351. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left));
  8352. }
  8353. return result;
  8354. };
  8355. TextareaInput.prototype.showSelection = function(drawn) {
  8356. var cm = this.cm, display = cm.display;
  8357. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  8358. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  8359. if (drawn.teTop != null) {
  8360. this.wrapper.style.top = drawn.teTop + "px";
  8361. this.wrapper.style.left = drawn.teLeft + "px";
  8362. }
  8363. };
  8364. TextareaInput.prototype.reset = function(typing) {
  8365. if (this.contextMenuPending || this.composing && typing) return;
  8366. var cm = this.cm;
  8367. this.resetting = true;
  8368. if (cm.somethingSelected()) {
  8369. this.prevInput = "";
  8370. var content = cm.getSelection();
  8371. this.textarea.value = content;
  8372. if (cm.state.focused) selectInput(this.textarea);
  8373. if (ie && ie_version >= 9) this.hasSelection = content;
  8374. } else if (!typing) {
  8375. this.prevInput = this.textarea.value = "";
  8376. if (ie && ie_version >= 9) this.hasSelection = null;
  8377. }
  8378. this.resetting = false;
  8379. };
  8380. TextareaInput.prototype.getField = function() {
  8381. return this.textarea;
  8382. };
  8383. TextareaInput.prototype.supportsTouch = function() {
  8384. return false;
  8385. };
  8386. TextareaInput.prototype.focus = function() {
  8387. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) try {
  8388. this.textarea.focus();
  8389. } catch (e) {}
  8390. };
  8391. TextareaInput.prototype.blur = function() {
  8392. this.textarea.blur();
  8393. };
  8394. TextareaInput.prototype.resetPosition = function() {
  8395. this.wrapper.style.top = this.wrapper.style.left = 0;
  8396. };
  8397. TextareaInput.prototype.receivedFocus = function() {
  8398. this.slowPoll();
  8399. };
  8400. TextareaInput.prototype.slowPoll = function() {
  8401. var this$1 = this;
  8402. if (this.pollingFast) return;
  8403. this.polling.set(this.cm.options.pollInterval, function() {
  8404. this$1.poll();
  8405. if (this$1.cm.state.focused) this$1.slowPoll();
  8406. });
  8407. };
  8408. TextareaInput.prototype.fastPoll = function() {
  8409. var missed = false, input = this;
  8410. input.pollingFast = true;
  8411. function p() {
  8412. var changed = input.poll();
  8413. if (!changed && !missed) {
  8414. missed = true;
  8415. input.polling.set(60, p);
  8416. } else {
  8417. input.pollingFast = false;
  8418. input.slowPoll();
  8419. }
  8420. }
  8421. input.polling.set(20, p);
  8422. };
  8423. TextareaInput.prototype.poll = function() {
  8424. var this$1 = this;
  8425. var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
  8426. if (this.contextMenuPending || this.resetting || !cm.state.focused || hasSelection(input) && !prevInput && !this.composing || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) return false;
  8427. var text = input.value;
  8428. if (text == prevInput && !cm.somethingSelected()) return false;
  8429. if (ie && ie_version >= 9 && this.hasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) {
  8430. cm.display.input.reset();
  8431. return false;
  8432. }
  8433. if (cm.doc.sel == cm.display.selForContextMenu) {
  8434. var first = text.charCodeAt(0);
  8435. if (first == 8203 && !prevInput) prevInput = "​";
  8436. if (first == 8666) {
  8437. this.reset();
  8438. return this.cm.execCommand("undo");
  8439. }
  8440. }
  8441. var same = 0, l = Math.min(prevInput.length, text.length);
  8442. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
  8443. runInOp(cm, function() {
  8444. applyTextInput(cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null);
  8445. if (text.length > 1e3 || text.indexOf("\n") > -1) input.value = this$1.prevInput = "";
  8446. else this$1.prevInput = text;
  8447. if (this$1.composing) {
  8448. this$1.composing.range.clear();
  8449. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), { className: "CodeMirror-composing" });
  8450. }
  8451. });
  8452. return true;
  8453. };
  8454. TextareaInput.prototype.ensurePolled = function() {
  8455. if (this.pollingFast && this.poll()) this.pollingFast = false;
  8456. };
  8457. TextareaInput.prototype.onKeyPress = function() {
  8458. if (ie && ie_version >= 9) this.hasSelection = null;
  8459. this.fastPoll();
  8460. };
  8461. TextareaInput.prototype.onContextMenu = function(e) {
  8462. var input = this, cm = input.cm, display = cm.display, te = input.textarea;
  8463. if (input.contextMenuPending) input.contextMenuPending();
  8464. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
  8465. if (!pos || presto) return;
  8466. var reset = cm.options.resetSelectionOnContextMenu;
  8467. if (reset && cm.doc.sel.contains(pos) == -1) operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
  8468. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
  8469. var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();
  8470. input.wrapper.style.cssText = "position: static";
  8471. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
  8472. var oldScrollY;
  8473. if (webkit) oldScrollY = te.ownerDocument.defaultView.scrollY;
  8474. display.input.focus();
  8475. if (webkit) te.ownerDocument.defaultView.scrollTo(null, oldScrollY);
  8476. display.input.reset();
  8477. if (!cm.somethingSelected()) te.value = input.prevInput = " ";
  8478. input.contextMenuPending = rehide;
  8479. display.selForContextMenu = cm.doc.sel;
  8480. clearTimeout(display.detectingSelectAll);
  8481. function prepareSelectAllHack() {
  8482. if (te.selectionStart != null) {
  8483. var selected = cm.somethingSelected();
  8484. var extval = "​" + (selected ? te.value : "");
  8485. te.value = "⇚";
  8486. te.value = extval;
  8487. input.prevInput = selected ? "" : "​";
  8488. te.selectionStart = 1;
  8489. te.selectionEnd = extval.length;
  8490. display.selForContextMenu = cm.doc.sel;
  8491. }
  8492. }
  8493. function rehide() {
  8494. if (input.contextMenuPending != rehide) return;
  8495. input.contextMenuPending = false;
  8496. input.wrapper.style.cssText = oldWrapperCSS;
  8497. te.style.cssText = oldCSS;
  8498. if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
  8499. if (te.selectionStart != null) {
  8500. if (!ie || ie && ie_version < 9) prepareSelectAllHack();
  8501. var i$3 = 0, poll = function() {
  8502. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && te.selectionEnd > 0 && input.prevInput == "​") operation(cm, selectAll)(cm);
  8503. else if (i$3++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
  8504. else {
  8505. display.selForContextMenu = null;
  8506. display.input.reset();
  8507. }
  8508. };
  8509. display.detectingSelectAll = setTimeout(poll, 200);
  8510. }
  8511. }
  8512. if (ie && ie_version >= 9) prepareSelectAllHack();
  8513. if (captureRightClick) {
  8514. e_stop(e);
  8515. var mouseup = function() {
  8516. off(window, "mouseup", mouseup);
  8517. setTimeout(rehide, 20);
  8518. };
  8519. on(window, "mouseup", mouseup);
  8520. } else setTimeout(rehide, 50);
  8521. };
  8522. TextareaInput.prototype.readOnlyChanged = function(val) {
  8523. if (!val) this.reset();
  8524. this.textarea.disabled = val == "nocursor";
  8525. this.textarea.readOnly = !!val;
  8526. };
  8527. TextareaInput.prototype.setUneditable = function() {};
  8528. TextareaInput.prototype.needsContentAttribute = false;
  8529. function fromTextArea(textarea, options) {
  8530. options = options ? copyObj(options) : {};
  8531. options.value = textarea.value;
  8532. if (!options.tabindex && textarea.tabIndex) options.tabindex = textarea.tabIndex;
  8533. if (!options.placeholder && textarea.placeholder) options.placeholder = textarea.placeholder;
  8534. if (options.autofocus == null) {
  8535. var hasFocus = activeElt(rootNode(textarea));
  8536. options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  8537. }
  8538. function save() {
  8539. textarea.value = cm.getValue();
  8540. }
  8541. var realSubmit;
  8542. if (textarea.form) {
  8543. on(textarea.form, "submit", save);
  8544. if (!options.leaveSubmitMethodAlone) {
  8545. var form = textarea.form;
  8546. realSubmit = form.submit;
  8547. try {
  8548. var wrappedSubmit = form.submit = function() {
  8549. save();
  8550. form.submit = realSubmit;
  8551. form.submit();
  8552. form.submit = wrappedSubmit;
  8553. };
  8554. } catch (e) {}
  8555. }
  8556. }
  8557. options.finishInit = function(cm$1) {
  8558. cm$1.save = save;
  8559. cm$1.getTextArea = function() {
  8560. return textarea;
  8561. };
  8562. cm$1.toTextArea = function() {
  8563. cm$1.toTextArea = isNaN;
  8564. save();
  8565. textarea.parentNode.removeChild(cm$1.getWrapperElement());
  8566. textarea.style.display = "";
  8567. if (textarea.form) {
  8568. off(textarea.form, "submit", save);
  8569. if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function") textarea.form.submit = realSubmit;
  8570. }
  8571. };
  8572. };
  8573. textarea.style.display = "none";
  8574. var cm = CodeMirror$1(function(node) {
  8575. return textarea.parentNode.insertBefore(node, textarea.nextSibling);
  8576. }, options);
  8577. return cm;
  8578. }
  8579. function addLegacyProps(CodeMirror$2) {
  8580. CodeMirror$2.off = off;
  8581. CodeMirror$2.on = on;
  8582. CodeMirror$2.wheelEventPixels = wheelEventPixels;
  8583. CodeMirror$2.Doc = Doc;
  8584. CodeMirror$2.splitLines = splitLinesAuto;
  8585. CodeMirror$2.countColumn = countColumn;
  8586. CodeMirror$2.findColumn = findColumn;
  8587. CodeMirror$2.isWordChar = isWordCharBasic;
  8588. CodeMirror$2.Pass = Pass;
  8589. CodeMirror$2.signal = signal;
  8590. CodeMirror$2.Line = Line;
  8591. CodeMirror$2.changeEnd = changeEnd;
  8592. CodeMirror$2.scrollbarModel = scrollbarModel;
  8593. CodeMirror$2.Pos = Pos;
  8594. CodeMirror$2.cmpPos = cmp;
  8595. CodeMirror$2.modes = modes;
  8596. CodeMirror$2.mimeModes = mimeModes;
  8597. CodeMirror$2.resolveMode = resolveMode;
  8598. CodeMirror$2.getMode = getMode;
  8599. CodeMirror$2.modeExtensions = modeExtensions;
  8600. CodeMirror$2.extendMode = extendMode;
  8601. CodeMirror$2.copyState = copyState;
  8602. CodeMirror$2.startState = startState;
  8603. CodeMirror$2.innerMode = innerMode;
  8604. CodeMirror$2.commands = commands;
  8605. CodeMirror$2.keyMap = keyMap;
  8606. CodeMirror$2.keyName = keyName;
  8607. CodeMirror$2.isModifierKey = isModifierKey;
  8608. CodeMirror$2.lookupKey = lookupKey;
  8609. CodeMirror$2.normalizeKeyMap = normalizeKeyMap;
  8610. CodeMirror$2.StringStream = StringStream;
  8611. CodeMirror$2.SharedTextMarker = SharedTextMarker;
  8612. CodeMirror$2.TextMarker = TextMarker;
  8613. CodeMirror$2.LineWidget = LineWidget;
  8614. CodeMirror$2.e_preventDefault = e_preventDefault;
  8615. CodeMirror$2.e_stopPropagation = e_stopPropagation;
  8616. CodeMirror$2.e_stop = e_stop;
  8617. CodeMirror$2.addClass = addClass;
  8618. CodeMirror$2.contains = contains;
  8619. CodeMirror$2.rmClass = rmClass;
  8620. CodeMirror$2.keyNames = keyNames;
  8621. }
  8622. defineOptions(CodeMirror$1);
  8623. addEditorMethods(CodeMirror$1);
  8624. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  8625. for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) CodeMirror$1.prototype[prop] = function(method) {
  8626. return function() {
  8627. return method.apply(this.doc, arguments);
  8628. };
  8629. }(Doc.prototype[prop]);
  8630. eventMixin(Doc);
  8631. CodeMirror$1.inputStyles = {
  8632. "textarea": TextareaInput,
  8633. "contenteditable": ContentEditableInput
  8634. };
  8635. CodeMirror$1.defineMode = function(name) {
  8636. if (!CodeMirror$1.defaults.mode && name != "null") CodeMirror$1.defaults.mode = name;
  8637. defineMode.apply(this, arguments);
  8638. };
  8639. CodeMirror$1.defineMIME = defineMIME;
  8640. CodeMirror$1.defineMode("null", function() {
  8641. return { token: function(stream) {
  8642. return stream.skipToEnd();
  8643. } };
  8644. });
  8645. CodeMirror$1.defineMIME("text/plain", "null");
  8646. CodeMirror$1.defineExtension = function(name, func) {
  8647. CodeMirror$1.prototype[name] = func;
  8648. };
  8649. CodeMirror$1.defineDocExtension = function(name, func) {
  8650. Doc.prototype[name] = func;
  8651. };
  8652. CodeMirror$1.fromTextArea = fromTextArea;
  8653. addLegacyProps(CodeMirror$1);
  8654. CodeMirror$1.version = "5.65.18";
  8655. return CodeMirror$1;
  8656. });
  8657. });
  8658. var import_codemirror = __toESM(require_codemirror());
  8659. var require_dialog = __commonJSMin((exports, module) => {
  8660. (function(mod) {
  8661. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  8662. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  8663. else mod(CodeMirror);
  8664. })(function(CodeMirror$1) {
  8665. function dialogDiv(cm, template, bottom) {
  8666. var wrap$1 = cm.getWrapperElement();
  8667. var dialog;
  8668. dialog = wrap$1.appendChild(document.createElement("div"));
  8669. if (bottom) dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
  8670. else dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
  8671. if (typeof template == "string") dialog.innerHTML = template;
  8672. else dialog.appendChild(template);
  8673. CodeMirror$1.addClass(wrap$1, "dialog-opened");
  8674. return dialog;
  8675. }
  8676. function closeNotification(cm, newVal) {
  8677. if (cm.state.currentNotificationClose) cm.state.currentNotificationClose();
  8678. cm.state.currentNotificationClose = newVal;
  8679. }
  8680. CodeMirror$1.defineExtension("openDialog", function(template, callback, options) {
  8681. if (!options) options = {};
  8682. closeNotification(this, null);
  8683. var dialog = dialogDiv(this, template, options.bottom);
  8684. var closed = false, me = this;
  8685. function close(newVal) {
  8686. if (typeof newVal == "string") inp.value = newVal;
  8687. else {
  8688. if (closed) return;
  8689. closed = true;
  8690. CodeMirror$1.rmClass(dialog.parentNode, "dialog-opened");
  8691. dialog.parentNode.removeChild(dialog);
  8692. me.focus();
  8693. if (options.onClose) options.onClose(dialog);
  8694. }
  8695. }
  8696. var inp = dialog.getElementsByTagName("input")[0], button;
  8697. if (inp) {
  8698. inp.focus();
  8699. if (options.value) {
  8700. inp.value = options.value;
  8701. if (options.selectValueOnOpen !== false) inp.select();
  8702. }
  8703. if (options.onInput) CodeMirror$1.on(inp, "input", function(e) {
  8704. options.onInput(e, inp.value, close);
  8705. });
  8706. if (options.onKeyUp) CodeMirror$1.on(inp, "keyup", function(e) {
  8707. options.onKeyUp(e, inp.value, close);
  8708. });
  8709. CodeMirror$1.on(inp, "keydown", function(e) {
  8710. if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) return;
  8711. if (e.keyCode == 27 || options.closeOnEnter !== false && e.keyCode == 13) {
  8712. inp.blur();
  8713. CodeMirror$1.e_stop(e);
  8714. close();
  8715. }
  8716. if (e.keyCode == 13) callback(inp.value, e);
  8717. });
  8718. if (options.closeOnBlur !== false) CodeMirror$1.on(dialog, "focusout", function(evt) {
  8719. if (evt.relatedTarget !== null) close();
  8720. });
  8721. } else if (button = dialog.getElementsByTagName("button")[0]) {
  8722. CodeMirror$1.on(button, "click", function() {
  8723. close();
  8724. me.focus();
  8725. });
  8726. if (options.closeOnBlur !== false) CodeMirror$1.on(button, "blur", close);
  8727. button.focus();
  8728. }
  8729. return close;
  8730. });
  8731. CodeMirror$1.defineExtension("openConfirm", function(template, callbacks, options) {
  8732. closeNotification(this, null);
  8733. var dialog = dialogDiv(this, template, options && options.bottom);
  8734. var buttons = dialog.getElementsByTagName("button");
  8735. var closed = false, me = this, blurring = 1;
  8736. function close() {
  8737. if (closed) return;
  8738. closed = true;
  8739. CodeMirror$1.rmClass(dialog.parentNode, "dialog-opened");
  8740. dialog.parentNode.removeChild(dialog);
  8741. me.focus();
  8742. }
  8743. buttons[0].focus();
  8744. for (var i = 0; i < buttons.length; ++i) {
  8745. var b = buttons[i];
  8746. (function(callback) {
  8747. CodeMirror$1.on(b, "click", function(e) {
  8748. CodeMirror$1.e_preventDefault(e);
  8749. close();
  8750. if (callback) callback(me);
  8751. });
  8752. })(callbacks[i]);
  8753. CodeMirror$1.on(b, "blur", function() {
  8754. --blurring;
  8755. setTimeout(function() {
  8756. if (blurring <= 0) close();
  8757. }, 200);
  8758. });
  8759. CodeMirror$1.on(b, "focus", function() {
  8760. ++blurring;
  8761. });
  8762. }
  8763. });
  8764. CodeMirror$1.defineExtension("openNotification", function(template, options) {
  8765. closeNotification(this, close);
  8766. var dialog = dialogDiv(this, template, options && options.bottom);
  8767. var closed = false, doneTimer;
  8768. var duration = options && typeof options.duration !== "undefined" ? options.duration : 5e3;
  8769. function close() {
  8770. if (closed) return;
  8771. closed = true;
  8772. clearTimeout(doneTimer);
  8773. CodeMirror$1.rmClass(dialog.parentNode, "dialog-opened");
  8774. dialog.parentNode.removeChild(dialog);
  8775. }
  8776. CodeMirror$1.on(dialog, "click", function(e) {
  8777. CodeMirror$1.e_preventDefault(e);
  8778. close();
  8779. });
  8780. if (duration) doneTimer = setTimeout(close, duration);
  8781. return close;
  8782. });
  8783. });
  8784. });
  8785. var require_placeholder = __commonJSMin((exports, module) => {
  8786. (function(mod) {
  8787. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  8788. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  8789. else mod(CodeMirror);
  8790. })(function(CodeMirror$1) {
  8791. CodeMirror$1.defineOption("placeholder", "", function(cm, val, old) {
  8792. var prev = old && old != CodeMirror$1.Init;
  8793. if (val && !prev) {
  8794. cm.on("blur", onBlur);
  8795. cm.on("change", onChange);
  8796. cm.on("swapDoc", onChange);
  8797. CodeMirror$1.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() {
  8798. onComposition(cm);
  8799. });
  8800. onChange(cm);
  8801. } else if (!val && prev) {
  8802. cm.off("blur", onBlur);
  8803. cm.off("change", onChange);
  8804. cm.off("swapDoc", onChange);
  8805. CodeMirror$1.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose);
  8806. clearPlaceholder(cm);
  8807. var wrapper = cm.getWrapperElement();
  8808. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
  8809. }
  8810. if (val && !cm.hasFocus()) onBlur(cm);
  8811. });
  8812. function clearPlaceholder(cm) {
  8813. if (cm.state.placeholder) {
  8814. cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
  8815. cm.state.placeholder = null;
  8816. }
  8817. }
  8818. function setPlaceholder(cm) {
  8819. clearPlaceholder(cm);
  8820. var elt = cm.state.placeholder = document.createElement("pre");
  8821. elt.style.cssText = "height: 0; overflow: visible";
  8822. elt.style.direction = cm.getOption("direction");
  8823. elt.className = "CodeMirror-placeholder CodeMirror-line-like";
  8824. var placeHolder = cm.getOption("placeholder");
  8825. if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder);
  8826. elt.appendChild(placeHolder);
  8827. cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
  8828. }
  8829. function onComposition(cm) {
  8830. setTimeout(function() {
  8831. var empty = false;
  8832. if (cm.lineCount() == 1) {
  8833. var input = cm.getInputField();
  8834. empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length : !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent);
  8835. }
  8836. if (empty) setPlaceholder(cm);
  8837. else clearPlaceholder(cm);
  8838. }, 20);
  8839. }
  8840. function onBlur(cm) {
  8841. if (isEmpty(cm)) setPlaceholder(cm);
  8842. }
  8843. function onChange(cm) {
  8844. var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
  8845. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
  8846. if (empty) setPlaceholder(cm);
  8847. else clearPlaceholder(cm);
  8848. }
  8849. function isEmpty(cm) {
  8850. return cm.lineCount() === 1 && cm.getLine(0) === "";
  8851. }
  8852. });
  8853. });
  8854. var require_jump_to_line = __commonJSMin((exports, module) => {
  8855. (function(mod) {
  8856. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_dialog());
  8857. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror", "../dialog/dialog"], mod);
  8858. else mod(CodeMirror);
  8859. })(function(CodeMirror$1) {
  8860. "use strict";
  8861. CodeMirror$1.defineOption("search", { bottom: false });
  8862. function dialog(cm, text, shortText, deflt, f) {
  8863. if (cm.openDialog) cm.openDialog(text, f, {
  8864. value: deflt,
  8865. selectValueOnOpen: true,
  8866. bottom: cm.options.search.bottom
  8867. });
  8868. else f(prompt(shortText, deflt));
  8869. }
  8870. function getJumpDialog(cm) {
  8871. return cm.phrase("Jump to line:") + " <input type=\"text\" style=\"width: 10em\" class=\"CodeMirror-search-field\"/> <span style=\"color: #888\" class=\"CodeMirror-search-hint\">" + cm.phrase("(Use line:column or scroll% syntax)") + "</span>";
  8872. }
  8873. function interpretLine(cm, string) {
  8874. var num = Number(string);
  8875. if (/^[-+]/.test(string)) return cm.getCursor().line + num;
  8876. else return num - 1;
  8877. }
  8878. CodeMirror$1.commands.jumpToLine = function(cm) {
  8879. var cur = cm.getCursor();
  8880. dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), cur.line + 1 + ":" + cur.ch, function(posStr) {
  8881. if (!posStr) return;
  8882. var match;
  8883. if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) cm.setCursor(interpretLine(cm, match[1]), Number(match[2]));
  8884. else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
  8885. var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
  8886. if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
  8887. cm.setCursor(line - 1, cur.ch);
  8888. } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) cm.setCursor(interpretLine(cm, match[1]), cur.ch);
  8889. });
  8890. };
  8891. CodeMirror$1.keyMap["default"]["Alt-G"] = "jumpToLine";
  8892. });
  8893. });
  8894. var require_searchcursor = __commonJSMin((exports, module) => {
  8895. (function(mod) {
  8896. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  8897. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  8898. else mod(CodeMirror);
  8899. })(function(CodeMirror$1) {
  8900. "use strict";
  8901. var Pos = CodeMirror$1.Pos;
  8902. function regexpFlags(regexp) {
  8903. var flags = regexp.flags;
  8904. return flags != null ? flags : (regexp.ignoreCase ? "i" : "") + (regexp.global ? "g" : "") + (regexp.multiline ? "m" : "");
  8905. }
  8906. function ensureFlags(regexp, flags) {
  8907. var current = regexpFlags(regexp), target = current;
  8908. for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1) target += flags.charAt(i);
  8909. return current == target ? regexp : new RegExp(regexp.source, target);
  8910. }
  8911. function maybeMultiline(regexp) {
  8912. return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source);
  8913. }
  8914. function searchRegexpForward(doc, regexp, start) {
  8915. regexp = ensureFlags(regexp, "g");
  8916. for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) {
  8917. regexp.lastIndex = ch;
  8918. var string = doc.getLine(line), match = regexp.exec(string);
  8919. if (match) return {
  8920. from: Pos(line, match.index),
  8921. to: Pos(line, match.index + match[0].length),
  8922. match
  8923. };
  8924. }
  8925. }
  8926. function searchRegexpForwardMultiline(doc, regexp, start) {
  8927. if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start);
  8928. regexp = ensureFlags(regexp, "gm");
  8929. var string, chunk = 1;
  8930. for (var line = start.line, last = doc.lastLine(); line <= last;) {
  8931. for (var i = 0; i < chunk; i++) {
  8932. if (line > last) break;
  8933. var curLine = doc.getLine(line++);
  8934. string = string == null ? curLine : string + "\n" + curLine;
  8935. }
  8936. chunk = chunk * 2;
  8937. regexp.lastIndex = start.ch;
  8938. var match = regexp.exec(string);
  8939. if (match) {
  8940. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n");
  8941. var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length;
  8942. return {
  8943. from: Pos(startLine, startCh),
  8944. to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  8945. match
  8946. };
  8947. }
  8948. }
  8949. }
  8950. function lastMatchIn(string, regexp, endMargin) {
  8951. var match, from = 0;
  8952. while (from <= string.length) {
  8953. regexp.lastIndex = from;
  8954. var newMatch = regexp.exec(string);
  8955. if (!newMatch) break;
  8956. var end = newMatch.index + newMatch[0].length;
  8957. if (end > string.length - endMargin) break;
  8958. if (!match || end > match.index + match[0].length) match = newMatch;
  8959. from = newMatch.index + 1;
  8960. }
  8961. return match;
  8962. }
  8963. function searchRegexpBackward(doc, regexp, start) {
  8964. regexp = ensureFlags(regexp, "g");
  8965. for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) {
  8966. var string = doc.getLine(line);
  8967. var match = lastMatchIn(string, regexp, ch < 0 ? 0 : string.length - ch);
  8968. if (match) return {
  8969. from: Pos(line, match.index),
  8970. to: Pos(line, match.index + match[0].length),
  8971. match
  8972. };
  8973. }
  8974. }
  8975. function searchRegexpBackwardMultiline(doc, regexp, start) {
  8976. if (!maybeMultiline(regexp)) return searchRegexpBackward(doc, regexp, start);
  8977. regexp = ensureFlags(regexp, "gm");
  8978. var string, chunkSize = 1, endMargin = doc.getLine(start.line).length - start.ch;
  8979. for (var line = start.line, first = doc.firstLine(); line >= first;) {
  8980. for (var i = 0; i < chunkSize && line >= first; i++) {
  8981. var curLine = doc.getLine(line--);
  8982. string = string == null ? curLine : curLine + "\n" + string;
  8983. }
  8984. chunkSize *= 2;
  8985. var match = lastMatchIn(string, regexp, endMargin);
  8986. if (match) {
  8987. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n");
  8988. var startLine = line + before.length, startCh = before[before.length - 1].length;
  8989. return {
  8990. from: Pos(startLine, startCh),
  8991. to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  8992. match
  8993. };
  8994. }
  8995. }
  8996. }
  8997. var doFold, noFold;
  8998. if (String.prototype.normalize) {
  8999. doFold = function(str) {
  9000. return str.normalize("NFD").toLowerCase();
  9001. };
  9002. noFold = function(str) {
  9003. return str.normalize("NFD");
  9004. };
  9005. } else {
  9006. doFold = function(str) {
  9007. return str.toLowerCase();
  9008. };
  9009. noFold = function(str) {
  9010. return str;
  9011. };
  9012. }
  9013. function adjustPos(orig, folded, pos, foldFunc) {
  9014. if (orig.length == folded.length) return pos;
  9015. for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) {
  9016. if (min == max) return min;
  9017. var mid = min + max >> 1;
  9018. var len = foldFunc(orig.slice(0, mid)).length;
  9019. if (len == pos) return mid;
  9020. else if (len > pos) max = mid;
  9021. else min = mid + 1;
  9022. }
  9023. }
  9024. function searchStringForward(doc, query, start, caseFold) {
  9025. if (!query.length) return null;
  9026. var fold = caseFold ? doFold : noFold;
  9027. var lines = fold(query).split(/\r|\n\r?/);
  9028. search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) {
  9029. var orig = doc.getLine(line).slice(ch), string = fold(orig);
  9030. if (lines.length == 1) {
  9031. var found = string.indexOf(lines[0]);
  9032. if (found == -1) continue search;
  9033. var start = adjustPos(orig, string, found, fold) + ch;
  9034. return {
  9035. from: Pos(line, adjustPos(orig, string, found, fold) + ch),
  9036. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)
  9037. };
  9038. } else {
  9039. var cutFrom = string.length - lines[0].length;
  9040. if (string.slice(cutFrom) != lines[0]) continue search;
  9041. for (var i = 1; i < lines.length - 1; i++) if (fold(doc.getLine(line + i)) != lines[i]) continue search;
  9042. var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1];
  9043. if (endString.slice(0, lastLine.length) != lastLine) continue search;
  9044. return {
  9045. from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch),
  9046. to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))
  9047. };
  9048. }
  9049. }
  9050. }
  9051. function searchStringBackward(doc, query, start, caseFold) {
  9052. if (!query.length) return null;
  9053. var fold = caseFold ? doFold : noFold;
  9054. var lines = fold(query).split(/\r|\n\r?/);
  9055. search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) {
  9056. var orig = doc.getLine(line);
  9057. if (ch > -1) orig = orig.slice(0, ch);
  9058. var string = fold(orig);
  9059. if (lines.length == 1) {
  9060. var found = string.lastIndexOf(lines[0]);
  9061. if (found == -1) continue search;
  9062. return {
  9063. from: Pos(line, adjustPos(orig, string, found, fold)),
  9064. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))
  9065. };
  9066. } else {
  9067. var lastLine = lines[lines.length - 1];
  9068. if (string.slice(0, lastLine.length) != lastLine) continue search;
  9069. for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++) if (fold(doc.getLine(start + i)) != lines[i]) continue search;
  9070. var top = doc.getLine(line + 1 - lines.length), topString = fold(top);
  9071. if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search;
  9072. return {
  9073. from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)),
  9074. to: Pos(line, adjustPos(orig, string, lastLine.length, fold))
  9075. };
  9076. }
  9077. }
  9078. }
  9079. function SearchCursor(doc, query, pos, options) {
  9080. this.atOccurrence = false;
  9081. this.afterEmptyMatch = false;
  9082. this.doc = doc;
  9083. pos = pos ? doc.clipPos(pos) : Pos(0, 0);
  9084. this.pos = {
  9085. from: pos,
  9086. to: pos
  9087. };
  9088. var caseFold;
  9089. if (typeof options == "object") caseFold = options.caseFold;
  9090. else {
  9091. caseFold = options;
  9092. options = null;
  9093. }
  9094. if (typeof query == "string") {
  9095. if (caseFold == null) caseFold = false;
  9096. this.matches = function(reverse, pos$1) {
  9097. return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos$1, caseFold);
  9098. };
  9099. } else {
  9100. query = ensureFlags(query, "gm");
  9101. if (!options || options.multiline !== false) this.matches = function(reverse, pos$1) {
  9102. return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos$1);
  9103. };
  9104. else this.matches = function(reverse, pos$1) {
  9105. return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos$1);
  9106. };
  9107. }
  9108. }
  9109. SearchCursor.prototype = {
  9110. findNext: function() {
  9111. return this.find(false);
  9112. },
  9113. findPrevious: function() {
  9114. return this.find(true);
  9115. },
  9116. find: function(reverse) {
  9117. var head = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
  9118. if (this.afterEmptyMatch && this.atOccurrence) {
  9119. head = Pos(head.line, head.ch);
  9120. if (reverse) {
  9121. head.ch--;
  9122. if (head.ch < 0) {
  9123. head.line--;
  9124. head.ch = (this.doc.getLine(head.line) || "").length;
  9125. }
  9126. } else {
  9127. head.ch++;
  9128. if (head.ch > (this.doc.getLine(head.line) || "").length) {
  9129. head.ch = 0;
  9130. head.line++;
  9131. }
  9132. }
  9133. if (CodeMirror$1.cmpPos(head, this.doc.clipPos(head)) != 0) return this.atOccurrence = false;
  9134. }
  9135. var result = this.matches(reverse, head);
  9136. this.afterEmptyMatch = result && CodeMirror$1.cmpPos(result.from, result.to) == 0;
  9137. if (result) {
  9138. this.pos = result;
  9139. this.atOccurrence = true;
  9140. return this.pos.match || true;
  9141. } else {
  9142. var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0);
  9143. this.pos = {
  9144. from: end,
  9145. to: end
  9146. };
  9147. return this.atOccurrence = false;
  9148. }
  9149. },
  9150. from: function() {
  9151. if (this.atOccurrence) return this.pos.from;
  9152. },
  9153. to: function() {
  9154. if (this.atOccurrence) return this.pos.to;
  9155. },
  9156. replace: function(newText, origin) {
  9157. if (!this.atOccurrence) return;
  9158. var lines = CodeMirror$1.splitLines(newText);
  9159. this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin);
  9160. this.pos.to = Pos(this.pos.from.line + lines.length - 1, lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
  9161. }
  9162. };
  9163. CodeMirror$1.defineExtension("getSearchCursor", function(query, pos, caseFold) {
  9164. return new SearchCursor(this.doc, query, pos, caseFold);
  9165. });
  9166. CodeMirror$1.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
  9167. return new SearchCursor(this, query, pos, caseFold);
  9168. });
  9169. CodeMirror$1.defineExtension("selectMatches", function(query, caseFold) {
  9170. var ranges = [];
  9171. var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
  9172. while (cur.findNext()) {
  9173. if (CodeMirror$1.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
  9174. ranges.push({
  9175. anchor: cur.from(),
  9176. head: cur.to()
  9177. });
  9178. }
  9179. if (ranges.length) this.setSelections(ranges, 0);
  9180. });
  9181. });
  9182. });
  9183. var require_search = __commonJSMin((exports, module) => {
  9184. (function(mod) {
  9185. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_searchcursor(), require_dialog());
  9186. else if (typeof define == "function" && define.amd) define([
  9187. "../../lib/codemirror",
  9188. "./searchcursor",
  9189. "../dialog/dialog"
  9190. ], mod);
  9191. else mod(CodeMirror);
  9192. })(function(CodeMirror$1) {
  9193. "use strict";
  9194. CodeMirror$1.defineOption("search", { bottom: false });
  9195. function searchOverlay(query, caseInsensitive) {
  9196. if (typeof query == "string") query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
  9197. else if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
  9198. return { token: function(stream) {
  9199. query.lastIndex = stream.pos;
  9200. var match = query.exec(stream.string);
  9201. if (match && match.index == stream.pos) {
  9202. stream.pos += match[0].length || 1;
  9203. return "searching";
  9204. } else if (match) stream.pos = match.index;
  9205. else stream.skipToEnd();
  9206. } };
  9207. }
  9208. function SearchState() {
  9209. this.posFrom = this.posTo = this.lastQuery = this.query = null;
  9210. this.overlay = null;
  9211. }
  9212. function getSearchState(cm) {
  9213. return cm.state.search || (cm.state.search = new SearchState());
  9214. }
  9215. function queryCaseInsensitive(query) {
  9216. return typeof query == "string" && query == query.toLowerCase();
  9217. }
  9218. function getSearchCursor(cm, query, pos) {
  9219. return cm.getSearchCursor(query, pos, {
  9220. caseFold: queryCaseInsensitive(query),
  9221. multiline: true
  9222. });
  9223. }
  9224. function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
  9225. cm.openDialog(text, onEnter, {
  9226. value: deflt,
  9227. selectValueOnOpen: true,
  9228. closeOnEnter: false,
  9229. onClose: function() {
  9230. clearSearch(cm);
  9231. },
  9232. onKeyDown,
  9233. bottom: cm.options.search.bottom
  9234. });
  9235. }
  9236. function dialog(cm, text, shortText, deflt, f) {
  9237. if (cm.openDialog) cm.openDialog(text, f, {
  9238. value: deflt,
  9239. selectValueOnOpen: true,
  9240. bottom: cm.options.search.bottom
  9241. });
  9242. else f(prompt(shortText, deflt));
  9243. }
  9244. function confirmDialog(cm, text, shortText, fs) {
  9245. if (cm.openConfirm) cm.openConfirm(text, fs);
  9246. else if (confirm(shortText)) fs[0]();
  9247. }
  9248. function parseString(string) {
  9249. return string.replace(/\\([nrt\\])/g, function(match, ch) {
  9250. if (ch == "n") return "\n";
  9251. if (ch == "r") return "\r";
  9252. if (ch == "t") return " ";
  9253. if (ch == "\\") return "\\";
  9254. return match;
  9255. });
  9256. }
  9257. function parseQuery(query) {
  9258. var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
  9259. if (isRE) try {
  9260. query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i");
  9261. } catch (e) {}
  9262. else query = parseString(query);
  9263. if (typeof query == "string" ? query == "" : query.test("")) query = /x^/;
  9264. return query;
  9265. }
  9266. function startSearch(cm, state, query) {
  9267. state.queryText = query;
  9268. state.query = parseQuery(query);
  9269. cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
  9270. state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
  9271. cm.addOverlay(state.overlay);
  9272. if (cm.showMatchesOnScrollbar) {
  9273. if (state.annotate) {
  9274. state.annotate.clear();
  9275. state.annotate = null;
  9276. }
  9277. state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
  9278. }
  9279. }
  9280. function doSearch(cm, rev, persistent, immediate) {
  9281. var state = getSearchState(cm);
  9282. if (state.query) return findNext(cm, rev);
  9283. var q = cm.getSelection() || state.lastQuery;
  9284. if (q instanceof RegExp && q.source == "x^") q = null;
  9285. if (persistent && cm.openDialog) {
  9286. var hiding = null;
  9287. var searchNext = function(query, event) {
  9288. CodeMirror$1.e_stop(event);
  9289. if (!query) return;
  9290. if (query != state.queryText) {
  9291. startSearch(cm, state, query);
  9292. state.posFrom = state.posTo = cm.getCursor();
  9293. }
  9294. if (hiding) hiding.style.opacity = 1;
  9295. findNext(cm, event.shiftKey, function(_, to) {
  9296. var dialog$1;
  9297. if (to.line < 3 && document.querySelector && (dialog$1 = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && dialog$1.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) (hiding = dialog$1).style.opacity = .4;
  9298. });
  9299. };
  9300. persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) {
  9301. var keyName = CodeMirror$1.keyName(event);
  9302. var extra = cm.getOption("extraKeys"), cmd = extra && extra[keyName] || CodeMirror$1.keyMap[cm.getOption("keyMap")][keyName];
  9303. if (cmd == "findNext" || cmd == "findPrev" || cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
  9304. CodeMirror$1.e_stop(event);
  9305. startSearch(cm, getSearchState(cm), query);
  9306. cm.execCommand(cmd);
  9307. } else if (cmd == "find" || cmd == "findPersistent") {
  9308. CodeMirror$1.e_stop(event);
  9309. searchNext(query, event);
  9310. }
  9311. });
  9312. if (immediate && q) {
  9313. startSearch(cm, state, q);
  9314. findNext(cm, rev);
  9315. }
  9316. } else dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) {
  9317. if (query && !state.query) cm.operation(function() {
  9318. startSearch(cm, state, query);
  9319. state.posFrom = state.posTo = cm.getCursor();
  9320. findNext(cm, rev);
  9321. });
  9322. });
  9323. }
  9324. function findNext(cm, rev, callback) {
  9325. cm.operation(function() {
  9326. var state = getSearchState(cm);
  9327. var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
  9328. if (!cursor.find(rev)) {
  9329. cursor = getSearchCursor(cm, state.query, rev ? CodeMirror$1.Pos(cm.lastLine()) : CodeMirror$1.Pos(cm.firstLine(), 0));
  9330. if (!cursor.find(rev)) return;
  9331. }
  9332. cm.setSelection(cursor.from(), cursor.to());
  9333. cm.scrollIntoView({
  9334. from: cursor.from(),
  9335. to: cursor.to()
  9336. }, 20);
  9337. state.posFrom = cursor.from();
  9338. state.posTo = cursor.to();
  9339. if (callback) callback(cursor.from(), cursor.to());
  9340. });
  9341. }
  9342. function clearSearch(cm) {
  9343. cm.operation(function() {
  9344. var state = getSearchState(cm);
  9345. state.lastQuery = state.query;
  9346. if (!state.query) return;
  9347. state.query = state.queryText = null;
  9348. cm.removeOverlay(state.overlay);
  9349. if (state.annotate) {
  9350. state.annotate.clear();
  9351. state.annotate = null;
  9352. }
  9353. });
  9354. }
  9355. function el(tag, attrs) {
  9356. var element = tag ? document.createElement(tag) : document.createDocumentFragment();
  9357. for (var key in attrs) element[key] = attrs[key];
  9358. for (var i = 2; i < arguments.length; i++) {
  9359. var child = arguments[i];
  9360. element.appendChild(typeof child == "string" ? document.createTextNode(child) : child);
  9361. }
  9362. return element;
  9363. }
  9364. function getQueryDialog(cm) {
  9365. var label = el("label", { className: "CodeMirror-search-label" }, cm.phrase("Search:"), el("input", {
  9366. type: "text",
  9367. "style": "width: 10em",
  9368. className: "CodeMirror-search-field",
  9369. id: "CodeMirror-search-field"
  9370. }));
  9371. label.setAttribute("for", "CodeMirror-search-field");
  9372. return el("", null, label, " ", el("span", {
  9373. style: "color: #666",
  9374. className: "CodeMirror-search-hint"
  9375. }, cm.phrase("(Use /re/ syntax for regexp search)")));
  9376. }
  9377. function getReplaceQueryDialog(cm) {
  9378. return el("", null, " ", el("input", {
  9379. type: "text",
  9380. "style": "width: 10em",
  9381. className: "CodeMirror-search-field"
  9382. }), " ", el("span", {
  9383. style: "color: #666",
  9384. className: "CodeMirror-search-hint"
  9385. }, cm.phrase("(Use /re/ syntax for regexp search)")));
  9386. }
  9387. function getReplacementQueryDialog(cm) {
  9388. return el("", null, el("span", { className: "CodeMirror-search-label" }, cm.phrase("With:")), " ", el("input", {
  9389. type: "text",
  9390. "style": "width: 10em",
  9391. className: "CodeMirror-search-field"
  9392. }));
  9393. }
  9394. function getDoReplaceConfirm(cm) {
  9395. return el("", null, el("span", { className: "CodeMirror-search-label" }, cm.phrase("Replace?")), " ", el("button", {}, cm.phrase("Yes")), " ", el("button", {}, cm.phrase("No")), " ", el("button", {}, cm.phrase("All")), " ", el("button", {}, cm.phrase("Stop")));
  9396. }
  9397. function replaceAll(cm, query, text) {
  9398. cm.operation(function() {
  9399. for (var cursor = getSearchCursor(cm, query); cursor.findNext();) if (typeof query != "string") {
  9400. var match = cm.getRange(cursor.from(), cursor.to()).match(query);
  9401. cursor.replace(text.replace(/\$(\d)/g, function(_, i) {
  9402. return match[i];
  9403. }));
  9404. } else cursor.replace(text);
  9405. });
  9406. }
  9407. function replace(cm, all) {
  9408. if (cm.getOption("readOnly")) return;
  9409. var query = cm.getSelection() || getSearchState(cm).lastQuery;
  9410. var dialogText = all ? cm.phrase("Replace all:") : cm.phrase("Replace:");
  9411. var fragment = el("", null, el("span", { className: "CodeMirror-search-label" }, dialogText), getReplaceQueryDialog(cm));
  9412. dialog(cm, fragment, dialogText, query, function(query$1) {
  9413. if (!query$1) return;
  9414. query$1 = parseQuery(query$1);
  9415. dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {
  9416. text = parseString(text);
  9417. if (all) replaceAll(cm, query$1, text);
  9418. else {
  9419. clearSearch(cm);
  9420. var cursor = getSearchCursor(cm, query$1, cm.getCursor("from"));
  9421. var advance = function() {
  9422. var start = cursor.from(), match;
  9423. if (!(match = cursor.findNext())) {
  9424. cursor = getSearchCursor(cm, query$1);
  9425. if (!(match = cursor.findNext()) || start && cursor.from().line == start.line && cursor.from().ch == start.ch) return;
  9426. }
  9427. cm.setSelection(cursor.from(), cursor.to());
  9428. cm.scrollIntoView({
  9429. from: cursor.from(),
  9430. to: cursor.to()
  9431. });
  9432. confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"), [
  9433. function() {
  9434. doReplace(match);
  9435. },
  9436. advance,
  9437. function() {
  9438. replaceAll(cm, query$1, text);
  9439. }
  9440. ]);
  9441. };
  9442. var doReplace = function(match) {
  9443. cursor.replace(typeof query$1 == "string" ? text : text.replace(/\$(\d)/g, function(_, i) {
  9444. return match[i];
  9445. }));
  9446. advance();
  9447. };
  9448. advance();
  9449. }
  9450. });
  9451. });
  9452. }
  9453. CodeMirror$1.commands.find = function(cm) {
  9454. clearSearch(cm);
  9455. doSearch(cm);
  9456. };
  9457. CodeMirror$1.commands.findPersistent = function(cm) {
  9458. clearSearch(cm);
  9459. doSearch(cm, false, true);
  9460. };
  9461. CodeMirror$1.commands.findPersistentNext = function(cm) {
  9462. doSearch(cm, false, true, true);
  9463. };
  9464. CodeMirror$1.commands.findPersistentPrev = function(cm) {
  9465. doSearch(cm, true, true, true);
  9466. };
  9467. CodeMirror$1.commands.findNext = doSearch;
  9468. CodeMirror$1.commands.findPrev = function(cm) {
  9469. doSearch(cm, true);
  9470. };
  9471. CodeMirror$1.commands.clearSearch = clearSearch;
  9472. CodeMirror$1.commands.replace = replace;
  9473. CodeMirror$1.commands.replaceAll = function(cm) {
  9474. replace(cm, true);
  9475. };
  9476. });
  9477. });
  9478. var require_css = __commonJSMin((exports, module) => {
  9479. (function(mod) {
  9480. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  9481. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  9482. else mod(CodeMirror);
  9483. })(function(CodeMirror$1) {
  9484. "use strict";
  9485. CodeMirror$1.defineMode("css", function(config, parserConfig) {
  9486. var inline = parserConfig.inline;
  9487. if (!parserConfig.propertyKeywords) parserConfig = CodeMirror$1.resolveMode("text/css");
  9488. var indentUnit = config.indentUnit, tokenHooks = parserConfig.tokenHooks, documentTypes$1 = parserConfig.documentTypes || {}, mediaTypes$1 = parserConfig.mediaTypes || {}, mediaFeatures$1 = parserConfig.mediaFeatures || {}, mediaValueKeywords$1 = parserConfig.mediaValueKeywords || {}, propertyKeywords$1 = parserConfig.propertyKeywords || {}, nonStandardPropertyKeywords$1 = parserConfig.nonStandardPropertyKeywords || {}, fontProperties$1 = parserConfig.fontProperties || {}, counterDescriptors$1 = parserConfig.counterDescriptors || {}, colorKeywords$1 = parserConfig.colorKeywords || {}, valueKeywords$1 = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, supportsAtComponent = parserConfig.supportsAtComponent === true, highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;
  9489. var type, override;
  9490. function ret(style, tp) {
  9491. type = tp;
  9492. return style;
  9493. }
  9494. function tokenBase(stream, state) {
  9495. var ch = stream.next();
  9496. if (tokenHooks[ch]) {
  9497. var result = tokenHooks[ch](stream, state);
  9498. if (result !== false) return result;
  9499. }
  9500. if (ch == "@") {
  9501. stream.eatWhile(/[\w\\\-]/);
  9502. return ret("def", stream.current());
  9503. } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
  9504. else if (ch == "\"" || ch == "'") {
  9505. state.tokenize = tokenString(ch);
  9506. return state.tokenize(stream, state);
  9507. } else if (ch == "#") {
  9508. stream.eatWhile(/[\w\\\-]/);
  9509. return ret("atom", "hash");
  9510. } else if (ch == "!") {
  9511. stream.match(/^\s*\w*/);
  9512. return ret("keyword", "important");
  9513. } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
  9514. stream.eatWhile(/[\w.%]/);
  9515. return ret("number", "unit");
  9516. } else if (ch === "-") {
  9517. if (/[\d.]/.test(stream.peek())) {
  9518. stream.eatWhile(/[\w.%]/);
  9519. return ret("number", "unit");
  9520. } else if (stream.match(/^-[\w\\\-]*/)) {
  9521. stream.eatWhile(/[\w\\\-]/);
  9522. if (stream.match(/^\s*:/, false)) return ret("variable-2", "variable-definition");
  9523. return ret("variable-2", "variable");
  9524. } else if (stream.match(/^\w+-/)) return ret("meta", "meta");
  9525. } else if (/[,+>*\/]/.test(ch)) return ret(null, "select-op");
  9526. else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) return ret("qualifier", "qualifier");
  9527. else if (/[:;{}\[\]\(\)]/.test(ch)) return ret(null, ch);
  9528. else if (stream.match(/^[\w-.]+(?=\()/)) {
  9529. if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) state.tokenize = tokenParenthesized;
  9530. return ret("variable callee", "variable");
  9531. } else if (/[\w\\\-]/.test(ch)) {
  9532. stream.eatWhile(/[\w\\\-]/);
  9533. return ret("property", "word");
  9534. } else return ret(null, null);
  9535. }
  9536. function tokenString(quote) {
  9537. return function(stream, state) {
  9538. var escaped = false, ch;
  9539. while ((ch = stream.next()) != null) {
  9540. if (ch == quote && !escaped) {
  9541. if (quote == ")") stream.backUp(1);
  9542. break;
  9543. }
  9544. escaped = !escaped && ch == "\\";
  9545. }
  9546. if (ch == quote || !escaped && quote != ")") state.tokenize = null;
  9547. return ret("string", "string");
  9548. };
  9549. }
  9550. function tokenParenthesized(stream, state) {
  9551. stream.next();
  9552. if (!stream.match(/^\s*[\"\')]/, false)) state.tokenize = tokenString(")");
  9553. else state.tokenize = null;
  9554. return ret(null, "(");
  9555. }
  9556. function Context(type$1, indent, prev) {
  9557. this.type = type$1;
  9558. this.indent = indent;
  9559. this.prev = prev;
  9560. }
  9561. function pushContext(state, stream, type$1, indent) {
  9562. state.context = new Context(type$1, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
  9563. return type$1;
  9564. }
  9565. function popContext(state) {
  9566. if (state.context.prev) state.context = state.context.prev;
  9567. return state.context.type;
  9568. }
  9569. function pass(type$1, stream, state) {
  9570. return states[state.context.type](type$1, stream, state);
  9571. }
  9572. function popAndPass(type$1, stream, state, n) {
  9573. for (var i = n || 1; i > 0; i--) state.context = state.context.prev;
  9574. return pass(type$1, stream, state);
  9575. }
  9576. function wordAsValue(stream) {
  9577. var word = stream.current().toLowerCase();
  9578. if (valueKeywords$1.hasOwnProperty(word)) override = "atom";
  9579. else if (colorKeywords$1.hasOwnProperty(word)) override = "keyword";
  9580. else override = "variable";
  9581. }
  9582. var states = {};
  9583. states.top = function(type$1, stream, state) {
  9584. if (type$1 == "{") return pushContext(state, stream, "block");
  9585. else if (type$1 == "}" && state.context.prev) return popContext(state);
  9586. else if (supportsAtComponent && /@component/i.test(type$1)) return pushContext(state, stream, "atComponentBlock");
  9587. else if (/^@(-moz-)?document$/i.test(type$1)) return pushContext(state, stream, "documentTypes");
  9588. else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type$1)) return pushContext(state, stream, "atBlock");
  9589. else if (/^@(font-face|counter-style)/i.test(type$1)) {
  9590. state.stateArg = type$1;
  9591. return "restricted_atBlock_before";
  9592. } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type$1)) return "keyframes";
  9593. else if (type$1 && type$1.charAt(0) == "@") return pushContext(state, stream, "at");
  9594. else if (type$1 == "hash") override = "builtin";
  9595. else if (type$1 == "word") override = "tag";
  9596. else if (type$1 == "variable-definition") return "maybeprop";
  9597. else if (type$1 == "interpolation") return pushContext(state, stream, "interpolation");
  9598. else if (type$1 == ":") return "pseudo";
  9599. else if (allowNested && type$1 == "(") return pushContext(state, stream, "parens");
  9600. return state.context.type;
  9601. };
  9602. states.block = function(type$1, stream, state) {
  9603. if (type$1 == "word") {
  9604. var word = stream.current().toLowerCase();
  9605. if (propertyKeywords$1.hasOwnProperty(word)) {
  9606. override = "property";
  9607. return "maybeprop";
  9608. } else if (nonStandardPropertyKeywords$1.hasOwnProperty(word)) {
  9609. override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
  9610. return "maybeprop";
  9611. } else if (allowNested) {
  9612. override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
  9613. return "block";
  9614. } else {
  9615. override += " error";
  9616. return "maybeprop";
  9617. }
  9618. } else if (type$1 == "meta") return "block";
  9619. else if (!allowNested && (type$1 == "hash" || type$1 == "qualifier")) {
  9620. override = "error";
  9621. return "block";
  9622. } else return states.top(type$1, stream, state);
  9623. };
  9624. states.maybeprop = function(type$1, stream, state) {
  9625. if (type$1 == ":") return pushContext(state, stream, "prop");
  9626. return pass(type$1, stream, state);
  9627. };
  9628. states.prop = function(type$1, stream, state) {
  9629. if (type$1 == ";") return popContext(state);
  9630. if (type$1 == "{" && allowNested) return pushContext(state, stream, "propBlock");
  9631. if (type$1 == "}" || type$1 == "{") return popAndPass(type$1, stream, state);
  9632. if (type$1 == "(") return pushContext(state, stream, "parens");
  9633. if (type$1 == "hash" && !/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(stream.current())) override += " error";
  9634. else if (type$1 == "word") wordAsValue(stream);
  9635. else if (type$1 == "interpolation") return pushContext(state, stream, "interpolation");
  9636. return "prop";
  9637. };
  9638. states.propBlock = function(type$1, _stream, state) {
  9639. if (type$1 == "}") return popContext(state);
  9640. if (type$1 == "word") {
  9641. override = "property";
  9642. return "maybeprop";
  9643. }
  9644. return state.context.type;
  9645. };
  9646. states.parens = function(type$1, stream, state) {
  9647. if (type$1 == "{" || type$1 == "}") return popAndPass(type$1, stream, state);
  9648. if (type$1 == ")") return popContext(state);
  9649. if (type$1 == "(") return pushContext(state, stream, "parens");
  9650. if (type$1 == "interpolation") return pushContext(state, stream, "interpolation");
  9651. if (type$1 == "word") wordAsValue(stream);
  9652. return "parens";
  9653. };
  9654. states.pseudo = function(type$1, stream, state) {
  9655. if (type$1 == "meta") return "pseudo";
  9656. if (type$1 == "word") {
  9657. override = "variable-3";
  9658. return state.context.type;
  9659. }
  9660. return pass(type$1, stream, state);
  9661. };
  9662. states.documentTypes = function(type$1, stream, state) {
  9663. if (type$1 == "word" && documentTypes$1.hasOwnProperty(stream.current())) {
  9664. override = "tag";
  9665. return state.context.type;
  9666. } else return states.atBlock(type$1, stream, state);
  9667. };
  9668. states.atBlock = function(type$1, stream, state) {
  9669. if (type$1 == "(") return pushContext(state, stream, "atBlock_parens");
  9670. if (type$1 == "}" || type$1 == ";") return popAndPass(type$1, stream, state);
  9671. if (type$1 == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
  9672. if (type$1 == "interpolation") return pushContext(state, stream, "interpolation");
  9673. if (type$1 == "word") {
  9674. var word = stream.current().toLowerCase();
  9675. if (word == "only" || word == "not" || word == "and" || word == "or") override = "keyword";
  9676. else if (mediaTypes$1.hasOwnProperty(word)) override = "attribute";
  9677. else if (mediaFeatures$1.hasOwnProperty(word)) override = "property";
  9678. else if (mediaValueKeywords$1.hasOwnProperty(word)) override = "keyword";
  9679. else if (propertyKeywords$1.hasOwnProperty(word)) override = "property";
  9680. else if (nonStandardPropertyKeywords$1.hasOwnProperty(word)) override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
  9681. else if (valueKeywords$1.hasOwnProperty(word)) override = "atom";
  9682. else if (colorKeywords$1.hasOwnProperty(word)) override = "keyword";
  9683. else override = "error";
  9684. }
  9685. return state.context.type;
  9686. };
  9687. states.atComponentBlock = function(type$1, stream, state) {
  9688. if (type$1 == "}") return popAndPass(type$1, stream, state);
  9689. if (type$1 == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
  9690. if (type$1 == "word") override = "error";
  9691. return state.context.type;
  9692. };
  9693. states.atBlock_parens = function(type$1, stream, state) {
  9694. if (type$1 == ")") return popContext(state);
  9695. if (type$1 == "{" || type$1 == "}") return popAndPass(type$1, stream, state, 2);
  9696. return states.atBlock(type$1, stream, state);
  9697. };
  9698. states.restricted_atBlock_before = function(type$1, stream, state) {
  9699. if (type$1 == "{") return pushContext(state, stream, "restricted_atBlock");
  9700. if (type$1 == "word" && state.stateArg == "@counter-style") {
  9701. override = "variable";
  9702. return "restricted_atBlock_before";
  9703. }
  9704. return pass(type$1, stream, state);
  9705. };
  9706. states.restricted_atBlock = function(type$1, stream, state) {
  9707. if (type$1 == "}") {
  9708. state.stateArg = null;
  9709. return popContext(state);
  9710. }
  9711. if (type$1 == "word") {
  9712. if (state.stateArg == "@font-face" && !fontProperties$1.hasOwnProperty(stream.current().toLowerCase()) || state.stateArg == "@counter-style" && !counterDescriptors$1.hasOwnProperty(stream.current().toLowerCase())) override = "error";
  9713. else override = "property";
  9714. return "maybeprop";
  9715. }
  9716. return "restricted_atBlock";
  9717. };
  9718. states.keyframes = function(type$1, stream, state) {
  9719. if (type$1 == "word") {
  9720. override = "variable";
  9721. return "keyframes";
  9722. }
  9723. if (type$1 == "{") return pushContext(state, stream, "top");
  9724. return pass(type$1, stream, state);
  9725. };
  9726. states.at = function(type$1, stream, state) {
  9727. if (type$1 == ";") return popContext(state);
  9728. if (type$1 == "{" || type$1 == "}") return popAndPass(type$1, stream, state);
  9729. if (type$1 == "word") override = "tag";
  9730. else if (type$1 == "hash") override = "builtin";
  9731. return "at";
  9732. };
  9733. states.interpolation = function(type$1, stream, state) {
  9734. if (type$1 == "}") return popContext(state);
  9735. if (type$1 == "{" || type$1 == ";") return popAndPass(type$1, stream, state);
  9736. if (type$1 == "word") override = "variable";
  9737. else if (type$1 != "variable" && type$1 != "(" && type$1 != ")") override = "error";
  9738. return "interpolation";
  9739. };
  9740. return {
  9741. startState: function(base) {
  9742. return {
  9743. tokenize: null,
  9744. state: inline ? "block" : "top",
  9745. stateArg: null,
  9746. context: new Context(inline ? "block" : "top", base || 0, null)
  9747. };
  9748. },
  9749. token: function(stream, state) {
  9750. if (!state.tokenize && stream.eatSpace()) return null;
  9751. var style = (state.tokenize || tokenBase)(stream, state);
  9752. if (style && typeof style == "object") {
  9753. type = style[1];
  9754. style = style[0];
  9755. }
  9756. override = style;
  9757. if (type != "comment") state.state = states[state.state](type, stream, state);
  9758. return override;
  9759. },
  9760. indent: function(state, textAfter) {
  9761. var cx = state.context, ch = textAfter && textAfter.charAt(0);
  9762. var indent = cx.indent;
  9763. if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
  9764. if (cx.prev) {
  9765. if (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
  9766. cx = cx.prev;
  9767. indent = cx.indent;
  9768. } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || ch == "{" && (cx.type == "at" || cx.type == "atBlock")) indent = Math.max(0, cx.indent - indentUnit);
  9769. }
  9770. return indent;
  9771. },
  9772. electricChars: "}",
  9773. blockCommentStart: "/*",
  9774. blockCommentEnd: "*/",
  9775. blockCommentContinue: " * ",
  9776. lineComment,
  9777. fold: "brace"
  9778. };
  9779. });
  9780. function keySet(array) {
  9781. var keys = {};
  9782. for (var i = 0; i < array.length; ++i) keys[array[i].toLowerCase()] = true;
  9783. return keys;
  9784. }
  9785. var documentTypes_ = [
  9786. "domain",
  9787. "regexp",
  9788. "url",
  9789. "url-prefix"
  9790. ], documentTypes = keySet(documentTypes_);
  9791. var mediaTypes_ = [
  9792. "all",
  9793. "aural",
  9794. "braille",
  9795. "handheld",
  9796. "print",
  9797. "projection",
  9798. "screen",
  9799. "tty",
  9800. "tv",
  9801. "embossed"
  9802. ], mediaTypes = keySet(mediaTypes_);
  9803. var mediaFeatures_ = [
  9804. "width",
  9805. "min-width",
  9806. "max-width",
  9807. "height",
  9808. "min-height",
  9809. "max-height",
  9810. "device-width",
  9811. "min-device-width",
  9812. "max-device-width",
  9813. "device-height",
  9814. "min-device-height",
  9815. "max-device-height",
  9816. "aspect-ratio",
  9817. "min-aspect-ratio",
  9818. "max-aspect-ratio",
  9819. "device-aspect-ratio",
  9820. "min-device-aspect-ratio",
  9821. "max-device-aspect-ratio",
  9822. "color",
  9823. "min-color",
  9824. "max-color",
  9825. "color-index",
  9826. "min-color-index",
  9827. "max-color-index",
  9828. "monochrome",
  9829. "min-monochrome",
  9830. "max-monochrome",
  9831. "resolution",
  9832. "min-resolution",
  9833. "max-resolution",
  9834. "scan",
  9835. "grid",
  9836. "orientation",
  9837. "device-pixel-ratio",
  9838. "min-device-pixel-ratio",
  9839. "max-device-pixel-ratio",
  9840. "pointer",
  9841. "any-pointer",
  9842. "hover",
  9843. "any-hover",
  9844. "prefers-color-scheme",
  9845. "dynamic-range",
  9846. "video-dynamic-range"
  9847. ], mediaFeatures = keySet(mediaFeatures_);
  9848. var mediaValueKeywords_ = [
  9849. "landscape",
  9850. "portrait",
  9851. "none",
  9852. "coarse",
  9853. "fine",
  9854. "on-demand",
  9855. "hover",
  9856. "interlace",
  9857. "progressive",
  9858. "dark",
  9859. "light",
  9860. "standard",
  9861. "high"
  9862. ], mediaValueKeywords = keySet(mediaValueKeywords_);
  9863. var propertyKeywords_ = [
  9864. "align-content",
  9865. "align-items",
  9866. "align-self",
  9867. "alignment-adjust",
  9868. "alignment-baseline",
  9869. "all",
  9870. "anchor-point",
  9871. "animation",
  9872. "animation-delay",
  9873. "animation-direction",
  9874. "animation-duration",
  9875. "animation-fill-mode",
  9876. "animation-iteration-count",
  9877. "animation-name",
  9878. "animation-play-state",
  9879. "animation-timing-function",
  9880. "appearance",
  9881. "azimuth",
  9882. "backdrop-filter",
  9883. "backface-visibility",
  9884. "background",
  9885. "background-attachment",
  9886. "background-blend-mode",
  9887. "background-clip",
  9888. "background-color",
  9889. "background-image",
  9890. "background-origin",
  9891. "background-position",
  9892. "background-position-x",
  9893. "background-position-y",
  9894. "background-repeat",
  9895. "background-size",
  9896. "baseline-shift",
  9897. "binding",
  9898. "bleed",
  9899. "block-size",
  9900. "bookmark-label",
  9901. "bookmark-level",
  9902. "bookmark-state",
  9903. "bookmark-target",
  9904. "border",
  9905. "border-bottom",
  9906. "border-bottom-color",
  9907. "border-bottom-left-radius",
  9908. "border-bottom-right-radius",
  9909. "border-bottom-style",
  9910. "border-bottom-width",
  9911. "border-collapse",
  9912. "border-color",
  9913. "border-image",
  9914. "border-image-outset",
  9915. "border-image-repeat",
  9916. "border-image-slice",
  9917. "border-image-source",
  9918. "border-image-width",
  9919. "border-left",
  9920. "border-left-color",
  9921. "border-left-style",
  9922. "border-left-width",
  9923. "border-radius",
  9924. "border-right",
  9925. "border-right-color",
  9926. "border-right-style",
  9927. "border-right-width",
  9928. "border-spacing",
  9929. "border-style",
  9930. "border-top",
  9931. "border-top-color",
  9932. "border-top-left-radius",
  9933. "border-top-right-radius",
  9934. "border-top-style",
  9935. "border-top-width",
  9936. "border-width",
  9937. "bottom",
  9938. "box-decoration-break",
  9939. "box-shadow",
  9940. "box-sizing",
  9941. "break-after",
  9942. "break-before",
  9943. "break-inside",
  9944. "caption-side",
  9945. "caret-color",
  9946. "clear",
  9947. "clip",
  9948. "color",
  9949. "color-profile",
  9950. "column-count",
  9951. "column-fill",
  9952. "column-gap",
  9953. "column-rule",
  9954. "column-rule-color",
  9955. "column-rule-style",
  9956. "column-rule-width",
  9957. "column-span",
  9958. "column-width",
  9959. "columns",
  9960. "contain",
  9961. "content",
  9962. "counter-increment",
  9963. "counter-reset",
  9964. "crop",
  9965. "cue",
  9966. "cue-after",
  9967. "cue-before",
  9968. "cursor",
  9969. "direction",
  9970. "display",
  9971. "dominant-baseline",
  9972. "drop-initial-after-adjust",
  9973. "drop-initial-after-align",
  9974. "drop-initial-before-adjust",
  9975. "drop-initial-before-align",
  9976. "drop-initial-size",
  9977. "drop-initial-value",
  9978. "elevation",
  9979. "empty-cells",
  9980. "fit",
  9981. "fit-content",
  9982. "fit-position",
  9983. "flex",
  9984. "flex-basis",
  9985. "flex-direction",
  9986. "flex-flow",
  9987. "flex-grow",
  9988. "flex-shrink",
  9989. "flex-wrap",
  9990. "float",
  9991. "float-offset",
  9992. "flow-from",
  9993. "flow-into",
  9994. "font",
  9995. "font-family",
  9996. "font-feature-settings",
  9997. "font-kerning",
  9998. "font-language-override",
  9999. "font-optical-sizing",
  10000. "font-size",
  10001. "font-size-adjust",
  10002. "font-stretch",
  10003. "font-style",
  10004. "font-synthesis",
  10005. "font-variant",
  10006. "font-variant-alternates",
  10007. "font-variant-caps",
  10008. "font-variant-east-asian",
  10009. "font-variant-ligatures",
  10010. "font-variant-numeric",
  10011. "font-variant-position",
  10012. "font-variation-settings",
  10013. "font-weight",
  10014. "gap",
  10015. "grid",
  10016. "grid-area",
  10017. "grid-auto-columns",
  10018. "grid-auto-flow",
  10019. "grid-auto-rows",
  10020. "grid-column",
  10021. "grid-column-end",
  10022. "grid-column-gap",
  10023. "grid-column-start",
  10024. "grid-gap",
  10025. "grid-row",
  10026. "grid-row-end",
  10027. "grid-row-gap",
  10028. "grid-row-start",
  10029. "grid-template",
  10030. "grid-template-areas",
  10031. "grid-template-columns",
  10032. "grid-template-rows",
  10033. "hanging-punctuation",
  10034. "height",
  10035. "hyphens",
  10036. "icon",
  10037. "image-orientation",
  10038. "image-rendering",
  10039. "image-resolution",
  10040. "inline-box-align",
  10041. "inset",
  10042. "inset-block",
  10043. "inset-block-end",
  10044. "inset-block-start",
  10045. "inset-inline",
  10046. "inset-inline-end",
  10047. "inset-inline-start",
  10048. "isolation",
  10049. "justify-content",
  10050. "justify-items",
  10051. "justify-self",
  10052. "left",
  10053. "letter-spacing",
  10054. "line-break",
  10055. "line-height",
  10056. "line-height-step",
  10057. "line-stacking",
  10058. "line-stacking-ruby",
  10059. "line-stacking-shift",
  10060. "line-stacking-strategy",
  10061. "list-style",
  10062. "list-style-image",
  10063. "list-style-position",
  10064. "list-style-type",
  10065. "margin",
  10066. "margin-bottom",
  10067. "margin-left",
  10068. "margin-right",
  10069. "margin-top",
  10070. "marks",
  10071. "marquee-direction",
  10072. "marquee-loop",
  10073. "marquee-play-count",
  10074. "marquee-speed",
  10075. "marquee-style",
  10076. "mask-clip",
  10077. "mask-composite",
  10078. "mask-image",
  10079. "mask-mode",
  10080. "mask-origin",
  10081. "mask-position",
  10082. "mask-repeat",
  10083. "mask-size",
  10084. "mask-type",
  10085. "max-block-size",
  10086. "max-height",
  10087. "max-inline-size",
  10088. "max-width",
  10089. "min-block-size",
  10090. "min-height",
  10091. "min-inline-size",
  10092. "min-width",
  10093. "mix-blend-mode",
  10094. "move-to",
  10095. "nav-down",
  10096. "nav-index",
  10097. "nav-left",
  10098. "nav-right",
  10099. "nav-up",
  10100. "object-fit",
  10101. "object-position",
  10102. "offset",
  10103. "offset-anchor",
  10104. "offset-distance",
  10105. "offset-path",
  10106. "offset-position",
  10107. "offset-rotate",
  10108. "opacity",
  10109. "order",
  10110. "orphans",
  10111. "outline",
  10112. "outline-color",
  10113. "outline-offset",
  10114. "outline-style",
  10115. "outline-width",
  10116. "overflow",
  10117. "overflow-style",
  10118. "overflow-wrap",
  10119. "overflow-x",
  10120. "overflow-y",
  10121. "padding",
  10122. "padding-bottom",
  10123. "padding-left",
  10124. "padding-right",
  10125. "padding-top",
  10126. "page",
  10127. "page-break-after",
  10128. "page-break-before",
  10129. "page-break-inside",
  10130. "page-policy",
  10131. "pause",
  10132. "pause-after",
  10133. "pause-before",
  10134. "perspective",
  10135. "perspective-origin",
  10136. "pitch",
  10137. "pitch-range",
  10138. "place-content",
  10139. "place-items",
  10140. "place-self",
  10141. "play-during",
  10142. "position",
  10143. "presentation-level",
  10144. "punctuation-trim",
  10145. "quotes",
  10146. "region-break-after",
  10147. "region-break-before",
  10148. "region-break-inside",
  10149. "region-fragment",
  10150. "rendering-intent",
  10151. "resize",
  10152. "rest",
  10153. "rest-after",
  10154. "rest-before",
  10155. "richness",
  10156. "right",
  10157. "rotate",
  10158. "rotation",
  10159. "rotation-point",
  10160. "row-gap",
  10161. "ruby-align",
  10162. "ruby-overhang",
  10163. "ruby-position",
  10164. "ruby-span",
  10165. "scale",
  10166. "scroll-behavior",
  10167. "scroll-margin",
  10168. "scroll-margin-block",
  10169. "scroll-margin-block-end",
  10170. "scroll-margin-block-start",
  10171. "scroll-margin-bottom",
  10172. "scroll-margin-inline",
  10173. "scroll-margin-inline-end",
  10174. "scroll-margin-inline-start",
  10175. "scroll-margin-left",
  10176. "scroll-margin-right",
  10177. "scroll-margin-top",
  10178. "scroll-padding",
  10179. "scroll-padding-block",
  10180. "scroll-padding-block-end",
  10181. "scroll-padding-block-start",
  10182. "scroll-padding-bottom",
  10183. "scroll-padding-inline",
  10184. "scroll-padding-inline-end",
  10185. "scroll-padding-inline-start",
  10186. "scroll-padding-left",
  10187. "scroll-padding-right",
  10188. "scroll-padding-top",
  10189. "scroll-snap-align",
  10190. "scroll-snap-type",
  10191. "shape-image-threshold",
  10192. "shape-inside",
  10193. "shape-margin",
  10194. "shape-outside",
  10195. "size",
  10196. "speak",
  10197. "speak-as",
  10198. "speak-header",
  10199. "speak-numeral",
  10200. "speak-punctuation",
  10201. "speech-rate",
  10202. "stress",
  10203. "string-set",
  10204. "tab-size",
  10205. "table-layout",
  10206. "target",
  10207. "target-name",
  10208. "target-new",
  10209. "target-position",
  10210. "text-align",
  10211. "text-align-last",
  10212. "text-combine-upright",
  10213. "text-decoration",
  10214. "text-decoration-color",
  10215. "text-decoration-line",
  10216. "text-decoration-skip",
  10217. "text-decoration-skip-ink",
  10218. "text-decoration-style",
  10219. "text-emphasis",
  10220. "text-emphasis-color",
  10221. "text-emphasis-position",
  10222. "text-emphasis-style",
  10223. "text-height",
  10224. "text-indent",
  10225. "text-justify",
  10226. "text-orientation",
  10227. "text-outline",
  10228. "text-overflow",
  10229. "text-rendering",
  10230. "text-shadow",
  10231. "text-size-adjust",
  10232. "text-space-collapse",
  10233. "text-transform",
  10234. "text-underline-position",
  10235. "text-wrap",
  10236. "top",
  10237. "touch-action",
  10238. "transform",
  10239. "transform-origin",
  10240. "transform-style",
  10241. "transition",
  10242. "transition-delay",
  10243. "transition-duration",
  10244. "transition-property",
  10245. "transition-timing-function",
  10246. "translate",
  10247. "unicode-bidi",
  10248. "user-select",
  10249. "vertical-align",
  10250. "visibility",
  10251. "voice-balance",
  10252. "voice-duration",
  10253. "voice-family",
  10254. "voice-pitch",
  10255. "voice-range",
  10256. "voice-rate",
  10257. "voice-stress",
  10258. "voice-volume",
  10259. "volume",
  10260. "white-space",
  10261. "widows",
  10262. "width",
  10263. "will-change",
  10264. "word-break",
  10265. "word-spacing",
  10266. "word-wrap",
  10267. "writing-mode",
  10268. "z-index",
  10269. "clip-path",
  10270. "clip-rule",
  10271. "mask",
  10272. "enable-background",
  10273. "filter",
  10274. "flood-color",
  10275. "flood-opacity",
  10276. "lighting-color",
  10277. "stop-color",
  10278. "stop-opacity",
  10279. "pointer-events",
  10280. "color-interpolation",
  10281. "color-interpolation-filters",
  10282. "color-rendering",
  10283. "fill",
  10284. "fill-opacity",
  10285. "fill-rule",
  10286. "image-rendering",
  10287. "marker",
  10288. "marker-end",
  10289. "marker-mid",
  10290. "marker-start",
  10291. "paint-order",
  10292. "shape-rendering",
  10293. "stroke",
  10294. "stroke-dasharray",
  10295. "stroke-dashoffset",
  10296. "stroke-linecap",
  10297. "stroke-linejoin",
  10298. "stroke-miterlimit",
  10299. "stroke-opacity",
  10300. "stroke-width",
  10301. "text-rendering",
  10302. "baseline-shift",
  10303. "dominant-baseline",
  10304. "glyph-orientation-horizontal",
  10305. "glyph-orientation-vertical",
  10306. "text-anchor",
  10307. "writing-mode"
  10308. ], propertyKeywords = keySet(propertyKeywords_);
  10309. var nonStandardPropertyKeywords_ = [
  10310. "accent-color",
  10311. "aspect-ratio",
  10312. "border-block",
  10313. "border-block-color",
  10314. "border-block-end",
  10315. "border-block-end-color",
  10316. "border-block-end-style",
  10317. "border-block-end-width",
  10318. "border-block-start",
  10319. "border-block-start-color",
  10320. "border-block-start-style",
  10321. "border-block-start-width",
  10322. "border-block-style",
  10323. "border-block-width",
  10324. "border-inline",
  10325. "border-inline-color",
  10326. "border-inline-end",
  10327. "border-inline-end-color",
  10328. "border-inline-end-style",
  10329. "border-inline-end-width",
  10330. "border-inline-start",
  10331. "border-inline-start-color",
  10332. "border-inline-start-style",
  10333. "border-inline-start-width",
  10334. "border-inline-style",
  10335. "border-inline-width",
  10336. "content-visibility",
  10337. "margin-block",
  10338. "margin-block-end",
  10339. "margin-block-start",
  10340. "margin-inline",
  10341. "margin-inline-end",
  10342. "margin-inline-start",
  10343. "overflow-anchor",
  10344. "overscroll-behavior",
  10345. "padding-block",
  10346. "padding-block-end",
  10347. "padding-block-start",
  10348. "padding-inline",
  10349. "padding-inline-end",
  10350. "padding-inline-start",
  10351. "scroll-snap-stop",
  10352. "scrollbar-3d-light-color",
  10353. "scrollbar-arrow-color",
  10354. "scrollbar-base-color",
  10355. "scrollbar-dark-shadow-color",
  10356. "scrollbar-face-color",
  10357. "scrollbar-highlight-color",
  10358. "scrollbar-shadow-color",
  10359. "scrollbar-track-color",
  10360. "searchfield-cancel-button",
  10361. "searchfield-decoration",
  10362. "searchfield-results-button",
  10363. "searchfield-results-decoration",
  10364. "shape-inside",
  10365. "zoom"
  10366. ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
  10367. var fontProperties_ = [
  10368. "font-display",
  10369. "font-family",
  10370. "src",
  10371. "unicode-range",
  10372. "font-variant",
  10373. "font-feature-settings",
  10374. "font-stretch",
  10375. "font-weight",
  10376. "font-style"
  10377. ], fontProperties = keySet(fontProperties_);
  10378. var counterDescriptors_ = [
  10379. "additive-symbols",
  10380. "fallback",
  10381. "negative",
  10382. "pad",
  10383. "prefix",
  10384. "range",
  10385. "speak-as",
  10386. "suffix",
  10387. "symbols",
  10388. "system"
  10389. ], counterDescriptors = keySet(counterDescriptors_);
  10390. var colorKeywords_ = [
  10391. "aliceblue",
  10392. "antiquewhite",
  10393. "aqua",
  10394. "aquamarine",
  10395. "azure",
  10396. "beige",
  10397. "bisque",
  10398. "black",
  10399. "blanchedalmond",
  10400. "blue",
  10401. "blueviolet",
  10402. "brown",
  10403. "burlywood",
  10404. "cadetblue",
  10405. "chartreuse",
  10406. "chocolate",
  10407. "coral",
  10408. "cornflowerblue",
  10409. "cornsilk",
  10410. "crimson",
  10411. "cyan",
  10412. "darkblue",
  10413. "darkcyan",
  10414. "darkgoldenrod",
  10415. "darkgray",
  10416. "darkgreen",
  10417. "darkgrey",
  10418. "darkkhaki",
  10419. "darkmagenta",
  10420. "darkolivegreen",
  10421. "darkorange",
  10422. "darkorchid",
  10423. "darkred",
  10424. "darksalmon",
  10425. "darkseagreen",
  10426. "darkslateblue",
  10427. "darkslategray",
  10428. "darkslategrey",
  10429. "darkturquoise",
  10430. "darkviolet",
  10431. "deeppink",
  10432. "deepskyblue",
  10433. "dimgray",
  10434. "dimgrey",
  10435. "dodgerblue",
  10436. "firebrick",
  10437. "floralwhite",
  10438. "forestgreen",
  10439. "fuchsia",
  10440. "gainsboro",
  10441. "ghostwhite",
  10442. "gold",
  10443. "goldenrod",
  10444. "gray",
  10445. "grey",
  10446. "green",
  10447. "greenyellow",
  10448. "honeydew",
  10449. "hotpink",
  10450. "indianred",
  10451. "indigo",
  10452. "ivory",
  10453. "khaki",
  10454. "lavender",
  10455. "lavenderblush",
  10456. "lawngreen",
  10457. "lemonchiffon",
  10458. "lightblue",
  10459. "lightcoral",
  10460. "lightcyan",
  10461. "lightgoldenrodyellow",
  10462. "lightgray",
  10463. "lightgreen",
  10464. "lightgrey",
  10465. "lightpink",
  10466. "lightsalmon",
  10467. "lightseagreen",
  10468. "lightskyblue",
  10469. "lightslategray",
  10470. "lightslategrey",
  10471. "lightsteelblue",
  10472. "lightyellow",
  10473. "lime",
  10474. "limegreen",
  10475. "linen",
  10476. "magenta",
  10477. "maroon",
  10478. "mediumaquamarine",
  10479. "mediumblue",
  10480. "mediumorchid",
  10481. "mediumpurple",
  10482. "mediumseagreen",
  10483. "mediumslateblue",
  10484. "mediumspringgreen",
  10485. "mediumturquoise",
  10486. "mediumvioletred",
  10487. "midnightblue",
  10488. "mintcream",
  10489. "mistyrose",
  10490. "moccasin",
  10491. "navajowhite",
  10492. "navy",
  10493. "oldlace",
  10494. "olive",
  10495. "olivedrab",
  10496. "orange",
  10497. "orangered",
  10498. "orchid",
  10499. "palegoldenrod",
  10500. "palegreen",
  10501. "paleturquoise",
  10502. "palevioletred",
  10503. "papayawhip",
  10504. "peachpuff",
  10505. "peru",
  10506. "pink",
  10507. "plum",
  10508. "powderblue",
  10509. "purple",
  10510. "rebeccapurple",
  10511. "red",
  10512. "rosybrown",
  10513. "royalblue",
  10514. "saddlebrown",
  10515. "salmon",
  10516. "sandybrown",
  10517. "seagreen",
  10518. "seashell",
  10519. "sienna",
  10520. "silver",
  10521. "skyblue",
  10522. "slateblue",
  10523. "slategray",
  10524. "slategrey",
  10525. "snow",
  10526. "springgreen",
  10527. "steelblue",
  10528. "tan",
  10529. "teal",
  10530. "thistle",
  10531. "tomato",
  10532. "turquoise",
  10533. "violet",
  10534. "wheat",
  10535. "white",
  10536. "whitesmoke",
  10537. "yellow",
  10538. "yellowgreen"
  10539. ], colorKeywords = keySet(colorKeywords_);
  10540. var valueKeywords_ = [
  10541. "above",
  10542. "absolute",
  10543. "activeborder",
  10544. "additive",
  10545. "activecaption",
  10546. "afar",
  10547. "after-white-space",
  10548. "ahead",
  10549. "alias",
  10550. "all",
  10551. "all-scroll",
  10552. "alphabetic",
  10553. "alternate",
  10554. "always",
  10555. "amharic",
  10556. "amharic-abegede",
  10557. "antialiased",
  10558. "appworkspace",
  10559. "arabic-indic",
  10560. "armenian",
  10561. "asterisks",
  10562. "attr",
  10563. "auto",
  10564. "auto-flow",
  10565. "avoid",
  10566. "avoid-column",
  10567. "avoid-page",
  10568. "avoid-region",
  10569. "axis-pan",
  10570. "background",
  10571. "backwards",
  10572. "baseline",
  10573. "below",
  10574. "bidi-override",
  10575. "binary",
  10576. "bengali",
  10577. "blink",
  10578. "block",
  10579. "block-axis",
  10580. "blur",
  10581. "bold",
  10582. "bolder",
  10583. "border",
  10584. "border-box",
  10585. "both",
  10586. "bottom",
  10587. "break",
  10588. "break-all",
  10589. "break-word",
  10590. "brightness",
  10591. "bullets",
  10592. "button",
  10593. "buttonface",
  10594. "buttonhighlight",
  10595. "buttonshadow",
  10596. "buttontext",
  10597. "calc",
  10598. "cambodian",
  10599. "capitalize",
  10600. "caps-lock-indicator",
  10601. "caption",
  10602. "captiontext",
  10603. "caret",
  10604. "cell",
  10605. "center",
  10606. "checkbox",
  10607. "circle",
  10608. "cjk-decimal",
  10609. "cjk-earthly-branch",
  10610. "cjk-heavenly-stem",
  10611. "cjk-ideographic",
  10612. "clear",
  10613. "clip",
  10614. "close-quote",
  10615. "col-resize",
  10616. "collapse",
  10617. "color",
  10618. "color-burn",
  10619. "color-dodge",
  10620. "column",
  10621. "column-reverse",
  10622. "compact",
  10623. "condensed",
  10624. "conic-gradient",
  10625. "contain",
  10626. "content",
  10627. "contents",
  10628. "content-box",
  10629. "context-menu",
  10630. "continuous",
  10631. "contrast",
  10632. "copy",
  10633. "counter",
  10634. "counters",
  10635. "cover",
  10636. "crop",
  10637. "cross",
  10638. "crosshair",
  10639. "cubic-bezier",
  10640. "currentcolor",
  10641. "cursive",
  10642. "cyclic",
  10643. "darken",
  10644. "dashed",
  10645. "decimal",
  10646. "decimal-leading-zero",
  10647. "default",
  10648. "default-button",
  10649. "dense",
  10650. "destination-atop",
  10651. "destination-in",
  10652. "destination-out",
  10653. "destination-over",
  10654. "devanagari",
  10655. "difference",
  10656. "disc",
  10657. "discard",
  10658. "disclosure-closed",
  10659. "disclosure-open",
  10660. "document",
  10661. "dot-dash",
  10662. "dot-dot-dash",
  10663. "dotted",
  10664. "double",
  10665. "down",
  10666. "drop-shadow",
  10667. "e-resize",
  10668. "ease",
  10669. "ease-in",
  10670. "ease-in-out",
  10671. "ease-out",
  10672. "element",
  10673. "ellipse",
  10674. "ellipsis",
  10675. "embed",
  10676. "end",
  10677. "ethiopic",
  10678. "ethiopic-abegede",
  10679. "ethiopic-abegede-am-et",
  10680. "ethiopic-abegede-gez",
  10681. "ethiopic-abegede-ti-er",
  10682. "ethiopic-abegede-ti-et",
  10683. "ethiopic-halehame-aa-er",
  10684. "ethiopic-halehame-aa-et",
  10685. "ethiopic-halehame-am-et",
  10686. "ethiopic-halehame-gez",
  10687. "ethiopic-halehame-om-et",
  10688. "ethiopic-halehame-sid-et",
  10689. "ethiopic-halehame-so-et",
  10690. "ethiopic-halehame-ti-er",
  10691. "ethiopic-halehame-ti-et",
  10692. "ethiopic-halehame-tig",
  10693. "ethiopic-numeric",
  10694. "ew-resize",
  10695. "exclusion",
  10696. "expanded",
  10697. "extends",
  10698. "extra-condensed",
  10699. "extra-expanded",
  10700. "fantasy",
  10701. "fast",
  10702. "fill",
  10703. "fill-box",
  10704. "fixed",
  10705. "flat",
  10706. "flex",
  10707. "flex-end",
  10708. "flex-start",
  10709. "footnotes",
  10710. "forwards",
  10711. "from",
  10712. "geometricPrecision",
  10713. "georgian",
  10714. "grayscale",
  10715. "graytext",
  10716. "grid",
  10717. "groove",
  10718. "gujarati",
  10719. "gurmukhi",
  10720. "hand",
  10721. "hangul",
  10722. "hangul-consonant",
  10723. "hard-light",
  10724. "hebrew",
  10725. "help",
  10726. "hidden",
  10727. "hide",
  10728. "higher",
  10729. "highlight",
  10730. "highlighttext",
  10731. "hiragana",
  10732. "hiragana-iroha",
  10733. "horizontal",
  10734. "hsl",
  10735. "hsla",
  10736. "hue",
  10737. "hue-rotate",
  10738. "icon",
  10739. "ignore",
  10740. "inactiveborder",
  10741. "inactivecaption",
  10742. "inactivecaptiontext",
  10743. "infinite",
  10744. "infobackground",
  10745. "infotext",
  10746. "inherit",
  10747. "initial",
  10748. "inline",
  10749. "inline-axis",
  10750. "inline-block",
  10751. "inline-flex",
  10752. "inline-grid",
  10753. "inline-table",
  10754. "inset",
  10755. "inside",
  10756. "intrinsic",
  10757. "invert",
  10758. "italic",
  10759. "japanese-formal",
  10760. "japanese-informal",
  10761. "justify",
  10762. "kannada",
  10763. "katakana",
  10764. "katakana-iroha",
  10765. "keep-all",
  10766. "khmer",
  10767. "korean-hangul-formal",
  10768. "korean-hanja-formal",
  10769. "korean-hanja-informal",
  10770. "landscape",
  10771. "lao",
  10772. "large",
  10773. "larger",
  10774. "left",
  10775. "level",
  10776. "lighter",
  10777. "lighten",
  10778. "line-through",
  10779. "linear",
  10780. "linear-gradient",
  10781. "lines",
  10782. "list-item",
  10783. "listbox",
  10784. "listitem",
  10785. "local",
  10786. "logical",
  10787. "loud",
  10788. "lower",
  10789. "lower-alpha",
  10790. "lower-armenian",
  10791. "lower-greek",
  10792. "lower-hexadecimal",
  10793. "lower-latin",
  10794. "lower-norwegian",
  10795. "lower-roman",
  10796. "lowercase",
  10797. "ltr",
  10798. "luminosity",
  10799. "malayalam",
  10800. "manipulation",
  10801. "match",
  10802. "matrix",
  10803. "matrix3d",
  10804. "media-play-button",
  10805. "media-slider",
  10806. "media-sliderthumb",
  10807. "media-volume-slider",
  10808. "media-volume-sliderthumb",
  10809. "medium",
  10810. "menu",
  10811. "menulist",
  10812. "menulist-button",
  10813. "menutext",
  10814. "message-box",
  10815. "middle",
  10816. "min-intrinsic",
  10817. "mix",
  10818. "mongolian",
  10819. "monospace",
  10820. "move",
  10821. "multiple",
  10822. "multiple_mask_images",
  10823. "multiply",
  10824. "myanmar",
  10825. "n-resize",
  10826. "narrower",
  10827. "ne-resize",
  10828. "nesw-resize",
  10829. "no-close-quote",
  10830. "no-drop",
  10831. "no-open-quote",
  10832. "no-repeat",
  10833. "none",
  10834. "normal",
  10835. "not-allowed",
  10836. "nowrap",
  10837. "ns-resize",
  10838. "numbers",
  10839. "numeric",
  10840. "nw-resize",
  10841. "nwse-resize",
  10842. "oblique",
  10843. "octal",
  10844. "opacity",
  10845. "open-quote",
  10846. "optimizeLegibility",
  10847. "optimizeSpeed",
  10848. "oriya",
  10849. "oromo",
  10850. "outset",
  10851. "outside",
  10852. "outside-shape",
  10853. "overlay",
  10854. "overline",
  10855. "padding",
  10856. "padding-box",
  10857. "painted",
  10858. "page",
  10859. "paused",
  10860. "persian",
  10861. "perspective",
  10862. "pinch-zoom",
  10863. "plus-darker",
  10864. "plus-lighter",
  10865. "pointer",
  10866. "polygon",
  10867. "portrait",
  10868. "pre",
  10869. "pre-line",
  10870. "pre-wrap",
  10871. "preserve-3d",
  10872. "progress",
  10873. "push-button",
  10874. "radial-gradient",
  10875. "radio",
  10876. "read-only",
  10877. "read-write",
  10878. "read-write-plaintext-only",
  10879. "rectangle",
  10880. "region",
  10881. "relative",
  10882. "repeat",
  10883. "repeating-linear-gradient",
  10884. "repeating-radial-gradient",
  10885. "repeating-conic-gradient",
  10886. "repeat-x",
  10887. "repeat-y",
  10888. "reset",
  10889. "reverse",
  10890. "rgb",
  10891. "rgba",
  10892. "ridge",
  10893. "right",
  10894. "rotate",
  10895. "rotate3d",
  10896. "rotateX",
  10897. "rotateY",
  10898. "rotateZ",
  10899. "round",
  10900. "row",
  10901. "row-resize",
  10902. "row-reverse",
  10903. "rtl",
  10904. "run-in",
  10905. "running",
  10906. "s-resize",
  10907. "sans-serif",
  10908. "saturate",
  10909. "saturation",
  10910. "scale",
  10911. "scale3d",
  10912. "scaleX",
  10913. "scaleY",
  10914. "scaleZ",
  10915. "screen",
  10916. "scroll",
  10917. "scrollbar",
  10918. "scroll-position",
  10919. "se-resize",
  10920. "searchfield",
  10921. "searchfield-cancel-button",
  10922. "searchfield-decoration",
  10923. "searchfield-results-button",
  10924. "searchfield-results-decoration",
  10925. "self-start",
  10926. "self-end",
  10927. "semi-condensed",
  10928. "semi-expanded",
  10929. "separate",
  10930. "sepia",
  10931. "serif",
  10932. "show",
  10933. "sidama",
  10934. "simp-chinese-formal",
  10935. "simp-chinese-informal",
  10936. "single",
  10937. "skew",
  10938. "skewX",
  10939. "skewY",
  10940. "skip-white-space",
  10941. "slide",
  10942. "slider-horizontal",
  10943. "slider-vertical",
  10944. "sliderthumb-horizontal",
  10945. "sliderthumb-vertical",
  10946. "slow",
  10947. "small",
  10948. "small-caps",
  10949. "small-caption",
  10950. "smaller",
  10951. "soft-light",
  10952. "solid",
  10953. "somali",
  10954. "source-atop",
  10955. "source-in",
  10956. "source-out",
  10957. "source-over",
  10958. "space",
  10959. "space-around",
  10960. "space-between",
  10961. "space-evenly",
  10962. "spell-out",
  10963. "square",
  10964. "square-button",
  10965. "start",
  10966. "static",
  10967. "status-bar",
  10968. "stretch",
  10969. "stroke",
  10970. "stroke-box",
  10971. "sub",
  10972. "subpixel-antialiased",
  10973. "svg_masks",
  10974. "super",
  10975. "sw-resize",
  10976. "symbolic",
  10977. "symbols",
  10978. "system-ui",
  10979. "table",
  10980. "table-caption",
  10981. "table-cell",
  10982. "table-column",
  10983. "table-column-group",
  10984. "table-footer-group",
  10985. "table-header-group",
  10986. "table-row",
  10987. "table-row-group",
  10988. "tamil",
  10989. "telugu",
  10990. "text",
  10991. "text-bottom",
  10992. "text-top",
  10993. "textarea",
  10994. "textfield",
  10995. "thai",
  10996. "thick",
  10997. "thin",
  10998. "threeddarkshadow",
  10999. "threedface",
  11000. "threedhighlight",
  11001. "threedlightshadow",
  11002. "threedshadow",
  11003. "tibetan",
  11004. "tigre",
  11005. "tigrinya-er",
  11006. "tigrinya-er-abegede",
  11007. "tigrinya-et",
  11008. "tigrinya-et-abegede",
  11009. "to",
  11010. "top",
  11011. "trad-chinese-formal",
  11012. "trad-chinese-informal",
  11013. "transform",
  11014. "translate",
  11015. "translate3d",
  11016. "translateX",
  11017. "translateY",
  11018. "translateZ",
  11019. "transparent",
  11020. "ultra-condensed",
  11021. "ultra-expanded",
  11022. "underline",
  11023. "unidirectional-pan",
  11024. "unset",
  11025. "up",
  11026. "upper-alpha",
  11027. "upper-armenian",
  11028. "upper-greek",
  11029. "upper-hexadecimal",
  11030. "upper-latin",
  11031. "upper-norwegian",
  11032. "upper-roman",
  11033. "uppercase",
  11034. "urdu",
  11035. "url",
  11036. "var",
  11037. "vertical",
  11038. "vertical-text",
  11039. "view-box",
  11040. "visible",
  11041. "visibleFill",
  11042. "visiblePainted",
  11043. "visibleStroke",
  11044. "visual",
  11045. "w-resize",
  11046. "wait",
  11047. "wave",
  11048. "wider",
  11049. "window",
  11050. "windowframe",
  11051. "windowtext",
  11052. "words",
  11053. "wrap",
  11054. "wrap-reverse",
  11055. "x-large",
  11056. "x-small",
  11057. "xor",
  11058. "xx-large",
  11059. "xx-small"
  11060. ], valueKeywords = keySet(valueKeywords_);
  11061. var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_).concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
  11062. CodeMirror$1.registerHelper("hintWords", "css", allWords);
  11063. function tokenCComment(stream, state) {
  11064. var maybeEnd = false, ch;
  11065. while ((ch = stream.next()) != null) {
  11066. if (maybeEnd && ch == "/") {
  11067. state.tokenize = null;
  11068. break;
  11069. }
  11070. maybeEnd = ch == "*";
  11071. }
  11072. return ["comment", "comment"];
  11073. }
  11074. CodeMirror$1.defineMIME("text/css", {
  11075. documentTypes,
  11076. mediaTypes,
  11077. mediaFeatures,
  11078. mediaValueKeywords,
  11079. propertyKeywords,
  11080. nonStandardPropertyKeywords,
  11081. fontProperties,
  11082. counterDescriptors,
  11083. colorKeywords,
  11084. valueKeywords,
  11085. tokenHooks: { "/": function(stream, state) {
  11086. if (!stream.eat("*")) return false;
  11087. state.tokenize = tokenCComment;
  11088. return tokenCComment(stream, state);
  11089. } },
  11090. name: "css"
  11091. });
  11092. CodeMirror$1.defineMIME("text/x-scss", {
  11093. mediaTypes,
  11094. mediaFeatures,
  11095. mediaValueKeywords,
  11096. propertyKeywords,
  11097. nonStandardPropertyKeywords,
  11098. colorKeywords,
  11099. valueKeywords,
  11100. fontProperties,
  11101. allowNested: true,
  11102. lineComment: "//",
  11103. tokenHooks: {
  11104. "/": function(stream, state) {
  11105. if (stream.eat("/")) {
  11106. stream.skipToEnd();
  11107. return ["comment", "comment"];
  11108. } else if (stream.eat("*")) {
  11109. state.tokenize = tokenCComment;
  11110. return tokenCComment(stream, state);
  11111. } else return ["operator", "operator"];
  11112. },
  11113. ":": function(stream) {
  11114. if (stream.match(/^\s*\{/, false)) return [null, null];
  11115. return false;
  11116. },
  11117. "$": function(stream) {
  11118. stream.match(/^[\w-]+/);
  11119. if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"];
  11120. return ["variable-2", "variable"];
  11121. },
  11122. "#": function(stream) {
  11123. if (!stream.eat("{")) return false;
  11124. return [null, "interpolation"];
  11125. }
  11126. },
  11127. name: "css",
  11128. helperType: "scss"
  11129. });
  11130. CodeMirror$1.defineMIME("text/x-less", {
  11131. mediaTypes,
  11132. mediaFeatures,
  11133. mediaValueKeywords,
  11134. propertyKeywords,
  11135. nonStandardPropertyKeywords,
  11136. colorKeywords,
  11137. valueKeywords,
  11138. fontProperties,
  11139. allowNested: true,
  11140. lineComment: "//",
  11141. tokenHooks: {
  11142. "/": function(stream, state) {
  11143. if (stream.eat("/")) {
  11144. stream.skipToEnd();
  11145. return ["comment", "comment"];
  11146. } else if (stream.eat("*")) {
  11147. state.tokenize = tokenCComment;
  11148. return tokenCComment(stream, state);
  11149. } else return ["operator", "operator"];
  11150. },
  11151. "@": function(stream) {
  11152. if (stream.eat("{")) return [null, "interpolation"];
  11153. if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
  11154. stream.eatWhile(/[\w\\\-]/);
  11155. if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"];
  11156. return ["variable-2", "variable"];
  11157. },
  11158. "&": function() {
  11159. return ["atom", "atom"];
  11160. }
  11161. },
  11162. name: "css",
  11163. helperType: "less"
  11164. });
  11165. CodeMirror$1.defineMIME("text/x-gss", {
  11166. documentTypes,
  11167. mediaTypes,
  11168. mediaFeatures,
  11169. propertyKeywords,
  11170. nonStandardPropertyKeywords,
  11171. fontProperties,
  11172. counterDescriptors,
  11173. colorKeywords,
  11174. valueKeywords,
  11175. supportsAtComponent: true,
  11176. tokenHooks: { "/": function(stream, state) {
  11177. if (!stream.eat("*")) return false;
  11178. state.tokenize = tokenCComment;
  11179. return tokenCComment(stream, state);
  11180. } },
  11181. name: "css",
  11182. helperType: "gss"
  11183. });
  11184. });
  11185. });
  11186. var require_simple = __commonJSMin((exports, module) => {
  11187. (function(mod) {
  11188. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  11189. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  11190. else mod(CodeMirror);
  11191. })(function(CodeMirror$1) {
  11192. "use strict";
  11193. CodeMirror$1.defineSimpleMode = function(name, states) {
  11194. CodeMirror$1.defineMode(name, function(config) {
  11195. return CodeMirror$1.simpleMode(config, states);
  11196. });
  11197. };
  11198. CodeMirror$1.simpleMode = function(config, states) {
  11199. ensureState(states, "start");
  11200. var states_ = {}, meta = states.meta || {}, hasIndentation = false;
  11201. for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
  11202. var list = states_[state] = [], orig = states[state];
  11203. for (var i = 0; i < orig.length; i++) {
  11204. var data = orig[i];
  11205. list.push(new Rule(data, states));
  11206. if (data.indent || data.dedent) hasIndentation = true;
  11207. }
  11208. }
  11209. var mode = {
  11210. startState: function() {
  11211. return {
  11212. state: "start",
  11213. pending: null,
  11214. local: null,
  11215. localState: null,
  11216. indent: hasIndentation ? [] : null
  11217. };
  11218. },
  11219. copyState: function(state$1) {
  11220. var s = {
  11221. state: state$1.state,
  11222. pending: state$1.pending,
  11223. local: state$1.local,
  11224. localState: null,
  11225. indent: state$1.indent && state$1.indent.slice(0)
  11226. };
  11227. if (state$1.localState) s.localState = CodeMirror$1.copyState(state$1.local.mode, state$1.localState);
  11228. if (state$1.stack) s.stack = state$1.stack.slice(0);
  11229. for (var pers = state$1.persistentStates; pers; pers = pers.next) s.persistentStates = {
  11230. mode: pers.mode,
  11231. spec: pers.spec,
  11232. state: pers.state == state$1.localState ? s.localState : CodeMirror$1.copyState(pers.mode, pers.state),
  11233. next: s.persistentStates
  11234. };
  11235. return s;
  11236. },
  11237. token: tokenFunction(states_, config),
  11238. innerMode: function(state$1) {
  11239. return state$1.local && {
  11240. mode: state$1.local.mode,
  11241. state: state$1.localState
  11242. };
  11243. },
  11244. indent: indentFunction(states_, meta)
  11245. };
  11246. if (meta) {
  11247. for (var prop in meta) if (meta.hasOwnProperty(prop)) mode[prop] = meta[prop];
  11248. }
  11249. return mode;
  11250. };
  11251. function ensureState(states, name) {
  11252. if (!states.hasOwnProperty(name)) throw new Error("Undefined state " + name + " in simple mode");
  11253. }
  11254. function toRegex(val, caret) {
  11255. if (!val) return /(?:)/;
  11256. var flags = "";
  11257. if (val instanceof RegExp) {
  11258. if (val.ignoreCase) flags = "i";
  11259. if (val.unicode) flags += "u";
  11260. val = val.source;
  11261. } else val = String(val);
  11262. return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
  11263. }
  11264. function asToken(val) {
  11265. if (!val) return null;
  11266. if (val.apply) return val;
  11267. if (typeof val == "string") return val.replace(/\./g, " ");
  11268. var result = [];
  11269. for (var i = 0; i < val.length; i++) result.push(val[i] && val[i].replace(/\./g, " "));
  11270. return result;
  11271. }
  11272. function Rule(data, states) {
  11273. if (data.next || data.push) ensureState(states, data.next || data.push);
  11274. this.regex = toRegex(data.regex);
  11275. this.token = asToken(data.token);
  11276. this.data = data;
  11277. }
  11278. function tokenFunction(states, config) {
  11279. return function(stream, state) {
  11280. if (state.pending) {
  11281. var pend = state.pending.shift();
  11282. if (state.pending.length == 0) state.pending = null;
  11283. stream.pos += pend.text.length;
  11284. return pend.token;
  11285. }
  11286. if (state.local) if (state.local.end && stream.match(state.local.end)) {
  11287. var tok = state.local.endToken || null;
  11288. state.local = state.localState = null;
  11289. return tok;
  11290. } else {
  11291. var tok = state.local.mode.token(stream, state.localState), m;
  11292. if (state.local.endScan && (m = state.local.endScan.exec(stream.current()))) stream.pos = stream.start + m.index;
  11293. return tok;
  11294. }
  11295. var curState = states[state.state];
  11296. for (var i = 0; i < curState.length; i++) {
  11297. var rule = curState[i];
  11298. var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
  11299. if (matches) {
  11300. if (rule.data.next) state.state = rule.data.next;
  11301. else if (rule.data.push) {
  11302. (state.stack || (state.stack = [])).push(state.state);
  11303. state.state = rule.data.push;
  11304. } else if (rule.data.pop && state.stack && state.stack.length) state.state = state.stack.pop();
  11305. if (rule.data.mode) enterLocalMode(config, state, rule.data.mode, rule.token);
  11306. if (rule.data.indent) state.indent.push(stream.indentation() + config.indentUnit);
  11307. if (rule.data.dedent) state.indent.pop();
  11308. var token = rule.token;
  11309. if (token && token.apply) token = token(matches);
  11310. if (matches.length > 2 && rule.token && typeof rule.token != "string") {
  11311. for (var j = 2; j < matches.length; j++) if (matches[j]) (state.pending || (state.pending = [])).push({
  11312. text: matches[j],
  11313. token: rule.token[j - 1]
  11314. });
  11315. stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
  11316. return token[0];
  11317. } else if (token && token.join) return token[0];
  11318. else return token;
  11319. }
  11320. }
  11321. stream.next();
  11322. return null;
  11323. };
  11324. }
  11325. function cmp(a, b) {
  11326. if (a === b) return true;
  11327. if (!a || typeof a != "object" || !b || typeof b != "object") return false;
  11328. var props = 0;
  11329. for (var prop in a) if (a.hasOwnProperty(prop)) {
  11330. if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
  11331. props++;
  11332. }
  11333. for (var prop in b) if (b.hasOwnProperty(prop)) props--;
  11334. return props == 0;
  11335. }
  11336. function enterLocalMode(config, state, spec, token) {
  11337. var pers;
  11338. if (spec.persistent) {
  11339. for (var p = state.persistentStates; p && !pers; p = p.next) if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
  11340. }
  11341. var mode = pers ? pers.mode : spec.mode || CodeMirror$1.getMode(config, spec.spec);
  11342. var lState = pers ? pers.state : CodeMirror$1.startState(mode);
  11343. if (spec.persistent && !pers) state.persistentStates = {
  11344. mode,
  11345. spec: spec.spec,
  11346. state: lState,
  11347. next: state.persistentStates
  11348. };
  11349. state.localState = lState;
  11350. state.local = {
  11351. mode,
  11352. end: spec.end && toRegex(spec.end),
  11353. endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
  11354. endToken: token && token.join ? token[token.length - 1] : token
  11355. };
  11356. }
  11357. function indexOf(val, arr) {
  11358. for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
  11359. }
  11360. function indentFunction(states, meta) {
  11361. return function(state, textAfter, line) {
  11362. if (state.local && state.local.mode.indent) return state.local.mode.indent(state.localState, textAfter, line);
  11363. if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1) return CodeMirror$1.Pass;
  11364. var pos = state.indent.length - 1, rules = states[state.state];
  11365. scan: for (;;) {
  11366. for (var i = 0; i < rules.length; i++) {
  11367. var rule = rules[i];
  11368. if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
  11369. var m = rule.regex.exec(textAfter);
  11370. if (m && m[0]) {
  11371. pos--;
  11372. if (rule.next || rule.push) rules = states[rule.next || rule.push];
  11373. textAfter = textAfter.slice(m[0].length);
  11374. continue scan;
  11375. }
  11376. }
  11377. }
  11378. break;
  11379. }
  11380. return pos < 0 ? 0 : state.indent[pos];
  11381. };
  11382. }
  11383. });
  11384. });
  11385. var require_multiplex = __commonJSMin((exports, module) => {
  11386. (function(mod) {
  11387. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  11388. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  11389. else mod(CodeMirror);
  11390. })(function(CodeMirror$1) {
  11391. "use strict";
  11392. CodeMirror$1.multiplexingMode = function(outer) {
  11393. var others = Array.prototype.slice.call(arguments, 1);
  11394. function indexOf(string, pattern, from, returnEnd) {
  11395. if (typeof pattern == "string") {
  11396. var found = string.indexOf(pattern, from);
  11397. return returnEnd && found > -1 ? found + pattern.length : found;
  11398. }
  11399. var m = pattern.exec(from ? string.slice(from) : string);
  11400. return m ? m.index + from + (returnEnd ? m[0].length : 0) : -1;
  11401. }
  11402. return {
  11403. startState: function() {
  11404. return {
  11405. outer: CodeMirror$1.startState(outer),
  11406. innerActive: null,
  11407. inner: null,
  11408. startingInner: false
  11409. };
  11410. },
  11411. copyState: function(state) {
  11412. return {
  11413. outer: CodeMirror$1.copyState(outer, state.outer),
  11414. innerActive: state.innerActive,
  11415. inner: state.innerActive && CodeMirror$1.copyState(state.innerActive.mode, state.inner),
  11416. startingInner: state.startingInner
  11417. };
  11418. },
  11419. token: function(stream, state) {
  11420. if (!state.innerActive) {
  11421. var cutOff = Infinity, oldContent = stream.string;
  11422. for (var i = 0; i < others.length; ++i) {
  11423. var other = others[i];
  11424. var found = indexOf(oldContent, other.open, stream.pos);
  11425. if (found == stream.pos) {
  11426. if (!other.parseDelimiters) stream.match(other.open);
  11427. state.startingInner = !!other.parseDelimiters;
  11428. state.innerActive = other;
  11429. var outerIndent = 0;
  11430. if (outer.indent) {
  11431. var possibleOuterIndent = outer.indent(state.outer, "", "");
  11432. if (possibleOuterIndent !== CodeMirror$1.Pass) outerIndent = possibleOuterIndent;
  11433. }
  11434. state.inner = CodeMirror$1.startState(other.mode, outerIndent);
  11435. return other.delimStyle && other.delimStyle + " " + other.delimStyle + "-open";
  11436. } else if (found != -1 && found < cutOff) cutOff = found;
  11437. }
  11438. if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
  11439. var outerToken = outer.token(stream, state.outer);
  11440. if (cutOff != Infinity) stream.string = oldContent;
  11441. return outerToken;
  11442. } else {
  11443. var curInner = state.innerActive, oldContent = stream.string;
  11444. if (!curInner.close && stream.sol()) {
  11445. state.innerActive = state.inner = null;
  11446. return this.token(stream, state);
  11447. }
  11448. var found = curInner.close && !state.startingInner ? indexOf(oldContent, curInner.close, stream.pos, curInner.parseDelimiters) : -1;
  11449. if (found == stream.pos && !curInner.parseDelimiters) {
  11450. stream.match(curInner.close);
  11451. state.innerActive = state.inner = null;
  11452. return curInner.delimStyle && curInner.delimStyle + " " + curInner.delimStyle + "-close";
  11453. }
  11454. if (found > -1) stream.string = oldContent.slice(0, found);
  11455. var innerToken = curInner.mode.token(stream, state.inner);
  11456. if (found > -1) stream.string = oldContent;
  11457. else if (stream.pos > stream.start) state.startingInner = false;
  11458. if (found == stream.pos && curInner.parseDelimiters) state.innerActive = state.inner = null;
  11459. if (curInner.innerStyle) if (innerToken) innerToken = innerToken + " " + curInner.innerStyle;
  11460. else innerToken = curInner.innerStyle;
  11461. return innerToken;
  11462. }
  11463. },
  11464. indent: function(state, textAfter, line) {
  11465. var mode = state.innerActive ? state.innerActive.mode : outer;
  11466. if (!mode.indent) return CodeMirror$1.Pass;
  11467. return mode.indent(state.innerActive ? state.inner : state.outer, textAfter, line);
  11468. },
  11469. blankLine: function(state) {
  11470. var mode = state.innerActive ? state.innerActive.mode : outer;
  11471. if (mode.blankLine) mode.blankLine(state.innerActive ? state.inner : state.outer);
  11472. if (!state.innerActive) for (var i = 0; i < others.length; ++i) {
  11473. var other = others[i];
  11474. if (other.open === "\n") {
  11475. state.innerActive = other;
  11476. state.inner = CodeMirror$1.startState(other.mode, mode.indent ? mode.indent(state.outer, "", "") : 0);
  11477. }
  11478. }
  11479. else if (state.innerActive.close === "\n") state.innerActive = state.inner = null;
  11480. },
  11481. electricChars: outer.electricChars,
  11482. innerMode: function(state) {
  11483. return state.inner ? {
  11484. state: state.inner,
  11485. mode: state.innerActive.mode
  11486. } : {
  11487. state: state.outer,
  11488. mode: outer
  11489. };
  11490. }
  11491. };
  11492. };
  11493. });
  11494. });
  11495. var require_handlebars = __commonJSMin((exports, module) => {
  11496. (function(mod) {
  11497. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_simple(), require_multiplex());
  11498. else if (typeof define == "function" && define.amd) define([
  11499. "../../lib/codemirror",
  11500. "../../addon/mode/simple",
  11501. "../../addon/mode/multiplex"
  11502. ], mod);
  11503. else mod(CodeMirror);
  11504. })(function(CodeMirror$1) {
  11505. "use strict";
  11506. CodeMirror$1.defineSimpleMode("handlebars-tags", {
  11507. start: [
  11508. {
  11509. regex: /\{\{\{/,
  11510. push: "handlebars_raw",
  11511. token: "tag"
  11512. },
  11513. {
  11514. regex: /\{\{!--/,
  11515. push: "dash_comment",
  11516. token: "comment"
  11517. },
  11518. {
  11519. regex: /\{\{!/,
  11520. push: "comment",
  11521. token: "comment"
  11522. },
  11523. {
  11524. regex: /\{\{/,
  11525. push: "handlebars",
  11526. token: "tag"
  11527. }
  11528. ],
  11529. handlebars_raw: [{
  11530. regex: /\}\}\}/,
  11531. pop: true,
  11532. token: "tag"
  11533. }],
  11534. handlebars: [
  11535. {
  11536. regex: /\}\}/,
  11537. pop: true,
  11538. token: "tag"
  11539. },
  11540. {
  11541. regex: /"(?:[^\\"]|\\.)*"?/,
  11542. token: "string"
  11543. },
  11544. {
  11545. regex: /'(?:[^\\']|\\.)*'?/,
  11546. token: "string"
  11547. },
  11548. {
  11549. regex: />|[#\/]([A-Za-z_]\w*)/,
  11550. token: "keyword"
  11551. },
  11552. {
  11553. regex: /(?:else|this)\b/,
  11554. token: "keyword"
  11555. },
  11556. {
  11557. regex: /\d+/i,
  11558. token: "number"
  11559. },
  11560. {
  11561. regex: /=|~|@|true|false/,
  11562. token: "atom"
  11563. },
  11564. {
  11565. regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/,
  11566. token: "variable-2"
  11567. }
  11568. ],
  11569. dash_comment: [{
  11570. regex: /--\}\}/,
  11571. pop: true,
  11572. token: "comment"
  11573. }, {
  11574. regex: /./,
  11575. token: "comment"
  11576. }],
  11577. comment: [{
  11578. regex: /\}\}/,
  11579. pop: true,
  11580. token: "comment"
  11581. }, {
  11582. regex: /./,
  11583. token: "comment"
  11584. }],
  11585. meta: {
  11586. blockCommentStart: "{{--",
  11587. blockCommentEnd: "--}}"
  11588. }
  11589. });
  11590. CodeMirror$1.defineMode("handlebars", function(config, parserConfig) {
  11591. var handlebars = CodeMirror$1.getMode(config, "handlebars-tags");
  11592. if (!parserConfig || !parserConfig.base) return handlebars;
  11593. return CodeMirror$1.multiplexingMode(CodeMirror$1.getMode(config, parserConfig.base), {
  11594. open: "{{",
  11595. close: /\}\}\}?/,
  11596. mode: handlebars,
  11597. parseDelimiters: true
  11598. });
  11599. });
  11600. CodeMirror$1.defineMIME("text/x-handlebars-template", "handlebars");
  11601. });
  11602. });
  11603. var require_xml = __commonJSMin((exports, module) => {
  11604. (function(mod) {
  11605. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  11606. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  11607. else mod(CodeMirror);
  11608. })(function(CodeMirror$1) {
  11609. "use strict";
  11610. var htmlConfig = {
  11611. autoSelfClosers: {
  11612. "area": true,
  11613. "base": true,
  11614. "br": true,
  11615. "col": true,
  11616. "command": true,
  11617. "embed": true,
  11618. "frame": true,
  11619. "hr": true,
  11620. "img": true,
  11621. "input": true,
  11622. "keygen": true,
  11623. "link": true,
  11624. "meta": true,
  11625. "param": true,
  11626. "source": true,
  11627. "track": true,
  11628. "wbr": true,
  11629. "menuitem": true
  11630. },
  11631. implicitlyClosed: {
  11632. "dd": true,
  11633. "li": true,
  11634. "optgroup": true,
  11635. "option": true,
  11636. "p": true,
  11637. "rp": true,
  11638. "rt": true,
  11639. "tbody": true,
  11640. "td": true,
  11641. "tfoot": true,
  11642. "th": true,
  11643. "tr": true
  11644. },
  11645. contextGrabbers: {
  11646. "dd": {
  11647. "dd": true,
  11648. "dt": true
  11649. },
  11650. "dt": {
  11651. "dd": true,
  11652. "dt": true
  11653. },
  11654. "li": { "li": true },
  11655. "option": {
  11656. "option": true,
  11657. "optgroup": true
  11658. },
  11659. "optgroup": { "optgroup": true },
  11660. "p": {
  11661. "address": true,
  11662. "article": true,
  11663. "aside": true,
  11664. "blockquote": true,
  11665. "dir": true,
  11666. "div": true,
  11667. "dl": true,
  11668. "fieldset": true,
  11669. "footer": true,
  11670. "form": true,
  11671. "h1": true,
  11672. "h2": true,
  11673. "h3": true,
  11674. "h4": true,
  11675. "h5": true,
  11676. "h6": true,
  11677. "header": true,
  11678. "hgroup": true,
  11679. "hr": true,
  11680. "menu": true,
  11681. "nav": true,
  11682. "ol": true,
  11683. "p": true,
  11684. "pre": true,
  11685. "section": true,
  11686. "table": true,
  11687. "ul": true
  11688. },
  11689. "rp": {
  11690. "rp": true,
  11691. "rt": true
  11692. },
  11693. "rt": {
  11694. "rp": true,
  11695. "rt": true
  11696. },
  11697. "tbody": {
  11698. "tbody": true,
  11699. "tfoot": true
  11700. },
  11701. "td": {
  11702. "td": true,
  11703. "th": true
  11704. },
  11705. "tfoot": { "tbody": true },
  11706. "th": {
  11707. "td": true,
  11708. "th": true
  11709. },
  11710. "thead": {
  11711. "tbody": true,
  11712. "tfoot": true
  11713. },
  11714. "tr": { "tr": true }
  11715. },
  11716. doNotIndent: { "pre": true },
  11717. allowUnquoted: true,
  11718. allowMissing: true,
  11719. caseFold: true
  11720. };
  11721. var xmlConfig = {
  11722. autoSelfClosers: {},
  11723. implicitlyClosed: {},
  11724. contextGrabbers: {},
  11725. doNotIndent: {},
  11726. allowUnquoted: false,
  11727. allowMissing: false,
  11728. allowMissingTagName: false,
  11729. caseFold: false
  11730. };
  11731. CodeMirror$1.defineMode("xml", function(editorConf, config_) {
  11732. var indentUnit = editorConf.indentUnit;
  11733. var config = {};
  11734. var defaults = config_.htmlMode ? htmlConfig : xmlConfig;
  11735. for (var prop in defaults) config[prop] = defaults[prop];
  11736. for (var prop in config_) config[prop] = config_[prop];
  11737. var type, setStyle;
  11738. function inText(stream, state) {
  11739. function chain(parser) {
  11740. state.tokenize = parser;
  11741. return parser(stream, state);
  11742. }
  11743. var ch = stream.next();
  11744. if (ch == "<") if (stream.eat("!")) if (stream.eat("[")) if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
  11745. else return null;
  11746. else if (stream.match("--")) return chain(inBlock("comment", "-->"));
  11747. else if (stream.match("DOCTYPE", true, true)) {
  11748. stream.eatWhile(/[\w\._\-]/);
  11749. return chain(doctype(1));
  11750. } else return null;
  11751. else if (stream.eat("?")) {
  11752. stream.eatWhile(/[\w\._\-]/);
  11753. state.tokenize = inBlock("meta", "?>");
  11754. return "meta";
  11755. } else {
  11756. type = stream.eat("/") ? "closeTag" : "openTag";
  11757. state.tokenize = inTag;
  11758. return "tag bracket";
  11759. }
  11760. else if (ch == "&") {
  11761. var ok;
  11762. if (stream.eat("#")) if (stream.eat("x")) ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
  11763. else ok = stream.eatWhile(/[\d]/) && stream.eat(";");
  11764. else ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
  11765. return ok ? "atom" : "error";
  11766. } else {
  11767. stream.eatWhile(/[^&<]/);
  11768. return null;
  11769. }
  11770. }
  11771. inText.isInText = true;
  11772. function inTag(stream, state) {
  11773. var ch = stream.next();
  11774. if (ch == ">" || ch == "/" && stream.eat(">")) {
  11775. state.tokenize = inText;
  11776. type = ch == ">" ? "endTag" : "selfcloseTag";
  11777. return "tag bracket";
  11778. } else if (ch == "=") {
  11779. type = "equals";
  11780. return null;
  11781. } else if (ch == "<") {
  11782. state.tokenize = inText;
  11783. state.state = baseState;
  11784. state.tagName = state.tagStart = null;
  11785. var next = state.tokenize(stream, state);
  11786. return next ? next + " tag error" : "tag error";
  11787. } else if (/[\'\"]/.test(ch)) {
  11788. state.tokenize = inAttribute(ch);
  11789. state.stringStartCol = stream.column();
  11790. return state.tokenize(stream, state);
  11791. } else {
  11792. stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
  11793. return "word";
  11794. }
  11795. }
  11796. function inAttribute(quote) {
  11797. var closure = function(stream, state) {
  11798. while (!stream.eol()) if (stream.next() == quote) {
  11799. state.tokenize = inTag;
  11800. break;
  11801. }
  11802. return "string";
  11803. };
  11804. closure.isInAttribute = true;
  11805. return closure;
  11806. }
  11807. function inBlock(style, terminator) {
  11808. return function(stream, state) {
  11809. while (!stream.eol()) {
  11810. if (stream.match(terminator)) {
  11811. state.tokenize = inText;
  11812. break;
  11813. }
  11814. stream.next();
  11815. }
  11816. return style;
  11817. };
  11818. }
  11819. function doctype(depth) {
  11820. return function(stream, state) {
  11821. var ch;
  11822. while ((ch = stream.next()) != null) if (ch == "<") {
  11823. state.tokenize = doctype(depth + 1);
  11824. return state.tokenize(stream, state);
  11825. } else if (ch == ">") if (depth == 1) {
  11826. state.tokenize = inText;
  11827. break;
  11828. } else {
  11829. state.tokenize = doctype(depth - 1);
  11830. return state.tokenize(stream, state);
  11831. }
  11832. return "meta";
  11833. };
  11834. }
  11835. function lower(tagName) {
  11836. return tagName && tagName.toLowerCase();
  11837. }
  11838. function Context(state, tagName, startOfLine) {
  11839. this.prev = state.context;
  11840. this.tagName = tagName || "";
  11841. this.indent = state.indented;
  11842. this.startOfLine = startOfLine;
  11843. if (config.doNotIndent.hasOwnProperty(tagName) || state.context && state.context.noIndent) this.noIndent = true;
  11844. }
  11845. function popContext(state) {
  11846. if (state.context) state.context = state.context.prev;
  11847. }
  11848. function maybePopContext(state, nextTagName) {
  11849. var parentTagName;
  11850. while (true) {
  11851. if (!state.context) return;
  11852. parentTagName = state.context.tagName;
  11853. if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) || !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) return;
  11854. popContext(state);
  11855. }
  11856. }
  11857. function baseState(type$1, stream, state) {
  11858. if (type$1 == "openTag") {
  11859. state.tagStart = stream.column();
  11860. return tagNameState;
  11861. } else if (type$1 == "closeTag") return closeTagNameState;
  11862. else return baseState;
  11863. }
  11864. function tagNameState(type$1, stream, state) {
  11865. if (type$1 == "word") {
  11866. state.tagName = stream.current();
  11867. setStyle = "tag";
  11868. return attrState;
  11869. } else if (config.allowMissingTagName && type$1 == "endTag") {
  11870. setStyle = "tag bracket";
  11871. return attrState(type$1, stream, state);
  11872. } else {
  11873. setStyle = "error";
  11874. return tagNameState;
  11875. }
  11876. }
  11877. function closeTagNameState(type$1, stream, state) {
  11878. if (type$1 == "word") {
  11879. var tagName = stream.current();
  11880. if (state.context && state.context.tagName != tagName && config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName))) popContext(state);
  11881. if (state.context && state.context.tagName == tagName || config.matchClosing === false) {
  11882. setStyle = "tag";
  11883. return closeState;
  11884. } else {
  11885. setStyle = "tag error";
  11886. return closeStateErr;
  11887. }
  11888. } else if (config.allowMissingTagName && type$1 == "endTag") {
  11889. setStyle = "tag bracket";
  11890. return closeState(type$1, stream, state);
  11891. } else {
  11892. setStyle = "error";
  11893. return closeStateErr;
  11894. }
  11895. }
  11896. function closeState(type$1, _stream, state) {
  11897. if (type$1 != "endTag") {
  11898. setStyle = "error";
  11899. return closeState;
  11900. }
  11901. popContext(state);
  11902. return baseState;
  11903. }
  11904. function closeStateErr(type$1, stream, state) {
  11905. setStyle = "error";
  11906. return closeState(type$1, stream, state);
  11907. }
  11908. function attrState(type$1, _stream, state) {
  11909. if (type$1 == "word") {
  11910. setStyle = "attribute";
  11911. return attrEqState;
  11912. } else if (type$1 == "endTag" || type$1 == "selfcloseTag") {
  11913. var tagName = state.tagName, tagStart = state.tagStart;
  11914. state.tagName = state.tagStart = null;
  11915. if (type$1 == "selfcloseTag" || config.autoSelfClosers.hasOwnProperty(lower(tagName))) maybePopContext(state, tagName);
  11916. else {
  11917. maybePopContext(state, tagName);
  11918. state.context = new Context(state, tagName, tagStart == state.indented);
  11919. }
  11920. return baseState;
  11921. }
  11922. setStyle = "error";
  11923. return attrState;
  11924. }
  11925. function attrEqState(type$1, stream, state) {
  11926. if (type$1 == "equals") return attrValueState;
  11927. if (!config.allowMissing) setStyle = "error";
  11928. return attrState(type$1, stream, state);
  11929. }
  11930. function attrValueState(type$1, stream, state) {
  11931. if (type$1 == "string") return attrContinuedState;
  11932. if (type$1 == "word" && config.allowUnquoted) {
  11933. setStyle = "string";
  11934. return attrState;
  11935. }
  11936. setStyle = "error";
  11937. return attrState(type$1, stream, state);
  11938. }
  11939. function attrContinuedState(type$1, stream, state) {
  11940. if (type$1 == "string") return attrContinuedState;
  11941. return attrState(type$1, stream, state);
  11942. }
  11943. return {
  11944. startState: function(baseIndent) {
  11945. var state = {
  11946. tokenize: inText,
  11947. state: baseState,
  11948. indented: baseIndent || 0,
  11949. tagName: null,
  11950. tagStart: null,
  11951. context: null
  11952. };
  11953. if (baseIndent != null) state.baseIndent = baseIndent;
  11954. return state;
  11955. },
  11956. token: function(stream, state) {
  11957. if (!state.tagName && stream.sol()) state.indented = stream.indentation();
  11958. if (stream.eatSpace()) return null;
  11959. type = null;
  11960. var style = state.tokenize(stream, state);
  11961. if ((style || type) && style != "comment") {
  11962. setStyle = null;
  11963. state.state = state.state(type || style, stream, state);
  11964. if (setStyle) style = setStyle == "error" ? style + " error" : setStyle;
  11965. }
  11966. return style;
  11967. },
  11968. indent: function(state, textAfter, fullLine) {
  11969. var context = state.context;
  11970. if (state.tokenize.isInAttribute) if (state.tagStart == state.indented) return state.stringStartCol + 1;
  11971. else return state.indented + indentUnit;
  11972. if (context && context.noIndent) return CodeMirror$1.Pass;
  11973. if (state.tokenize != inTag && state.tokenize != inText) return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
  11974. if (state.tagName) if (config.multilineTagIndentPastTag !== false) return state.tagStart + state.tagName.length + 2;
  11975. else return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
  11976. if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
  11977. var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
  11978. if (tagAfter && tagAfter[1]) while (context) if (context.tagName == tagAfter[2]) {
  11979. context = context.prev;
  11980. break;
  11981. } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) context = context.prev;
  11982. else break;
  11983. else if (tagAfter) while (context) {
  11984. var grabbers = config.contextGrabbers[lower(context.tagName)];
  11985. if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2]))) context = context.prev;
  11986. else break;
  11987. }
  11988. while (context && context.prev && !context.startOfLine) context = context.prev;
  11989. if (context) return context.indent + indentUnit;
  11990. else return state.baseIndent || 0;
  11991. },
  11992. electricInput: /<\/[\s\w:]+>$/,
  11993. blockCommentStart: "<!--",
  11994. blockCommentEnd: "-->",
  11995. configuration: config.htmlMode ? "html" : "xml",
  11996. helperType: config.htmlMode ? "html" : "xml",
  11997. skipAttribute: function(state) {
  11998. if (state.state == attrValueState) state.state = attrState;
  11999. },
  12000. xmlCurrentTag: function(state) {
  12001. return state.tagName ? {
  12002. name: state.tagName,
  12003. close: state.type == "closeTag"
  12004. } : null;
  12005. },
  12006. xmlCurrentContext: function(state) {
  12007. var context = [];
  12008. for (var cx = state.context; cx; cx = cx.prev) context.push(cx.tagName);
  12009. return context.reverse();
  12010. }
  12011. };
  12012. });
  12013. CodeMirror$1.defineMIME("text/xml", "xml");
  12014. CodeMirror$1.defineMIME("application/xml", "xml");
  12015. if (!CodeMirror$1.mimeModes.hasOwnProperty("text/html")) CodeMirror$1.defineMIME("text/html", {
  12016. name: "xml",
  12017. htmlMode: true
  12018. });
  12019. });
  12020. });
  12021. var require_javascript = __commonJSMin((exports, module) => {
  12022. (function(mod) {
  12023. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  12024. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  12025. else mod(CodeMirror);
  12026. })(function(CodeMirror$1) {
  12027. "use strict";
  12028. CodeMirror$1.defineMode("javascript", function(config, parserConfig) {
  12029. var indentUnit = config.indentUnit;
  12030. var statementIndent = parserConfig.statementIndent;
  12031. var jsonldMode = parserConfig.jsonld;
  12032. var jsonMode = parserConfig.json || jsonldMode;
  12033. var trackScope = parserConfig.trackScope !== false;
  12034. var isTS = parserConfig.typescript;
  12035. var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
  12036. var keywords = function() {
  12037. function kw(type$1) {
  12038. return {
  12039. type: type$1,
  12040. style: "keyword"
  12041. };
  12042. }
  12043. var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
  12044. var operator = kw("operator"), atom = {
  12045. type: "atom",
  12046. style: "atom"
  12047. };
  12048. return {
  12049. "if": kw("if"),
  12050. "while": A,
  12051. "with": A,
  12052. "else": B,
  12053. "do": B,
  12054. "try": B,
  12055. "finally": B,
  12056. "return": D,
  12057. "break": D,
  12058. "continue": D,
  12059. "new": kw("new"),
  12060. "delete": C,
  12061. "void": C,
  12062. "throw": C,
  12063. "debugger": kw("debugger"),
  12064. "var": kw("var"),
  12065. "const": kw("var"),
  12066. "let": kw("var"),
  12067. "function": kw("function"),
  12068. "catch": kw("catch"),
  12069. "for": kw("for"),
  12070. "switch": kw("switch"),
  12071. "case": kw("case"),
  12072. "default": kw("default"),
  12073. "in": operator,
  12074. "typeof": operator,
  12075. "instanceof": operator,
  12076. "true": atom,
  12077. "false": atom,
  12078. "null": atom,
  12079. "undefined": atom,
  12080. "NaN": atom,
  12081. "Infinity": atom,
  12082. "this": kw("this"),
  12083. "class": kw("class"),
  12084. "super": kw("atom"),
  12085. "yield": C,
  12086. "export": kw("export"),
  12087. "import": kw("import"),
  12088. "extends": C,
  12089. "await": C
  12090. };
  12091. }();
  12092. var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
  12093. var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
  12094. function readRegexp(stream) {
  12095. var escaped = false, next, inSet = false;
  12096. while ((next = stream.next()) != null) {
  12097. if (!escaped) {
  12098. if (next == "/" && !inSet) return;
  12099. if (next == "[") inSet = true;
  12100. else if (inSet && next == "]") inSet = false;
  12101. }
  12102. escaped = !escaped && next == "\\";
  12103. }
  12104. }
  12105. var type, content;
  12106. function ret(tp, style, cont$1) {
  12107. type = tp;
  12108. content = cont$1;
  12109. return style;
  12110. }
  12111. function tokenBase(stream, state) {
  12112. var ch = stream.next();
  12113. if (ch == "\"" || ch == "'") {
  12114. state.tokenize = tokenString(ch);
  12115. return state.tokenize(stream, state);
  12116. } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) return ret("number", "number");
  12117. else if (ch == "." && stream.match("..")) return ret("spread", "meta");
  12118. else if (/[\[\]{}\(\),;\:\.]/.test(ch)) return ret(ch);
  12119. else if (ch == "=" && stream.eat(">")) return ret("=>", "operator");
  12120. else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) return ret("number", "number");
  12121. else if (/\d/.test(ch)) {
  12122. stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
  12123. return ret("number", "number");
  12124. } else if (ch == "/") if (stream.eat("*")) {
  12125. state.tokenize = tokenComment;
  12126. return tokenComment(stream, state);
  12127. } else if (stream.eat("/")) {
  12128. stream.skipToEnd();
  12129. return ret("comment", "comment");
  12130. } else if (expressionAllowed(stream, state, 1)) {
  12131. readRegexp(stream);
  12132. stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
  12133. return ret("regexp", "string-2");
  12134. } else {
  12135. stream.eat("=");
  12136. return ret("operator", "operator", stream.current());
  12137. }
  12138. else if (ch == "`") {
  12139. state.tokenize = tokenQuasi;
  12140. return tokenQuasi(stream, state);
  12141. } else if (ch == "#" && stream.peek() == "!") {
  12142. stream.skipToEnd();
  12143. return ret("meta", "meta");
  12144. } else if (ch == "#" && stream.eatWhile(wordRE)) return ret("variable", "property");
  12145. else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start))) {
  12146. stream.skipToEnd();
  12147. return ret("comment", "comment");
  12148. } else if (isOperatorChar.test(ch)) {
  12149. if (ch != ">" || !state.lexical || state.lexical.type != ">") {
  12150. if (stream.eat("=")) {
  12151. if (ch == "!" || ch == "=") stream.eat("=");
  12152. } else if (/[<>*+\-|&?]/.test(ch)) {
  12153. stream.eat(ch);
  12154. if (ch == ">") stream.eat(ch);
  12155. }
  12156. }
  12157. if (ch == "?" && stream.eat(".")) return ret(".");
  12158. return ret("operator", "operator", stream.current());
  12159. } else if (wordRE.test(ch)) {
  12160. stream.eatWhile(wordRE);
  12161. var word = stream.current();
  12162. if (state.lastType != ".") {
  12163. if (keywords.propertyIsEnumerable(word)) {
  12164. var kw = keywords[word];
  12165. return ret(kw.type, kw.style, word);
  12166. }
  12167. if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word);
  12168. }
  12169. return ret("variable", "variable", word);
  12170. }
  12171. }
  12172. function tokenString(quote) {
  12173. return function(stream, state) {
  12174. var escaped = false, next;
  12175. if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)) {
  12176. state.tokenize = tokenBase;
  12177. return ret("jsonld-keyword", "meta");
  12178. }
  12179. while ((next = stream.next()) != null) {
  12180. if (next == quote && !escaped) break;
  12181. escaped = !escaped && next == "\\";
  12182. }
  12183. if (!escaped) state.tokenize = tokenBase;
  12184. return ret("string", "string");
  12185. };
  12186. }
  12187. function tokenComment(stream, state) {
  12188. var maybeEnd = false, ch;
  12189. while (ch = stream.next()) {
  12190. if (ch == "/" && maybeEnd) {
  12191. state.tokenize = tokenBase;
  12192. break;
  12193. }
  12194. maybeEnd = ch == "*";
  12195. }
  12196. return ret("comment", "comment");
  12197. }
  12198. function tokenQuasi(stream, state) {
  12199. var escaped = false, next;
  12200. while ((next = stream.next()) != null) {
  12201. if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
  12202. state.tokenize = tokenBase;
  12203. break;
  12204. }
  12205. escaped = !escaped && next == "\\";
  12206. }
  12207. return ret("quasi", "string-2", stream.current());
  12208. }
  12209. var brackets = "([{}])";
  12210. function findFatArrow(stream, state) {
  12211. if (state.fatArrowAt) state.fatArrowAt = null;
  12212. var arrow = stream.string.indexOf("=>", stream.start);
  12213. if (arrow < 0) return;
  12214. if (isTS) {
  12215. var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow));
  12216. if (m) arrow = m.index;
  12217. }
  12218. var depth = 0, sawSomething = false;
  12219. for (var pos = arrow - 1; pos >= 0; --pos) {
  12220. var ch = stream.string.charAt(pos);
  12221. var bracket = brackets.indexOf(ch);
  12222. if (bracket >= 0 && bracket < 3) {
  12223. if (!depth) {
  12224. ++pos;
  12225. break;
  12226. }
  12227. if (--depth == 0) {
  12228. if (ch == "(") sawSomething = true;
  12229. break;
  12230. }
  12231. } else if (bracket >= 3 && bracket < 6) ++depth;
  12232. else if (wordRE.test(ch)) sawSomething = true;
  12233. else if (/["'\/`]/.test(ch)) for (;; --pos) {
  12234. if (pos == 0) return;
  12235. var next = stream.string.charAt(pos - 1);
  12236. if (next == ch && stream.string.charAt(pos - 2) != "\\") {
  12237. pos--;
  12238. break;
  12239. }
  12240. }
  12241. else if (sawSomething && !depth) {
  12242. ++pos;
  12243. break;
  12244. }
  12245. }
  12246. if (sawSomething && !depth) state.fatArrowAt = pos;
  12247. }
  12248. var atomicTypes = {
  12249. "atom": true,
  12250. "number": true,
  12251. "variable": true,
  12252. "string": true,
  12253. "regexp": true,
  12254. "this": true,
  12255. "import": true,
  12256. "jsonld-keyword": true
  12257. };
  12258. function JSLexical(indented, column, type$1, align, prev, info) {
  12259. this.indented = indented;
  12260. this.column = column;
  12261. this.type = type$1;
  12262. this.prev = prev;
  12263. this.info = info;
  12264. if (align != null) this.align = align;
  12265. }
  12266. function inScope(state, varname) {
  12267. if (!trackScope) return false;
  12268. for (var v = state.localVars; v; v = v.next) if (v.name == varname) return true;
  12269. for (var cx$1 = state.context; cx$1; cx$1 = cx$1.prev) for (var v = cx$1.vars; v; v = v.next) if (v.name == varname) return true;
  12270. }
  12271. function parseJS(state, style, type$1, content$1, stream) {
  12272. var cc = state.cc;
  12273. cx.state = state;
  12274. cx.stream = stream;
  12275. cx.marked = null, cx.cc = cc;
  12276. cx.style = style;
  12277. if (!state.lexical.hasOwnProperty("align")) state.lexical.align = true;
  12278. while (true) {
  12279. var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
  12280. if (combinator(type$1, content$1)) {
  12281. while (cc.length && cc[cc.length - 1].lex) cc.pop()();
  12282. if (cx.marked) return cx.marked;
  12283. if (type$1 == "variable" && inScope(state, content$1)) return "variable-2";
  12284. return style;
  12285. }
  12286. }
  12287. }
  12288. var cx = {
  12289. state: null,
  12290. column: null,
  12291. marked: null,
  12292. cc: null
  12293. };
  12294. function pass() {
  12295. for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
  12296. }
  12297. function cont() {
  12298. pass.apply(null, arguments);
  12299. return true;
  12300. }
  12301. function inList(name, list) {
  12302. for (var v = list; v; v = v.next) if (v.name == name) return true;
  12303. return false;
  12304. }
  12305. function register(varname) {
  12306. var state = cx.state;
  12307. cx.marked = "def";
  12308. if (!trackScope) return;
  12309. if (state.context) {
  12310. if (state.lexical.info == "var" && state.context && state.context.block) {
  12311. var newContext = registerVarScoped(varname, state.context);
  12312. if (newContext != null) {
  12313. state.context = newContext;
  12314. return;
  12315. }
  12316. } else if (!inList(varname, state.localVars)) {
  12317. state.localVars = new Var(varname, state.localVars);
  12318. return;
  12319. }
  12320. }
  12321. if (parserConfig.globalVars && !inList(varname, state.globalVars)) state.globalVars = new Var(varname, state.globalVars);
  12322. }
  12323. function registerVarScoped(varname, context) {
  12324. if (!context) return null;
  12325. else if (context.block) {
  12326. var inner = registerVarScoped(varname, context.prev);
  12327. if (!inner) return null;
  12328. if (inner == context.prev) return context;
  12329. return new Context(inner, context.vars, true);
  12330. } else if (inList(varname, context.vars)) return context;
  12331. else return new Context(context.prev, new Var(varname, context.vars), false);
  12332. }
  12333. function isModifier(name) {
  12334. return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly";
  12335. }
  12336. function Context(prev, vars, block$1) {
  12337. this.prev = prev;
  12338. this.vars = vars;
  12339. this.block = block$1;
  12340. }
  12341. function Var(name, next) {
  12342. this.name = name;
  12343. this.next = next;
  12344. }
  12345. var defaultVars = new Var("this", new Var("arguments", null));
  12346. function pushcontext() {
  12347. cx.state.context = new Context(cx.state.context, cx.state.localVars, false);
  12348. cx.state.localVars = defaultVars;
  12349. }
  12350. function pushblockcontext() {
  12351. cx.state.context = new Context(cx.state.context, cx.state.localVars, true);
  12352. cx.state.localVars = null;
  12353. }
  12354. pushcontext.lex = pushblockcontext.lex = true;
  12355. function popcontext() {
  12356. cx.state.localVars = cx.state.context.vars;
  12357. cx.state.context = cx.state.context.prev;
  12358. }
  12359. popcontext.lex = true;
  12360. function pushlex(type$1, info) {
  12361. var result = function() {
  12362. var state = cx.state, indent = state.indented;
  12363. if (state.lexical.type == "stat") indent = state.lexical.indented;
  12364. else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev) indent = outer.indented;
  12365. state.lexical = new JSLexical(indent, cx.stream.column(), type$1, null, state.lexical, info);
  12366. };
  12367. result.lex = true;
  12368. return result;
  12369. }
  12370. function poplex() {
  12371. var state = cx.state;
  12372. if (state.lexical.prev) {
  12373. if (state.lexical.type == ")") state.indented = state.lexical.indented;
  12374. state.lexical = state.lexical.prev;
  12375. }
  12376. }
  12377. poplex.lex = true;
  12378. function expect(wanted) {
  12379. function exp(type$1) {
  12380. if (type$1 == wanted) return cont();
  12381. else if (wanted == ";" || type$1 == "}" || type$1 == ")" || type$1 == "]") return pass();
  12382. else return cont(exp);
  12383. }
  12384. return exp;
  12385. }
  12386. function statement(type$1, value) {
  12387. if (type$1 == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
  12388. if (type$1 == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
  12389. if (type$1 == "keyword b") return cont(pushlex("form"), statement, poplex);
  12390. if (type$1 == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
  12391. if (type$1 == "debugger") return cont(expect(";"));
  12392. if (type$1 == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
  12393. if (type$1 == ";") return cont();
  12394. if (type$1 == "if") {
  12395. if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) cx.state.cc.pop()();
  12396. return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
  12397. }
  12398. if (type$1 == "function") return cont(functiondef);
  12399. if (type$1 == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
  12400. if (type$1 == "class" || isTS && value == "interface") {
  12401. cx.marked = "keyword";
  12402. return cont(pushlex("form", type$1 == "class" ? type$1 : value), className, poplex);
  12403. }
  12404. if (type$1 == "variable") if (isTS && value == "declare") {
  12405. cx.marked = "keyword";
  12406. return cont(statement);
  12407. } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
  12408. cx.marked = "keyword";
  12409. if (value == "enum") return cont(enumdef);
  12410. else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
  12411. else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex);
  12412. } else if (isTS && value == "namespace") {
  12413. cx.marked = "keyword";
  12414. return cont(pushlex("form"), expression, statement, poplex);
  12415. } else if (isTS && value == "abstract") {
  12416. cx.marked = "keyword";
  12417. return cont(statement);
  12418. } else return cont(pushlex("stat"), maybelabel);
  12419. if (type$1 == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, block, poplex, poplex, popcontext);
  12420. if (type$1 == "case") return cont(expression, expect(":"));
  12421. if (type$1 == "default") return cont(expect(":"));
  12422. if (type$1 == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
  12423. if (type$1 == "export") return cont(pushlex("stat"), afterExport, poplex);
  12424. if (type$1 == "import") return cont(pushlex("stat"), afterImport, poplex);
  12425. if (type$1 == "async") return cont(statement);
  12426. if (value == "@") return cont(expression, statement);
  12427. return pass(pushlex("stat"), expression, expect(";"), poplex);
  12428. }
  12429. function maybeCatchBinding(type$1) {
  12430. if (type$1 == "(") return cont(funarg, expect(")"));
  12431. }
  12432. function expression(type$1, value) {
  12433. return expressionInner(type$1, value, false);
  12434. }
  12435. function expressionNoComma(type$1, value) {
  12436. return expressionInner(type$1, value, true);
  12437. }
  12438. function parenExpr(type$1) {
  12439. if (type$1 != "(") return pass();
  12440. return cont(pushlex(")"), maybeexpression, expect(")"), poplex);
  12441. }
  12442. function expressionInner(type$1, value, noComma) {
  12443. if (cx.state.fatArrowAt == cx.stream.start) {
  12444. var body = noComma ? arrowBodyNoComma : arrowBody;
  12445. if (type$1 == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
  12446. else if (type$1 == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
  12447. }
  12448. var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
  12449. if (atomicTypes.hasOwnProperty(type$1)) return cont(maybeop);
  12450. if (type$1 == "function") return cont(functiondef, maybeop);
  12451. if (type$1 == "class" || isTS && value == "interface") {
  12452. cx.marked = "keyword";
  12453. return cont(pushlex("form"), classExpression, poplex);
  12454. }
  12455. if (type$1 == "keyword c" || type$1 == "async") return cont(noComma ? expressionNoComma : expression);
  12456. if (type$1 == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
  12457. if (type$1 == "operator" || type$1 == "spread") return cont(noComma ? expressionNoComma : expression);
  12458. if (type$1 == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
  12459. if (type$1 == "{") return contCommasep(objprop, "}", null, maybeop);
  12460. if (type$1 == "quasi") return pass(quasi, maybeop);
  12461. if (type$1 == "new") return cont(maybeTarget(noComma));
  12462. return cont();
  12463. }
  12464. function maybeexpression(type$1) {
  12465. if (type$1.match(/[;\}\)\],]/)) return pass();
  12466. return pass(expression);
  12467. }
  12468. function maybeoperatorComma(type$1, value) {
  12469. if (type$1 == ",") return cont(maybeexpression);
  12470. return maybeoperatorNoComma(type$1, value, false);
  12471. }
  12472. function maybeoperatorNoComma(type$1, value, noComma) {
  12473. var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
  12474. var expr = noComma == false ? expression : expressionNoComma;
  12475. if (type$1 == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
  12476. if (type$1 == "operator") {
  12477. if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
  12478. if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false)) return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
  12479. if (value == "?") return cont(expression, expect(":"), expr);
  12480. return cont(expr);
  12481. }
  12482. if (type$1 == "quasi") return pass(quasi, me);
  12483. if (type$1 == ";") return;
  12484. if (type$1 == "(") return contCommasep(expressionNoComma, ")", "call", me);
  12485. if (type$1 == ".") return cont(property, me);
  12486. if (type$1 == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
  12487. if (isTS && value == "as") {
  12488. cx.marked = "keyword";
  12489. return cont(typeexpr, me);
  12490. }
  12491. if (type$1 == "regexp") {
  12492. cx.state.lastType = cx.marked = "operator";
  12493. cx.stream.backUp(cx.stream.pos - cx.stream.start - 1);
  12494. return cont(expr);
  12495. }
  12496. }
  12497. function quasi(type$1, value) {
  12498. if (type$1 != "quasi") return pass();
  12499. if (value.slice(value.length - 2) != "\${") return cont(quasi);
  12500. return cont(maybeexpression, continueQuasi);
  12501. }
  12502. function continueQuasi(type$1) {
  12503. if (type$1 == "}") {
  12504. cx.marked = "string-2";
  12505. cx.state.tokenize = tokenQuasi;
  12506. return cont(quasi);
  12507. }
  12508. }
  12509. function arrowBody(type$1) {
  12510. findFatArrow(cx.stream, cx.state);
  12511. return pass(type$1 == "{" ? statement : expression);
  12512. }
  12513. function arrowBodyNoComma(type$1) {
  12514. findFatArrow(cx.stream, cx.state);
  12515. return pass(type$1 == "{" ? statement : expressionNoComma);
  12516. }
  12517. function maybeTarget(noComma) {
  12518. return function(type$1) {
  12519. if (type$1 == ".") return cont(noComma ? targetNoComma : target);
  12520. else if (type$1 == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma);
  12521. else return pass(noComma ? expressionNoComma : expression);
  12522. };
  12523. }
  12524. function target(_, value) {
  12525. if (value == "target") {
  12526. cx.marked = "keyword";
  12527. return cont(maybeoperatorComma);
  12528. }
  12529. }
  12530. function targetNoComma(_, value) {
  12531. if (value == "target") {
  12532. cx.marked = "keyword";
  12533. return cont(maybeoperatorNoComma);
  12534. }
  12535. }
  12536. function maybelabel(type$1) {
  12537. if (type$1 == ":") return cont(poplex, statement);
  12538. return pass(maybeoperatorComma, expect(";"), poplex);
  12539. }
  12540. function property(type$1) {
  12541. if (type$1 == "variable") {
  12542. cx.marked = "property";
  12543. return cont();
  12544. }
  12545. }
  12546. function objprop(type$1, value) {
  12547. if (type$1 == "async") {
  12548. cx.marked = "property";
  12549. return cont(objprop);
  12550. } else if (type$1 == "variable" || cx.style == "keyword") {
  12551. cx.marked = "property";
  12552. if (value == "get" || value == "set") return cont(getterSetter);
  12553. var m;
  12554. if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) cx.state.fatArrowAt = cx.stream.pos + m[0].length;
  12555. return cont(afterprop);
  12556. } else if (type$1 == "number" || type$1 == "string") {
  12557. cx.marked = jsonldMode ? "property" : cx.style + " property";
  12558. return cont(afterprop);
  12559. } else if (type$1 == "jsonld-keyword") return cont(afterprop);
  12560. else if (isTS && isModifier(value)) {
  12561. cx.marked = "keyword";
  12562. return cont(objprop);
  12563. } else if (type$1 == "[") return cont(expression, maybetype, expect("]"), afterprop);
  12564. else if (type$1 == "spread") return cont(expressionNoComma, afterprop);
  12565. else if (value == "*") {
  12566. cx.marked = "keyword";
  12567. return cont(objprop);
  12568. } else if (type$1 == ":") return pass(afterprop);
  12569. }
  12570. function getterSetter(type$1) {
  12571. if (type$1 != "variable") return pass(afterprop);
  12572. cx.marked = "property";
  12573. return cont(functiondef);
  12574. }
  12575. function afterprop(type$1) {
  12576. if (type$1 == ":") return cont(expressionNoComma);
  12577. if (type$1 == "(") return pass(functiondef);
  12578. }
  12579. function commasep(what, end, sep) {
  12580. function proceed(type$1, value) {
  12581. if (sep ? sep.indexOf(type$1) > -1 : type$1 == ",") {
  12582. var lex = cx.state.lexical;
  12583. if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
  12584. return cont(function(type$2, value$1) {
  12585. if (type$2 == end || value$1 == end) return pass();
  12586. return pass(what);
  12587. }, proceed);
  12588. }
  12589. if (type$1 == end || value == end) return cont();
  12590. if (sep && sep.indexOf(";") > -1) return pass(what);
  12591. return cont(expect(end));
  12592. }
  12593. return function(type$1, value) {
  12594. if (type$1 == end || value == end) return cont();
  12595. return pass(what, proceed);
  12596. };
  12597. }
  12598. function contCommasep(what, end, info) {
  12599. for (var i = 3; i < arguments.length; i++) cx.cc.push(arguments[i]);
  12600. return cont(pushlex(end, info), commasep(what, end), poplex);
  12601. }
  12602. function block(type$1) {
  12603. if (type$1 == "}") return cont();
  12604. return pass(statement, block);
  12605. }
  12606. function maybetype(type$1, value) {
  12607. if (isTS) {
  12608. if (type$1 == ":") return cont(typeexpr);
  12609. if (value == "?") return cont(maybetype);
  12610. }
  12611. }
  12612. function maybetypeOrIn(type$1, value) {
  12613. if (isTS && (type$1 == ":" || value == "in")) return cont(typeexpr);
  12614. }
  12615. function mayberettype(type$1) {
  12616. if (isTS && type$1 == ":") if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr);
  12617. else return cont(typeexpr);
  12618. }
  12619. function isKW(_, value) {
  12620. if (value == "is") {
  12621. cx.marked = "keyword";
  12622. return cont();
  12623. }
  12624. }
  12625. function typeexpr(type$1, value) {
  12626. if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
  12627. cx.marked = "keyword";
  12628. return cont(value == "typeof" ? expressionNoComma : typeexpr);
  12629. }
  12630. if (type$1 == "variable" || value == "void") {
  12631. cx.marked = "type";
  12632. return cont(afterType);
  12633. }
  12634. if (value == "|" || value == "&") return cont(typeexpr);
  12635. if (type$1 == "string" || type$1 == "number" || type$1 == "atom") return cont(afterType);
  12636. if (type$1 == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType);
  12637. if (type$1 == "{") return cont(pushlex("}"), typeprops, poplex, afterType);
  12638. if (type$1 == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType);
  12639. if (type$1 == "<") return cont(commasep(typeexpr, ">"), typeexpr);
  12640. if (type$1 == "quasi") return pass(quasiType, afterType);
  12641. }
  12642. function maybeReturnType(type$1) {
  12643. if (type$1 == "=>") return cont(typeexpr);
  12644. }
  12645. function typeprops(type$1) {
  12646. if (type$1.match(/[\}\)\]]/)) return cont();
  12647. if (type$1 == "," || type$1 == ";") return cont(typeprops);
  12648. return pass(typeprop, typeprops);
  12649. }
  12650. function typeprop(type$1, value) {
  12651. if (type$1 == "variable" || cx.style == "keyword") {
  12652. cx.marked = "property";
  12653. return cont(typeprop);
  12654. } else if (value == "?" || type$1 == "number" || type$1 == "string") return cont(typeprop);
  12655. else if (type$1 == ":") return cont(typeexpr);
  12656. else if (type$1 == "[") return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop);
  12657. else if (type$1 == "(") return pass(functiondecl, typeprop);
  12658. else if (!type$1.match(/[;\}\)\],]/)) return cont();
  12659. }
  12660. function quasiType(type$1, value) {
  12661. if (type$1 != "quasi") return pass();
  12662. if (value.slice(value.length - 2) != "\${") return cont(quasiType);
  12663. return cont(typeexpr, continueQuasiType);
  12664. }
  12665. function continueQuasiType(type$1) {
  12666. if (type$1 == "}") {
  12667. cx.marked = "string-2";
  12668. cx.state.tokenize = tokenQuasi;
  12669. return cont(quasiType);
  12670. }
  12671. }
  12672. function typearg(type$1, value) {
  12673. if (type$1 == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg);
  12674. if (type$1 == ":") return cont(typeexpr);
  12675. if (type$1 == "spread") return cont(typearg);
  12676. return pass(typeexpr);
  12677. }
  12678. function afterType(type$1, value) {
  12679. if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType);
  12680. if (value == "|" || type$1 == "." || value == "&") return cont(typeexpr);
  12681. if (type$1 == "[") return cont(typeexpr, expect("]"), afterType);
  12682. if (value == "extends" || value == "implements") {
  12683. cx.marked = "keyword";
  12684. return cont(typeexpr);
  12685. }
  12686. if (value == "?") return cont(typeexpr, expect(":"), typeexpr);
  12687. }
  12688. function maybeTypeArgs(_, value) {
  12689. if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType);
  12690. }
  12691. function typeparam() {
  12692. return pass(typeexpr, maybeTypeDefault);
  12693. }
  12694. function maybeTypeDefault(_, value) {
  12695. if (value == "=") return cont(typeexpr);
  12696. }
  12697. function vardef(_, value) {
  12698. if (value == "enum") {
  12699. cx.marked = "keyword";
  12700. return cont(enumdef);
  12701. }
  12702. return pass(pattern, maybetype, maybeAssign, vardefCont);
  12703. }
  12704. function pattern(type$1, value) {
  12705. if (isTS && isModifier(value)) {
  12706. cx.marked = "keyword";
  12707. return cont(pattern);
  12708. }
  12709. if (type$1 == "variable") {
  12710. register(value);
  12711. return cont();
  12712. }
  12713. if (type$1 == "spread") return cont(pattern);
  12714. if (type$1 == "[") return contCommasep(eltpattern, "]");
  12715. if (type$1 == "{") return contCommasep(proppattern, "}");
  12716. }
  12717. function proppattern(type$1, value) {
  12718. if (type$1 == "variable" && !cx.stream.match(/^\s*:/, false)) {
  12719. register(value);
  12720. return cont(maybeAssign);
  12721. }
  12722. if (type$1 == "variable") cx.marked = "property";
  12723. if (type$1 == "spread") return cont(pattern);
  12724. if (type$1 == "}") return pass();
  12725. if (type$1 == "[") return cont(expression, expect("]"), expect(":"), proppattern);
  12726. return cont(expect(":"), pattern, maybeAssign);
  12727. }
  12728. function eltpattern() {
  12729. return pass(pattern, maybeAssign);
  12730. }
  12731. function maybeAssign(_type, value) {
  12732. if (value == "=") return cont(expressionNoComma);
  12733. }
  12734. function vardefCont(type$1) {
  12735. if (type$1 == ",") return cont(vardef);
  12736. }
  12737. function maybeelse(type$1, value) {
  12738. if (type$1 == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
  12739. }
  12740. function forspec(type$1, value) {
  12741. if (value == "await") return cont(forspec);
  12742. if (type$1 == "(") return cont(pushlex(")"), forspec1, poplex);
  12743. }
  12744. function forspec1(type$1) {
  12745. if (type$1 == "var") return cont(vardef, forspec2);
  12746. if (type$1 == "variable") return cont(forspec2);
  12747. return pass(forspec2);
  12748. }
  12749. function forspec2(type$1, value) {
  12750. if (type$1 == ")") return cont();
  12751. if (type$1 == ";") return cont(forspec2);
  12752. if (value == "in" || value == "of") {
  12753. cx.marked = "keyword";
  12754. return cont(expression, forspec2);
  12755. }
  12756. return pass(expression, forspec2);
  12757. }
  12758. function functiondef(type$1, value) {
  12759. if (value == "*") {
  12760. cx.marked = "keyword";
  12761. return cont(functiondef);
  12762. }
  12763. if (type$1 == "variable") {
  12764. register(value);
  12765. return cont(functiondef);
  12766. }
  12767. if (type$1 == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
  12768. if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef);
  12769. }
  12770. function functiondecl(type$1, value) {
  12771. if (value == "*") {
  12772. cx.marked = "keyword";
  12773. return cont(functiondecl);
  12774. }
  12775. if (type$1 == "variable") {
  12776. register(value);
  12777. return cont(functiondecl);
  12778. }
  12779. if (type$1 == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
  12780. if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl);
  12781. }
  12782. function typename(type$1, value) {
  12783. if (type$1 == "keyword" || type$1 == "variable") {
  12784. cx.marked = "type";
  12785. return cont(typename);
  12786. } else if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex);
  12787. }
  12788. function funarg(type$1, value) {
  12789. if (value == "@") cont(expression, funarg);
  12790. if (type$1 == "spread") return cont(funarg);
  12791. if (isTS && isModifier(value)) {
  12792. cx.marked = "keyword";
  12793. return cont(funarg);
  12794. }
  12795. if (isTS && type$1 == "this") return cont(maybetype, maybeAssign);
  12796. return pass(pattern, maybetype, maybeAssign);
  12797. }
  12798. function classExpression(type$1, value) {
  12799. if (type$1 == "variable") return className(type$1, value);
  12800. return classNameAfter(type$1, value);
  12801. }
  12802. function className(type$1, value) {
  12803. if (type$1 == "variable") {
  12804. register(value);
  12805. return cont(classNameAfter);
  12806. }
  12807. }
  12808. function classNameAfter(type$1, value) {
  12809. if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter);
  12810. if (value == "extends" || value == "implements" || isTS && type$1 == ",") {
  12811. if (value == "implements") cx.marked = "keyword";
  12812. return cont(isTS ? typeexpr : expression, classNameAfter);
  12813. }
  12814. if (type$1 == "{") return cont(pushlex("}"), classBody, poplex);
  12815. }
  12816. function classBody(type$1, value) {
  12817. if (type$1 == "async" || type$1 == "variable" && (value == "static" || value == "get" || value == "set" || isTS && isModifier(value)) && cx.stream.match(/^\s+#?[\w$\xa1-\uffff]/, false)) {
  12818. cx.marked = "keyword";
  12819. return cont(classBody);
  12820. }
  12821. if (type$1 == "variable" || cx.style == "keyword") {
  12822. cx.marked = "property";
  12823. return cont(classfield, classBody);
  12824. }
  12825. if (type$1 == "number" || type$1 == "string") return cont(classfield, classBody);
  12826. if (type$1 == "[") return cont(expression, maybetype, expect("]"), classfield, classBody);
  12827. if (value == "*") {
  12828. cx.marked = "keyword";
  12829. return cont(classBody);
  12830. }
  12831. if (isTS && type$1 == "(") return pass(functiondecl, classBody);
  12832. if (type$1 == ";" || type$1 == ",") return cont(classBody);
  12833. if (type$1 == "}") return cont();
  12834. if (value == "@") return cont(expression, classBody);
  12835. }
  12836. function classfield(type$1, value) {
  12837. if (value == "!") return cont(classfield);
  12838. if (value == "?") return cont(classfield);
  12839. if (type$1 == ":") return cont(typeexpr, maybeAssign);
  12840. if (value == "=") return cont(expressionNoComma);
  12841. var context = cx.state.lexical.prev, isInterface = context && context.info == "interface";
  12842. return pass(isInterface ? functiondecl : functiondef);
  12843. }
  12844. function afterExport(type$1, value) {
  12845. if (value == "*") {
  12846. cx.marked = "keyword";
  12847. return cont(maybeFrom, expect(";"));
  12848. }
  12849. if (value == "default") {
  12850. cx.marked = "keyword";
  12851. return cont(expression, expect(";"));
  12852. }
  12853. if (type$1 == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
  12854. return pass(statement);
  12855. }
  12856. function exportField(type$1, value) {
  12857. if (value == "as") {
  12858. cx.marked = "keyword";
  12859. return cont(expect("variable"));
  12860. }
  12861. if (type$1 == "variable") return pass(expressionNoComma, exportField);
  12862. }
  12863. function afterImport(type$1) {
  12864. if (type$1 == "string") return cont();
  12865. if (type$1 == "(") return pass(expression);
  12866. if (type$1 == ".") return pass(maybeoperatorComma);
  12867. return pass(importSpec, maybeMoreImports, maybeFrom);
  12868. }
  12869. function importSpec(type$1, value) {
  12870. if (type$1 == "{") return contCommasep(importSpec, "}");
  12871. if (type$1 == "variable") register(value);
  12872. if (value == "*") cx.marked = "keyword";
  12873. return cont(maybeAs);
  12874. }
  12875. function maybeMoreImports(type$1) {
  12876. if (type$1 == ",") return cont(importSpec, maybeMoreImports);
  12877. }
  12878. function maybeAs(_type, value) {
  12879. if (value == "as") {
  12880. cx.marked = "keyword";
  12881. return cont(importSpec);
  12882. }
  12883. }
  12884. function maybeFrom(_type, value) {
  12885. if (value == "from") {
  12886. cx.marked = "keyword";
  12887. return cont(expression);
  12888. }
  12889. }
  12890. function arrayLiteral(type$1) {
  12891. if (type$1 == "]") return cont();
  12892. return pass(commasep(expressionNoComma, "]"));
  12893. }
  12894. function enumdef() {
  12895. return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex);
  12896. }
  12897. function enummember() {
  12898. return pass(pattern, maybeAssign);
  12899. }
  12900. function isContinuedStatement(state, textAfter) {
  12901. return state.lastType == "operator" || state.lastType == "," || isOperatorChar.test(textAfter.charAt(0)) || /[,.]/.test(textAfter.charAt(0));
  12902. }
  12903. function expressionAllowed(stream, state, backUp) {
  12904. return state.tokenize == tokenBase && /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)));
  12905. }
  12906. return {
  12907. startState: function(basecolumn) {
  12908. var state = {
  12909. tokenize: tokenBase,
  12910. lastType: "sof",
  12911. cc: [],
  12912. lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
  12913. localVars: parserConfig.localVars,
  12914. context: parserConfig.localVars && new Context(null, null, false),
  12915. indented: basecolumn || 0
  12916. };
  12917. if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") state.globalVars = parserConfig.globalVars;
  12918. return state;
  12919. },
  12920. token: function(stream, state) {
  12921. if (stream.sol()) {
  12922. if (!state.lexical.hasOwnProperty("align")) state.lexical.align = false;
  12923. state.indented = stream.indentation();
  12924. findFatArrow(stream, state);
  12925. }
  12926. if (state.tokenize != tokenComment && stream.eatSpace()) return null;
  12927. var style = state.tokenize(stream, state);
  12928. if (type == "comment") return style;
  12929. state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
  12930. return parseJS(state, style, type, content, stream);
  12931. },
  12932. indent: function(state, textAfter) {
  12933. if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror$1.Pass;
  12934. if (state.tokenize != tokenBase) return 0;
  12935. var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
  12936. if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
  12937. var c = state.cc[i];
  12938. if (c == poplex) lexical = lexical.prev;
  12939. else if (c != maybeelse && c != popcontext) break;
  12940. }
  12941. while ((lexical.type == "stat" || lexical.type == "form") && (firstChar == "}" || (top = state.cc[state.cc.length - 1]) && (top == maybeoperatorComma || top == maybeoperatorNoComma) && !/^[,\.=+\-*:?[\(]/.test(textAfter))) lexical = lexical.prev;
  12942. if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") lexical = lexical.prev;
  12943. var type$1 = lexical.type, closing = firstChar == type$1;
  12944. if (type$1 == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
  12945. else if (type$1 == "form" && firstChar == "{") return lexical.indented;
  12946. else if (type$1 == "form") return lexical.indented + indentUnit;
  12947. else if (type$1 == "stat") return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
  12948. else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false) return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
  12949. else if (lexical.align) return lexical.column + (closing ? 0 : 1);
  12950. else return lexical.indented + (closing ? 0 : indentUnit);
  12951. },
  12952. electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
  12953. blockCommentStart: jsonMode ? null : "/*",
  12954. blockCommentEnd: jsonMode ? null : "*/",
  12955. blockCommentContinue: jsonMode ? null : " * ",
  12956. lineComment: jsonMode ? null : "//",
  12957. fold: "brace",
  12958. closeBrackets: "()[]{}''\"\"``",
  12959. helperType: jsonMode ? "json" : "javascript",
  12960. jsonldMode,
  12961. jsonMode,
  12962. expressionAllowed,
  12963. skipExpression: function(state) {
  12964. parseJS(state, "atom", "atom", "true", new CodeMirror$1.StringStream("", 2, null));
  12965. }
  12966. };
  12967. });
  12968. CodeMirror$1.registerHelper("wordChars", "javascript", /[\w$]/);
  12969. CodeMirror$1.defineMIME("text/javascript", "javascript");
  12970. CodeMirror$1.defineMIME("text/ecmascript", "javascript");
  12971. CodeMirror$1.defineMIME("application/javascript", "javascript");
  12972. CodeMirror$1.defineMIME("application/x-javascript", "javascript");
  12973. CodeMirror$1.defineMIME("application/ecmascript", "javascript");
  12974. CodeMirror$1.defineMIME("application/json", {
  12975. name: "javascript",
  12976. json: true
  12977. });
  12978. CodeMirror$1.defineMIME("application/x-json", {
  12979. name: "javascript",
  12980. json: true
  12981. });
  12982. CodeMirror$1.defineMIME("application/manifest+json", {
  12983. name: "javascript",
  12984. json: true
  12985. });
  12986. CodeMirror$1.defineMIME("application/ld+json", {
  12987. name: "javascript",
  12988. jsonld: true
  12989. });
  12990. CodeMirror$1.defineMIME("text/typescript", {
  12991. name: "javascript",
  12992. typescript: true
  12993. });
  12994. CodeMirror$1.defineMIME("application/typescript", {
  12995. name: "javascript",
  12996. typescript: true
  12997. });
  12998. });
  12999. });
  13000. var require_htmlmixed = __commonJSMin((exports, module) => {
  13001. (function(mod) {
  13002. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_xml(), require_javascript(), require_css());
  13003. else if (typeof define == "function" && define.amd) define([
  13004. "../../lib/codemirror",
  13005. "../xml/xml",
  13006. "../javascript/javascript",
  13007. "../css/css"
  13008. ], mod);
  13009. else mod(CodeMirror);
  13010. })(function(CodeMirror$1) {
  13011. "use strict";
  13012. var defaultTags = {
  13013. script: [
  13014. [
  13015. "lang",
  13016. /(javascript|babel)/i,
  13017. "javascript"
  13018. ],
  13019. [
  13020. "type",
  13021. /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i,
  13022. "javascript"
  13023. ],
  13024. [
  13025. "type",
  13026. /./,
  13027. "text/plain"
  13028. ],
  13029. [
  13030. null,
  13031. null,
  13032. "javascript"
  13033. ]
  13034. ],
  13035. style: [
  13036. [
  13037. "lang",
  13038. /^css$/i,
  13039. "css"
  13040. ],
  13041. [
  13042. "type",
  13043. /^(text\/)?(x-)?(stylesheet|css)$/i,
  13044. "css"
  13045. ],
  13046. [
  13047. "type",
  13048. /./,
  13049. "text/plain"
  13050. ],
  13051. [
  13052. null,
  13053. null,
  13054. "css"
  13055. ]
  13056. ]
  13057. };
  13058. function maybeBackup(stream, pat, style) {
  13059. var cur = stream.current(), close = cur.search(pat);
  13060. if (close > -1) stream.backUp(cur.length - close);
  13061. else if (cur.match(/<\/?$/)) {
  13062. stream.backUp(cur.length);
  13063. if (!stream.match(pat, false)) stream.match(cur);
  13064. }
  13065. return style;
  13066. }
  13067. var attrRegexpCache = {};
  13068. function getAttrRegexp(attr) {
  13069. var regexp = attrRegexpCache[attr];
  13070. if (regexp) return regexp;
  13071. return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
  13072. }
  13073. function getAttrValue(text, attr) {
  13074. var match = text.match(getAttrRegexp(attr));
  13075. return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "";
  13076. }
  13077. function getTagRegexp(tagName, anchored) {
  13078. return new RegExp((anchored ? "^" : "") + "</\\s*" + tagName + "\\s*>", "i");
  13079. }
  13080. function addTags(from, to) {
  13081. for (var tag in from) {
  13082. var dest = to[tag] || (to[tag] = []);
  13083. var source = from[tag];
  13084. for (var i = source.length - 1; i >= 0; i--) dest.unshift(source[i]);
  13085. }
  13086. }
  13087. function findMatchingMode(tagInfo, tagText) {
  13088. for (var i = 0; i < tagInfo.length; i++) {
  13089. var spec = tagInfo[i];
  13090. if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
  13091. }
  13092. }
  13093. CodeMirror$1.defineMode("htmlmixed", function(config, parserConfig) {
  13094. var htmlMode = CodeMirror$1.getMode(config, {
  13095. name: "xml",
  13096. htmlMode: true,
  13097. multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
  13098. multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
  13099. allowMissingTagName: parserConfig.allowMissingTagName
  13100. });
  13101. var tags = {};
  13102. var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
  13103. addTags(defaultTags, tags);
  13104. if (configTags) addTags(configTags, tags);
  13105. if (configScript) for (var i = configScript.length - 1; i >= 0; i--) tags.script.unshift([
  13106. "type",
  13107. configScript[i].matches,
  13108. configScript[i].mode
  13109. ]);
  13110. function html(stream, state) {
  13111. var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName;
  13112. if (tag && !/[<>\s\/]/.test(stream.current()) && (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && tags.hasOwnProperty(tagName)) state.inTag = tagName + " ";
  13113. else if (state.inTag && tag && />$/.test(stream.current())) {
  13114. var inTag = /^([\S]+) (.*)/.exec(state.inTag);
  13115. state.inTag = null;
  13116. var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]);
  13117. var mode = CodeMirror$1.getMode(config, modeSpec);
  13118. var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
  13119. state.token = function(stream$1, state$1) {
  13120. if (stream$1.match(endTagA, false)) {
  13121. state$1.token = html;
  13122. state$1.localState = state$1.localMode = null;
  13123. return null;
  13124. }
  13125. return maybeBackup(stream$1, endTag, state$1.localMode.token(stream$1, state$1.localState));
  13126. };
  13127. state.localMode = mode;
  13128. state.localState = CodeMirror$1.startState(mode, htmlMode.indent(state.htmlState, "", ""));
  13129. } else if (state.inTag) {
  13130. state.inTag += stream.current();
  13131. if (stream.eol()) state.inTag += " ";
  13132. }
  13133. return style;
  13134. }
  13135. return {
  13136. startState: function() {
  13137. var state = CodeMirror$1.startState(htmlMode);
  13138. return {
  13139. token: html,
  13140. inTag: null,
  13141. localMode: null,
  13142. localState: null,
  13143. htmlState: state
  13144. };
  13145. },
  13146. copyState: function(state) {
  13147. var local;
  13148. if (state.localState) local = CodeMirror$1.copyState(state.localMode, state.localState);
  13149. return {
  13150. token: state.token,
  13151. inTag: state.inTag,
  13152. localMode: state.localMode,
  13153. localState: local,
  13154. htmlState: CodeMirror$1.copyState(htmlMode, state.htmlState)
  13155. };
  13156. },
  13157. token: function(stream, state) {
  13158. return state.token(stream, state);
  13159. },
  13160. indent: function(state, textAfter, line) {
  13161. if (!state.localMode || /^\s*<\//.test(textAfter)) return htmlMode.indent(state.htmlState, textAfter, line);
  13162. else if (state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line);
  13163. else return CodeMirror$1.Pass;
  13164. },
  13165. innerMode: function(state) {
  13166. return {
  13167. state: state.localState || state.htmlState,
  13168. mode: state.localMode || htmlMode
  13169. };
  13170. }
  13171. };
  13172. }, "xml", "javascript", "css");
  13173. CodeMirror$1.defineMIME("text/html", "htmlmixed");
  13174. });
  13175. });
  13176. var require_meta = __commonJSMin((exports, module) => {
  13177. (function(mod) {
  13178. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  13179. else if (typeof define == "function" && define.amd) define(["../lib/codemirror"], mod);
  13180. else mod(CodeMirror);
  13181. })(function(CodeMirror$1) {
  13182. "use strict";
  13183. CodeMirror$1.modeInfo = [
  13184. {
  13185. name: "APL",
  13186. mime: "text/apl",
  13187. mode: "apl",
  13188. ext: ["dyalog", "apl"]
  13189. },
  13190. {
  13191. name: "PGP",
  13192. mimes: [
  13193. "application/pgp",
  13194. "application/pgp-encrypted",
  13195. "application/pgp-keys",
  13196. "application/pgp-signature"
  13197. ],
  13198. mode: "asciiarmor",
  13199. ext: [
  13200. "asc",
  13201. "pgp",
  13202. "sig"
  13203. ]
  13204. },
  13205. {
  13206. name: "ASN.1",
  13207. mime: "text/x-ttcn-asn",
  13208. mode: "asn.1",
  13209. ext: ["asn", "asn1"]
  13210. },
  13211. {
  13212. name: "Asterisk",
  13213. mime: "text/x-asterisk",
  13214. mode: "asterisk",
  13215. file: /^extensions\.conf$/i
  13216. },
  13217. {
  13218. name: "Brainfuck",
  13219. mime: "text/x-brainfuck",
  13220. mode: "brainfuck",
  13221. ext: ["b", "bf"]
  13222. },
  13223. {
  13224. name: "C",
  13225. mime: "text/x-csrc",
  13226. mode: "clike",
  13227. ext: [
  13228. "c",
  13229. "h",
  13230. "ino"
  13231. ]
  13232. },
  13233. {
  13234. name: "C++",
  13235. mime: "text/x-c++src",
  13236. mode: "clike",
  13237. ext: [
  13238. "cpp",
  13239. "c++",
  13240. "cc",
  13241. "cxx",
  13242. "hpp",
  13243. "h++",
  13244. "hh",
  13245. "hxx"
  13246. ],
  13247. alias: ["cpp"]
  13248. },
  13249. {
  13250. name: "Cobol",
  13251. mime: "text/x-cobol",
  13252. mode: "cobol",
  13253. ext: [
  13254. "cob",
  13255. "cpy",
  13256. "cbl"
  13257. ]
  13258. },
  13259. {
  13260. name: "C#",
  13261. mime: "text/x-csharp",
  13262. mode: "clike",
  13263. ext: ["cs"],
  13264. alias: ["csharp", "cs"]
  13265. },
  13266. {
  13267. name: "Clojure",
  13268. mime: "text/x-clojure",
  13269. mode: "clojure",
  13270. ext: [
  13271. "clj",
  13272. "cljc",
  13273. "cljx"
  13274. ]
  13275. },
  13276. {
  13277. name: "ClojureScript",
  13278. mime: "text/x-clojurescript",
  13279. mode: "clojure",
  13280. ext: ["cljs"]
  13281. },
  13282. {
  13283. name: "Closure Stylesheets (GSS)",
  13284. mime: "text/x-gss",
  13285. mode: "css",
  13286. ext: ["gss"]
  13287. },
  13288. {
  13289. name: "CMake",
  13290. mime: "text/x-cmake",
  13291. mode: "cmake",
  13292. ext: ["cmake", "cmake.in"],
  13293. file: /^CMakeLists\.txt$/
  13294. },
  13295. {
  13296. name: "CoffeeScript",
  13297. mimes: [
  13298. "application/vnd.coffeescript",
  13299. "text/coffeescript",
  13300. "text/x-coffeescript"
  13301. ],
  13302. mode: "coffeescript",
  13303. ext: ["coffee"],
  13304. alias: ["coffee", "coffee-script"]
  13305. },
  13306. {
  13307. name: "Common Lisp",
  13308. mime: "text/x-common-lisp",
  13309. mode: "commonlisp",
  13310. ext: [
  13311. "cl",
  13312. "lisp",
  13313. "el"
  13314. ],
  13315. alias: ["lisp"]
  13316. },
  13317. {
  13318. name: "Cypher",
  13319. mime: "application/x-cypher-query",
  13320. mode: "cypher",
  13321. ext: ["cyp", "cypher"]
  13322. },
  13323. {
  13324. name: "Cython",
  13325. mime: "text/x-cython",
  13326. mode: "python",
  13327. ext: [
  13328. "pyx",
  13329. "pxd",
  13330. "pxi"
  13331. ]
  13332. },
  13333. {
  13334. name: "Crystal",
  13335. mime: "text/x-crystal",
  13336. mode: "crystal",
  13337. ext: ["cr"]
  13338. },
  13339. {
  13340. name: "CSS",
  13341. mime: "text/css",
  13342. mode: "css",
  13343. ext: ["css"]
  13344. },
  13345. {
  13346. name: "CQL",
  13347. mime: "text/x-cassandra",
  13348. mode: "sql",
  13349. ext: ["cql"]
  13350. },
  13351. {
  13352. name: "D",
  13353. mime: "text/x-d",
  13354. mode: "d",
  13355. ext: ["d"]
  13356. },
  13357. {
  13358. name: "Dart",
  13359. mimes: ["application/dart", "text/x-dart"],
  13360. mode: "dart",
  13361. ext: ["dart"]
  13362. },
  13363. {
  13364. name: "diff",
  13365. mime: "text/x-diff",
  13366. mode: "diff",
  13367. ext: ["diff", "patch"]
  13368. },
  13369. {
  13370. name: "Django",
  13371. mime: "text/x-django",
  13372. mode: "django"
  13373. },
  13374. {
  13375. name: "Dockerfile",
  13376. mime: "text/x-dockerfile",
  13377. mode: "dockerfile",
  13378. file: /^Dockerfile$/
  13379. },
  13380. {
  13381. name: "DTD",
  13382. mime: "application/xml-dtd",
  13383. mode: "dtd",
  13384. ext: ["dtd"]
  13385. },
  13386. {
  13387. name: "Dylan",
  13388. mime: "text/x-dylan",
  13389. mode: "dylan",
  13390. ext: [
  13391. "dylan",
  13392. "dyl",
  13393. "intr"
  13394. ]
  13395. },
  13396. {
  13397. name: "EBNF",
  13398. mime: "text/x-ebnf",
  13399. mode: "ebnf"
  13400. },
  13401. {
  13402. name: "ECL",
  13403. mime: "text/x-ecl",
  13404. mode: "ecl",
  13405. ext: ["ecl"]
  13406. },
  13407. {
  13408. name: "edn",
  13409. mime: "application/edn",
  13410. mode: "clojure",
  13411. ext: ["edn"]
  13412. },
  13413. {
  13414. name: "Eiffel",
  13415. mime: "text/x-eiffel",
  13416. mode: "eiffel",
  13417. ext: ["e"]
  13418. },
  13419. {
  13420. name: "Elm",
  13421. mime: "text/x-elm",
  13422. mode: "elm",
  13423. ext: ["elm"]
  13424. },
  13425. {
  13426. name: "Embedded JavaScript",
  13427. mime: "application/x-ejs",
  13428. mode: "htmlembedded",
  13429. ext: ["ejs"]
  13430. },
  13431. {
  13432. name: "Embedded Ruby",
  13433. mime: "application/x-erb",
  13434. mode: "htmlembedded",
  13435. ext: ["erb"]
  13436. },
  13437. {
  13438. name: "Erlang",
  13439. mime: "text/x-erlang",
  13440. mode: "erlang",
  13441. ext: ["erl"]
  13442. },
  13443. {
  13444. name: "Esper",
  13445. mime: "text/x-esper",
  13446. mode: "sql"
  13447. },
  13448. {
  13449. name: "Factor",
  13450. mime: "text/x-factor",
  13451. mode: "factor",
  13452. ext: ["factor"]
  13453. },
  13454. {
  13455. name: "FCL",
  13456. mime: "text/x-fcl",
  13457. mode: "fcl"
  13458. },
  13459. {
  13460. name: "Forth",
  13461. mime: "text/x-forth",
  13462. mode: "forth",
  13463. ext: [
  13464. "forth",
  13465. "fth",
  13466. "4th"
  13467. ]
  13468. },
  13469. {
  13470. name: "Fortran",
  13471. mime: "text/x-fortran",
  13472. mode: "fortran",
  13473. ext: [
  13474. "f",
  13475. "for",
  13476. "f77",
  13477. "f90",
  13478. "f95"
  13479. ]
  13480. },
  13481. {
  13482. name: "F#",
  13483. mime: "text/x-fsharp",
  13484. mode: "mllike",
  13485. ext: ["fs"],
  13486. alias: ["fsharp"]
  13487. },
  13488. {
  13489. name: "Gas",
  13490. mime: "text/x-gas",
  13491. mode: "gas",
  13492. ext: ["s"]
  13493. },
  13494. {
  13495. name: "Gherkin",
  13496. mime: "text/x-feature",
  13497. mode: "gherkin",
  13498. ext: ["feature"]
  13499. },
  13500. {
  13501. name: "GitHub Flavored Markdown",
  13502. mime: "text/x-gfm",
  13503. mode: "gfm",
  13504. file: /^(readme|contributing|history)\.md$/i
  13505. },
  13506. {
  13507. name: "Go",
  13508. mime: "text/x-go",
  13509. mode: "go",
  13510. ext: ["go"]
  13511. },
  13512. {
  13513. name: "Groovy",
  13514. mime: "text/x-groovy",
  13515. mode: "groovy",
  13516. ext: ["groovy", "gradle"],
  13517. file: /^Jenkinsfile$/
  13518. },
  13519. {
  13520. name: "HAML",
  13521. mime: "text/x-haml",
  13522. mode: "haml",
  13523. ext: ["haml"]
  13524. },
  13525. {
  13526. name: "Haskell",
  13527. mime: "text/x-haskell",
  13528. mode: "haskell",
  13529. ext: ["hs"]
  13530. },
  13531. {
  13532. name: "Haskell (Literate)",
  13533. mime: "text/x-literate-haskell",
  13534. mode: "haskell-literate",
  13535. ext: ["lhs"]
  13536. },
  13537. {
  13538. name: "Haxe",
  13539. mime: "text/x-haxe",
  13540. mode: "haxe",
  13541. ext: ["hx"]
  13542. },
  13543. {
  13544. name: "HXML",
  13545. mime: "text/x-hxml",
  13546. mode: "haxe",
  13547. ext: ["hxml"]
  13548. },
  13549. {
  13550. name: "ASP.NET",
  13551. mime: "application/x-aspx",
  13552. mode: "htmlembedded",
  13553. ext: ["aspx"],
  13554. alias: ["asp", "aspx"]
  13555. },
  13556. {
  13557. name: "HTML",
  13558. mime: "text/html",
  13559. mode: "htmlmixed",
  13560. ext: [
  13561. "html",
  13562. "htm",
  13563. "handlebars",
  13564. "hbs"
  13565. ],
  13566. alias: ["xhtml"]
  13567. },
  13568. {
  13569. name: "HTTP",
  13570. mime: "message/http",
  13571. mode: "http"
  13572. },
  13573. {
  13574. name: "IDL",
  13575. mime: "text/x-idl",
  13576. mode: "idl",
  13577. ext: ["pro"]
  13578. },
  13579. {
  13580. name: "Pug",
  13581. mime: "text/x-pug",
  13582. mode: "pug",
  13583. ext: ["jade", "pug"],
  13584. alias: ["jade"]
  13585. },
  13586. {
  13587. name: "Java",
  13588. mime: "text/x-java",
  13589. mode: "clike",
  13590. ext: ["java"]
  13591. },
  13592. {
  13593. name: "Java Server Pages",
  13594. mime: "application/x-jsp",
  13595. mode: "htmlembedded",
  13596. ext: ["jsp"],
  13597. alias: ["jsp"]
  13598. },
  13599. {
  13600. name: "JavaScript",
  13601. mimes: [
  13602. "text/javascript",
  13603. "text/ecmascript",
  13604. "application/javascript",
  13605. "application/x-javascript",
  13606. "application/ecmascript"
  13607. ],
  13608. mode: "javascript",
  13609. ext: ["js"],
  13610. alias: [
  13611. "ecmascript",
  13612. "js",
  13613. "node"
  13614. ]
  13615. },
  13616. {
  13617. name: "JSON",
  13618. mimes: ["application/json", "application/x-json"],
  13619. mode: "javascript",
  13620. ext: ["json", "map"],
  13621. alias: ["json5"]
  13622. },
  13623. {
  13624. name: "JSON-LD",
  13625. mime: "application/ld+json",
  13626. mode: "javascript",
  13627. ext: ["jsonld"],
  13628. alias: ["jsonld"]
  13629. },
  13630. {
  13631. name: "JSX",
  13632. mime: "text/jsx",
  13633. mode: "jsx",
  13634. ext: ["jsx"]
  13635. },
  13636. {
  13637. name: "Jinja2",
  13638. mime: "text/jinja2",
  13639. mode: "jinja2",
  13640. ext: [
  13641. "j2",
  13642. "jinja",
  13643. "jinja2"
  13644. ]
  13645. },
  13646. {
  13647. name: "Julia",
  13648. mime: "text/x-julia",
  13649. mode: "julia",
  13650. ext: ["jl"],
  13651. alias: ["jl"]
  13652. },
  13653. {
  13654. name: "Kotlin",
  13655. mime: "text/x-kotlin",
  13656. mode: "clike",
  13657. ext: ["kt"]
  13658. },
  13659. {
  13660. name: "LESS",
  13661. mime: "text/x-less",
  13662. mode: "css",
  13663. ext: ["less"]
  13664. },
  13665. {
  13666. name: "LiveScript",
  13667. mime: "text/x-livescript",
  13668. mode: "livescript",
  13669. ext: ["ls"],
  13670. alias: ["ls"]
  13671. },
  13672. {
  13673. name: "Lua",
  13674. mime: "text/x-lua",
  13675. mode: "lua",
  13676. ext: ["lua"]
  13677. },
  13678. {
  13679. name: "Markdown",
  13680. mime: "text/x-markdown",
  13681. mode: "markdown",
  13682. ext: [
  13683. "markdown",
  13684. "md",
  13685. "mkd"
  13686. ]
  13687. },
  13688. {
  13689. name: "mIRC",
  13690. mime: "text/mirc",
  13691. mode: "mirc"
  13692. },
  13693. {
  13694. name: "MariaDB SQL",
  13695. mime: "text/x-mariadb",
  13696. mode: "sql"
  13697. },
  13698. {
  13699. name: "Mathematica",
  13700. mime: "text/x-mathematica",
  13701. mode: "mathematica",
  13702. ext: [
  13703. "m",
  13704. "nb",
  13705. "wl",
  13706. "wls"
  13707. ]
  13708. },
  13709. {
  13710. name: "Modelica",
  13711. mime: "text/x-modelica",
  13712. mode: "modelica",
  13713. ext: ["mo"]
  13714. },
  13715. {
  13716. name: "MUMPS",
  13717. mime: "text/x-mumps",
  13718. mode: "mumps",
  13719. ext: ["mps"]
  13720. },
  13721. {
  13722. name: "MS SQL",
  13723. mime: "text/x-mssql",
  13724. mode: "sql"
  13725. },
  13726. {
  13727. name: "mbox",
  13728. mime: "application/mbox",
  13729. mode: "mbox",
  13730. ext: ["mbox"]
  13731. },
  13732. {
  13733. name: "MySQL",
  13734. mime: "text/x-mysql",
  13735. mode: "sql"
  13736. },
  13737. {
  13738. name: "Nginx",
  13739. mime: "text/x-nginx-conf",
  13740. mode: "nginx",
  13741. file: /nginx.*\.conf$/i
  13742. },
  13743. {
  13744. name: "NSIS",
  13745. mime: "text/x-nsis",
  13746. mode: "nsis",
  13747. ext: ["nsh", "nsi"]
  13748. },
  13749. {
  13750. name: "NTriples",
  13751. mimes: [
  13752. "application/n-triples",
  13753. "application/n-quads",
  13754. "text/n-triples"
  13755. ],
  13756. mode: "ntriples",
  13757. ext: ["nt", "nq"]
  13758. },
  13759. {
  13760. name: "Objective-C",
  13761. mime: "text/x-objectivec",
  13762. mode: "clike",
  13763. ext: ["m"],
  13764. alias: ["objective-c", "objc"]
  13765. },
  13766. {
  13767. name: "Objective-C++",
  13768. mime: "text/x-objectivec++",
  13769. mode: "clike",
  13770. ext: ["mm"],
  13771. alias: ["objective-c++", "objc++"]
  13772. },
  13773. {
  13774. name: "OCaml",
  13775. mime: "text/x-ocaml",
  13776. mode: "mllike",
  13777. ext: [
  13778. "ml",
  13779. "mli",
  13780. "mll",
  13781. "mly"
  13782. ]
  13783. },
  13784. {
  13785. name: "Octave",
  13786. mime: "text/x-octave",
  13787. mode: "octave",
  13788. ext: ["m"]
  13789. },
  13790. {
  13791. name: "Oz",
  13792. mime: "text/x-oz",
  13793. mode: "oz",
  13794. ext: ["oz"]
  13795. },
  13796. {
  13797. name: "Pascal",
  13798. mime: "text/x-pascal",
  13799. mode: "pascal",
  13800. ext: ["p", "pas"]
  13801. },
  13802. {
  13803. name: "PEG.js",
  13804. mime: "null",
  13805. mode: "pegjs",
  13806. ext: ["jsonld"]
  13807. },
  13808. {
  13809. name: "Perl",
  13810. mime: "text/x-perl",
  13811. mode: "perl",
  13812. ext: ["pl", "pm"]
  13813. },
  13814. {
  13815. name: "PHP",
  13816. mimes: [
  13817. "text/x-php",
  13818. "application/x-httpd-php",
  13819. "application/x-httpd-php-open"
  13820. ],
  13821. mode: "php",
  13822. ext: [
  13823. "php",
  13824. "php3",
  13825. "php4",
  13826. "php5",
  13827. "php7",
  13828. "phtml"
  13829. ]
  13830. },
  13831. {
  13832. name: "Pig",
  13833. mime: "text/x-pig",
  13834. mode: "pig",
  13835. ext: ["pig"]
  13836. },
  13837. {
  13838. name: "Plain Text",
  13839. mime: "text/plain",
  13840. mode: "null",
  13841. ext: [
  13842. "txt",
  13843. "text",
  13844. "conf",
  13845. "def",
  13846. "list",
  13847. "log"
  13848. ]
  13849. },
  13850. {
  13851. name: "PLSQL",
  13852. mime: "text/x-plsql",
  13853. mode: "sql",
  13854. ext: ["pls"]
  13855. },
  13856. {
  13857. name: "PostgreSQL",
  13858. mime: "text/x-pgsql",
  13859. mode: "sql"
  13860. },
  13861. {
  13862. name: "PowerShell",
  13863. mime: "application/x-powershell",
  13864. mode: "powershell",
  13865. ext: [
  13866. "ps1",
  13867. "psd1",
  13868. "psm1"
  13869. ]
  13870. },
  13871. {
  13872. name: "Properties files",
  13873. mime: "text/x-properties",
  13874. mode: "properties",
  13875. ext: [
  13876. "properties",
  13877. "ini",
  13878. "in"
  13879. ],
  13880. alias: ["ini", "properties"]
  13881. },
  13882. {
  13883. name: "ProtoBuf",
  13884. mime: "text/x-protobuf",
  13885. mode: "protobuf",
  13886. ext: ["proto"]
  13887. },
  13888. {
  13889. name: "Python",
  13890. mime: "text/x-python",
  13891. mode: "python",
  13892. ext: [
  13893. "BUILD",
  13894. "bzl",
  13895. "py",
  13896. "pyw"
  13897. ],
  13898. file: /^(BUCK|BUILD)$/
  13899. },
  13900. {
  13901. name: "Puppet",
  13902. mime: "text/x-puppet",
  13903. mode: "puppet",
  13904. ext: ["pp"]
  13905. },
  13906. {
  13907. name: "Q",
  13908. mime: "text/x-q",
  13909. mode: "q",
  13910. ext: ["q"]
  13911. },
  13912. {
  13913. name: "R",
  13914. mime: "text/x-rsrc",
  13915. mode: "r",
  13916. ext: ["r", "R"],
  13917. alias: ["rscript"]
  13918. },
  13919. {
  13920. name: "reStructuredText",
  13921. mime: "text/x-rst",
  13922. mode: "rst",
  13923. ext: ["rst"],
  13924. alias: ["rst"]
  13925. },
  13926. {
  13927. name: "RPM Changes",
  13928. mime: "text/x-rpm-changes",
  13929. mode: "rpm"
  13930. },
  13931. {
  13932. name: "RPM Spec",
  13933. mime: "text/x-rpm-spec",
  13934. mode: "rpm",
  13935. ext: ["spec"]
  13936. },
  13937. {
  13938. name: "Ruby",
  13939. mime: "text/x-ruby",
  13940. mode: "ruby",
  13941. ext: ["rb"],
  13942. alias: [
  13943. "jruby",
  13944. "macruby",
  13945. "rake",
  13946. "rb",
  13947. "rbx"
  13948. ]
  13949. },
  13950. {
  13951. name: "Rust",
  13952. mime: "text/x-rustsrc",
  13953. mode: "rust",
  13954. ext: ["rs"]
  13955. },
  13956. {
  13957. name: "SAS",
  13958. mime: "text/x-sas",
  13959. mode: "sas",
  13960. ext: ["sas"]
  13961. },
  13962. {
  13963. name: "Sass",
  13964. mime: "text/x-sass",
  13965. mode: "sass",
  13966. ext: ["sass"]
  13967. },
  13968. {
  13969. name: "Scala",
  13970. mime: "text/x-scala",
  13971. mode: "clike",
  13972. ext: ["scala"]
  13973. },
  13974. {
  13975. name: "Scheme",
  13976. mime: "text/x-scheme",
  13977. mode: "scheme",
  13978. ext: ["scm", "ss"]
  13979. },
  13980. {
  13981. name: "SCSS",
  13982. mime: "text/x-scss",
  13983. mode: "css",
  13984. ext: ["scss"]
  13985. },
  13986. {
  13987. name: "Shell",
  13988. mimes: ["text/x-sh", "application/x-sh"],
  13989. mode: "shell",
  13990. ext: [
  13991. "sh",
  13992. "ksh",
  13993. "bash"
  13994. ],
  13995. alias: [
  13996. "bash",
  13997. "sh",
  13998. "zsh"
  13999. ],
  14000. file: /^PKGBUILD$/
  14001. },
  14002. {
  14003. name: "Sieve",
  14004. mime: "application/sieve",
  14005. mode: "sieve",
  14006. ext: ["siv", "sieve"]
  14007. },
  14008. {
  14009. name: "Slim",
  14010. mimes: ["text/x-slim", "application/x-slim"],
  14011. mode: "slim",
  14012. ext: ["slim"]
  14013. },
  14014. {
  14015. name: "Smalltalk",
  14016. mime: "text/x-stsrc",
  14017. mode: "smalltalk",
  14018. ext: ["st"]
  14019. },
  14020. {
  14021. name: "Smarty",
  14022. mime: "text/x-smarty",
  14023. mode: "smarty",
  14024. ext: ["tpl"]
  14025. },
  14026. {
  14027. name: "Solr",
  14028. mime: "text/x-solr",
  14029. mode: "solr"
  14030. },
  14031. {
  14032. name: "SML",
  14033. mime: "text/x-sml",
  14034. mode: "mllike",
  14035. ext: [
  14036. "sml",
  14037. "sig",
  14038. "fun",
  14039. "smackspec"
  14040. ]
  14041. },
  14042. {
  14043. name: "Soy",
  14044. mime: "text/x-soy",
  14045. mode: "soy",
  14046. ext: ["soy"],
  14047. alias: ["closure template"]
  14048. },
  14049. {
  14050. name: "SPARQL",
  14051. mime: "application/sparql-query",
  14052. mode: "sparql",
  14053. ext: ["rq", "sparql"],
  14054. alias: ["sparul"]
  14055. },
  14056. {
  14057. name: "Spreadsheet",
  14058. mime: "text/x-spreadsheet",
  14059. mode: "spreadsheet",
  14060. alias: ["excel", "formula"]
  14061. },
  14062. {
  14063. name: "SQL",
  14064. mime: "text/x-sql",
  14065. mode: "sql",
  14066. ext: ["sql"]
  14067. },
  14068. {
  14069. name: "SQLite",
  14070. mime: "text/x-sqlite",
  14071. mode: "sql"
  14072. },
  14073. {
  14074. name: "Squirrel",
  14075. mime: "text/x-squirrel",
  14076. mode: "clike",
  14077. ext: ["nut"]
  14078. },
  14079. {
  14080. name: "Stylus",
  14081. mime: "text/x-styl",
  14082. mode: "stylus",
  14083. ext: ["styl"]
  14084. },
  14085. {
  14086. name: "Swift",
  14087. mime: "text/x-swift",
  14088. mode: "swift",
  14089. ext: ["swift"]
  14090. },
  14091. {
  14092. name: "sTeX",
  14093. mime: "text/x-stex",
  14094. mode: "stex"
  14095. },
  14096. {
  14097. name: "LaTeX",
  14098. mime: "text/x-latex",
  14099. mode: "stex",
  14100. ext: [
  14101. "text",
  14102. "ltx",
  14103. "tex"
  14104. ],
  14105. alias: ["tex"]
  14106. },
  14107. {
  14108. name: "SystemVerilog",
  14109. mime: "text/x-systemverilog",
  14110. mode: "verilog",
  14111. ext: [
  14112. "v",
  14113. "sv",
  14114. "svh"
  14115. ]
  14116. },
  14117. {
  14118. name: "Tcl",
  14119. mime: "text/x-tcl",
  14120. mode: "tcl",
  14121. ext: ["tcl"]
  14122. },
  14123. {
  14124. name: "Textile",
  14125. mime: "text/x-textile",
  14126. mode: "textile",
  14127. ext: ["textile"]
  14128. },
  14129. {
  14130. name: "TiddlyWiki",
  14131. mime: "text/x-tiddlywiki",
  14132. mode: "tiddlywiki"
  14133. },
  14134. {
  14135. name: "Tiki wiki",
  14136. mime: "text/tiki",
  14137. mode: "tiki"
  14138. },
  14139. {
  14140. name: "TOML",
  14141. mime: "text/x-toml",
  14142. mode: "toml",
  14143. ext: ["toml"]
  14144. },
  14145. {
  14146. name: "Tornado",
  14147. mime: "text/x-tornado",
  14148. mode: "tornado"
  14149. },
  14150. {
  14151. name: "troff",
  14152. mime: "text/troff",
  14153. mode: "troff",
  14154. ext: [
  14155. "1",
  14156. "2",
  14157. "3",
  14158. "4",
  14159. "5",
  14160. "6",
  14161. "7",
  14162. "8",
  14163. "9"
  14164. ]
  14165. },
  14166. {
  14167. name: "TTCN",
  14168. mime: "text/x-ttcn",
  14169. mode: "ttcn",
  14170. ext: [
  14171. "ttcn",
  14172. "ttcn3",
  14173. "ttcnpp"
  14174. ]
  14175. },
  14176. {
  14177. name: "TTCN_CFG",
  14178. mime: "text/x-ttcn-cfg",
  14179. mode: "ttcn-cfg",
  14180. ext: ["cfg"]
  14181. },
  14182. {
  14183. name: "Turtle",
  14184. mime: "text/turtle",
  14185. mode: "turtle",
  14186. ext: ["ttl"]
  14187. },
  14188. {
  14189. name: "TypeScript",
  14190. mime: "application/typescript",
  14191. mode: "javascript",
  14192. ext: ["ts"],
  14193. alias: ["ts"]
  14194. },
  14195. {
  14196. name: "TypeScript-JSX",
  14197. mime: "text/typescript-jsx",
  14198. mode: "jsx",
  14199. ext: ["tsx"],
  14200. alias: ["tsx"]
  14201. },
  14202. {
  14203. name: "Twig",
  14204. mime: "text/x-twig",
  14205. mode: "twig"
  14206. },
  14207. {
  14208. name: "Web IDL",
  14209. mime: "text/x-webidl",
  14210. mode: "webidl",
  14211. ext: ["webidl"]
  14212. },
  14213. {
  14214. name: "VB.NET",
  14215. mime: "text/x-vb",
  14216. mode: "vb",
  14217. ext: ["vb"]
  14218. },
  14219. {
  14220. name: "VBScript",
  14221. mime: "text/vbscript",
  14222. mode: "vbscript",
  14223. ext: ["vbs"]
  14224. },
  14225. {
  14226. name: "Velocity",
  14227. mime: "text/velocity",
  14228. mode: "velocity",
  14229. ext: ["vtl"]
  14230. },
  14231. {
  14232. name: "Verilog",
  14233. mime: "text/x-verilog",
  14234. mode: "verilog",
  14235. ext: ["v"]
  14236. },
  14237. {
  14238. name: "VHDL",
  14239. mime: "text/x-vhdl",
  14240. mode: "vhdl",
  14241. ext: ["vhd", "vhdl"]
  14242. },
  14243. {
  14244. name: "Vue.js Component",
  14245. mimes: ["script/x-vue", "text/x-vue"],
  14246. mode: "vue",
  14247. ext: ["vue"]
  14248. },
  14249. {
  14250. name: "XML",
  14251. mimes: ["application/xml", "text/xml"],
  14252. mode: "xml",
  14253. ext: [
  14254. "xml",
  14255. "xsl",
  14256. "xsd",
  14257. "svg"
  14258. ],
  14259. alias: [
  14260. "rss",
  14261. "wsdl",
  14262. "xsd"
  14263. ]
  14264. },
  14265. {
  14266. name: "XQuery",
  14267. mime: "application/xquery",
  14268. mode: "xquery",
  14269. ext: ["xy", "xquery"]
  14270. },
  14271. {
  14272. name: "Yacas",
  14273. mime: "text/x-yacas",
  14274. mode: "yacas",
  14275. ext: ["ys"]
  14276. },
  14277. {
  14278. name: "YAML",
  14279. mimes: ["text/x-yaml", "text/yaml"],
  14280. mode: "yaml",
  14281. ext: ["yaml", "yml"],
  14282. alias: ["yml"]
  14283. },
  14284. {
  14285. name: "Z80",
  14286. mime: "text/x-z80",
  14287. mode: "z80",
  14288. ext: ["z80"]
  14289. },
  14290. {
  14291. name: "mscgen",
  14292. mime: "text/x-mscgen",
  14293. mode: "mscgen",
  14294. ext: [
  14295. "mscgen",
  14296. "mscin",
  14297. "msc"
  14298. ]
  14299. },
  14300. {
  14301. name: "xu",
  14302. mime: "text/x-xu",
  14303. mode: "mscgen",
  14304. ext: ["xu"]
  14305. },
  14306. {
  14307. name: "msgenny",
  14308. mime: "text/x-msgenny",
  14309. mode: "mscgen",
  14310. ext: ["msgenny"]
  14311. },
  14312. {
  14313. name: "WebAssembly",
  14314. mime: "text/webassembly",
  14315. mode: "wast",
  14316. ext: ["wat", "wast"]
  14317. }
  14318. ];
  14319. for (var i = 0; i < CodeMirror$1.modeInfo.length; i++) {
  14320. var info = CodeMirror$1.modeInfo[i];
  14321. if (info.mimes) info.mime = info.mimes[0];
  14322. }
  14323. CodeMirror$1.findModeByMIME = function(mime) {
  14324. mime = mime.toLowerCase();
  14325. for (var i$1 = 0; i$1 < CodeMirror$1.modeInfo.length; i$1++) {
  14326. var info$1 = CodeMirror$1.modeInfo[i$1];
  14327. if (info$1.mime == mime) return info$1;
  14328. if (info$1.mimes) {
  14329. for (var j = 0; j < info$1.mimes.length; j++) if (info$1.mimes[j] == mime) return info$1;
  14330. }
  14331. }
  14332. if (/\+xml$/.test(mime)) return CodeMirror$1.findModeByMIME("application/xml");
  14333. if (/\+json$/.test(mime)) return CodeMirror$1.findModeByMIME("application/json");
  14334. };
  14335. CodeMirror$1.findModeByExtension = function(ext) {
  14336. ext = ext.toLowerCase();
  14337. for (var i$1 = 0; i$1 < CodeMirror$1.modeInfo.length; i$1++) {
  14338. var info$1 = CodeMirror$1.modeInfo[i$1];
  14339. if (info$1.ext) {
  14340. for (var j = 0; j < info$1.ext.length; j++) if (info$1.ext[j] == ext) return info$1;
  14341. }
  14342. }
  14343. };
  14344. CodeMirror$1.findModeByFileName = function(filename) {
  14345. for (var i$1 = 0; i$1 < CodeMirror$1.modeInfo.length; i$1++) {
  14346. var info$1 = CodeMirror$1.modeInfo[i$1];
  14347. if (info$1.file && info$1.file.test(filename)) return info$1;
  14348. }
  14349. var dot = filename.lastIndexOf(".");
  14350. var ext = dot > -1 && filename.substring(dot + 1, filename.length);
  14351. if (ext) return CodeMirror$1.findModeByExtension(ext);
  14352. };
  14353. CodeMirror$1.findModeByName = function(name) {
  14354. name = name.toLowerCase();
  14355. for (var i$1 = 0; i$1 < CodeMirror$1.modeInfo.length; i$1++) {
  14356. var info$1 = CodeMirror$1.modeInfo[i$1];
  14357. if (info$1.name.toLowerCase() == name) return info$1;
  14358. if (info$1.alias) {
  14359. for (var j = 0; j < info$1.alias.length; j++) if (info$1.alias[j].toLowerCase() == name) return info$1;
  14360. }
  14361. }
  14362. };
  14363. });
  14364. });
  14365. var require_markdown = __commonJSMin((exports, module) => {
  14366. (function(mod) {
  14367. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_xml(), require_meta());
  14368. else if (typeof define == "function" && define.amd) define([
  14369. "../../lib/codemirror",
  14370. "../xml/xml",
  14371. "../meta"
  14372. ], mod);
  14373. else mod(CodeMirror);
  14374. })(function(CodeMirror$1) {
  14375. "use strict";
  14376. CodeMirror$1.defineMode("markdown", function(cmCfg, modeCfg) {
  14377. var htmlMode = CodeMirror$1.getMode(cmCfg, "text/html");
  14378. var htmlModeMissing = htmlMode.name == "null";
  14379. function getMode(name) {
  14380. if (CodeMirror$1.findModeByName) {
  14381. var found = CodeMirror$1.findModeByName(name);
  14382. if (found) name = found.mime || found.mimes[0];
  14383. }
  14384. var mode$1 = CodeMirror$1.getMode(cmCfg, name);
  14385. return mode$1.name == "null" ? null : mode$1;
  14386. }
  14387. if (modeCfg.highlightFormatting === void 0) modeCfg.highlightFormatting = false;
  14388. if (modeCfg.maxBlockquoteDepth === void 0) modeCfg.maxBlockquoteDepth = 0;
  14389. if (modeCfg.taskLists === void 0) modeCfg.taskLists = false;
  14390. if (modeCfg.strikethrough === void 0) modeCfg.strikethrough = false;
  14391. if (modeCfg.emoji === void 0) modeCfg.emoji = false;
  14392. if (modeCfg.fencedCodeBlockHighlighting === void 0) modeCfg.fencedCodeBlockHighlighting = true;
  14393. if (modeCfg.fencedCodeBlockDefaultMode === void 0) modeCfg.fencedCodeBlockDefaultMode = "text/plain";
  14394. if (modeCfg.xml === void 0) modeCfg.xml = true;
  14395. if (modeCfg.tokenTypeOverrides === void 0) modeCfg.tokenTypeOverrides = {};
  14396. var tokenTypes = {
  14397. header: "header",
  14398. code: "comment",
  14399. quote: "quote",
  14400. list1: "variable-2",
  14401. list2: "variable-3",
  14402. list3: "keyword",
  14403. hr: "hr",
  14404. image: "image",
  14405. imageAltText: "image-alt-text",
  14406. imageMarker: "image-marker",
  14407. formatting: "formatting",
  14408. linkInline: "link",
  14409. linkEmail: "link",
  14410. linkText: "link",
  14411. linkHref: "string",
  14412. em: "em",
  14413. strong: "strong",
  14414. strikethrough: "strikethrough",
  14415. emoji: "builtin"
  14416. };
  14417. for (var tokenType in tokenTypes) if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
  14418. var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/, listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/, taskListRE = /^\[(x| )\](?=\s)/i, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/, setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/, textRE = /^[^#!\[\]*_\\<>` "'(~:]+/, fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/, linkDefRE = /^\s*\[[^\]]+?\]:.*$/, punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/, expandedTab = " ";
  14419. function switchInline(stream, state, f) {
  14420. state.f = state.inline = f;
  14421. return f(stream, state);
  14422. }
  14423. function switchBlock(stream, state, f) {
  14424. state.f = state.block = f;
  14425. return f(stream, state);
  14426. }
  14427. function lineIsEmpty(line) {
  14428. return !line || !/\S/.test(line.string);
  14429. }
  14430. function blankLine(state) {
  14431. state.linkTitle = false;
  14432. state.linkHref = false;
  14433. state.linkText = false;
  14434. state.em = false;
  14435. state.strong = false;
  14436. state.strikethrough = false;
  14437. state.quote = 0;
  14438. state.indentedCode = false;
  14439. if (state.f == htmlBlock) {
  14440. var exit = htmlModeMissing;
  14441. if (!exit) {
  14442. var inner = CodeMirror$1.innerMode(htmlMode, state.htmlState);
  14443. exit = inner.mode.name == "xml" && inner.state.tagStart === null && !inner.state.context && inner.state.tokenize.isInText;
  14444. }
  14445. if (exit) {
  14446. state.f = inlineNormal;
  14447. state.block = blockNormal;
  14448. state.htmlState = null;
  14449. }
  14450. }
  14451. state.trailingSpace = 0;
  14452. state.trailingSpaceNewLine = false;
  14453. state.prevLine = state.thisLine;
  14454. state.thisLine = { stream: null };
  14455. return null;
  14456. }
  14457. function blockNormal(stream, state) {
  14458. var firstTokenOnLine = stream.column() === state.indentation;
  14459. var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream);
  14460. var prevLineIsIndentedCode = state.indentedCode;
  14461. var prevLineIsHr = state.prevLine.hr;
  14462. var prevLineIsList = state.list !== false;
  14463. var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3;
  14464. state.indentedCode = false;
  14465. var lineIndentation = state.indentation;
  14466. if (state.indentationDiff === null) {
  14467. state.indentationDiff = state.indentation;
  14468. if (prevLineIsList) {
  14469. state.list = null;
  14470. while (lineIndentation < state.listStack[state.listStack.length - 1]) {
  14471. state.listStack.pop();
  14472. if (state.listStack.length) state.indentation = state.listStack[state.listStack.length - 1];
  14473. else state.list = false;
  14474. }
  14475. if (state.list !== false) state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1];
  14476. }
  14477. }
  14478. var allowsInlineContinuation = !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header && (!prevLineIsList || !prevLineIsIndentedCode) && !state.prevLine.fencedCodeEnd;
  14479. var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && state.indentation <= maxNonCodeIndentation && stream.match(hrRE);
  14480. var match = null;
  14481. if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd || state.prevLine.header || prevLineLineIsEmpty)) {
  14482. stream.skipToEnd();
  14483. state.indentedCode = true;
  14484. return tokenTypes.code;
  14485. } else if (stream.eatSpace()) return null;
  14486. else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
  14487. state.quote = 0;
  14488. state.header = match[1].length;
  14489. state.thisLine.header = true;
  14490. if (modeCfg.highlightFormatting) state.formatting = "header";
  14491. state.f = state.inline;
  14492. return getType(state);
  14493. } else if (state.indentation <= maxNonCodeIndentation && stream.eat(">")) {
  14494. state.quote = firstTokenOnLine ? 1 : state.quote + 1;
  14495. if (modeCfg.highlightFormatting) state.formatting = "quote";
  14496. stream.eatSpace();
  14497. return getType(state);
  14498. } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) {
  14499. var listType = match[1] ? "ol" : "ul";
  14500. state.indentation = lineIndentation + stream.current().length;
  14501. state.list = true;
  14502. state.quote = 0;
  14503. state.listStack.push(state.indentation);
  14504. state.em = false;
  14505. state.strong = false;
  14506. state.code = false;
  14507. state.strikethrough = false;
  14508. if (modeCfg.taskLists && stream.match(taskListRE, false)) state.taskList = true;
  14509. state.f = state.inline;
  14510. if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
  14511. return getType(state);
  14512. } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) {
  14513. state.quote = 0;
  14514. state.fencedEndRE = new RegExp(match[1] + "+ *$");
  14515. state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode);
  14516. if (state.localMode) state.localState = CodeMirror$1.startState(state.localMode);
  14517. state.f = state.block = local;
  14518. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  14519. state.code = -1;
  14520. return getType(state);
  14521. } else if (state.setext || (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false && !state.code && !isHr && !linkDefRE.test(stream.string) && (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE))) {
  14522. if (!state.setext) {
  14523. state.header = match[0].charAt(0) == "=" ? 1 : 2;
  14524. state.setext = state.header;
  14525. } else {
  14526. state.header = state.setext;
  14527. state.setext = 0;
  14528. stream.skipToEnd();
  14529. if (modeCfg.highlightFormatting) state.formatting = "header";
  14530. }
  14531. state.thisLine.header = true;
  14532. state.f = state.inline;
  14533. return getType(state);
  14534. } else if (isHr) {
  14535. stream.skipToEnd();
  14536. state.hr = true;
  14537. state.thisLine.hr = true;
  14538. return tokenTypes.hr;
  14539. } else if (stream.peek() === "[") return switchInline(stream, state, footnoteLink);
  14540. return switchInline(stream, state, state.inline);
  14541. }
  14542. function htmlBlock(stream, state) {
  14543. var style = htmlMode.token(stream, state.htmlState);
  14544. if (!htmlModeMissing) {
  14545. var inner = CodeMirror$1.innerMode(htmlMode, state.htmlState);
  14546. if (inner.mode.name == "xml" && inner.state.tagStart === null && !inner.state.context && inner.state.tokenize.isInText || state.md_inside && stream.current().indexOf(">") > -1) {
  14547. state.f = inlineNormal;
  14548. state.block = blockNormal;
  14549. state.htmlState = null;
  14550. }
  14551. }
  14552. return style;
  14553. }
  14554. function local(stream, state) {
  14555. var currListInd = state.listStack[state.listStack.length - 1] || 0;
  14556. var hasExitedList = state.indentation < currListInd;
  14557. var maxFencedEndInd = currListInd + 3;
  14558. if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) {
  14559. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  14560. var returnType;
  14561. if (!hasExitedList) returnType = getType(state);
  14562. state.localMode = state.localState = null;
  14563. state.block = blockNormal;
  14564. state.f = inlineNormal;
  14565. state.fencedEndRE = null;
  14566. state.code = 0;
  14567. state.thisLine.fencedCodeEnd = true;
  14568. if (hasExitedList) return switchBlock(stream, state, state.block);
  14569. return returnType;
  14570. } else if (state.localMode) return state.localMode.token(stream, state.localState);
  14571. else {
  14572. stream.skipToEnd();
  14573. return tokenTypes.code;
  14574. }
  14575. }
  14576. function getType(state) {
  14577. var styles = [];
  14578. if (state.formatting) {
  14579. styles.push(tokenTypes.formatting);
  14580. if (typeof state.formatting === "string") state.formatting = [state.formatting];
  14581. for (var i = 0; i < state.formatting.length; i++) {
  14582. styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
  14583. if (state.formatting[i] === "header") styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
  14584. if (state.formatting[i] === "quote") if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
  14585. else styles.push("error");
  14586. }
  14587. }
  14588. if (state.taskOpen) {
  14589. styles.push("meta");
  14590. return styles.length ? styles.join(" ") : null;
  14591. }
  14592. if (state.taskClosed) {
  14593. styles.push("property");
  14594. return styles.length ? styles.join(" ") : null;
  14595. }
  14596. if (state.linkHref) styles.push(tokenTypes.linkHref, "url");
  14597. else {
  14598. if (state.strong) styles.push(tokenTypes.strong);
  14599. if (state.em) styles.push(tokenTypes.em);
  14600. if (state.strikethrough) styles.push(tokenTypes.strikethrough);
  14601. if (state.emoji) styles.push(tokenTypes.emoji);
  14602. if (state.linkText) styles.push(tokenTypes.linkText);
  14603. if (state.code) styles.push(tokenTypes.code);
  14604. if (state.image) styles.push(tokenTypes.image);
  14605. if (state.imageAltText) styles.push(tokenTypes.imageAltText, "link");
  14606. if (state.imageMarker) styles.push(tokenTypes.imageMarker);
  14607. }
  14608. if (state.header) styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header);
  14609. if (state.quote) {
  14610. styles.push(tokenTypes.quote);
  14611. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) styles.push(tokenTypes.quote + "-" + state.quote);
  14612. else styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
  14613. }
  14614. if (state.list !== false) {
  14615. var listMod = (state.listStack.length - 1) % 3;
  14616. if (!listMod) styles.push(tokenTypes.list1);
  14617. else if (listMod === 1) styles.push(tokenTypes.list2);
  14618. else styles.push(tokenTypes.list3);
  14619. }
  14620. if (state.trailingSpaceNewLine) styles.push("trailing-space-new-line");
  14621. else if (state.trailingSpace) styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
  14622. return styles.length ? styles.join(" ") : null;
  14623. }
  14624. function handleText(stream, state) {
  14625. if (stream.match(textRE, true)) return getType(state);
  14626. return void 0;
  14627. }
  14628. function inlineNormal(stream, state) {
  14629. var style = state.text(stream, state);
  14630. if (typeof style !== "undefined") return style;
  14631. if (state.list) {
  14632. state.list = null;
  14633. return getType(state);
  14634. }
  14635. if (state.taskList) {
  14636. var taskOpen = stream.match(taskListRE, true)[1] === " ";
  14637. if (taskOpen) state.taskOpen = true;
  14638. else state.taskClosed = true;
  14639. if (modeCfg.highlightFormatting) state.formatting = "task";
  14640. state.taskList = false;
  14641. return getType(state);
  14642. }
  14643. state.taskOpen = false;
  14644. state.taskClosed = false;
  14645. if (state.header && stream.match(/^#+$/, true)) {
  14646. if (modeCfg.highlightFormatting) state.formatting = "header";
  14647. return getType(state);
  14648. }
  14649. var ch = stream.next();
  14650. if (state.linkTitle) {
  14651. state.linkTitle = false;
  14652. var matchCh = ch;
  14653. if (ch === "(") matchCh = ")";
  14654. matchCh = (matchCh + "").replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1");
  14655. var regex = "^\\s*(?:[^" + matchCh + "\\\\]+|\\\\\\\\|\\\\.)" + matchCh;
  14656. if (stream.match(new RegExp(regex), true)) return tokenTypes.linkHref;
  14657. }
  14658. if (ch === "`") {
  14659. var previousFormatting = state.formatting;
  14660. if (modeCfg.highlightFormatting) state.formatting = "code";
  14661. stream.eatWhile("`");
  14662. var count = stream.current().length;
  14663. if (state.code == 0 && (!state.quote || count == 1)) {
  14664. state.code = count;
  14665. return getType(state);
  14666. } else if (count == state.code) {
  14667. var t = getType(state);
  14668. state.code = 0;
  14669. return t;
  14670. } else {
  14671. state.formatting = previousFormatting;
  14672. return getType(state);
  14673. }
  14674. } else if (state.code) return getType(state);
  14675. if (ch === "\\") {
  14676. stream.next();
  14677. if (modeCfg.highlightFormatting) {
  14678. var type = getType(state);
  14679. var formattingEscape = tokenTypes.formatting + "-escape";
  14680. return type ? type + " " + formattingEscape : formattingEscape;
  14681. }
  14682. }
  14683. if (ch === "!" && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
  14684. state.imageMarker = true;
  14685. state.image = true;
  14686. if (modeCfg.highlightFormatting) state.formatting = "image";
  14687. return getType(state);
  14688. }
  14689. if (ch === "[" && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) {
  14690. state.imageMarker = false;
  14691. state.imageAltText = true;
  14692. if (modeCfg.highlightFormatting) state.formatting = "image";
  14693. return getType(state);
  14694. }
  14695. if (ch === "]" && state.imageAltText) {
  14696. if (modeCfg.highlightFormatting) state.formatting = "image";
  14697. var type = getType(state);
  14698. state.imageAltText = false;
  14699. state.image = false;
  14700. state.inline = state.f = linkHref;
  14701. return type;
  14702. }
  14703. if (ch === "[" && !state.image) {
  14704. if (state.linkText && stream.match(/^.*?\]/)) return getType(state);
  14705. state.linkText = true;
  14706. if (modeCfg.highlightFormatting) state.formatting = "link";
  14707. return getType(state);
  14708. }
  14709. if (ch === "]" && state.linkText) {
  14710. if (modeCfg.highlightFormatting) state.formatting = "link";
  14711. var type = getType(state);
  14712. state.linkText = false;
  14713. state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal;
  14714. return type;
  14715. }
  14716. if (ch === "<" && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
  14717. state.f = state.inline = linkInline;
  14718. if (modeCfg.highlightFormatting) state.formatting = "link";
  14719. var type = getType(state);
  14720. if (type) type += " ";
  14721. else type = "";
  14722. return type + tokenTypes.linkInline;
  14723. }
  14724. if (ch === "<" && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
  14725. state.f = state.inline = linkInline;
  14726. if (modeCfg.highlightFormatting) state.formatting = "link";
  14727. var type = getType(state);
  14728. if (type) type += " ";
  14729. else type = "";
  14730. return type + tokenTypes.linkEmail;
  14731. }
  14732. if (modeCfg.xml && ch === "<" && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) {
  14733. var end = stream.string.indexOf(">", stream.pos);
  14734. if (end != -1) {
  14735. var atts = stream.string.substring(stream.start, end);
  14736. if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
  14737. }
  14738. stream.backUp(1);
  14739. state.htmlState = CodeMirror$1.startState(htmlMode);
  14740. return switchBlock(stream, state, htmlBlock);
  14741. }
  14742. if (modeCfg.xml && ch === "<" && stream.match(/^\/\w*?>/)) {
  14743. state.md_inside = false;
  14744. return "tag";
  14745. } else if (ch === "*" || ch === "_") {
  14746. var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2);
  14747. while (len < 3 && stream.eat(ch)) len++;
  14748. var after = stream.peek() || " ";
  14749. var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before));
  14750. var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after));
  14751. var setEm = null, setStrong = null;
  14752. if (len % 2) {
  14753. if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setEm = true;
  14754. else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setEm = false;
  14755. }
  14756. if (len > 1) {
  14757. if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setStrong = true;
  14758. else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setStrong = false;
  14759. }
  14760. if (setStrong != null || setEm != null) {
  14761. if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em";
  14762. if (setEm === true) state.em = ch;
  14763. if (setStrong === true) state.strong = ch;
  14764. var t = getType(state);
  14765. if (setEm === false) state.em = false;
  14766. if (setStrong === false) state.strong = false;
  14767. return t;
  14768. }
  14769. } else if (ch === " ") {
  14770. if (stream.eat("*") || stream.eat("_")) if (stream.peek() === " ") return getType(state);
  14771. else stream.backUp(1);
  14772. }
  14773. if (modeCfg.strikethrough) {
  14774. if (ch === "~" && stream.eatWhile(ch)) {
  14775. if (state.strikethrough) {
  14776. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  14777. var t = getType(state);
  14778. state.strikethrough = false;
  14779. return t;
  14780. } else if (stream.match(/^[^\s]/, false)) {
  14781. state.strikethrough = true;
  14782. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  14783. return getType(state);
  14784. }
  14785. } else if (ch === " ") {
  14786. if (stream.match("~~", true)) if (stream.peek() === " ") return getType(state);
  14787. else stream.backUp(2);
  14788. }
  14789. }
  14790. if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) {
  14791. state.emoji = true;
  14792. if (modeCfg.highlightFormatting) state.formatting = "emoji";
  14793. var retType = getType(state);
  14794. state.emoji = false;
  14795. return retType;
  14796. }
  14797. if (ch === " ") {
  14798. if (stream.match(/^ +$/, false)) state.trailingSpace++;
  14799. else if (state.trailingSpace) state.trailingSpaceNewLine = true;
  14800. }
  14801. return getType(state);
  14802. }
  14803. function linkInline(stream, state) {
  14804. var ch = stream.next();
  14805. if (ch === ">") {
  14806. state.f = state.inline = inlineNormal;
  14807. if (modeCfg.highlightFormatting) state.formatting = "link";
  14808. var type = getType(state);
  14809. if (type) type += " ";
  14810. else type = "";
  14811. return type + tokenTypes.linkInline;
  14812. }
  14813. stream.match(/^[^>]+/, true);
  14814. return tokenTypes.linkInline;
  14815. }
  14816. function linkHref(stream, state) {
  14817. if (stream.eatSpace()) return null;
  14818. var ch = stream.next();
  14819. if (ch === "(" || ch === "[") {
  14820. state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
  14821. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  14822. state.linkHref = true;
  14823. return getType(state);
  14824. }
  14825. return "error";
  14826. }
  14827. var linkRE = {
  14828. ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
  14829. "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/
  14830. };
  14831. function getLinkHrefInside(endChar) {
  14832. return function(stream, state) {
  14833. var ch = stream.next();
  14834. if (ch === endChar) {
  14835. state.f = state.inline = inlineNormal;
  14836. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  14837. var returnState = getType(state);
  14838. state.linkHref = false;
  14839. return returnState;
  14840. }
  14841. stream.match(linkRE[endChar]);
  14842. state.linkHref = true;
  14843. return getType(state);
  14844. };
  14845. }
  14846. function footnoteLink(stream, state) {
  14847. if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
  14848. state.f = footnoteLinkInside;
  14849. stream.next();
  14850. if (modeCfg.highlightFormatting) state.formatting = "link";
  14851. state.linkText = true;
  14852. return getType(state);
  14853. }
  14854. return switchInline(stream, state, inlineNormal);
  14855. }
  14856. function footnoteLinkInside(stream, state) {
  14857. if (stream.match("]:", true)) {
  14858. state.f = state.inline = footnoteUrl;
  14859. if (modeCfg.highlightFormatting) state.formatting = "link";
  14860. var returnType = getType(state);
  14861. state.linkText = false;
  14862. return returnType;
  14863. }
  14864. stream.match(/^([^\]\\]|\\.)+/, true);
  14865. return tokenTypes.linkText;
  14866. }
  14867. function footnoteUrl(stream, state) {
  14868. if (stream.eatSpace()) return null;
  14869. stream.match(/^[^\s]+/, true);
  14870. if (stream.peek() === void 0) state.linkTitle = true;
  14871. else stream.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, true);
  14872. state.f = state.inline = inlineNormal;
  14873. return tokenTypes.linkHref + " url";
  14874. }
  14875. var mode = {
  14876. startState: function() {
  14877. return {
  14878. f: blockNormal,
  14879. prevLine: { stream: null },
  14880. thisLine: { stream: null },
  14881. block: blockNormal,
  14882. htmlState: null,
  14883. indentation: 0,
  14884. inline: inlineNormal,
  14885. text: handleText,
  14886. formatting: false,
  14887. linkText: false,
  14888. linkHref: false,
  14889. linkTitle: false,
  14890. code: 0,
  14891. em: false,
  14892. strong: false,
  14893. header: 0,
  14894. setext: 0,
  14895. hr: false,
  14896. taskList: false,
  14897. list: false,
  14898. listStack: [],
  14899. quote: 0,
  14900. trailingSpace: 0,
  14901. trailingSpaceNewLine: false,
  14902. strikethrough: false,
  14903. emoji: false,
  14904. fencedEndRE: null
  14905. };
  14906. },
  14907. copyState: function(s) {
  14908. return {
  14909. f: s.f,
  14910. prevLine: s.prevLine,
  14911. thisLine: s.thisLine,
  14912. block: s.block,
  14913. htmlState: s.htmlState && CodeMirror$1.copyState(htmlMode, s.htmlState),
  14914. indentation: s.indentation,
  14915. localMode: s.localMode,
  14916. localState: s.localMode ? CodeMirror$1.copyState(s.localMode, s.localState) : null,
  14917. inline: s.inline,
  14918. text: s.text,
  14919. formatting: false,
  14920. linkText: s.linkText,
  14921. linkTitle: s.linkTitle,
  14922. linkHref: s.linkHref,
  14923. code: s.code,
  14924. em: s.em,
  14925. strong: s.strong,
  14926. strikethrough: s.strikethrough,
  14927. emoji: s.emoji,
  14928. header: s.header,
  14929. setext: s.setext,
  14930. hr: s.hr,
  14931. taskList: s.taskList,
  14932. list: s.list,
  14933. listStack: s.listStack.slice(0),
  14934. quote: s.quote,
  14935. indentedCode: s.indentedCode,
  14936. trailingSpace: s.trailingSpace,
  14937. trailingSpaceNewLine: s.trailingSpaceNewLine,
  14938. md_inside: s.md_inside,
  14939. fencedEndRE: s.fencedEndRE
  14940. };
  14941. },
  14942. token: function(stream, state) {
  14943. state.formatting = false;
  14944. if (stream != state.thisLine.stream) {
  14945. state.header = 0;
  14946. state.hr = false;
  14947. if (stream.match(/^\s*$/, true)) {
  14948. blankLine(state);
  14949. return null;
  14950. }
  14951. state.prevLine = state.thisLine;
  14952. state.thisLine = { stream };
  14953. state.taskList = false;
  14954. state.trailingSpace = 0;
  14955. state.trailingSpaceNewLine = false;
  14956. if (!state.localState) {
  14957. state.f = state.block;
  14958. if (state.f != htmlBlock) {
  14959. var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length;
  14960. state.indentation = indentation;
  14961. state.indentationDiff = null;
  14962. if (indentation > 0) return null;
  14963. }
  14964. }
  14965. }
  14966. return state.f(stream, state);
  14967. },
  14968. innerMode: function(state) {
  14969. if (state.block == htmlBlock) return {
  14970. state: state.htmlState,
  14971. mode: htmlMode
  14972. };
  14973. if (state.localState) return {
  14974. state: state.localState,
  14975. mode: state.localMode
  14976. };
  14977. return {
  14978. state,
  14979. mode
  14980. };
  14981. },
  14982. indent: function(state, textAfter, line) {
  14983. if (state.block == htmlBlock && htmlMode.indent) return htmlMode.indent(state.htmlState, textAfter, line);
  14984. if (state.localState && state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line);
  14985. return CodeMirror$1.Pass;
  14986. },
  14987. blankLine,
  14988. getType,
  14989. blockCommentStart: "<!--",
  14990. blockCommentEnd: "-->",
  14991. closeBrackets: "()[]{}''\"\"``",
  14992. fold: "markdown"
  14993. };
  14994. return mode;
  14995. }, "xml");
  14996. CodeMirror$1.defineMIME("text/markdown", "markdown");
  14997. CodeMirror$1.defineMIME("text/x-markdown", "markdown");
  14998. });
  14999. });
  15000. var require_pug = __commonJSMin((exports, module) => {
  15001. (function(mod) {
  15002. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_javascript(), require_css(), require_htmlmixed());
  15003. else if (typeof define == "function" && define.amd) define([
  15004. "../../lib/codemirror",
  15005. "../javascript/javascript",
  15006. "../css/css",
  15007. "../htmlmixed/htmlmixed"
  15008. ], mod);
  15009. else mod(CodeMirror);
  15010. })(function(CodeMirror$1) {
  15011. "use strict";
  15012. CodeMirror$1.defineMode("pug", function(config) {
  15013. var KEYWORD = "keyword";
  15014. var DOCTYPE = "meta";
  15015. var ID = "builtin";
  15016. var CLASS = "qualifier";
  15017. var ATTRS_NEST = {
  15018. "{": "}",
  15019. "(": ")",
  15020. "[": "]"
  15021. };
  15022. var jsMode = CodeMirror$1.getMode(config, "javascript");
  15023. function State() {
  15024. this.javaScriptLine = false;
  15025. this.javaScriptLineExcludesColon = false;
  15026. this.javaScriptArguments = false;
  15027. this.javaScriptArgumentsDepth = 0;
  15028. this.isInterpolating = false;
  15029. this.interpolationNesting = 0;
  15030. this.jsState = CodeMirror$1.startState(jsMode);
  15031. this.restOfLine = "";
  15032. this.isIncludeFiltered = false;
  15033. this.isEach = false;
  15034. this.lastTag = "";
  15035. this.scriptType = "";
  15036. this.isAttrs = false;
  15037. this.attrsNest = [];
  15038. this.inAttributeName = true;
  15039. this.attributeIsType = false;
  15040. this.attrValue = "";
  15041. this.indentOf = Infinity;
  15042. this.indentToken = "";
  15043. this.innerMode = null;
  15044. this.innerState = null;
  15045. this.innerModeForLine = false;
  15046. }
  15047. /**
  15048. * Safely copy a state
  15049. *
  15050. * @return {State}
  15051. */
  15052. State.prototype.copy = function() {
  15053. var res = new State();
  15054. res.javaScriptLine = this.javaScriptLine;
  15055. res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon;
  15056. res.javaScriptArguments = this.javaScriptArguments;
  15057. res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth;
  15058. res.isInterpolating = this.isInterpolating;
  15059. res.interpolationNesting = this.interpolationNesting;
  15060. res.jsState = CodeMirror$1.copyState(jsMode, this.jsState);
  15061. res.innerMode = this.innerMode;
  15062. if (this.innerMode && this.innerState) res.innerState = CodeMirror$1.copyState(this.innerMode, this.innerState);
  15063. res.restOfLine = this.restOfLine;
  15064. res.isIncludeFiltered = this.isIncludeFiltered;
  15065. res.isEach = this.isEach;
  15066. res.lastTag = this.lastTag;
  15067. res.scriptType = this.scriptType;
  15068. res.isAttrs = this.isAttrs;
  15069. res.attrsNest = this.attrsNest.slice();
  15070. res.inAttributeName = this.inAttributeName;
  15071. res.attributeIsType = this.attributeIsType;
  15072. res.attrValue = this.attrValue;
  15073. res.indentOf = this.indentOf;
  15074. res.indentToken = this.indentToken;
  15075. res.innerModeForLine = this.innerModeForLine;
  15076. return res;
  15077. };
  15078. function javaScript(stream, state) {
  15079. if (stream.sol()) {
  15080. state.javaScriptLine = false;
  15081. state.javaScriptLineExcludesColon = false;
  15082. }
  15083. if (state.javaScriptLine) {
  15084. if (state.javaScriptLineExcludesColon && stream.peek() === ":") {
  15085. state.javaScriptLine = false;
  15086. state.javaScriptLineExcludesColon = false;
  15087. return;
  15088. }
  15089. var tok = jsMode.token(stream, state.jsState);
  15090. if (stream.eol()) state.javaScriptLine = false;
  15091. return tok || true;
  15092. }
  15093. }
  15094. function javaScriptArguments(stream, state) {
  15095. if (state.javaScriptArguments) {
  15096. if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== "(") {
  15097. state.javaScriptArguments = false;
  15098. return;
  15099. }
  15100. if (stream.peek() === "(") state.javaScriptArgumentsDepth++;
  15101. else if (stream.peek() === ")") state.javaScriptArgumentsDepth--;
  15102. if (state.javaScriptArgumentsDepth === 0) {
  15103. state.javaScriptArguments = false;
  15104. return;
  15105. }
  15106. var tok = jsMode.token(stream, state.jsState);
  15107. return tok || true;
  15108. }
  15109. }
  15110. function yieldStatement(stream) {
  15111. if (stream.match(/^yield\b/)) return "keyword";
  15112. }
  15113. function doctype(stream) {
  15114. if (stream.match(/^(?:doctype) *([^\n]+)?/)) return DOCTYPE;
  15115. }
  15116. function interpolation(stream, state) {
  15117. if (stream.match("#{")) {
  15118. state.isInterpolating = true;
  15119. state.interpolationNesting = 0;
  15120. return "punctuation";
  15121. }
  15122. }
  15123. function interpolationContinued(stream, state) {
  15124. if (state.isInterpolating) {
  15125. if (stream.peek() === "}") {
  15126. state.interpolationNesting--;
  15127. if (state.interpolationNesting < 0) {
  15128. stream.next();
  15129. state.isInterpolating = false;
  15130. return "punctuation";
  15131. }
  15132. } else if (stream.peek() === "{") state.interpolationNesting++;
  15133. return jsMode.token(stream, state.jsState) || true;
  15134. }
  15135. }
  15136. function caseStatement(stream, state) {
  15137. if (stream.match(/^case\b/)) {
  15138. state.javaScriptLine = true;
  15139. return KEYWORD;
  15140. }
  15141. }
  15142. function when(stream, state) {
  15143. if (stream.match(/^when\b/)) {
  15144. state.javaScriptLine = true;
  15145. state.javaScriptLineExcludesColon = true;
  15146. return KEYWORD;
  15147. }
  15148. }
  15149. function defaultStatement(stream) {
  15150. if (stream.match(/^default\b/)) return KEYWORD;
  15151. }
  15152. function extendsStatement(stream, state) {
  15153. if (stream.match(/^extends?\b/)) {
  15154. state.restOfLine = "string";
  15155. return KEYWORD;
  15156. }
  15157. }
  15158. function append(stream, state) {
  15159. if (stream.match(/^append\b/)) {
  15160. state.restOfLine = "variable";
  15161. return KEYWORD;
  15162. }
  15163. }
  15164. function prepend(stream, state) {
  15165. if (stream.match(/^prepend\b/)) {
  15166. state.restOfLine = "variable";
  15167. return KEYWORD;
  15168. }
  15169. }
  15170. function block(stream, state) {
  15171. if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) {
  15172. state.restOfLine = "variable";
  15173. return KEYWORD;
  15174. }
  15175. }
  15176. function include(stream, state) {
  15177. if (stream.match(/^include\b/)) {
  15178. state.restOfLine = "string";
  15179. return KEYWORD;
  15180. }
  15181. }
  15182. function includeFiltered(stream, state) {
  15183. if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match("include")) {
  15184. state.isIncludeFiltered = true;
  15185. return KEYWORD;
  15186. }
  15187. }
  15188. function includeFilteredContinued(stream, state) {
  15189. if (state.isIncludeFiltered) {
  15190. var tok = filter(stream, state);
  15191. state.isIncludeFiltered = false;
  15192. state.restOfLine = "string";
  15193. return tok;
  15194. }
  15195. }
  15196. function mixin(stream, state) {
  15197. if (stream.match(/^mixin\b/)) {
  15198. state.javaScriptLine = true;
  15199. return KEYWORD;
  15200. }
  15201. }
  15202. function call(stream, state) {
  15203. if (stream.match(/^\+([-\w]+)/)) {
  15204. if (!stream.match(/^\( *[-\w]+ *=/, false)) {
  15205. state.javaScriptArguments = true;
  15206. state.javaScriptArgumentsDepth = 0;
  15207. }
  15208. return "variable";
  15209. }
  15210. if (stream.match("+#{", false)) {
  15211. stream.next();
  15212. state.mixinCallAfter = true;
  15213. return interpolation(stream, state);
  15214. }
  15215. }
  15216. function callArguments(stream, state) {
  15217. if (state.mixinCallAfter) {
  15218. state.mixinCallAfter = false;
  15219. if (!stream.match(/^\( *[-\w]+ *=/, false)) {
  15220. state.javaScriptArguments = true;
  15221. state.javaScriptArgumentsDepth = 0;
  15222. }
  15223. return true;
  15224. }
  15225. }
  15226. function conditional(stream, state) {
  15227. if (stream.match(/^(if|unless|else if|else)\b/)) {
  15228. state.javaScriptLine = true;
  15229. return KEYWORD;
  15230. }
  15231. }
  15232. function each(stream, state) {
  15233. if (stream.match(/^(- *)?(each|for)\b/)) {
  15234. state.isEach = true;
  15235. return KEYWORD;
  15236. }
  15237. }
  15238. function eachContinued(stream, state) {
  15239. if (state.isEach) {
  15240. if (stream.match(/^ in\b/)) {
  15241. state.javaScriptLine = true;
  15242. state.isEach = false;
  15243. return KEYWORD;
  15244. } else if (stream.sol() || stream.eol()) state.isEach = false;
  15245. else if (stream.next()) {
  15246. while (!stream.match(/^ in\b/, false) && stream.next());
  15247. return "variable";
  15248. }
  15249. }
  15250. }
  15251. function whileStatement(stream, state) {
  15252. if (stream.match(/^while\b/)) {
  15253. state.javaScriptLine = true;
  15254. return KEYWORD;
  15255. }
  15256. }
  15257. function tag(stream, state) {
  15258. var captures;
  15259. if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) {
  15260. state.lastTag = captures[1].toLowerCase();
  15261. if (state.lastTag === "script") state.scriptType = "application/javascript";
  15262. return "tag";
  15263. }
  15264. }
  15265. function filter(stream, state) {
  15266. if (stream.match(/^:([\w\-]+)/)) {
  15267. var innerMode$1;
  15268. if (config && config.innerModes) innerMode$1 = config.innerModes(stream.current().substring(1));
  15269. if (!innerMode$1) innerMode$1 = stream.current().substring(1);
  15270. if (typeof innerMode$1 === "string") innerMode$1 = CodeMirror$1.getMode(config, innerMode$1);
  15271. setInnerMode(stream, state, innerMode$1);
  15272. return "atom";
  15273. }
  15274. }
  15275. function code(stream, state) {
  15276. if (stream.match(/^(!?=|-)/)) {
  15277. state.javaScriptLine = true;
  15278. return "punctuation";
  15279. }
  15280. }
  15281. function id(stream) {
  15282. if (stream.match(/^#([\w-]+)/)) return ID;
  15283. }
  15284. function className(stream) {
  15285. if (stream.match(/^\.([\w-]+)/)) return CLASS;
  15286. }
  15287. function attrs(stream, state) {
  15288. if (stream.peek() == "(") {
  15289. stream.next();
  15290. state.isAttrs = true;
  15291. state.attrsNest = [];
  15292. state.inAttributeName = true;
  15293. state.attrValue = "";
  15294. state.attributeIsType = false;
  15295. return "punctuation";
  15296. }
  15297. }
  15298. function attrsContinued(stream, state) {
  15299. if (state.isAttrs) {
  15300. if (ATTRS_NEST[stream.peek()]) state.attrsNest.push(ATTRS_NEST[stream.peek()]);
  15301. if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) state.attrsNest.pop();
  15302. else if (stream.eat(")")) {
  15303. state.isAttrs = false;
  15304. return "punctuation";
  15305. }
  15306. if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
  15307. if (stream.peek() === "=" || stream.peek() === "!") {
  15308. state.inAttributeName = false;
  15309. state.jsState = CodeMirror$1.startState(jsMode);
  15310. if (state.lastTag === "script" && stream.current().trim().toLowerCase() === "type") state.attributeIsType = true;
  15311. else state.attributeIsType = false;
  15312. }
  15313. return "attribute";
  15314. }
  15315. var tok = jsMode.token(stream, state.jsState);
  15316. if (state.attributeIsType && tok === "string") state.scriptType = stream.current().toString();
  15317. if (state.attrsNest.length === 0 && (tok === "string" || tok === "variable" || tok === "keyword")) try {
  15318. Function("", "var x " + state.attrValue.replace(/,\s*$/, "").replace(/^!/, ""));
  15319. state.inAttributeName = true;
  15320. state.attrValue = "";
  15321. stream.backUp(stream.current().length);
  15322. return attrsContinued(stream, state);
  15323. } catch (ex) {}
  15324. state.attrValue += stream.current();
  15325. return tok || true;
  15326. }
  15327. }
  15328. function attributesBlock(stream, state) {
  15329. if (stream.match(/^&attributes\b/)) {
  15330. state.javaScriptArguments = true;
  15331. state.javaScriptArgumentsDepth = 0;
  15332. return "keyword";
  15333. }
  15334. }
  15335. function indent(stream) {
  15336. if (stream.sol() && stream.eatSpace()) return "indent";
  15337. }
  15338. function comment(stream, state) {
  15339. if (stream.match(/^ *\/\/(-)?([^\n]*)/)) {
  15340. state.indentOf = stream.indentation();
  15341. state.indentToken = "comment";
  15342. return "comment";
  15343. }
  15344. }
  15345. function colon(stream) {
  15346. if (stream.match(/^: */)) return "colon";
  15347. }
  15348. function text(stream, state) {
  15349. if (stream.match(/^(?:\| ?| )([^\n]+)/)) return "string";
  15350. if (stream.match(/^(<[^\n]*)/, false)) {
  15351. setInnerMode(stream, state, "htmlmixed");
  15352. state.innerModeForLine = true;
  15353. return innerMode(stream, state, true);
  15354. }
  15355. }
  15356. function dot(stream, state) {
  15357. if (stream.eat(".")) {
  15358. var innerMode$1 = null;
  15359. if (state.lastTag === "script" && state.scriptType.toLowerCase().indexOf("javascript") != -1) innerMode$1 = state.scriptType.toLowerCase().replace(/"|'/g, "");
  15360. else if (state.lastTag === "style") innerMode$1 = "css";
  15361. setInnerMode(stream, state, innerMode$1);
  15362. return "dot";
  15363. }
  15364. }
  15365. function fail(stream) {
  15366. stream.next();
  15367. return null;
  15368. }
  15369. function setInnerMode(stream, state, mode) {
  15370. mode = CodeMirror$1.mimeModes[mode] || mode;
  15371. mode = config.innerModes ? config.innerModes(mode) || mode : mode;
  15372. mode = CodeMirror$1.mimeModes[mode] || mode;
  15373. mode = CodeMirror$1.getMode(config, mode);
  15374. state.indentOf = stream.indentation();
  15375. if (mode && mode.name !== "null") state.innerMode = mode;
  15376. else state.indentToken = "string";
  15377. }
  15378. function innerMode(stream, state, force) {
  15379. if (stream.indentation() > state.indentOf || state.innerModeForLine && !stream.sol() || force) if (state.innerMode) {
  15380. if (!state.innerState) state.innerState = state.innerMode.startState ? CodeMirror$1.startState(state.innerMode, stream.indentation()) : {};
  15381. return stream.hideFirstChars(state.indentOf + 2, function() {
  15382. return state.innerMode.token(stream, state.innerState) || true;
  15383. });
  15384. } else {
  15385. stream.skipToEnd();
  15386. return state.indentToken;
  15387. }
  15388. else if (stream.sol()) {
  15389. state.indentOf = Infinity;
  15390. state.indentToken = null;
  15391. state.innerMode = null;
  15392. state.innerState = null;
  15393. }
  15394. }
  15395. function restOfLine(stream, state) {
  15396. if (stream.sol()) state.restOfLine = "";
  15397. if (state.restOfLine) {
  15398. stream.skipToEnd();
  15399. var tok = state.restOfLine;
  15400. state.restOfLine = "";
  15401. return tok;
  15402. }
  15403. }
  15404. function startState() {
  15405. return new State();
  15406. }
  15407. function copyState(state) {
  15408. return state.copy();
  15409. }
  15410. /**
  15411. * Get the next token in the stream
  15412. *
  15413. * @param {Stream} stream
  15414. * @param {State} state
  15415. */
  15416. function nextToken(stream, state) {
  15417. var tok = innerMode(stream, state) || restOfLine(stream, state) || interpolationContinued(stream, state) || includeFilteredContinued(stream, state) || eachContinued(stream, state) || attrsContinued(stream, state) || javaScript(stream, state) || javaScriptArguments(stream, state) || callArguments(stream, state) || yieldStatement(stream) || doctype(stream) || interpolation(stream, state) || caseStatement(stream, state) || when(stream, state) || defaultStatement(stream) || extendsStatement(stream, state) || append(stream, state) || prepend(stream, state) || block(stream, state) || include(stream, state) || includeFiltered(stream, state) || mixin(stream, state) || call(stream, state) || conditional(stream, state) || each(stream, state) || whileStatement(stream, state) || tag(stream, state) || filter(stream, state) || code(stream, state) || id(stream) || className(stream) || attrs(stream, state) || attributesBlock(stream, state) || indent(stream) || text(stream, state) || comment(stream, state) || colon(stream) || dot(stream, state) || fail(stream);
  15418. return tok === true ? null : tok;
  15419. }
  15420. return {
  15421. startState,
  15422. copyState,
  15423. token: nextToken
  15424. };
  15425. }, "javascript", "css", "htmlmixed");
  15426. CodeMirror$1.defineMIME("text/x-pug", "pug");
  15427. CodeMirror$1.defineMIME("text/x-jade", "pug");
  15428. });
  15429. });
  15430. var require_sass = __commonJSMin((exports, module) => {
  15431. (function(mod) {
  15432. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror(), require_css());
  15433. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror", "../css/css"], mod);
  15434. else mod(CodeMirror);
  15435. })(function(CodeMirror$1) {
  15436. "use strict";
  15437. CodeMirror$1.defineMode("sass", function(config) {
  15438. var cssMode = CodeMirror$1.mimeModes["text/css"];
  15439. var propertyKeywords = cssMode.propertyKeywords || {}, colorKeywords = cssMode.colorKeywords || {}, valueKeywords = cssMode.valueKeywords || {}, fontProperties = cssMode.fontProperties || {};
  15440. function tokenRegexp(words) {
  15441. return new RegExp("^" + words.join("|"));
  15442. }
  15443. var keywords = [
  15444. "true",
  15445. "false",
  15446. "null",
  15447. "auto"
  15448. ];
  15449. var keywordsRegexp = new RegExp("^" + keywords.join("|"));
  15450. var operators = [
  15451. "\\(",
  15452. "\\)",
  15453. "=",
  15454. ">",
  15455. "<",
  15456. "==",
  15457. ">=",
  15458. "<=",
  15459. "\\+",
  15460. "-",
  15461. "\\!=",
  15462. "/",
  15463. "\\*",
  15464. "%",
  15465. "and",
  15466. "or",
  15467. "not",
  15468. ";",
  15469. "\\{",
  15470. "\\}",
  15471. ":"
  15472. ];
  15473. var opRegexp = tokenRegexp(operators);
  15474. var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
  15475. var word;
  15476. function isEndLine(stream) {
  15477. return !stream.peek() || stream.match(/\s+$/, false);
  15478. }
  15479. function urlTokens(stream, state) {
  15480. var ch = stream.peek();
  15481. if (ch === ")") {
  15482. stream.next();
  15483. state.tokenizer = tokenBase;
  15484. return "operator";
  15485. } else if (ch === "(") {
  15486. stream.next();
  15487. stream.eatSpace();
  15488. return "operator";
  15489. } else if (ch === "'" || ch === "\"") {
  15490. state.tokenizer = buildStringTokenizer(stream.next());
  15491. return "string";
  15492. } else {
  15493. state.tokenizer = buildStringTokenizer(")", false);
  15494. return "string";
  15495. }
  15496. }
  15497. function comment(indentation, multiLine) {
  15498. return function(stream, state) {
  15499. if (stream.sol() && stream.indentation() <= indentation) {
  15500. state.tokenizer = tokenBase;
  15501. return tokenBase(stream, state);
  15502. }
  15503. if (multiLine && stream.skipTo("*/")) {
  15504. stream.next();
  15505. stream.next();
  15506. state.tokenizer = tokenBase;
  15507. } else stream.skipToEnd();
  15508. return "comment";
  15509. };
  15510. }
  15511. function buildStringTokenizer(quote, greedy) {
  15512. if (greedy == null) greedy = true;
  15513. function stringTokenizer(stream, state) {
  15514. var nextChar = stream.next();
  15515. var peekChar = stream.peek();
  15516. var previousChar = stream.string.charAt(stream.pos - 2);
  15517. var endingString = nextChar !== "\\" && peekChar === quote || nextChar === quote && previousChar !== "\\";
  15518. if (endingString) {
  15519. if (nextChar !== quote && greedy) stream.next();
  15520. if (isEndLine(stream)) state.cursorHalf = 0;
  15521. state.tokenizer = tokenBase;
  15522. return "string";
  15523. } else if (nextChar === "#" && peekChar === "{") {
  15524. state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
  15525. stream.next();
  15526. return "operator";
  15527. } else return "string";
  15528. }
  15529. return stringTokenizer;
  15530. }
  15531. function buildInterpolationTokenizer(currentTokenizer) {
  15532. return function(stream, state) {
  15533. if (stream.peek() === "}") {
  15534. stream.next();
  15535. state.tokenizer = currentTokenizer;
  15536. return "operator";
  15537. } else return tokenBase(stream, state);
  15538. };
  15539. }
  15540. function indent(state) {
  15541. if (state.indentCount == 0) {
  15542. state.indentCount++;
  15543. var lastScopeOffset = state.scopes[0].offset;
  15544. var currentOffset = lastScopeOffset + config.indentUnit;
  15545. state.scopes.unshift({ offset: currentOffset });
  15546. }
  15547. }
  15548. function dedent(state) {
  15549. if (state.scopes.length == 1) return;
  15550. state.scopes.shift();
  15551. }
  15552. function tokenBase(stream, state) {
  15553. var ch = stream.peek();
  15554. if (stream.match("/*")) {
  15555. state.tokenizer = comment(stream.indentation(), true);
  15556. return state.tokenizer(stream, state);
  15557. }
  15558. if (stream.match("//")) {
  15559. state.tokenizer = comment(stream.indentation(), false);
  15560. return state.tokenizer(stream, state);
  15561. }
  15562. if (stream.match("#{")) {
  15563. state.tokenizer = buildInterpolationTokenizer(tokenBase);
  15564. return "operator";
  15565. }
  15566. if (ch === "\"" || ch === "'") {
  15567. stream.next();
  15568. state.tokenizer = buildStringTokenizer(ch);
  15569. return "string";
  15570. }
  15571. if (!state.cursorHalf) {
  15572. if (ch === "-") {
  15573. if (stream.match(/^-\w+-/)) return "meta";
  15574. }
  15575. if (ch === ".") {
  15576. stream.next();
  15577. if (stream.match(/^[\w-]+/)) {
  15578. indent(state);
  15579. return "qualifier";
  15580. } else if (stream.peek() === "#") {
  15581. indent(state);
  15582. return "tag";
  15583. }
  15584. }
  15585. if (ch === "#") {
  15586. stream.next();
  15587. if (stream.match(/^[\w-]+/)) {
  15588. indent(state);
  15589. return "builtin";
  15590. }
  15591. if (stream.peek() === "#") {
  15592. indent(state);
  15593. return "tag";
  15594. }
  15595. }
  15596. if (ch === "$") {
  15597. stream.next();
  15598. stream.eatWhile(/[\w-]/);
  15599. return "variable-2";
  15600. }
  15601. if (stream.match(/^-?[0-9\.]+/)) return "number";
  15602. if (stream.match(/^(px|em|in)\b/)) return "unit";
  15603. if (stream.match(keywordsRegexp)) return "keyword";
  15604. if (stream.match(/^url/) && stream.peek() === "(") {
  15605. state.tokenizer = urlTokens;
  15606. return "atom";
  15607. }
  15608. if (ch === "=") {
  15609. if (stream.match(/^=[\w-]+/)) {
  15610. indent(state);
  15611. return "meta";
  15612. }
  15613. }
  15614. if (ch === "+") {
  15615. if (stream.match(/^\+[\w-]+/)) return "variable-3";
  15616. }
  15617. if (ch === "@") {
  15618. if (stream.match("@extend")) {
  15619. if (!stream.match(/\s*[\w]/)) dedent(state);
  15620. }
  15621. }
  15622. if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
  15623. indent(state);
  15624. return "def";
  15625. }
  15626. if (ch === "@") {
  15627. stream.next();
  15628. stream.eatWhile(/[\w-]/);
  15629. return "def";
  15630. }
  15631. if (stream.eatWhile(/[\w-]/)) if (stream.match(/ *: *[\w-\+\$#!\("']/, false)) {
  15632. word = stream.current().toLowerCase();
  15633. var prop = state.prevProp + "-" + word;
  15634. if (propertyKeywords.hasOwnProperty(prop)) return "property";
  15635. else if (propertyKeywords.hasOwnProperty(word)) {
  15636. state.prevProp = word;
  15637. return "property";
  15638. } else if (fontProperties.hasOwnProperty(word)) return "property";
  15639. return "tag";
  15640. } else if (stream.match(/ *:/, false)) {
  15641. indent(state);
  15642. state.cursorHalf = 1;
  15643. state.prevProp = stream.current().toLowerCase();
  15644. return "property";
  15645. } else if (stream.match(/ *,/, false)) return "tag";
  15646. else {
  15647. indent(state);
  15648. return "tag";
  15649. }
  15650. if (ch === ":") {
  15651. if (stream.match(pseudoElementsRegexp)) return "variable-3";
  15652. stream.next();
  15653. state.cursorHalf = 1;
  15654. return "operator";
  15655. }
  15656. } else {
  15657. if (ch === "#") {
  15658. stream.next();
  15659. if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)) {
  15660. if (isEndLine(stream)) state.cursorHalf = 0;
  15661. return "number";
  15662. }
  15663. }
  15664. if (stream.match(/^-?[0-9\.]+/)) {
  15665. if (isEndLine(stream)) state.cursorHalf = 0;
  15666. return "number";
  15667. }
  15668. if (stream.match(/^(px|em|in)\b/)) {
  15669. if (isEndLine(stream)) state.cursorHalf = 0;
  15670. return "unit";
  15671. }
  15672. if (stream.match(keywordsRegexp)) {
  15673. if (isEndLine(stream)) state.cursorHalf = 0;
  15674. return "keyword";
  15675. }
  15676. if (stream.match(/^url/) && stream.peek() === "(") {
  15677. state.tokenizer = urlTokens;
  15678. if (isEndLine(stream)) state.cursorHalf = 0;
  15679. return "atom";
  15680. }
  15681. if (ch === "$") {
  15682. stream.next();
  15683. stream.eatWhile(/[\w-]/);
  15684. if (isEndLine(stream)) state.cursorHalf = 0;
  15685. return "variable-2";
  15686. }
  15687. if (ch === "!") {
  15688. stream.next();
  15689. state.cursorHalf = 0;
  15690. return stream.match(/^[\w]+/) ? "keyword" : "operator";
  15691. }
  15692. if (stream.match(opRegexp)) {
  15693. if (isEndLine(stream)) state.cursorHalf = 0;
  15694. return "operator";
  15695. }
  15696. if (stream.eatWhile(/[\w-]/)) {
  15697. if (isEndLine(stream)) state.cursorHalf = 0;
  15698. word = stream.current().toLowerCase();
  15699. if (valueKeywords.hasOwnProperty(word)) return "atom";
  15700. else if (colorKeywords.hasOwnProperty(word)) return "keyword";
  15701. else if (propertyKeywords.hasOwnProperty(word)) {
  15702. state.prevProp = stream.current().toLowerCase();
  15703. return "property";
  15704. } else return "tag";
  15705. }
  15706. if (isEndLine(stream)) {
  15707. state.cursorHalf = 0;
  15708. return null;
  15709. }
  15710. }
  15711. if (stream.match(opRegexp)) return "operator";
  15712. stream.next();
  15713. return null;
  15714. }
  15715. function tokenLexer(stream, state) {
  15716. if (stream.sol()) state.indentCount = 0;
  15717. var style = state.tokenizer(stream, state);
  15718. var current = stream.current();
  15719. if (current === "@return" || current === "}") dedent(state);
  15720. if (style !== null) {
  15721. var startOfToken = stream.pos - current.length;
  15722. var withCurrentIndent = startOfToken + config.indentUnit * state.indentCount;
  15723. var newScopes = [];
  15724. for (var i = 0; i < state.scopes.length; i++) {
  15725. var scope = state.scopes[i];
  15726. if (scope.offset <= withCurrentIndent) newScopes.push(scope);
  15727. }
  15728. state.scopes = newScopes;
  15729. }
  15730. return style;
  15731. }
  15732. return {
  15733. startState: function() {
  15734. return {
  15735. tokenizer: tokenBase,
  15736. scopes: [{
  15737. offset: 0,
  15738. type: "sass"
  15739. }],
  15740. indentCount: 0,
  15741. cursorHalf: 0,
  15742. definedVars: [],
  15743. definedMixins: []
  15744. };
  15745. },
  15746. token: function(stream, state) {
  15747. var style = tokenLexer(stream, state);
  15748. state.lastToken = {
  15749. style,
  15750. content: stream.current()
  15751. };
  15752. return style;
  15753. },
  15754. indent: function(state) {
  15755. return state.scopes[0].offset;
  15756. },
  15757. blockCommentStart: "/*",
  15758. blockCommentEnd: "*/",
  15759. lineComment: "//",
  15760. fold: "indent"
  15761. };
  15762. }, "css");
  15763. CodeMirror$1.defineMIME("text/x-sass", "sass");
  15764. });
  15765. });
  15766. var require_overlay = __commonJSMin((exports, module) => {
  15767. (function(mod) {
  15768. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  15769. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  15770. else mod(CodeMirror);
  15771. })(function(CodeMirror$1) {
  15772. "use strict";
  15773. CodeMirror$1.overlayMode = function(base, overlay, combine) {
  15774. return {
  15775. startState: function() {
  15776. return {
  15777. base: CodeMirror$1.startState(base),
  15778. overlay: CodeMirror$1.startState(overlay),
  15779. basePos: 0,
  15780. baseCur: null,
  15781. overlayPos: 0,
  15782. overlayCur: null,
  15783. streamSeen: null
  15784. };
  15785. },
  15786. copyState: function(state) {
  15787. return {
  15788. base: CodeMirror$1.copyState(base, state.base),
  15789. overlay: CodeMirror$1.copyState(overlay, state.overlay),
  15790. basePos: state.basePos,
  15791. baseCur: null,
  15792. overlayPos: state.overlayPos,
  15793. overlayCur: null
  15794. };
  15795. },
  15796. token: function(stream, state) {
  15797. if (stream != state.streamSeen || Math.min(state.basePos, state.overlayPos) < stream.start) {
  15798. state.streamSeen = stream;
  15799. state.basePos = state.overlayPos = stream.start;
  15800. }
  15801. if (stream.start == state.basePos) {
  15802. state.baseCur = base.token(stream, state.base);
  15803. state.basePos = stream.pos;
  15804. }
  15805. if (stream.start == state.overlayPos) {
  15806. stream.pos = stream.start;
  15807. state.overlayCur = overlay.token(stream, state.overlay);
  15808. state.overlayPos = stream.pos;
  15809. }
  15810. stream.pos = Math.min(state.basePos, state.overlayPos);
  15811. if (state.overlayCur == null) return state.baseCur;
  15812. else if (state.baseCur != null && state.overlay.combineTokens || combine && state.overlay.combineTokens == null) return state.baseCur + " " + state.overlayCur;
  15813. else return state.overlayCur;
  15814. },
  15815. indent: base.indent && function(state, textAfter, line) {
  15816. return base.indent(state.base, textAfter, line);
  15817. },
  15818. electricChars: base.electricChars,
  15819. innerMode: function(state) {
  15820. return {
  15821. state: state.base,
  15822. mode: base
  15823. };
  15824. },
  15825. blankLine: function(state) {
  15826. var baseToken, overlayToken;
  15827. if (base.blankLine) baseToken = base.blankLine(state.base);
  15828. if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);
  15829. return overlayToken == null ? baseToken : combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken;
  15830. }
  15831. };
  15832. };
  15833. });
  15834. });
  15835. var require_coffeescript = __commonJSMin((exports, module) => {
  15836. /**
  15837. * Link to the project's GitHub page:
  15838. * https://github.com/pickhardt/coffeescript-codemirror-mode
  15839. */
  15840. (function(mod) {
  15841. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  15842. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  15843. else mod(CodeMirror);
  15844. })(function(CodeMirror$1) {
  15845. "use strict";
  15846. CodeMirror$1.defineMode("coffeescript", function(conf, parserConf) {
  15847. var ERRORCLASS = "error";
  15848. function wordRegexp(words) {
  15849. return new RegExp("^((" + words.join(")|(") + "))\\b");
  15850. }
  15851. var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
  15852. var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
  15853. var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
  15854. var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
  15855. var wordOperators = wordRegexp([
  15856. "and",
  15857. "or",
  15858. "not",
  15859. "is",
  15860. "isnt",
  15861. "in",
  15862. "instanceof",
  15863. "typeof"
  15864. ]);
  15865. var indentKeywords = [
  15866. "for",
  15867. "while",
  15868. "loop",
  15869. "if",
  15870. "unless",
  15871. "else",
  15872. "switch",
  15873. "try",
  15874. "catch",
  15875. "finally",
  15876. "class"
  15877. ];
  15878. var commonKeywords = [
  15879. "break",
  15880. "by",
  15881. "continue",
  15882. "debugger",
  15883. "delete",
  15884. "do",
  15885. "in",
  15886. "of",
  15887. "new",
  15888. "return",
  15889. "then",
  15890. "this",
  15891. "@",
  15892. "throw",
  15893. "when",
  15894. "until",
  15895. "extends"
  15896. ];
  15897. var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
  15898. indentKeywords = wordRegexp(indentKeywords);
  15899. var stringPrefixes = /^('{3}|\"{3}|['\"])/;
  15900. var regexPrefixes = /^(\/{3}|\/)/;
  15901. var commonConstants = [
  15902. "Infinity",
  15903. "NaN",
  15904. "undefined",
  15905. "null",
  15906. "true",
  15907. "false",
  15908. "on",
  15909. "off",
  15910. "yes",
  15911. "no"
  15912. ];
  15913. var constants = wordRegexp(commonConstants);
  15914. function tokenBase(stream, state) {
  15915. if (stream.sol()) {
  15916. if (state.scope.align === null) state.scope.align = false;
  15917. var scopeOffset = state.scope.offset;
  15918. if (stream.eatSpace()) {
  15919. var lineOffset = stream.indentation();
  15920. if (lineOffset > scopeOffset && state.scope.type == "coffee") return "indent";
  15921. else if (lineOffset < scopeOffset) return "dedent";
  15922. return null;
  15923. } else if (scopeOffset > 0) dedent(stream, state);
  15924. }
  15925. if (stream.eatSpace()) return null;
  15926. var ch = stream.peek();
  15927. if (stream.match("####")) {
  15928. stream.skipToEnd();
  15929. return "comment";
  15930. }
  15931. if (stream.match("###")) {
  15932. state.tokenize = longComment;
  15933. return state.tokenize(stream, state);
  15934. }
  15935. if (ch === "#") {
  15936. stream.skipToEnd();
  15937. return "comment";
  15938. }
  15939. if (stream.match(/^-?[0-9\.]/, false)) {
  15940. var floatLiteral = false;
  15941. if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) floatLiteral = true;
  15942. if (stream.match(/^-?\d+\.\d*/)) floatLiteral = true;
  15943. if (stream.match(/^-?\.\d+/)) floatLiteral = true;
  15944. if (floatLiteral) {
  15945. if (stream.peek() == ".") stream.backUp(1);
  15946. return "number";
  15947. }
  15948. var intLiteral = false;
  15949. if (stream.match(/^-?0x[0-9a-f]+/i)) intLiteral = true;
  15950. if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) intLiteral = true;
  15951. if (stream.match(/^-?0(?![\dx])/i)) intLiteral = true;
  15952. if (intLiteral) return "number";
  15953. }
  15954. if (stream.match(stringPrefixes)) {
  15955. state.tokenize = tokenFactory(stream.current(), false, "string");
  15956. return state.tokenize(stream, state);
  15957. }
  15958. if (stream.match(regexPrefixes)) if (stream.current() != "/" || stream.match(/^.*\//, false)) {
  15959. state.tokenize = tokenFactory(stream.current(), true, "string-2");
  15960. return state.tokenize(stream, state);
  15961. } else stream.backUp(1);
  15962. if (stream.match(operators) || stream.match(wordOperators)) return "operator";
  15963. if (stream.match(delimiters)) return "punctuation";
  15964. if (stream.match(constants)) return "atom";
  15965. if (stream.match(atProp) || state.prop && stream.match(identifiers)) return "property";
  15966. if (stream.match(keywords)) return "keyword";
  15967. if (stream.match(identifiers)) return "variable";
  15968. stream.next();
  15969. return ERRORCLASS;
  15970. }
  15971. function tokenFactory(delimiter, singleline, outclass) {
  15972. return function(stream, state) {
  15973. while (!stream.eol()) {
  15974. stream.eatWhile(/[^'"\/\\]/);
  15975. if (stream.eat("\\")) {
  15976. stream.next();
  15977. if (singleline && stream.eol()) return outclass;
  15978. } else if (stream.match(delimiter)) {
  15979. state.tokenize = tokenBase;
  15980. return outclass;
  15981. } else stream.eat(/['"\/]/);
  15982. }
  15983. if (singleline) if (parserConf.singleLineStringErrors) outclass = ERRORCLASS;
  15984. else state.tokenize = tokenBase;
  15985. return outclass;
  15986. };
  15987. }
  15988. function longComment(stream, state) {
  15989. while (!stream.eol()) {
  15990. stream.eatWhile(/[^#]/);
  15991. if (stream.match("###")) {
  15992. state.tokenize = tokenBase;
  15993. break;
  15994. }
  15995. stream.eatWhile("#");
  15996. }
  15997. return "comment";
  15998. }
  15999. function indent(stream, state, type) {
  16000. type = type || "coffee";
  16001. var offset = 0, align = false, alignOffset = null;
  16002. for (var scope = state.scope; scope; scope = scope.prev) if (scope.type === "coffee" || scope.type == "}") {
  16003. offset = scope.offset + conf.indentUnit;
  16004. break;
  16005. }
  16006. if (type !== "coffee") {
  16007. align = null;
  16008. alignOffset = stream.column() + stream.current().length;
  16009. } else if (state.scope.align) state.scope.align = false;
  16010. state.scope = {
  16011. offset,
  16012. type,
  16013. prev: state.scope,
  16014. align,
  16015. alignOffset
  16016. };
  16017. }
  16018. function dedent(stream, state) {
  16019. if (!state.scope.prev) return;
  16020. if (state.scope.type === "coffee") {
  16021. var _indent = stream.indentation();
  16022. var matched = false;
  16023. for (var scope = state.scope; scope; scope = scope.prev) if (_indent === scope.offset) {
  16024. matched = true;
  16025. break;
  16026. }
  16027. if (!matched) return true;
  16028. while (state.scope.prev && state.scope.offset !== _indent) state.scope = state.scope.prev;
  16029. return false;
  16030. } else {
  16031. state.scope = state.scope.prev;
  16032. return false;
  16033. }
  16034. }
  16035. function tokenLexer(stream, state) {
  16036. var style = state.tokenize(stream, state);
  16037. var current = stream.current();
  16038. if (current === "return") state.dedent = true;
  16039. if ((current === "->" || current === "=>") && stream.eol() || style === "indent") indent(stream, state);
  16040. var delimiter_index = "[({".indexOf(current);
  16041. if (delimiter_index !== -1) indent(stream, state, "])}".slice(delimiter_index, delimiter_index + 1));
  16042. if (indentKeywords.exec(current)) indent(stream, state);
  16043. if (current == "then") dedent(stream, state);
  16044. if (style === "dedent") {
  16045. if (dedent(stream, state)) return ERRORCLASS;
  16046. }
  16047. delimiter_index = "])}".indexOf(current);
  16048. if (delimiter_index !== -1) {
  16049. while (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev;
  16050. if (state.scope.type == current) state.scope = state.scope.prev;
  16051. }
  16052. if (state.dedent && stream.eol()) {
  16053. if (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev;
  16054. state.dedent = false;
  16055. }
  16056. return style;
  16057. }
  16058. var external = {
  16059. startState: function(basecolumn) {
  16060. return {
  16061. tokenize: tokenBase,
  16062. scope: {
  16063. offset: basecolumn || 0,
  16064. type: "coffee",
  16065. prev: null,
  16066. align: false
  16067. },
  16068. prop: false,
  16069. dedent: 0
  16070. };
  16071. },
  16072. token: function(stream, state) {
  16073. var fillAlign = state.scope.align === null && state.scope;
  16074. if (fillAlign && stream.sol()) fillAlign.align = false;
  16075. var style = tokenLexer(stream, state);
  16076. if (style && style != "comment") {
  16077. if (fillAlign) fillAlign.align = true;
  16078. state.prop = style == "punctuation" && stream.current() == ".";
  16079. }
  16080. return style;
  16081. },
  16082. indent: function(state, text) {
  16083. if (state.tokenize != tokenBase) return 0;
  16084. var scope = state.scope;
  16085. var closer = text && "])}".indexOf(text.charAt(0)) > -1;
  16086. if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev;
  16087. var closes = closer && scope.type === text.charAt(0);
  16088. if (scope.align) return scope.alignOffset - (closes ? 1 : 0);
  16089. else return (closes ? scope.prev : scope).offset;
  16090. },
  16091. lineComment: "#",
  16092. fold: "indent"
  16093. };
  16094. return external;
  16095. });
  16096. CodeMirror$1.defineMIME("application/vnd.coffeescript", "coffeescript");
  16097. CodeMirror$1.defineMIME("text/x-coffeescript", "coffeescript");
  16098. CodeMirror$1.defineMIME("text/coffeescript", "coffeescript");
  16099. });
  16100. });
  16101. var require_stylus = __commonJSMin((exports, module) => {
  16102. (function(mod) {
  16103. if (typeof exports == "object" && typeof module == "object") mod(require_codemirror());
  16104. else if (typeof define == "function" && define.amd) define(["../../lib/codemirror"], mod);
  16105. else mod(CodeMirror);
  16106. })(function(CodeMirror$1) {
  16107. "use strict";
  16108. CodeMirror$1.defineMode("stylus", function(config) {
  16109. var indentUnit = config.indentUnit, indentUnitString = "", tagKeywords = keySet(tagKeywords_), tagVariablesRegexp = /^(a|b|i|s|col|em)$/i, propertyKeywords = keySet(propertyKeywords_), nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_), valueKeywords = keySet(valueKeywords_), colorKeywords = keySet(colorKeywords_), documentTypes = keySet(documentTypes_), documentTypesRegexp = wordRegexp(documentTypes_), mediaFeatures = keySet(mediaFeatures_), mediaTypes = keySet(mediaTypes_), fontProperties = keySet(fontProperties_), operatorsRegexp = /^\s*([.]{2,3}|&&|\|\||\*\*|[?!=:]?=|[-+*\/%<>]=?|\?:|\~)/, wordOperatorKeywordsRegexp = wordRegexp(wordOperatorKeywords_), blockKeywords = keySet(blockKeywords_), vendorPrefixesRegexp = new RegExp(/^\-(moz|ms|o|webkit)-/i), commonAtoms = keySet(commonAtoms_), firstWordMatch = "", states = {}, ch, style, type, override;
  16110. while (indentUnitString.length < indentUnit) indentUnitString += " ";
  16111. /**
  16112. * Tokenizers
  16113. */
  16114. function tokenBase(stream, state) {
  16115. firstWordMatch = stream.string.match(/(^[\w-]+\s*=\s*$)|(^\s*[\w-]+\s*=\s*[\w-])|(^\s*(\.|#|@|\$|\&|\[|\d|\+|::?|\{|\>|~|\/)?\s*[\w-]*([a-z0-9-]|\*|\/\*)(\(|,)?)/);
  16116. state.context.line.firstWord = firstWordMatch ? firstWordMatch[0].replace(/^\s*/, "") : "";
  16117. state.context.line.indent = stream.indentation();
  16118. ch = stream.peek();
  16119. if (stream.match("//")) {
  16120. stream.skipToEnd();
  16121. return ["comment", "comment"];
  16122. }
  16123. if (stream.match("/*")) {
  16124. state.tokenize = tokenCComment;
  16125. return tokenCComment(stream, state);
  16126. }
  16127. if (ch == "\"" || ch == "'") {
  16128. stream.next();
  16129. state.tokenize = tokenString(ch);
  16130. return state.tokenize(stream, state);
  16131. }
  16132. if (ch == "@") {
  16133. stream.next();
  16134. stream.eatWhile(/[\w\\-]/);
  16135. return ["def", stream.current()];
  16136. }
  16137. if (ch == "#") {
  16138. stream.next();
  16139. if (stream.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b(?!-)/i)) return ["atom", "atom"];
  16140. if (stream.match(/^[a-z][\w-]*/i)) return ["builtin", "hash"];
  16141. }
  16142. if (stream.match(vendorPrefixesRegexp)) return ["meta", "vendor-prefixes"];
  16143. if (stream.match(/^-?[0-9]?\.?[0-9]/)) {
  16144. stream.eatWhile(/[a-z%]/i);
  16145. return ["number", "unit"];
  16146. }
  16147. if (ch == "!") {
  16148. stream.next();
  16149. return [stream.match(/^(important|optional)/i) ? "keyword" : "operator", "important"];
  16150. }
  16151. if (ch == "." && stream.match(/^\.[a-z][\w-]*/i)) return ["qualifier", "qualifier"];
  16152. if (stream.match(documentTypesRegexp)) {
  16153. if (stream.peek() == "(") state.tokenize = tokenParenthesized;
  16154. return ["property", "word"];
  16155. }
  16156. if (stream.match(/^[a-z][\w-]*\(/i)) {
  16157. stream.backUp(1);
  16158. return ["keyword", "mixin"];
  16159. }
  16160. if (stream.match(/^(\+|-)[a-z][\w-]*\(/i)) {
  16161. stream.backUp(1);
  16162. return ["keyword", "block-mixin"];
  16163. }
  16164. if (stream.string.match(/^\s*&/) && stream.match(/^[-_]+[a-z][\w-]*/)) return ["qualifier", "qualifier"];
  16165. if (stream.match(/^(\/|&)(-|_|:|\.|#|[a-z])/)) {
  16166. stream.backUp(1);
  16167. return ["variable-3", "reference"];
  16168. }
  16169. if (stream.match(/^&{1}\s*$/)) return ["variable-3", "reference"];
  16170. if (stream.match(wordOperatorKeywordsRegexp)) return ["operator", "operator"];
  16171. if (stream.match(/^\$?[-_]*[a-z0-9]+[\w-]*/i)) {
  16172. if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) {
  16173. if (!wordIsTag(stream.current())) {
  16174. stream.match(".");
  16175. return ["variable-2", "variable-name"];
  16176. }
  16177. }
  16178. return ["variable-2", "word"];
  16179. }
  16180. if (stream.match(operatorsRegexp)) return ["operator", stream.current()];
  16181. if (/[:;,{}\[\]\(\)]/.test(ch)) {
  16182. stream.next();
  16183. return [null, ch];
  16184. }
  16185. stream.next();
  16186. return [null, null];
  16187. }
  16188. /**
  16189. * Token comment
  16190. */
  16191. function tokenCComment(stream, state) {
  16192. var maybeEnd = false, ch$1;
  16193. while ((ch$1 = stream.next()) != null) {
  16194. if (maybeEnd && ch$1 == "/") {
  16195. state.tokenize = null;
  16196. break;
  16197. }
  16198. maybeEnd = ch$1 == "*";
  16199. }
  16200. return ["comment", "comment"];
  16201. }
  16202. /**
  16203. * Token string
  16204. */
  16205. function tokenString(quote) {
  16206. return function(stream, state) {
  16207. var escaped = false, ch$1;
  16208. while ((ch$1 = stream.next()) != null) {
  16209. if (ch$1 == quote && !escaped) {
  16210. if (quote == ")") stream.backUp(1);
  16211. break;
  16212. }
  16213. escaped = !escaped && ch$1 == "\\";
  16214. }
  16215. if (ch$1 == quote || !escaped && quote != ")") state.tokenize = null;
  16216. return ["string", "string"];
  16217. };
  16218. }
  16219. /**
  16220. * Token parenthesized
  16221. */
  16222. function tokenParenthesized(stream, state) {
  16223. stream.next();
  16224. if (!stream.match(/\s*[\"\')]/, false)) state.tokenize = tokenString(")");
  16225. else state.tokenize = null;
  16226. return [null, "("];
  16227. }
  16228. /**
  16229. * Context management
  16230. */
  16231. function Context(type$1, indent, prev, line) {
  16232. this.type = type$1;
  16233. this.indent = indent;
  16234. this.prev = prev;
  16235. this.line = line || {
  16236. firstWord: "",
  16237. indent: 0
  16238. };
  16239. }
  16240. function pushContext(state, stream, type$1, indent) {
  16241. indent = indent >= 0 ? indent : indentUnit;
  16242. state.context = new Context(type$1, stream.indentation() + indent, state.context);
  16243. return type$1;
  16244. }
  16245. function popContext(state, currentIndent) {
  16246. var contextIndent = state.context.indent - indentUnit;
  16247. currentIndent = currentIndent || false;
  16248. state.context = state.context.prev;
  16249. if (currentIndent) state.context.indent = contextIndent;
  16250. return state.context.type;
  16251. }
  16252. function pass(type$1, stream, state) {
  16253. return states[state.context.type](type$1, stream, state);
  16254. }
  16255. function popAndPass(type$1, stream, state, n) {
  16256. for (var i = n || 1; i > 0; i--) state.context = state.context.prev;
  16257. return pass(type$1, stream, state);
  16258. }
  16259. /**
  16260. * Parser
  16261. */
  16262. function wordIsTag(word) {
  16263. return word.toLowerCase() in tagKeywords;
  16264. }
  16265. function wordIsProperty(word) {
  16266. word = word.toLowerCase();
  16267. return word in propertyKeywords || word in fontProperties;
  16268. }
  16269. function wordIsBlock(word) {
  16270. return word.toLowerCase() in blockKeywords;
  16271. }
  16272. function wordIsVendorPrefix(word) {
  16273. return word.toLowerCase().match(vendorPrefixesRegexp);
  16274. }
  16275. function wordAsValue(word) {
  16276. var wordLC = word.toLowerCase();
  16277. var override$1 = "variable-2";
  16278. if (wordIsTag(word)) override$1 = "tag";
  16279. else if (wordIsBlock(word)) override$1 = "block-keyword";
  16280. else if (wordIsProperty(word)) override$1 = "property";
  16281. else if (wordLC in valueKeywords || wordLC in commonAtoms) override$1 = "atom";
  16282. else if (wordLC == "return" || wordLC in colorKeywords) override$1 = "keyword";
  16283. else if (word.match(/^[A-Z]/)) override$1 = "string";
  16284. return override$1;
  16285. }
  16286. function typeIsBlock(type$1, stream) {
  16287. return endOfLine(stream) && (type$1 == "{" || type$1 == "]" || type$1 == "hash" || type$1 == "qualifier") || type$1 == "block-mixin";
  16288. }
  16289. function typeIsInterpolation(type$1, stream) {
  16290. return type$1 == "{" && stream.match(/^\s*\$?[\w-]+/i, false);
  16291. }
  16292. function typeIsPseudo(type$1, stream) {
  16293. return type$1 == ":" && stream.match(/^[a-z-]+/, false);
  16294. }
  16295. function startOfLine(stream) {
  16296. return stream.sol() || stream.string.match(new RegExp("^\\s*" + escapeRegExp(stream.current())));
  16297. }
  16298. function endOfLine(stream) {
  16299. return stream.eol() || stream.match(/^\s*$/, false);
  16300. }
  16301. function firstWordOfLine(line) {
  16302. var re = /^\s*[-_]*[a-z0-9]+[\w-]*/i;
  16303. var result = typeof line == "string" ? line.match(re) : line.string.match(re);
  16304. return result ? result[0].replace(/^\s*/, "") : "";
  16305. }
  16306. /**
  16307. * Block
  16308. */
  16309. states.block = function(type$1, stream, state) {
  16310. if (type$1 == "comment" && startOfLine(stream) || type$1 == "," && endOfLine(stream) || type$1 == "mixin") return pushContext(state, stream, "block", 0);
  16311. if (typeIsInterpolation(type$1, stream)) return pushContext(state, stream, "interpolation");
  16312. if (endOfLine(stream) && type$1 == "]") {
  16313. if (!/^\s*(\.|#|:|\[|\*|&)/.test(stream.string) && !wordIsTag(firstWordOfLine(stream))) return pushContext(state, stream, "block", 0);
  16314. }
  16315. if (typeIsBlock(type$1, stream)) return pushContext(state, stream, "block");
  16316. if (type$1 == "}" && endOfLine(stream)) return pushContext(state, stream, "block", 0);
  16317. if (type$1 == "variable-name") if (stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/) || wordIsBlock(firstWordOfLine(stream))) return pushContext(state, stream, "variableName");
  16318. else return pushContext(state, stream, "variableName", 0);
  16319. if (type$1 == "=") {
  16320. if (!endOfLine(stream) && !wordIsBlock(firstWordOfLine(stream))) return pushContext(state, stream, "block", 0);
  16321. return pushContext(state, stream, "block");
  16322. }
  16323. if (type$1 == "*") {
  16324. if (endOfLine(stream) || stream.match(/\s*(,|\.|#|\[|:|{)/, false)) {
  16325. override = "tag";
  16326. return pushContext(state, stream, "block");
  16327. }
  16328. }
  16329. if (typeIsPseudo(type$1, stream)) return pushContext(state, stream, "pseudo");
  16330. if (/@(font-face|media|supports|(-moz-)?document)/.test(type$1)) return pushContext(state, stream, endOfLine(stream) ? "block" : "atBlock");
  16331. if (/@(-(moz|ms|o|webkit)-)?keyframes$/.test(type$1)) return pushContext(state, stream, "keyframes");
  16332. if (/@extends?/.test(type$1)) return pushContext(state, stream, "extend", 0);
  16333. if (type$1 && type$1.charAt(0) == "@") {
  16334. if (stream.indentation() > 0 && wordIsProperty(stream.current().slice(1))) {
  16335. override = "variable-2";
  16336. return "block";
  16337. }
  16338. if (/(@import|@require|@charset)/.test(type$1)) return pushContext(state, stream, "block", 0);
  16339. return pushContext(state, stream, "block");
  16340. }
  16341. if (type$1 == "reference" && endOfLine(stream)) return pushContext(state, stream, "block");
  16342. if (type$1 == "(") return pushContext(state, stream, "parens");
  16343. if (type$1 == "vendor-prefixes") return pushContext(state, stream, "vendorPrefixes");
  16344. if (type$1 == "word") {
  16345. var word = stream.current();
  16346. override = wordAsValue(word);
  16347. if (override == "property") if (startOfLine(stream)) return pushContext(state, stream, "block", 0);
  16348. else {
  16349. override = "atom";
  16350. return "block";
  16351. }
  16352. if (override == "tag") {
  16353. if (/embed|menu|pre|progress|sub|table/.test(word)) {
  16354. if (wordIsProperty(firstWordOfLine(stream))) {
  16355. override = "atom";
  16356. return "block";
  16357. }
  16358. }
  16359. if (stream.string.match(new RegExp("\\[\\s*" + word + "|" + word + "\\s*\\]"))) {
  16360. override = "atom";
  16361. return "block";
  16362. }
  16363. if (tagVariablesRegexp.test(word)) {
  16364. if (startOfLine(stream) && stream.string.match(/=/) || !startOfLine(stream) && !stream.string.match(/^(\s*\.|#|\&|\[|\/|>|\*)/) && !wordIsTag(firstWordOfLine(stream))) {
  16365. override = "variable-2";
  16366. if (wordIsBlock(firstWordOfLine(stream))) return "block";
  16367. return pushContext(state, stream, "block", 0);
  16368. }
  16369. }
  16370. if (endOfLine(stream)) return pushContext(state, stream, "block");
  16371. }
  16372. if (override == "block-keyword") {
  16373. override = "keyword";
  16374. if (stream.current(/(if|unless)/) && !startOfLine(stream)) return "block";
  16375. return pushContext(state, stream, "block");
  16376. }
  16377. if (word == "return") return pushContext(state, stream, "block", 0);
  16378. if (override == "variable-2" && stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/)) return pushContext(state, stream, "block");
  16379. }
  16380. return state.context.type;
  16381. };
  16382. /**
  16383. * Parens
  16384. */
  16385. states.parens = function(type$1, stream, state) {
  16386. if (type$1 == "(") return pushContext(state, stream, "parens");
  16387. if (type$1 == ")") {
  16388. if (state.context.prev.type == "parens") return popContext(state);
  16389. if (stream.string.match(/^[a-z][\w-]*\(/i) && endOfLine(stream) || wordIsBlock(firstWordOfLine(stream)) || /(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(firstWordOfLine(stream)) || !stream.string.match(/^-?[a-z][\w-\.\[\]\'\"]*\s*=/) && wordIsTag(firstWordOfLine(stream))) return pushContext(state, stream, "block");
  16390. if (stream.string.match(/^[\$-]?[a-z][\w-\.\[\]\'\"]*\s*=/) || stream.string.match(/^\s*(\(|\)|[0-9])/) || stream.string.match(/^\s+[a-z][\w-]*\(/i) || stream.string.match(/^\s+[\$-]?[a-z]/i)) return pushContext(state, stream, "block", 0);
  16391. if (endOfLine(stream)) return pushContext(state, stream, "block");
  16392. else return pushContext(state, stream, "block", 0);
  16393. }
  16394. if (type$1 && type$1.charAt(0) == "@" && wordIsProperty(stream.current().slice(1))) override = "variable-2";
  16395. if (type$1 == "word") {
  16396. var word = stream.current();
  16397. override = wordAsValue(word);
  16398. if (override == "tag" && tagVariablesRegexp.test(word)) override = "variable-2";
  16399. if (override == "property" || word == "to") override = "atom";
  16400. }
  16401. if (type$1 == "variable-name") return pushContext(state, stream, "variableName");
  16402. if (typeIsPseudo(type$1, stream)) return pushContext(state, stream, "pseudo");
  16403. return state.context.type;
  16404. };
  16405. /**
  16406. * Vendor prefixes
  16407. */
  16408. states.vendorPrefixes = function(type$1, stream, state) {
  16409. if (type$1 == "word") {
  16410. override = "property";
  16411. return pushContext(state, stream, "block", 0);
  16412. }
  16413. return popContext(state);
  16414. };
  16415. /**
  16416. * Pseudo
  16417. */
  16418. states.pseudo = function(type$1, stream, state) {
  16419. if (!wordIsProperty(firstWordOfLine(stream.string))) {
  16420. stream.match(/^[a-z-]+/);
  16421. override = "variable-3";
  16422. if (endOfLine(stream)) return pushContext(state, stream, "block");
  16423. return popContext(state);
  16424. }
  16425. return popAndPass(type$1, stream, state);
  16426. };
  16427. /**
  16428. * atBlock
  16429. */
  16430. states.atBlock = function(type$1, stream, state) {
  16431. if (type$1 == "(") return pushContext(state, stream, "atBlock_parens");
  16432. if (typeIsBlock(type$1, stream)) return pushContext(state, stream, "block");
  16433. if (typeIsInterpolation(type$1, stream)) return pushContext(state, stream, "interpolation");
  16434. if (type$1 == "word") {
  16435. var word = stream.current().toLowerCase();
  16436. if (/^(only|not|and|or)$/.test(word)) override = "keyword";
  16437. else if (documentTypes.hasOwnProperty(word)) override = "tag";
  16438. else if (mediaTypes.hasOwnProperty(word)) override = "attribute";
  16439. else if (mediaFeatures.hasOwnProperty(word)) override = "property";
  16440. else if (nonStandardPropertyKeywords.hasOwnProperty(word)) override = "string-2";
  16441. else override = wordAsValue(stream.current());
  16442. if (override == "tag" && endOfLine(stream)) return pushContext(state, stream, "block");
  16443. }
  16444. if (type$1 == "operator" && /^(not|and|or)$/.test(stream.current())) override = "keyword";
  16445. return state.context.type;
  16446. };
  16447. states.atBlock_parens = function(type$1, stream, state) {
  16448. if (type$1 == "{" || type$1 == "}") return state.context.type;
  16449. if (type$1 == ")") if (endOfLine(stream)) return pushContext(state, stream, "block");
  16450. else return pushContext(state, stream, "atBlock");
  16451. if (type$1 == "word") {
  16452. var word = stream.current().toLowerCase();
  16453. override = wordAsValue(word);
  16454. if (/^(max|min)/.test(word)) override = "property";
  16455. if (override == "tag") tagVariablesRegexp.test(word) ? override = "variable-2" : override = "atom";
  16456. return state.context.type;
  16457. }
  16458. return states.atBlock(type$1, stream, state);
  16459. };
  16460. /**
  16461. * Keyframes
  16462. */
  16463. states.keyframes = function(type$1, stream, state) {
  16464. if (stream.indentation() == "0" && (type$1 == "}" && startOfLine(stream) || type$1 == "]" || type$1 == "hash" || type$1 == "qualifier" || wordIsTag(stream.current()))) return popAndPass(type$1, stream, state);
  16465. if (type$1 == "{") return pushContext(state, stream, "keyframes");
  16466. if (type$1 == "}") if (startOfLine(stream)) return popContext(state, true);
  16467. else return pushContext(state, stream, "keyframes");
  16468. if (type$1 == "unit" && /^[0-9]+\%$/.test(stream.current())) return pushContext(state, stream, "keyframes");
  16469. if (type$1 == "word") {
  16470. override = wordAsValue(stream.current());
  16471. if (override == "block-keyword") {
  16472. override = "keyword";
  16473. return pushContext(state, stream, "keyframes");
  16474. }
  16475. }
  16476. if (/@(font-face|media|supports|(-moz-)?document)/.test(type$1)) return pushContext(state, stream, endOfLine(stream) ? "block" : "atBlock");
  16477. if (type$1 == "mixin") return pushContext(state, stream, "block", 0);
  16478. return state.context.type;
  16479. };
  16480. /**
  16481. * Interpolation
  16482. */
  16483. states.interpolation = function(type$1, stream, state) {
  16484. if (type$1 == "{") popContext(state) && pushContext(state, stream, "block");
  16485. if (type$1 == "}") {
  16486. if (stream.string.match(/^\s*(\.|#|:|\[|\*|&|>|~|\+|\/)/i) || stream.string.match(/^\s*[a-z]/i) && wordIsTag(firstWordOfLine(stream))) return pushContext(state, stream, "block");
  16487. if (!stream.string.match(/^(\{|\s*\&)/) || stream.match(/\s*[\w-]/, false)) return pushContext(state, stream, "block", 0);
  16488. return pushContext(state, stream, "block");
  16489. }
  16490. if (type$1 == "variable-name") return pushContext(state, stream, "variableName", 0);
  16491. if (type$1 == "word") {
  16492. override = wordAsValue(stream.current());
  16493. if (override == "tag") override = "atom";
  16494. }
  16495. return state.context.type;
  16496. };
  16497. /**
  16498. * Extend/s
  16499. */
  16500. states.extend = function(type$1, stream, state) {
  16501. if (type$1 == "[" || type$1 == "=") return "extend";
  16502. if (type$1 == "]") return popContext(state);
  16503. if (type$1 == "word") {
  16504. override = wordAsValue(stream.current());
  16505. return "extend";
  16506. }
  16507. return popContext(state);
  16508. };
  16509. /**
  16510. * Variable name
  16511. */
  16512. states.variableName = function(type$1, stream, state) {
  16513. if (type$1 == "string" || type$1 == "[" || type$1 == "]" || stream.current().match(/^(\.|\$)/)) {
  16514. if (stream.current().match(/^\.[\w-]+/i)) override = "variable-2";
  16515. return "variableName";
  16516. }
  16517. return popAndPass(type$1, stream, state);
  16518. };
  16519. return {
  16520. startState: function(base) {
  16521. return {
  16522. tokenize: null,
  16523. state: "block",
  16524. context: new Context("block", base || 0, null)
  16525. };
  16526. },
  16527. token: function(stream, state) {
  16528. if (!state.tokenize && stream.eatSpace()) return null;
  16529. style = (state.tokenize || tokenBase)(stream, state);
  16530. if (style && typeof style == "object") {
  16531. type = style[1];
  16532. style = style[0];
  16533. }
  16534. override = style;
  16535. state.state = states[state.state](type, stream, state);
  16536. return override;
  16537. },
  16538. indent: function(state, textAfter, line) {
  16539. var cx = state.context, ch$1 = textAfter && textAfter.charAt(0), indent = cx.indent, lineFirstWord = firstWordOfLine(textAfter), lineIndent = line.match(/^\s*/)[0].replace(/\t/g, indentUnitString).length, prevLineFirstWord = state.context.prev ? state.context.prev.line.firstWord : "", prevLineIndent = state.context.prev ? state.context.prev.line.indent : lineIndent;
  16540. if (cx.prev && (ch$1 == "}" && (cx.type == "block" || cx.type == "atBlock" || cx.type == "keyframes") || ch$1 == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || ch$1 == "{" && cx.type == "at")) indent = cx.indent - indentUnit;
  16541. else if (!/(\})/.test(ch$1)) {
  16542. if (/@|\$|\d/.test(ch$1) || /^\{/.test(textAfter) || /^\s*\/(\/|\*)/.test(textAfter) || /^\s*\/\*/.test(prevLineFirstWord) || /^\s*[\w-\.\[\]\'\"]+\s*(\?|:|\+)?=/i.test(textAfter) || /^(\+|-)?[a-z][\w-]*\(/i.test(textAfter) || /^return/.test(textAfter) || wordIsBlock(lineFirstWord)) indent = lineIndent;
  16543. else if (/(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(ch$1) || wordIsTag(lineFirstWord)) if (/\,\s*$/.test(prevLineFirstWord)) indent = prevLineIndent;
  16544. else if (/^\s+/.test(line) && (/(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(prevLineFirstWord) || wordIsTag(prevLineFirstWord))) indent = lineIndent <= prevLineIndent ? prevLineIndent : prevLineIndent + indentUnit;
  16545. else indent = lineIndent;
  16546. else if (!/,\s*$/.test(line) && (wordIsVendorPrefix(lineFirstWord) || wordIsProperty(lineFirstWord))) if (wordIsBlock(prevLineFirstWord)) indent = lineIndent <= prevLineIndent ? prevLineIndent : prevLineIndent + indentUnit;
  16547. else if (/^\{/.test(prevLineFirstWord)) indent = lineIndent <= prevLineIndent ? lineIndent : prevLineIndent + indentUnit;
  16548. else if (wordIsVendorPrefix(prevLineFirstWord) || wordIsProperty(prevLineFirstWord)) indent = lineIndent >= prevLineIndent ? prevLineIndent : lineIndent;
  16549. else if (/^(\.|#|:|\[|\*|&|@|\+|\-|>|~|\/)/.test(prevLineFirstWord) || /=\s*$/.test(prevLineFirstWord) || wordIsTag(prevLineFirstWord) || /^\$[\w-\.\[\]\'\"]/.test(prevLineFirstWord)) indent = prevLineIndent + indentUnit;
  16550. else indent = lineIndent;
  16551. }
  16552. return indent;
  16553. },
  16554. electricChars: "}",
  16555. blockCommentStart: "/*",
  16556. blockCommentEnd: "*/",
  16557. blockCommentContinue: " * ",
  16558. lineComment: "//",
  16559. fold: "indent"
  16560. };
  16561. });
  16562. var tagKeywords_ = [
  16563. "a",
  16564. "abbr",
  16565. "address",
  16566. "area",
  16567. "article",
  16568. "aside",
  16569. "audio",
  16570. "b",
  16571. "base",
  16572. "bdi",
  16573. "bdo",
  16574. "bgsound",
  16575. "blockquote",
  16576. "body",
  16577. "br",
  16578. "button",
  16579. "canvas",
  16580. "caption",
  16581. "cite",
  16582. "code",
  16583. "col",
  16584. "colgroup",
  16585. "data",
  16586. "datalist",
  16587. "dd",
  16588. "del",
  16589. "details",
  16590. "dfn",
  16591. "div",
  16592. "dl",
  16593. "dt",
  16594. "em",
  16595. "embed",
  16596. "fieldset",
  16597. "figcaption",
  16598. "figure",
  16599. "footer",
  16600. "form",
  16601. "h1",
  16602. "h2",
  16603. "h3",
  16604. "h4",
  16605. "h5",
  16606. "h6",
  16607. "head",
  16608. "header",
  16609. "hgroup",
  16610. "hr",
  16611. "html",
  16612. "i",
  16613. "iframe",
  16614. "img",
  16615. "input",
  16616. "ins",
  16617. "kbd",
  16618. "keygen",
  16619. "label",
  16620. "legend",
  16621. "li",
  16622. "link",
  16623. "main",
  16624. "map",
  16625. "mark",
  16626. "marquee",
  16627. "menu",
  16628. "menuitem",
  16629. "meta",
  16630. "meter",
  16631. "nav",
  16632. "nobr",
  16633. "noframes",
  16634. "noscript",
  16635. "object",
  16636. "ol",
  16637. "optgroup",
  16638. "option",
  16639. "output",
  16640. "p",
  16641. "param",
  16642. "pre",
  16643. "progress",
  16644. "q",
  16645. "rp",
  16646. "rt",
  16647. "ruby",
  16648. "s",
  16649. "samp",
  16650. "script",
  16651. "section",
  16652. "select",
  16653. "small",
  16654. "source",
  16655. "span",
  16656. "strong",
  16657. "style",
  16658. "sub",
  16659. "summary",
  16660. "sup",
  16661. "table",
  16662. "tbody",
  16663. "td",
  16664. "textarea",
  16665. "tfoot",
  16666. "th",
  16667. "thead",
  16668. "time",
  16669. "tr",
  16670. "track",
  16671. "u",
  16672. "ul",
  16673. "var",
  16674. "video"
  16675. ];
  16676. var documentTypes_ = [
  16677. "domain",
  16678. "regexp",
  16679. "url-prefix",
  16680. "url"
  16681. ];
  16682. var mediaTypes_ = [
  16683. "all",
  16684. "aural",
  16685. "braille",
  16686. "handheld",
  16687. "print",
  16688. "projection",
  16689. "screen",
  16690. "tty",
  16691. "tv",
  16692. "embossed"
  16693. ];
  16694. var mediaFeatures_ = [
  16695. "width",
  16696. "min-width",
  16697. "max-width",
  16698. "height",
  16699. "min-height",
  16700. "max-height",
  16701. "device-width",
  16702. "min-device-width",
  16703. "max-device-width",
  16704. "device-height",
  16705. "min-device-height",
  16706. "max-device-height",
  16707. "aspect-ratio",
  16708. "min-aspect-ratio",
  16709. "max-aspect-ratio",
  16710. "device-aspect-ratio",
  16711. "min-device-aspect-ratio",
  16712. "max-device-aspect-ratio",
  16713. "color",
  16714. "min-color",
  16715. "max-color",
  16716. "color-index",
  16717. "min-color-index",
  16718. "max-color-index",
  16719. "monochrome",
  16720. "min-monochrome",
  16721. "max-monochrome",
  16722. "resolution",
  16723. "min-resolution",
  16724. "max-resolution",
  16725. "scan",
  16726. "grid",
  16727. "dynamic-range",
  16728. "video-dynamic-range"
  16729. ];
  16730. var propertyKeywords_ = [
  16731. "align-content",
  16732. "align-items",
  16733. "align-self",
  16734. "alignment-adjust",
  16735. "alignment-baseline",
  16736. "anchor-point",
  16737. "animation",
  16738. "animation-delay",
  16739. "animation-direction",
  16740. "animation-duration",
  16741. "animation-fill-mode",
  16742. "animation-iteration-count",
  16743. "animation-name",
  16744. "animation-play-state",
  16745. "animation-timing-function",
  16746. "appearance",
  16747. "azimuth",
  16748. "backface-visibility",
  16749. "background",
  16750. "background-attachment",
  16751. "background-clip",
  16752. "background-color",
  16753. "background-image",
  16754. "background-origin",
  16755. "background-position",
  16756. "background-repeat",
  16757. "background-size",
  16758. "baseline-shift",
  16759. "binding",
  16760. "bleed",
  16761. "bookmark-label",
  16762. "bookmark-level",
  16763. "bookmark-state",
  16764. "bookmark-target",
  16765. "border",
  16766. "border-bottom",
  16767. "border-bottom-color",
  16768. "border-bottom-left-radius",
  16769. "border-bottom-right-radius",
  16770. "border-bottom-style",
  16771. "border-bottom-width",
  16772. "border-collapse",
  16773. "border-color",
  16774. "border-image",
  16775. "border-image-outset",
  16776. "border-image-repeat",
  16777. "border-image-slice",
  16778. "border-image-source",
  16779. "border-image-width",
  16780. "border-left",
  16781. "border-left-color",
  16782. "border-left-style",
  16783. "border-left-width",
  16784. "border-radius",
  16785. "border-right",
  16786. "border-right-color",
  16787. "border-right-style",
  16788. "border-right-width",
  16789. "border-spacing",
  16790. "border-style",
  16791. "border-top",
  16792. "border-top-color",
  16793. "border-top-left-radius",
  16794. "border-top-right-radius",
  16795. "border-top-style",
  16796. "border-top-width",
  16797. "border-width",
  16798. "bottom",
  16799. "box-decoration-break",
  16800. "box-shadow",
  16801. "box-sizing",
  16802. "break-after",
  16803. "break-before",
  16804. "break-inside",
  16805. "caption-side",
  16806. "clear",
  16807. "clip",
  16808. "color",
  16809. "color-profile",
  16810. "column-count",
  16811. "column-fill",
  16812. "column-gap",
  16813. "column-rule",
  16814. "column-rule-color",
  16815. "column-rule-style",
  16816. "column-rule-width",
  16817. "column-span",
  16818. "column-width",
  16819. "columns",
  16820. "content",
  16821. "counter-increment",
  16822. "counter-reset",
  16823. "crop",
  16824. "cue",
  16825. "cue-after",
  16826. "cue-before",
  16827. "cursor",
  16828. "direction",
  16829. "display",
  16830. "dominant-baseline",
  16831. "drop-initial-after-adjust",
  16832. "drop-initial-after-align",
  16833. "drop-initial-before-adjust",
  16834. "drop-initial-before-align",
  16835. "drop-initial-size",
  16836. "drop-initial-value",
  16837. "elevation",
  16838. "empty-cells",
  16839. "fit",
  16840. "fit-position",
  16841. "flex",
  16842. "flex-basis",
  16843. "flex-direction",
  16844. "flex-flow",
  16845. "flex-grow",
  16846. "flex-shrink",
  16847. "flex-wrap",
  16848. "float",
  16849. "float-offset",
  16850. "flow-from",
  16851. "flow-into",
  16852. "font",
  16853. "font-feature-settings",
  16854. "font-family",
  16855. "font-kerning",
  16856. "font-language-override",
  16857. "font-size",
  16858. "font-size-adjust",
  16859. "font-stretch",
  16860. "font-style",
  16861. "font-synthesis",
  16862. "font-variant",
  16863. "font-variant-alternates",
  16864. "font-variant-caps",
  16865. "font-variant-east-asian",
  16866. "font-variant-ligatures",
  16867. "font-variant-numeric",
  16868. "font-variant-position",
  16869. "font-weight",
  16870. "grid",
  16871. "grid-area",
  16872. "grid-auto-columns",
  16873. "grid-auto-flow",
  16874. "grid-auto-position",
  16875. "grid-auto-rows",
  16876. "grid-column",
  16877. "grid-column-end",
  16878. "grid-column-start",
  16879. "grid-row",
  16880. "grid-row-end",
  16881. "grid-row-start",
  16882. "grid-template",
  16883. "grid-template-areas",
  16884. "grid-template-columns",
  16885. "grid-template-rows",
  16886. "hanging-punctuation",
  16887. "height",
  16888. "hyphens",
  16889. "icon",
  16890. "image-orientation",
  16891. "image-rendering",
  16892. "image-resolution",
  16893. "inline-box-align",
  16894. "justify-content",
  16895. "left",
  16896. "letter-spacing",
  16897. "line-break",
  16898. "line-height",
  16899. "line-stacking",
  16900. "line-stacking-ruby",
  16901. "line-stacking-shift",
  16902. "line-stacking-strategy",
  16903. "list-style",
  16904. "list-style-image",
  16905. "list-style-position",
  16906. "list-style-type",
  16907. "margin",
  16908. "margin-bottom",
  16909. "margin-left",
  16910. "margin-right",
  16911. "margin-top",
  16912. "marker-offset",
  16913. "marks",
  16914. "marquee-direction",
  16915. "marquee-loop",
  16916. "marquee-play-count",
  16917. "marquee-speed",
  16918. "marquee-style",
  16919. "max-height",
  16920. "max-width",
  16921. "min-height",
  16922. "min-width",
  16923. "move-to",
  16924. "nav-down",
  16925. "nav-index",
  16926. "nav-left",
  16927. "nav-right",
  16928. "nav-up",
  16929. "object-fit",
  16930. "object-position",
  16931. "opacity",
  16932. "order",
  16933. "orphans",
  16934. "outline",
  16935. "outline-color",
  16936. "outline-offset",
  16937. "outline-style",
  16938. "outline-width",
  16939. "overflow",
  16940. "overflow-style",
  16941. "overflow-wrap",
  16942. "overflow-x",
  16943. "overflow-y",
  16944. "padding",
  16945. "padding-bottom",
  16946. "padding-left",
  16947. "padding-right",
  16948. "padding-top",
  16949. "page",
  16950. "page-break-after",
  16951. "page-break-before",
  16952. "page-break-inside",
  16953. "page-policy",
  16954. "pause",
  16955. "pause-after",
  16956. "pause-before",
  16957. "perspective",
  16958. "perspective-origin",
  16959. "pitch",
  16960. "pitch-range",
  16961. "play-during",
  16962. "position",
  16963. "presentation-level",
  16964. "punctuation-trim",
  16965. "quotes",
  16966. "region-break-after",
  16967. "region-break-before",
  16968. "region-break-inside",
  16969. "region-fragment",
  16970. "rendering-intent",
  16971. "resize",
  16972. "rest",
  16973. "rest-after",
  16974. "rest-before",
  16975. "richness",
  16976. "right",
  16977. "rotation",
  16978. "rotation-point",
  16979. "ruby-align",
  16980. "ruby-overhang",
  16981. "ruby-position",
  16982. "ruby-span",
  16983. "shape-image-threshold",
  16984. "shape-inside",
  16985. "shape-margin",
  16986. "shape-outside",
  16987. "size",
  16988. "speak",
  16989. "speak-as",
  16990. "speak-header",
  16991. "speak-numeral",
  16992. "speak-punctuation",
  16993. "speech-rate",
  16994. "stress",
  16995. "string-set",
  16996. "tab-size",
  16997. "table-layout",
  16998. "target",
  16999. "target-name",
  17000. "target-new",
  17001. "target-position",
  17002. "text-align",
  17003. "text-align-last",
  17004. "text-decoration",
  17005. "text-decoration-color",
  17006. "text-decoration-line",
  17007. "text-decoration-skip",
  17008. "text-decoration-style",
  17009. "text-emphasis",
  17010. "text-emphasis-color",
  17011. "text-emphasis-position",
  17012. "text-emphasis-style",
  17013. "text-height",
  17014. "text-indent",
  17015. "text-justify",
  17016. "text-outline",
  17017. "text-overflow",
  17018. "text-shadow",
  17019. "text-size-adjust",
  17020. "text-space-collapse",
  17021. "text-transform",
  17022. "text-underline-position",
  17023. "text-wrap",
  17024. "top",
  17025. "transform",
  17026. "transform-origin",
  17027. "transform-style",
  17028. "transition",
  17029. "transition-delay",
  17030. "transition-duration",
  17031. "transition-property",
  17032. "transition-timing-function",
  17033. "unicode-bidi",
  17034. "vertical-align",
  17035. "visibility",
  17036. "voice-balance",
  17037. "voice-duration",
  17038. "voice-family",
  17039. "voice-pitch",
  17040. "voice-range",
  17041. "voice-rate",
  17042. "voice-stress",
  17043. "voice-volume",
  17044. "volume",
  17045. "white-space",
  17046. "widows",
  17047. "width",
  17048. "will-change",
  17049. "word-break",
  17050. "word-spacing",
  17051. "word-wrap",
  17052. "z-index",
  17053. "clip-path",
  17054. "clip-rule",
  17055. "mask",
  17056. "enable-background",
  17057. "filter",
  17058. "flood-color",
  17059. "flood-opacity",
  17060. "lighting-color",
  17061. "stop-color",
  17062. "stop-opacity",
  17063. "pointer-events",
  17064. "color-interpolation",
  17065. "color-interpolation-filters",
  17066. "color-rendering",
  17067. "fill",
  17068. "fill-opacity",
  17069. "fill-rule",
  17070. "image-rendering",
  17071. "marker",
  17072. "marker-end",
  17073. "marker-mid",
  17074. "marker-start",
  17075. "shape-rendering",
  17076. "stroke",
  17077. "stroke-dasharray",
  17078. "stroke-dashoffset",
  17079. "stroke-linecap",
  17080. "stroke-linejoin",
  17081. "stroke-miterlimit",
  17082. "stroke-opacity",
  17083. "stroke-width",
  17084. "text-rendering",
  17085. "baseline-shift",
  17086. "dominant-baseline",
  17087. "glyph-orientation-horizontal",
  17088. "glyph-orientation-vertical",
  17089. "text-anchor",
  17090. "writing-mode",
  17091. "font-smoothing",
  17092. "osx-font-smoothing"
  17093. ];
  17094. var nonStandardPropertyKeywords_ = [
  17095. "scrollbar-arrow-color",
  17096. "scrollbar-base-color",
  17097. "scrollbar-dark-shadow-color",
  17098. "scrollbar-face-color",
  17099. "scrollbar-highlight-color",
  17100. "scrollbar-shadow-color",
  17101. "scrollbar-3d-light-color",
  17102. "scrollbar-track-color",
  17103. "shape-inside",
  17104. "searchfield-cancel-button",
  17105. "searchfield-decoration",
  17106. "searchfield-results-button",
  17107. "searchfield-results-decoration",
  17108. "zoom"
  17109. ];
  17110. var fontProperties_ = [
  17111. "font-family",
  17112. "src",
  17113. "unicode-range",
  17114. "font-variant",
  17115. "font-feature-settings",
  17116. "font-stretch",
  17117. "font-weight",
  17118. "font-style"
  17119. ];
  17120. var colorKeywords_ = [
  17121. "aliceblue",
  17122. "antiquewhite",
  17123. "aqua",
  17124. "aquamarine",
  17125. "azure",
  17126. "beige",
  17127. "bisque",
  17128. "black",
  17129. "blanchedalmond",
  17130. "blue",
  17131. "blueviolet",
  17132. "brown",
  17133. "burlywood",
  17134. "cadetblue",
  17135. "chartreuse",
  17136. "chocolate",
  17137. "coral",
  17138. "cornflowerblue",
  17139. "cornsilk",
  17140. "crimson",
  17141. "cyan",
  17142. "darkblue",
  17143. "darkcyan",
  17144. "darkgoldenrod",
  17145. "darkgray",
  17146. "darkgreen",
  17147. "darkkhaki",
  17148. "darkmagenta",
  17149. "darkolivegreen",
  17150. "darkorange",
  17151. "darkorchid",
  17152. "darkred",
  17153. "darksalmon",
  17154. "darkseagreen",
  17155. "darkslateblue",
  17156. "darkslategray",
  17157. "darkturquoise",
  17158. "darkviolet",
  17159. "deeppink",
  17160. "deepskyblue",
  17161. "dimgray",
  17162. "dodgerblue",
  17163. "firebrick",
  17164. "floralwhite",
  17165. "forestgreen",
  17166. "fuchsia",
  17167. "gainsboro",
  17168. "ghostwhite",
  17169. "gold",
  17170. "goldenrod",
  17171. "gray",
  17172. "grey",
  17173. "green",
  17174. "greenyellow",
  17175. "honeydew",
  17176. "hotpink",
  17177. "indianred",
  17178. "indigo",
  17179. "ivory",
  17180. "khaki",
  17181. "lavender",
  17182. "lavenderblush",
  17183. "lawngreen",
  17184. "lemonchiffon",
  17185. "lightblue",
  17186. "lightcoral",
  17187. "lightcyan",
  17188. "lightgoldenrodyellow",
  17189. "lightgray",
  17190. "lightgreen",
  17191. "lightpink",
  17192. "lightsalmon",
  17193. "lightseagreen",
  17194. "lightskyblue",
  17195. "lightslategray",
  17196. "lightsteelblue",
  17197. "lightyellow",
  17198. "lime",
  17199. "limegreen",
  17200. "linen",
  17201. "magenta",
  17202. "maroon",
  17203. "mediumaquamarine",
  17204. "mediumblue",
  17205. "mediumorchid",
  17206. "mediumpurple",
  17207. "mediumseagreen",
  17208. "mediumslateblue",
  17209. "mediumspringgreen",
  17210. "mediumturquoise",
  17211. "mediumvioletred",
  17212. "midnightblue",
  17213. "mintcream",
  17214. "mistyrose",
  17215. "moccasin",
  17216. "navajowhite",
  17217. "navy",
  17218. "oldlace",
  17219. "olive",
  17220. "olivedrab",
  17221. "orange",
  17222. "orangered",
  17223. "orchid",
  17224. "palegoldenrod",
  17225. "palegreen",
  17226. "paleturquoise",
  17227. "palevioletred",
  17228. "papayawhip",
  17229. "peachpuff",
  17230. "peru",
  17231. "pink",
  17232. "plum",
  17233. "powderblue",
  17234. "purple",
  17235. "rebeccapurple",
  17236. "red",
  17237. "rosybrown",
  17238. "royalblue",
  17239. "saddlebrown",
  17240. "salmon",
  17241. "sandybrown",
  17242. "seagreen",
  17243. "seashell",
  17244. "sienna",
  17245. "silver",
  17246. "skyblue",
  17247. "slateblue",
  17248. "slategray",
  17249. "snow",
  17250. "springgreen",
  17251. "steelblue",
  17252. "tan",
  17253. "teal",
  17254. "thistle",
  17255. "tomato",
  17256. "turquoise",
  17257. "violet",
  17258. "wheat",
  17259. "white",
  17260. "whitesmoke",
  17261. "yellow",
  17262. "yellowgreen"
  17263. ];
  17264. var valueKeywords_ = [
  17265. "above",
  17266. "absolute",
  17267. "activeborder",
  17268. "additive",
  17269. "activecaption",
  17270. "afar",
  17271. "after-white-space",
  17272. "ahead",
  17273. "alias",
  17274. "all",
  17275. "all-scroll",
  17276. "alphabetic",
  17277. "alternate",
  17278. "always",
  17279. "amharic",
  17280. "amharic-abegede",
  17281. "antialiased",
  17282. "appworkspace",
  17283. "arabic-indic",
  17284. "armenian",
  17285. "asterisks",
  17286. "attr",
  17287. "auto",
  17288. "avoid",
  17289. "avoid-column",
  17290. "avoid-page",
  17291. "avoid-region",
  17292. "background",
  17293. "backwards",
  17294. "baseline",
  17295. "below",
  17296. "bidi-override",
  17297. "binary",
  17298. "bengali",
  17299. "blink",
  17300. "block",
  17301. "block-axis",
  17302. "bold",
  17303. "bolder",
  17304. "border",
  17305. "border-box",
  17306. "both",
  17307. "bottom",
  17308. "break",
  17309. "break-all",
  17310. "break-word",
  17311. "bullets",
  17312. "button",
  17313. "buttonface",
  17314. "buttonhighlight",
  17315. "buttonshadow",
  17316. "buttontext",
  17317. "calc",
  17318. "cambodian",
  17319. "capitalize",
  17320. "caps-lock-indicator",
  17321. "caption",
  17322. "captiontext",
  17323. "caret",
  17324. "cell",
  17325. "center",
  17326. "checkbox",
  17327. "circle",
  17328. "cjk-decimal",
  17329. "cjk-earthly-branch",
  17330. "cjk-heavenly-stem",
  17331. "cjk-ideographic",
  17332. "clear",
  17333. "clip",
  17334. "close-quote",
  17335. "col-resize",
  17336. "collapse",
  17337. "column",
  17338. "compact",
  17339. "condensed",
  17340. "conic-gradient",
  17341. "contain",
  17342. "content",
  17343. "contents",
  17344. "content-box",
  17345. "context-menu",
  17346. "continuous",
  17347. "copy",
  17348. "counter",
  17349. "counters",
  17350. "cover",
  17351. "crop",
  17352. "cross",
  17353. "crosshair",
  17354. "currentcolor",
  17355. "cursive",
  17356. "cyclic",
  17357. "dashed",
  17358. "decimal",
  17359. "decimal-leading-zero",
  17360. "default",
  17361. "default-button",
  17362. "destination-atop",
  17363. "destination-in",
  17364. "destination-out",
  17365. "destination-over",
  17366. "devanagari",
  17367. "disc",
  17368. "discard",
  17369. "disclosure-closed",
  17370. "disclosure-open",
  17371. "document",
  17372. "dot-dash",
  17373. "dot-dot-dash",
  17374. "dotted",
  17375. "double",
  17376. "down",
  17377. "e-resize",
  17378. "ease",
  17379. "ease-in",
  17380. "ease-in-out",
  17381. "ease-out",
  17382. "element",
  17383. "ellipse",
  17384. "ellipsis",
  17385. "embed",
  17386. "end",
  17387. "ethiopic",
  17388. "ethiopic-abegede",
  17389. "ethiopic-abegede-am-et",
  17390. "ethiopic-abegede-gez",
  17391. "ethiopic-abegede-ti-er",
  17392. "ethiopic-abegede-ti-et",
  17393. "ethiopic-halehame-aa-er",
  17394. "ethiopic-halehame-aa-et",
  17395. "ethiopic-halehame-am-et",
  17396. "ethiopic-halehame-gez",
  17397. "ethiopic-halehame-om-et",
  17398. "ethiopic-halehame-sid-et",
  17399. "ethiopic-halehame-so-et",
  17400. "ethiopic-halehame-ti-er",
  17401. "ethiopic-halehame-ti-et",
  17402. "ethiopic-halehame-tig",
  17403. "ethiopic-numeric",
  17404. "ew-resize",
  17405. "expanded",
  17406. "extends",
  17407. "extra-condensed",
  17408. "extra-expanded",
  17409. "fantasy",
  17410. "fast",
  17411. "fill",
  17412. "fixed",
  17413. "flat",
  17414. "flex",
  17415. "footnotes",
  17416. "forwards",
  17417. "from",
  17418. "geometricPrecision",
  17419. "georgian",
  17420. "graytext",
  17421. "groove",
  17422. "gujarati",
  17423. "gurmukhi",
  17424. "hand",
  17425. "hangul",
  17426. "hangul-consonant",
  17427. "hebrew",
  17428. "help",
  17429. "hidden",
  17430. "hide",
  17431. "high",
  17432. "higher",
  17433. "highlight",
  17434. "highlighttext",
  17435. "hiragana",
  17436. "hiragana-iroha",
  17437. "horizontal",
  17438. "hsl",
  17439. "hsla",
  17440. "icon",
  17441. "ignore",
  17442. "inactiveborder",
  17443. "inactivecaption",
  17444. "inactivecaptiontext",
  17445. "infinite",
  17446. "infobackground",
  17447. "infotext",
  17448. "inherit",
  17449. "initial",
  17450. "inline",
  17451. "inline-axis",
  17452. "inline-block",
  17453. "inline-flex",
  17454. "inline-table",
  17455. "inset",
  17456. "inside",
  17457. "intrinsic",
  17458. "invert",
  17459. "italic",
  17460. "japanese-formal",
  17461. "japanese-informal",
  17462. "justify",
  17463. "kannada",
  17464. "katakana",
  17465. "katakana-iroha",
  17466. "keep-all",
  17467. "khmer",
  17468. "korean-hangul-formal",
  17469. "korean-hanja-formal",
  17470. "korean-hanja-informal",
  17471. "landscape",
  17472. "lao",
  17473. "large",
  17474. "larger",
  17475. "left",
  17476. "level",
  17477. "lighter",
  17478. "line-through",
  17479. "linear",
  17480. "linear-gradient",
  17481. "lines",
  17482. "list-item",
  17483. "listbox",
  17484. "listitem",
  17485. "local",
  17486. "logical",
  17487. "loud",
  17488. "lower",
  17489. "lower-alpha",
  17490. "lower-armenian",
  17491. "lower-greek",
  17492. "lower-hexadecimal",
  17493. "lower-latin",
  17494. "lower-norwegian",
  17495. "lower-roman",
  17496. "lowercase",
  17497. "ltr",
  17498. "malayalam",
  17499. "match",
  17500. "matrix",
  17501. "matrix3d",
  17502. "media-play-button",
  17503. "media-slider",
  17504. "media-sliderthumb",
  17505. "media-volume-slider",
  17506. "media-volume-sliderthumb",
  17507. "medium",
  17508. "menu",
  17509. "menulist",
  17510. "menulist-button",
  17511. "menutext",
  17512. "message-box",
  17513. "middle",
  17514. "min-intrinsic",
  17515. "mix",
  17516. "mongolian",
  17517. "monospace",
  17518. "move",
  17519. "multiple",
  17520. "myanmar",
  17521. "n-resize",
  17522. "narrower",
  17523. "ne-resize",
  17524. "nesw-resize",
  17525. "no-close-quote",
  17526. "no-drop",
  17527. "no-open-quote",
  17528. "no-repeat",
  17529. "none",
  17530. "normal",
  17531. "not-allowed",
  17532. "nowrap",
  17533. "ns-resize",
  17534. "numbers",
  17535. "numeric",
  17536. "nw-resize",
  17537. "nwse-resize",
  17538. "oblique",
  17539. "octal",
  17540. "open-quote",
  17541. "optimizeLegibility",
  17542. "optimizeSpeed",
  17543. "oriya",
  17544. "oromo",
  17545. "outset",
  17546. "outside",
  17547. "outside-shape",
  17548. "overlay",
  17549. "overline",
  17550. "padding",
  17551. "padding-box",
  17552. "painted",
  17553. "page",
  17554. "paused",
  17555. "persian",
  17556. "perspective",
  17557. "plus-darker",
  17558. "plus-lighter",
  17559. "pointer",
  17560. "polygon",
  17561. "portrait",
  17562. "pre",
  17563. "pre-line",
  17564. "pre-wrap",
  17565. "preserve-3d",
  17566. "progress",
  17567. "push-button",
  17568. "radial-gradient",
  17569. "radio",
  17570. "read-only",
  17571. "read-write",
  17572. "read-write-plaintext-only",
  17573. "rectangle",
  17574. "region",
  17575. "relative",
  17576. "repeat",
  17577. "repeating-linear-gradient",
  17578. "repeating-radial-gradient",
  17579. "repeating-conic-gradient",
  17580. "repeat-x",
  17581. "repeat-y",
  17582. "reset",
  17583. "reverse",
  17584. "rgb",
  17585. "rgba",
  17586. "ridge",
  17587. "right",
  17588. "rotate",
  17589. "rotate3d",
  17590. "rotateX",
  17591. "rotateY",
  17592. "rotateZ",
  17593. "round",
  17594. "row-resize",
  17595. "rtl",
  17596. "run-in",
  17597. "running",
  17598. "s-resize",
  17599. "sans-serif",
  17600. "scale",
  17601. "scale3d",
  17602. "scaleX",
  17603. "scaleY",
  17604. "scaleZ",
  17605. "scroll",
  17606. "scrollbar",
  17607. "scroll-position",
  17608. "se-resize",
  17609. "searchfield",
  17610. "searchfield-cancel-button",
  17611. "searchfield-decoration",
  17612. "searchfield-results-button",
  17613. "searchfield-results-decoration",
  17614. "semi-condensed",
  17615. "semi-expanded",
  17616. "separate",
  17617. "serif",
  17618. "show",
  17619. "sidama",
  17620. "simp-chinese-formal",
  17621. "simp-chinese-informal",
  17622. "single",
  17623. "skew",
  17624. "skewX",
  17625. "skewY",
  17626. "skip-white-space",
  17627. "slide",
  17628. "slider-horizontal",
  17629. "slider-vertical",
  17630. "sliderthumb-horizontal",
  17631. "sliderthumb-vertical",
  17632. "slow",
  17633. "small",
  17634. "small-caps",
  17635. "small-caption",
  17636. "smaller",
  17637. "solid",
  17638. "somali",
  17639. "source-atop",
  17640. "source-in",
  17641. "source-out",
  17642. "source-over",
  17643. "space",
  17644. "spell-out",
  17645. "square",
  17646. "square-button",
  17647. "standard",
  17648. "start",
  17649. "static",
  17650. "status-bar",
  17651. "stretch",
  17652. "stroke",
  17653. "sub",
  17654. "subpixel-antialiased",
  17655. "super",
  17656. "sw-resize",
  17657. "symbolic",
  17658. "symbols",
  17659. "table",
  17660. "table-caption",
  17661. "table-cell",
  17662. "table-column",
  17663. "table-column-group",
  17664. "table-footer-group",
  17665. "table-header-group",
  17666. "table-row",
  17667. "table-row-group",
  17668. "tamil",
  17669. "telugu",
  17670. "text",
  17671. "text-bottom",
  17672. "text-top",
  17673. "textarea",
  17674. "textfield",
  17675. "thai",
  17676. "thick",
  17677. "thin",
  17678. "threeddarkshadow",
  17679. "threedface",
  17680. "threedhighlight",
  17681. "threedlightshadow",
  17682. "threedshadow",
  17683. "tibetan",
  17684. "tigre",
  17685. "tigrinya-er",
  17686. "tigrinya-er-abegede",
  17687. "tigrinya-et",
  17688. "tigrinya-et-abegede",
  17689. "to",
  17690. "top",
  17691. "trad-chinese-formal",
  17692. "trad-chinese-informal",
  17693. "translate",
  17694. "translate3d",
  17695. "translateX",
  17696. "translateY",
  17697. "translateZ",
  17698. "transparent",
  17699. "ultra-condensed",
  17700. "ultra-expanded",
  17701. "underline",
  17702. "up",
  17703. "upper-alpha",
  17704. "upper-armenian",
  17705. "upper-greek",
  17706. "upper-hexadecimal",
  17707. "upper-latin",
  17708. "upper-norwegian",
  17709. "upper-roman",
  17710. "uppercase",
  17711. "urdu",
  17712. "url",
  17713. "var",
  17714. "vertical",
  17715. "vertical-text",
  17716. "visible",
  17717. "visibleFill",
  17718. "visiblePainted",
  17719. "visibleStroke",
  17720. "visual",
  17721. "w-resize",
  17722. "wait",
  17723. "wave",
  17724. "wider",
  17725. "window",
  17726. "windowframe",
  17727. "windowtext",
  17728. "words",
  17729. "x-large",
  17730. "x-small",
  17731. "xor",
  17732. "xx-large",
  17733. "xx-small",
  17734. "bicubic",
  17735. "optimizespeed",
  17736. "grayscale",
  17737. "row",
  17738. "row-reverse",
  17739. "wrap",
  17740. "wrap-reverse",
  17741. "column-reverse",
  17742. "flex-start",
  17743. "flex-end",
  17744. "space-between",
  17745. "space-around",
  17746. "unset"
  17747. ];
  17748. var wordOperatorKeywords_ = [
  17749. "in",
  17750. "and",
  17751. "or",
  17752. "not",
  17753. "is not",
  17754. "is a",
  17755. "is",
  17756. "isnt",
  17757. "defined",
  17758. "if unless"
  17759. ], blockKeywords_ = [
  17760. "for",
  17761. "if",
  17762. "else",
  17763. "unless",
  17764. "from",
  17765. "to"
  17766. ], commonAtoms_ = [
  17767. "null",
  17768. "true",
  17769. "false",
  17770. "href",
  17771. "title",
  17772. "type",
  17773. "not-allowed",
  17774. "readonly",
  17775. "disabled"
  17776. ], commonDef_ = [
  17777. "@font-face",
  17778. "@keyframes",
  17779. "@media",
  17780. "@viewport",
  17781. "@page",
  17782. "@host",
  17783. "@supports",
  17784. "@block",
  17785. "@css"
  17786. ];
  17787. var hintWords = tagKeywords_.concat(documentTypes_, mediaTypes_, mediaFeatures_, propertyKeywords_, nonStandardPropertyKeywords_, colorKeywords_, valueKeywords_, fontProperties_, wordOperatorKeywords_, blockKeywords_, commonAtoms_, commonDef_);
  17788. function wordRegexp(words) {
  17789. words = words.sort(function(a, b) {
  17790. return b > a;
  17791. });
  17792. return new RegExp("^((" + words.join(")|(") + "))\\b");
  17793. }
  17794. function keySet(array) {
  17795. var keys = {};
  17796. for (var i = 0; i < array.length; ++i) keys[array[i]] = true;
  17797. return keys;
  17798. }
  17799. function escapeRegExp(text) {
  17800. return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  17801. }
  17802. CodeMirror$1.registerHelper("hintWords", "stylus", hintWords);
  17803. CodeMirror$1.defineMIME("text/x-styl", "stylus");
  17804. });
  17805. });
  17806. var require_vue = __commonJSMin((exports, module) => {
  17807. (function(mod) {
  17808. "use strict";
  17809. if (typeof exports === "object" && typeof module === "object") mod(require_codemirror(), require_overlay(), require_xml(), require_javascript(), require_coffeescript(), require_css(), require_sass(), require_stylus(), require_pug(), require_handlebars());
  17810. else if (typeof define === "function" && define.amd) define([
  17811. "../../lib/codemirror",
  17812. "../../addon/mode/overlay",
  17813. "../xml/xml",
  17814. "../javascript/javascript",
  17815. "../coffeescript/coffeescript",
  17816. "../css/css",
  17817. "../sass/sass",
  17818. "../stylus/stylus",
  17819. "../pug/pug",
  17820. "../handlebars/handlebars"
  17821. ], mod);
  17822. else mod(CodeMirror);
  17823. })(function(CodeMirror$1) {
  17824. var tagLanguages = {
  17825. script: [
  17826. [
  17827. "lang",
  17828. /coffee(script)?/,
  17829. "coffeescript"
  17830. ],
  17831. [
  17832. "type",
  17833. /^(?:text|application)\/(?:x-)?coffee(?:script)?$/,
  17834. "coffeescript"
  17835. ],
  17836. [
  17837. "lang",
  17838. /^babel$/,
  17839. "javascript"
  17840. ],
  17841. [
  17842. "type",
  17843. /^text\/babel$/,
  17844. "javascript"
  17845. ],
  17846. [
  17847. "type",
  17848. /^text\/ecmascript-\d+$/,
  17849. "javascript"
  17850. ]
  17851. ],
  17852. style: [
  17853. [
  17854. "lang",
  17855. /^stylus$/i,
  17856. "stylus"
  17857. ],
  17858. [
  17859. "lang",
  17860. /^sass$/i,
  17861. "sass"
  17862. ],
  17863. [
  17864. "lang",
  17865. /^less$/i,
  17866. "text/x-less"
  17867. ],
  17868. [
  17869. "lang",
  17870. /^scss$/i,
  17871. "text/x-scss"
  17872. ],
  17873. [
  17874. "type",
  17875. /^(text\/)?(x-)?styl(us)?$/i,
  17876. "stylus"
  17877. ],
  17878. [
  17879. "type",
  17880. /^text\/sass/i,
  17881. "sass"
  17882. ],
  17883. [
  17884. "type",
  17885. /^(text\/)?(x-)?scss$/i,
  17886. "text/x-scss"
  17887. ],
  17888. [
  17889. "type",
  17890. /^(text\/)?(x-)?less$/i,
  17891. "text/x-less"
  17892. ]
  17893. ],
  17894. template: [
  17895. [
  17896. "lang",
  17897. /^vue-template$/i,
  17898. "vue"
  17899. ],
  17900. [
  17901. "lang",
  17902. /^pug$/i,
  17903. "pug"
  17904. ],
  17905. [
  17906. "lang",
  17907. /^handlebars$/i,
  17908. "handlebars"
  17909. ],
  17910. [
  17911. "type",
  17912. /^(text\/)?(x-)?pug$/i,
  17913. "pug"
  17914. ],
  17915. [
  17916. "type",
  17917. /^text\/x-handlebars-template$/i,
  17918. "handlebars"
  17919. ],
  17920. [
  17921. null,
  17922. null,
  17923. "vue-template"
  17924. ]
  17925. ]
  17926. };
  17927. CodeMirror$1.defineMode("vue-template", function(config, parserConfig) {
  17928. var mustacheOverlay = { token: function(stream) {
  17929. if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache";
  17930. while (stream.next() && !stream.match("{{", false));
  17931. return null;
  17932. } };
  17933. return CodeMirror$1.overlayMode(CodeMirror$1.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
  17934. });
  17935. CodeMirror$1.defineMode("vue", function(config) {
  17936. return CodeMirror$1.getMode(config, {
  17937. name: "htmlmixed",
  17938. tags: tagLanguages
  17939. });
  17940. }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
  17941. CodeMirror$1.defineMIME("script/x-vue", "vue");
  17942. CodeMirror$1.defineMIME("text/x-vue", "vue");
  17943. });
  17944. });
  17945. function useCodeMirror(container, input, options = {}) {
  17946. const cm = (0, import_codemirror.default)(container.value, {
  17947. theme: "vars",
  17948. value: input.value,
  17949. ...options
  17950. });
  17951. let skip = false;
  17952. cm.on("change", () => {
  17953. if (skip) {
  17954. skip = false;
  17955. return;
  17956. }
  17957. input.value = cm.getValue();
  17958. });
  17959. watch(input, (v) => {
  17960. if (v !== cm.getValue()) {
  17961. skip = true;
  17962. const selections = cm.listSelections();
  17963. cm.replaceRange(v, cm.posFromIndex(0), cm.posFromIndex(Number.POSITIVE_INFINITY));
  17964. cm.setSelections(selections);
  17965. cm.scrollTo(0, 0);
  17966. }
  17967. }, { immediate: true });
  17968. return cm;
  17969. }
  17970. function syncEditorScrolls(primary, target) {
  17971. const pInfo = primary.getScrollInfo();
  17972. const tInfo = target.getScrollInfo();
  17973. let x = (tInfo.width - tInfo.clientWidth) / (pInfo.width - pInfo.clientWidth) * pInfo.left;
  17974. let y = (tInfo.height - tInfo.clientHeight) / (pInfo.height - pInfo.clientHeight) * pInfo.top;
  17975. x = Number.isNaN(x) ? 0 : x;
  17976. y = Number.isNaN(y) ? 0 : y;
  17977. target.scrollTo(x, y);
  17978. }
  17979. function syncScrollListeners(cm1, cm2) {
  17980. let activeCm = 1;
  17981. cm1.getWrapperElement().addEventListener("mouseenter", () => {
  17982. activeCm = 1;
  17983. });
  17984. cm2.getWrapperElement().addEventListener("mouseenter", () => {
  17985. activeCm = 2;
  17986. });
  17987. cm1.on("scroll", (editor) => {
  17988. if (activeCm === 1) syncEditorScrolls(editor, cm2);
  17989. });
  17990. cm1.on("scrollCursorIntoView", (editor) => syncEditorScrolls(editor, cm2));
  17991. cm2.on("scroll", (editor) => {
  17992. if (activeCm === 2) syncEditorScrolls(editor, cm1);
  17993. });
  17994. cm2.on("scrollCursorIntoView", (editor) => syncEditorScrolls(editor, cm1));
  17995. }
  17996. /**
  17997. * @license
  17998. * Copyright 2019 Google LLC
  17999. * SPDX-License-Identifier: Apache-2.0
  18000. */
  18001. const proxyMarker = Symbol("Comlink.proxy");
  18002. const createEndpoint = Symbol("Comlink.endpoint");
  18003. const releaseProxy = Symbol("Comlink.releaseProxy");
  18004. const finalizer = Symbol("Comlink.finalizer");
  18005. const throwMarker = Symbol("Comlink.thrown");
  18006. const isObject = (val) => typeof val === "object" && val !== null || typeof val === "function";
  18007. /**
  18008. * Internal transfer handle to handle objects marked to proxy.
  18009. */
  18010. const proxyTransferHandler = {
  18011. canHandle: (val) => isObject(val) && val[proxyMarker],
  18012. serialize(obj) {
  18013. const { port1, port2 } = new MessageChannel();
  18014. expose(obj, port1);
  18015. return [port2, [port2]];
  18016. },
  18017. deserialize(port) {
  18018. port.start();
  18019. return wrap(port);
  18020. }
  18021. };
  18022. /**
  18023. * Internal transfer handler to handle thrown exceptions.
  18024. */
  18025. const throwTransferHandler = {
  18026. canHandle: (value) => isObject(value) && throwMarker in value,
  18027. serialize({ value }) {
  18028. let serialized;
  18029. if (value instanceof Error) serialized = {
  18030. isError: true,
  18031. value: {
  18032. message: value.message,
  18033. name: value.name,
  18034. stack: value.stack
  18035. }
  18036. };
  18037. else serialized = {
  18038. isError: false,
  18039. value
  18040. };
  18041. return [serialized, []];
  18042. },
  18043. deserialize(serialized) {
  18044. if (serialized.isError) throw Object.assign(new Error(serialized.value.message), serialized.value);
  18045. throw serialized.value;
  18046. }
  18047. };
  18048. /**
  18049. * Allows customizing the serialization of certain values.
  18050. */
  18051. const transferHandlers = new Map([["proxy", proxyTransferHandler], ["throw", throwTransferHandler]]);
  18052. function isAllowedOrigin(allowedOrigins, origin) {
  18053. for (const allowedOrigin of allowedOrigins) {
  18054. if (origin === allowedOrigin || allowedOrigin === "*") return true;
  18055. if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) return true;
  18056. }
  18057. return false;
  18058. }
  18059. function expose(obj, ep = globalThis, allowedOrigins = ["*"]) {
  18060. ep.addEventListener("message", function callback(ev) {
  18061. if (!ev || !ev.data) return;
  18062. if (!isAllowedOrigin(allowedOrigins, ev.origin)) {
  18063. console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);
  18064. return;
  18065. }
  18066. const { id, type, path } = Object.assign({ path: [] }, ev.data);
  18067. const argumentList = (ev.data.argumentList || []).map(fromWireValue);
  18068. let returnValue;
  18069. try {
  18070. const parent = path.slice(0, -1).reduce((obj$1, prop) => obj$1[prop], obj);
  18071. const rawValue = path.reduce((obj$1, prop) => obj$1[prop], obj);
  18072. switch (type) {
  18073. case "GET":
  18074. returnValue = rawValue;
  18075. break;
  18076. case "SET":
  18077. {
  18078. parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);
  18079. returnValue = true;
  18080. }
  18081. break;
  18082. case "APPLY":
  18083. returnValue = rawValue.apply(parent, argumentList);
  18084. break;
  18085. case "CONSTRUCT":
  18086. {
  18087. const value = new rawValue(...argumentList);
  18088. returnValue = proxy(value);
  18089. }
  18090. break;
  18091. case "ENDPOINT":
  18092. {
  18093. const { port1, port2 } = new MessageChannel();
  18094. expose(obj, port2);
  18095. returnValue = transfer(port1, [port1]);
  18096. }
  18097. break;
  18098. case "RELEASE":
  18099. returnValue = void 0;
  18100. break;
  18101. default: return;
  18102. }
  18103. } catch (value) {
  18104. returnValue = {
  18105. value,
  18106. [throwMarker]: 0
  18107. };
  18108. }
  18109. Promise.resolve(returnValue).catch((value) => {
  18110. return {
  18111. value,
  18112. [throwMarker]: 0
  18113. };
  18114. }).then((returnValue$1) => {
  18115. const [wireValue, transferables] = toWireValue(returnValue$1);
  18116. ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
  18117. if (type === "RELEASE") {
  18118. ep.removeEventListener("message", callback);
  18119. closeEndPoint(ep);
  18120. if (finalizer in obj && typeof obj[finalizer] === "function") obj[finalizer]();
  18121. }
  18122. }).catch((error) => {
  18123. const [wireValue, transferables] = toWireValue({
  18124. value: new TypeError("Unserializable return value"),
  18125. [throwMarker]: 0
  18126. });
  18127. ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
  18128. });
  18129. });
  18130. if (ep.start) ep.start();
  18131. }
  18132. function isMessagePort(endpoint) {
  18133. return endpoint.constructor.name === "MessagePort";
  18134. }
  18135. function closeEndPoint(endpoint) {
  18136. if (isMessagePort(endpoint)) endpoint.close();
  18137. }
  18138. function wrap(ep, target) {
  18139. const pendingListeners = new Map();
  18140. ep.addEventListener("message", function handleMessage(ev) {
  18141. const { data } = ev;
  18142. if (!data || !data.id) return;
  18143. const resolver = pendingListeners.get(data.id);
  18144. if (!resolver) return;
  18145. try {
  18146. resolver(data);
  18147. } finally {
  18148. pendingListeners.delete(data.id);
  18149. }
  18150. });
  18151. return createProxy(ep, pendingListeners, [], target);
  18152. }
  18153. function throwIfProxyReleased(isReleased) {
  18154. if (isReleased) throw new Error("Proxy has been released and is not useable");
  18155. }
  18156. function releaseEndpoint(ep) {
  18157. return requestResponseMessage(ep, new Map(), { type: "RELEASE" }).then(() => {
  18158. closeEndPoint(ep);
  18159. });
  18160. }
  18161. const proxyCounter = new WeakMap();
  18162. const proxyFinalizers = "FinalizationRegistry" in globalThis && new FinalizationRegistry((ep) => {
  18163. const newCount = (proxyCounter.get(ep) || 0) - 1;
  18164. proxyCounter.set(ep, newCount);
  18165. if (newCount === 0) releaseEndpoint(ep);
  18166. });
  18167. function registerProxy(proxy$1, ep) {
  18168. const newCount = (proxyCounter.get(ep) || 0) + 1;
  18169. proxyCounter.set(ep, newCount);
  18170. if (proxyFinalizers) proxyFinalizers.register(proxy$1, ep, proxy$1);
  18171. }
  18172. function unregisterProxy(proxy$1) {
  18173. if (proxyFinalizers) proxyFinalizers.unregister(proxy$1);
  18174. }
  18175. function createProxy(ep, pendingListeners, path = [], target = function() {}) {
  18176. let isProxyReleased = false;
  18177. const proxy$1 = new Proxy(target, {
  18178. get(_target, prop) {
  18179. throwIfProxyReleased(isProxyReleased);
  18180. if (prop === releaseProxy) return () => {
  18181. unregisterProxy(proxy$1);
  18182. releaseEndpoint(ep);
  18183. pendingListeners.clear();
  18184. isProxyReleased = true;
  18185. };
  18186. if (prop === "then") {
  18187. if (path.length === 0) return { then: () => proxy$1 };
  18188. const r = requestResponseMessage(ep, pendingListeners, {
  18189. type: "GET",
  18190. path: path.map((p) => p.toString())
  18191. }).then(fromWireValue);
  18192. return r.then.bind(r);
  18193. }
  18194. return createProxy(ep, pendingListeners, [...path, prop]);
  18195. },
  18196. set(_target, prop, rawValue) {
  18197. throwIfProxyReleased(isProxyReleased);
  18198. const [value, transferables] = toWireValue(rawValue);
  18199. return requestResponseMessage(ep, pendingListeners, {
  18200. type: "SET",
  18201. path: [...path, prop].map((p) => p.toString()),
  18202. value
  18203. }, transferables).then(fromWireValue);
  18204. },
  18205. apply(_target, _thisArg, rawArgumentList) {
  18206. throwIfProxyReleased(isProxyReleased);
  18207. const last = path[path.length - 1];
  18208. if (last === createEndpoint) return requestResponseMessage(ep, pendingListeners, { type: "ENDPOINT" }).then(fromWireValue);
  18209. if (last === "bind") return createProxy(ep, pendingListeners, path.slice(0, -1));
  18210. const [argumentList, transferables] = processArguments(rawArgumentList);
  18211. return requestResponseMessage(ep, pendingListeners, {
  18212. type: "APPLY",
  18213. path: path.map((p) => p.toString()),
  18214. argumentList
  18215. }, transferables).then(fromWireValue);
  18216. },
  18217. construct(_target, rawArgumentList) {
  18218. throwIfProxyReleased(isProxyReleased);
  18219. const [argumentList, transferables] = processArguments(rawArgumentList);
  18220. return requestResponseMessage(ep, pendingListeners, {
  18221. type: "CONSTRUCT",
  18222. path: path.map((p) => p.toString()),
  18223. argumentList
  18224. }, transferables).then(fromWireValue);
  18225. }
  18226. });
  18227. registerProxy(proxy$1, ep);
  18228. return proxy$1;
  18229. }
  18230. function myFlat(arr) {
  18231. return Array.prototype.concat.apply([], arr);
  18232. }
  18233. function processArguments(argumentList) {
  18234. const processed = argumentList.map(toWireValue);
  18235. return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];
  18236. }
  18237. const transferCache = new WeakMap();
  18238. function transfer(obj, transfers) {
  18239. transferCache.set(obj, transfers);
  18240. return obj;
  18241. }
  18242. function proxy(obj) {
  18243. return Object.assign(obj, { [proxyMarker]: true });
  18244. }
  18245. function toWireValue(value) {
  18246. for (const [name, handler] of transferHandlers) if (handler.canHandle(value)) {
  18247. const [serializedValue, transferables] = handler.serialize(value);
  18248. return [{
  18249. type: "HANDLER",
  18250. name,
  18251. value: serializedValue
  18252. }, transferables];
  18253. }
  18254. return [{
  18255. type: "RAW",
  18256. value
  18257. }, transferCache.get(value) || []];
  18258. }
  18259. function fromWireValue(value) {
  18260. switch (value.type) {
  18261. case "HANDLER": return transferHandlers.get(value.name).deserialize(value.value);
  18262. case "RAW": return value.value;
  18263. }
  18264. }
  18265. function requestResponseMessage(ep, pendingListeners, msg, transfers) {
  18266. return new Promise((resolve) => {
  18267. const id = generateUUID();
  18268. pendingListeners.set(id, resolve);
  18269. if (ep.start) ep.start();
  18270. ep.postMessage(Object.assign({ id }, msg), transfers);
  18271. });
  18272. }
  18273. function generateUUID() {
  18274. return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
  18275. }
  18276. let diffWorker;
  18277. async function calculateDiffWithWorker(left, right) {
  18278. if (!diffWorker) diffWorker = wrap(new Worker(new URL(
  18279. /* @vite-ignore */
  18280. "" + new URL("diff.worker-CMaeQEBs.js", import.meta.url).href,
  18281. "" + import.meta.url
  18282. ), { type: "module" }));
  18283. const result = await diffWorker.calculateDiff(left, right);
  18284. return result;
  18285. }
  18286. var DiffEditor_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
  18287. __name: "DiffEditor",
  18288. props: {
  18289. from: {},
  18290. to: {},
  18291. oneColumn: { type: Boolean },
  18292. diff: { type: Boolean }
  18293. },
  18294. setup(__props) {
  18295. const props = __props;
  18296. const options = useOptionsStore();
  18297. const { from, to } = toRefs(props);
  18298. const fromEl = useTemplateRef("fromEl");
  18299. const toEl = useTemplateRef("toEl");
  18300. let cm1;
  18301. let cm2;
  18302. onMounted(() => {
  18303. cm1 = useCodeMirror(fromEl, from, {
  18304. mode: "javascript",
  18305. readOnly: true,
  18306. lineNumbers: true
  18307. });
  18308. cm2 = useCodeMirror(toEl, to, {
  18309. mode: "javascript",
  18310. readOnly: true,
  18311. lineNumbers: true
  18312. });
  18313. syncScrollListeners(cm1, cm2);
  18314. watchEffect(() => {
  18315. cm1.setOption("lineWrapping", options.view.lineWrapping);
  18316. cm2.setOption("lineWrapping", options.view.lineWrapping);
  18317. });
  18318. watchEffect(async () => {
  18319. cm1.getWrapperElement().style.display = props.oneColumn ? "none" : "";
  18320. if (!props.oneColumn) {
  18321. await nextTick();
  18322. cm1.refresh();
  18323. syncEditorScrolls(cm2, cm1);
  18324. }
  18325. });
  18326. watchEffect(async () => {
  18327. const l = from.value;
  18328. const r = to.value;
  18329. const diffEnabled = props.diff;
  18330. cm1.setOption("mode", guessMode(l));
  18331. cm2.setOption("mode", guessMode(r));
  18332. await nextTick();
  18333. cm1.startOperation();
  18334. cm2.startOperation();
  18335. cm1.getAllMarks().forEach((i) => i.clear());
  18336. cm2.getAllMarks().forEach((i) => i.clear());
  18337. for (let i = 0; i < cm1.lineCount() + 2; i++) cm1.removeLineClass(i, "background", "diff-removed");
  18338. for (let i = 0; i < cm2.lineCount() + 2; i++) cm2.removeLineClass(i, "background", "diff-added");
  18339. if (diffEnabled && from.value) {
  18340. const changes = await calculateDiffWithWorker(l, r);
  18341. const addedLines = new Set();
  18342. const removedLines = new Set();
  18343. let indexL = 0;
  18344. let indexR = 0;
  18345. changes.forEach(([type, change]) => {
  18346. if (type === 1) {
  18347. const start = cm2.posFromIndex(indexR);
  18348. indexR += change.length;
  18349. const end = cm2.posFromIndex(indexR);
  18350. cm2.markText(start, end, { className: "diff-added-inline" });
  18351. for (let i = start.line; i <= end.line; i++) addedLines.add(i);
  18352. } else if (type === -1) {
  18353. const start = cm1.posFromIndex(indexL);
  18354. indexL += change.length;
  18355. const end = cm1.posFromIndex(indexL);
  18356. cm1.markText(start, end, { className: "diff-removed-inline" });
  18357. for (let i = start.line; i <= end.line; i++) removedLines.add(i);
  18358. } else {
  18359. indexL += change.length;
  18360. indexR += change.length;
  18361. }
  18362. });
  18363. Array.from(removedLines).forEach((i) => cm1.addLineClass(i, "background", "diff-removed"));
  18364. Array.from(addedLines).forEach((i) => cm2.addLineClass(i, "background", "diff-added"));
  18365. }
  18366. cm1.endOperation();
  18367. cm2.endOperation();
  18368. });
  18369. });
  18370. const leftPanelSize = computed(() => {
  18371. return props.oneColumn ? 0 : options.view.panelSizeDiff;
  18372. });
  18373. function onUpdate(size) {
  18374. cm1?.refresh();
  18375. cm2?.refresh();
  18376. if (props.oneColumn) return;
  18377. options.view.panelSizeDiff = size;
  18378. }
  18379. return (_ctx, _cache) => {
  18380. return openBlock(), createBlock(unref(Pe), { onResize: _cache[0] || (_cache[0] = ($event) => onUpdate($event.prevPane.size)) }, {
  18381. default: withCtx(() => [withDirectives(createVNode(unref(ge), {
  18382. "min-size": "10",
  18383. size: unref(leftPanelSize)
  18384. }, {
  18385. default: withCtx(() => [createBaseVNode("div", {
  18386. ref_key: "fromEl",
  18387. ref: fromEl,
  18388. class: "h-inherit"
  18389. }, null, 512)]),
  18390. _: 1
  18391. }, 8, ["size"]), [[vShow, !_ctx.oneColumn]]), createVNode(unref(ge), {
  18392. "min-size": "10",
  18393. size: 100 - unref(leftPanelSize)
  18394. }, {
  18395. default: withCtx(() => [createBaseVNode("div", {
  18396. ref_key: "toEl",
  18397. ref: toEl,
  18398. class: "h-inherit"
  18399. }, null, 512)]),
  18400. _: 1
  18401. }, 8, ["size"])]),
  18402. _: 1
  18403. });
  18404. };
  18405. }
  18406. });
  18407. var DiffEditor_default = DiffEditor_vue_vue_type_script_setup_true_lang_default;
  18408. const _hoisted_1$2 = {
  18409. "fw-600": "",
  18410. "dark:fw-unset": ""
  18411. };
  18412. const _hoisted_2$2 = {
  18413. op72: "",
  18414. "dark:op50": ""
  18415. };
  18416. const _hoisted_3$2 = {
  18417. key: 0,
  18418. op72: "",
  18419. "dark:op50": ""
  18420. };
  18421. var FilepathItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
  18422. __name: "FilepathItem",
  18423. props: {
  18424. filepath: {},
  18425. line: {},
  18426. column: {}
  18427. },
  18428. setup(__props) {
  18429. const props = __props;
  18430. async function openInEditor() {
  18431. await fetch(`/__open-in-editor?file=${encodeURI(props.filepath)}:${props.line}:${props.column}`);
  18432. }
  18433. const display = computed(() => {
  18434. const path = props.filepath.replace(/\\/g, "/");
  18435. if (props.filepath.includes("/node_modules/")) {
  18436. const match = path.match(/.*\/node_modules\/(@[^/]+\/[^/]+|[^/]+)(\/.*)?$/);
  18437. if (match) return [match[1], match[2]];
  18438. }
  18439. return [path];
  18440. });
  18441. return (_ctx, _cache) => {
  18442. return openBlock(), createElementBlock("button", {
  18443. flex: "~",
  18444. hover: "underline",
  18445. onClick: openInEditor
  18446. }, [
  18447. createBaseVNode("span", _hoisted_1$2, toDisplayString(unref(display)[0]), 1),
  18448. createBaseVNode("span", _hoisted_2$2, toDisplayString(unref(display)[1]), 1),
  18449. props.line != null && props.column != null ? (openBlock(), createElementBlock("span", _hoisted_3$2, ":" + toDisplayString(props.line) + ":" + toDisplayString(props.column), 1)) : createCommentVNode("", true)
  18450. ]);
  18451. };
  18452. }
  18453. });
  18454. var FilepathItem_default = FilepathItem_vue_vue_type_script_setup_true_lang_default;
  18455. const _hoisted_1$1 = {
  18456. "of-auto": "",
  18457. p4: "",
  18458. "font-mono": "",
  18459. flex: "~ col gap-4"
  18460. };
  18461. const _hoisted_2$1 = {
  18462. "text-sm": "",
  18463. "status-red": ""
  18464. };
  18465. const _hoisted_3$1 = {
  18466. class: "text-xs",
  18467. mt2: "",
  18468. grid: "~ cols-[max-content_1fr] gap-x-4 gap-y-1",
  18469. "font-mono": ""
  18470. };
  18471. const _hoisted_4$1 = {
  18472. "text-right": "",
  18473. op72: "",
  18474. "dark:op50": ""
  18475. };
  18476. const _hoisted_5$1 = { "ws-nowrap": "" };
  18477. var ErrorDisplay_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
  18478. __name: "ErrorDisplay",
  18479. props: { error: {} },
  18480. setup(__props) {
  18481. function normalizeFilename(filename) {
  18482. return (filename || "").replace(/^async\s+/, "").replace(/^file:\/\//, "");
  18483. }
  18484. return (_ctx, _cache) => {
  18485. const _component_FilepathItem = FilepathItem_default;
  18486. return openBlock(), createElementBlock("div", _hoisted_1$1, [
  18487. _cache[0] || (_cache[0] = createBaseVNode("div", {
  18488. "text-xl": "",
  18489. "status-red": "",
  18490. flex: "~ gap-2 items-center"
  18491. }, [createBaseVNode("div", { "i-carbon:warning-square": "" }), createTextVNode(" Error ")], -1)),
  18492. createBaseVNode("pre", _hoisted_2$1, toDisplayString(_ctx.error.message), 1),
  18493. _cache[1] || (_cache[1] = createBaseVNode("div", {
  18494. border: "t main",
  18495. "h-1px": "",
  18496. "w-full": ""
  18497. }, null, -1)),
  18498. createBaseVNode("div", _hoisted_3$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.error.stack, (item, idx) => {
  18499. return openBlock(), createElementBlock(Fragment, { key: idx }, [createBaseVNode("div", _hoisted_4$1, toDisplayString(item.functionName || `(anonymous)`), 1), createBaseVNode("div", _hoisted_5$1, [createVNode(_component_FilepathItem, {
  18500. filepath: normalizeFilename(item.fileName),
  18501. line: item.lineNumber,
  18502. column: item.columnNumber
  18503. }, null, 8, [
  18504. "filepath",
  18505. "line",
  18506. "column"
  18507. ])])], 64);
  18508. }), 128))])
  18509. ]);
  18510. };
  18511. }
  18512. });
  18513. var ErrorDisplay_default = ErrorDisplay_vue_vue_type_script_setup_true_lang_default;
  18514. const _queue = /* @__PURE__ */ new WeakMap();
  18515. function useRouteQuery(name, defaultValue, options = {}) {
  18516. const { mode = "replace", route = useRoute(), router = useRouter(), transform } = options;
  18517. let transformGet = (value) => value;
  18518. let transformSet = (value) => value;
  18519. if (typeof transform === "function") transformGet = transform;
  18520. else if (transform) {
  18521. if (transform.get) transformGet = transform.get;
  18522. if (transform.set) transformSet = transform.set;
  18523. }
  18524. if (!_queue.has(router)) _queue.set(router, /* @__PURE__ */ new Map());
  18525. const _queriesQueue = _queue.get(router);
  18526. let query = route.query[name];
  18527. tryOnScopeDispose(() => {
  18528. query = void 0;
  18529. });
  18530. let _trigger;
  18531. const proxy$1 = customRef((track, trigger) => {
  18532. _trigger = trigger;
  18533. return {
  18534. get() {
  18535. track();
  18536. return transformGet(query !== void 0 ? query : toValue(defaultValue));
  18537. },
  18538. set(v) {
  18539. v = transformSet(v);
  18540. if (query === v) return;
  18541. query = v === toValue(defaultValue) ? void 0 : v;
  18542. _queriesQueue.set(name, v === toValue(defaultValue) ? void 0 : v);
  18543. trigger();
  18544. nextTick(() => {
  18545. if (_queriesQueue.size === 0) return;
  18546. const newQueries = Object.fromEntries(_queriesQueue.entries());
  18547. _queriesQueue.clear();
  18548. const { params, query: query2, hash } = route;
  18549. router[toValue(mode)]({
  18550. params,
  18551. query: {
  18552. ...query2,
  18553. ...newQueries
  18554. },
  18555. hash
  18556. });
  18557. });
  18558. }
  18559. };
  18560. });
  18561. watch(() => route.query[name], (v) => {
  18562. if (query === transformGet(v)) return;
  18563. query = v;
  18564. _trigger();
  18565. }, { flush: "sync" });
  18566. return proxy$1;
  18567. }
  18568. const _hoisted_1 = {
  18569. title: "Dependencies",
  18570. flex: "~ gap-2 items-center",
  18571. "icon-btn": "",
  18572. "text-lg": ""
  18573. };
  18574. const _hoisted_2 = { "line-height-1em": "" };
  18575. const _hoisted_3 = {
  18576. "max-h-400": "",
  18577. "max-w-200": "",
  18578. "of-auto": ""
  18579. };
  18580. const _hoisted_4 = {
  18581. title: "Importers",
  18582. flex: "~ gap-2 items-center",
  18583. "icon-btn": "",
  18584. "text-lg": ""
  18585. };
  18586. const _hoisted_5 = { "line-height-1em": "" };
  18587. const _hoisted_6 = {
  18588. "max-h-400": "",
  18589. "max-w-200": "",
  18590. "of-auto": ""
  18591. };
  18592. const _hoisted_7 = ["title", "disabled"];
  18593. const _hoisted_8 = {
  18594. key: 0,
  18595. "i-carbon-side-panel-open": ""
  18596. };
  18597. const _hoisted_9 = {
  18598. key: 1,
  18599. "i-carbon-side-panel-close": ""
  18600. };
  18601. const _hoisted_10 = {
  18602. key: 0,
  18603. flex: "~ col gap-2 items-center justify-center",
  18604. "h-full": ""
  18605. };
  18606. const _hoisted_11 = {
  18607. flex: "~ gap2 items-center",
  18608. p2: "",
  18609. "tracking-widest": "",
  18610. class: "op75 dark:op50"
  18611. };
  18612. const _hoisted_12 = {
  18613. "flex-auto": "",
  18614. "text-center": "",
  18615. "text-sm": "",
  18616. uppercase: ""
  18617. };
  18618. const _hoisted_13 = ["onClick"];
  18619. const _hoisted_14 = {
  18620. "h-full": "",
  18621. "of-auto": ""
  18622. };
  18623. var module_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
  18624. __name: "module",
  18625. async setup(__props) {
  18626. let __temp, __restore;
  18627. function getModuleId(fullPath) {
  18628. if (!fullPath) return void 0;
  18629. return new URL(fullPath, "http://localhost").searchParams.get("id") || void 0;
  18630. }
  18631. const options = useOptionsStore();
  18632. const payload = usePayloadStore();
  18633. const route = useRoute();
  18634. const id = computed(() => getModuleId(route.fullPath));
  18635. const info = ref(id.value ? ([__temp, __restore] = withAsyncContext(() => rpc.getModuleTransformInfo(payload.query, id.value)), __temp = await __temp, __restore(), __temp) : void 0);
  18636. const mod = computed(() => payload.modules.find((m) => m.id === id.value));
  18637. const index = useRouteQuery("index");
  18638. const currentIndex = computed(() => (index.value != null ? +index.value : null) ?? (info.value?.transforms.length || 1) - 1);
  18639. const deps = computed(() => {
  18640. return mod.value?.deps.map((dep) => payload.modules.find((m) => m.id === dep)).filter(Boolean);
  18641. });
  18642. const importers = computed(() => {
  18643. return mod.value?.importers.map((dep) => payload.modules.find((m) => m.id === dep)).filter(Boolean);
  18644. });
  18645. const transforms = computed(() => {
  18646. const trs = info.value?.transforms;
  18647. if (!trs) return void 0;
  18648. let load = false;
  18649. return trs.map((tr, index$1) => ({
  18650. ...tr,
  18651. noChange: !!tr.result && index$1 > 0 && tr.result === trs[index$1 - 1]?.result,
  18652. load: tr.result && (load ? false : load = true),
  18653. index: index$1
  18654. }));
  18655. });
  18656. const filteredTransforms = computed(() => transforms.value?.filter((tr) => options.view.showBailout || tr.result));
  18657. async function refetch(clear = false) {
  18658. if (id.value) info.value = await rpc.getModuleTransformInfo(payload.query, id.value, clear);
  18659. }
  18660. onModuleUpdated.on(async () => {
  18661. await refetch(false);
  18662. });
  18663. watch(() => [id.value, payload.query], () => refetch(false), { deep: true });
  18664. const lastTransform = computed(() => transforms.value?.slice(0, currentIndex.value).reverse().find((tr) => tr.result));
  18665. const currentTransform = computed(() => transforms.value?.find((tr) => tr.index === currentIndex.value));
  18666. const from = computed(() => lastTransform.value?.result || "");
  18667. const to = computed(() => currentTransform.value?.result || from.value);
  18668. const sourcemaps = computed(() => {
  18669. let sourcemaps$1 = currentTransform.value?.sourcemaps;
  18670. if (!sourcemaps$1) return void 0;
  18671. if (typeof sourcemaps$1 === "string") sourcemaps$1 = safeJsonParse(sourcemaps$1);
  18672. if (!sourcemaps$1?.mappings) return;
  18673. if (sourcemaps$1 && !sourcemaps$1.sourcesContent?.filter(Boolean)?.length) sourcemaps$1.sourcesContent = [from.value];
  18674. if (sourcemaps$1 && !sourcemaps$1.sources?.filter(Boolean)?.length) sourcemaps$1.sources = ["index.js"];
  18675. return JSON.stringify(sourcemaps$1);
  18676. });
  18677. getHot().then((hot) => {
  18678. if (hot) hot.on("vite-plugin-inspect:update", ({ ids }) => {
  18679. if (id.value && ids.includes(id.value)) refetch();
  18680. });
  18681. });
  18682. return (_ctx, _cache) => {
  18683. const _component_RouterLink = resolveComponent("RouterLink");
  18684. const _component_ModuleId = ModuleId_default;
  18685. const _component_QuerySelector = QuerySelector_default;
  18686. const _component_ModuleList = ModuleList_default;
  18687. const _component_NavBar = NavBar_default;
  18688. const _component_Badge = Badge_default;
  18689. const _component_PluginName = PluginName_default;
  18690. const _component_DurationDisplay = DurationDisplay_default;
  18691. const _component_ErrorDisplay = ErrorDisplay_default;
  18692. const _component_DiffEditor = DiffEditor_default;
  18693. const _component_Container = Container_default;
  18694. return openBlock(), createElementBlock(Fragment, null, [createVNode(_component_NavBar, null, {
  18695. default: withCtx(() => [
  18696. createVNode(_component_RouterLink, {
  18697. "my-auto": "",
  18698. "icon-btn": "",
  18699. "outline-none": "",
  18700. to: "/"
  18701. }, {
  18702. default: withCtx(() => [..._cache[8] || (_cache[8] = [createBaseVNode("div", { "i-carbon-arrow-left": "" }, null, -1)])]),
  18703. _: 1
  18704. }),
  18705. unref(id) ? (openBlock(), createBlock(_component_ModuleId, {
  18706. key: 0,
  18707. id: unref(id)
  18708. }, null, 8, ["id"])) : createCommentVNode("", true),
  18709. _cache[13] || (_cache[13] = createBaseVNode("div", { "flex-auto": "" }, null, -1)),
  18710. createVNode(_component_QuerySelector),
  18711. unref(deps)?.length || unref(importers)?.length ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
  18712. _cache[11] || (_cache[11] = createBaseVNode("div", {
  18713. mx1: "",
  18714. "h-full": "",
  18715. "w-0": "",
  18716. border: "r main"
  18717. }, null, -1)),
  18718. unref(deps)?.length ? (openBlock(), createBlock(unref(kt), { key: 0 }, {
  18719. popper: withCtx(() => [createBaseVNode("div", _hoisted_3, [createVNode(_component_ModuleList, { modules: unref(deps) }, null, 8, ["modules"])])]),
  18720. default: withCtx(() => [createBaseVNode("button", _hoisted_1, [_cache[9] || (_cache[9] = createBaseVNode("span", { "i-carbon-downstream": "" }, null, -1)), createBaseVNode("span", _hoisted_2, toDisplayString(unref(deps).length), 1)])]),
  18721. _: 1
  18722. })) : createCommentVNode("", true),
  18723. unref(importers)?.length ? (openBlock(), createBlock(unref(kt), { key: 1 }, {
  18724. popper: withCtx(() => [createBaseVNode("div", _hoisted_6, [createVNode(_component_ModuleList, { modules: unref(importers) }, null, 8, ["modules"])])]),
  18725. default: withCtx(() => [createBaseVNode("button", _hoisted_4, [_cache[10] || (_cache[10] = createBaseVNode("span", { "i-carbon-upstream": "" }, null, -1)), createBaseVNode("span", _hoisted_5, toDisplayString(unref(importers).length), 1)])]),
  18726. _: 1
  18727. })) : createCommentVNode("", true)
  18728. ], 64)) : createCommentVNode("", true),
  18729. _cache[14] || (_cache[14] = createBaseVNode("div", {
  18730. mx1: "",
  18731. "h-full": "",
  18732. "w-0": "",
  18733. border: "r main"
  18734. }, null, -1)),
  18735. createBaseVNode("button", {
  18736. "icon-btn": "",
  18737. "text-lg": "",
  18738. title: unref(sourcemaps) ? "Inspect sourcemaps" : "Sourcemap is not available",
  18739. disabled: !unref(sourcemaps),
  18740. onClick: _cache[0] || (_cache[0] = ($event) => unref(inspectSourcemaps)({
  18741. code: unref(to),
  18742. sourcemaps: unref(sourcemaps)
  18743. }))
  18744. }, [createBaseVNode("span", {
  18745. "i-carbon-choropleth-map": "",
  18746. block: "",
  18747. class: normalizeClass(unref(sourcemaps) ? "opacity-100" : "opacity-25")
  18748. }, null, 2)], 8, _hoisted_7),
  18749. createBaseVNode("button", {
  18750. "icon-btn": "",
  18751. "text-lg": "",
  18752. title: "Line Wrapping",
  18753. onClick: _cache[1] || (_cache[1] = ($event) => unref(options).view.lineWrapping = !unref(options).view.lineWrapping)
  18754. }, [createBaseVNode("span", {
  18755. "i-carbon-text-wrap": "",
  18756. class: normalizeClass(unref(options).view.lineWrapping ? "opacity-100" : "opacity-25")
  18757. }, null, 2)]),
  18758. createBaseVNode("button", {
  18759. "icon-btn": "",
  18760. "text-lg": "",
  18761. title: "Toggle one column",
  18762. onClick: _cache[2] || (_cache[2] = ($event) => unref(options).view.showOneColumn = !unref(options).view.showOneColumn)
  18763. }, [unref(options).view.showOneColumn ? (openBlock(), createElementBlock("span", _hoisted_8)) : (openBlock(), createElementBlock("span", _hoisted_9))]),
  18764. createBaseVNode("button", {
  18765. class: "icon-btn text-lg",
  18766. title: "Toggle Diff",
  18767. onClick: _cache[3] || (_cache[3] = ($event) => unref(options).view.diff = !unref(options).view.diff)
  18768. }, [createBaseVNode("span", {
  18769. "i-carbon-compare": "",
  18770. class: normalizeClass(unref(options).view.diff ? "opacity-100" : "opacity-25")
  18771. }, null, 2)]),
  18772. !unref(payload).isStatic ? (openBlock(), createElementBlock("button", {
  18773. key: 2,
  18774. class: "icon-btn text-lg",
  18775. title: "Refetch",
  18776. onClick: _cache[4] || (_cache[4] = ($event) => refetch(true))
  18777. }, [..._cache[12] || (_cache[12] = [createBaseVNode("span", { "i-carbon-renew": "" }, null, -1)])])) : createCommentVNode("", true)
  18778. ]),
  18779. _: 1
  18780. }), !unref(info)?.transforms.length ? (openBlock(), createElementBlock("div", _hoisted_10, [createBaseVNode("div", null, [
  18781. _cache[15] || (_cache[15] = createTextVNode("No transform data for this module in the ", -1)),
  18782. createVNode(_component_Badge, {
  18783. text: unref(payload).query.env,
  18784. size: "none",
  18785. px1: "",
  18786. "py0.5": "",
  18787. "line-height-1em": ""
  18788. }, null, 8, ["text"]),
  18789. _cache[16] || (_cache[16] = createTextVNode(" env", -1))
  18790. ]), !unref(isStaticMode) ? (openBlock(), createElementBlock("button", {
  18791. key: 0,
  18792. rounded: "",
  18793. "bg-teal5": "",
  18794. px2: "",
  18795. py1: "",
  18796. "text-white": "",
  18797. onClick: _cache[5] || (_cache[5] = ($event) => refetch(true))
  18798. }, " Request the module ")) : createCommentVNode("", true)])) : unref(info) && unref(filteredTransforms) ? (openBlock(), createBlock(_component_Container, {
  18799. key: 1,
  18800. flex: "",
  18801. "overflow-hidden": ""
  18802. }, {
  18803. default: withCtx(() => [createVNode(unref(Pe), {
  18804. "h-full": "",
  18805. "of-hidden": "",
  18806. onResize: _cache[7] || (_cache[7] = ($event) => unref(options).view.panelSizeModule = $event.prevPane.size)
  18807. }, {
  18808. default: withCtx(() => [createVNode(unref(ge), {
  18809. size: unref(options).view.panelSizeModule,
  18810. "min-size": "10",
  18811. flex: "~ col",
  18812. "overflow-y-auto": ""
  18813. }, {
  18814. default: withCtx(() => [
  18815. createBaseVNode("div", _hoisted_11, [createBaseVNode("span", _hoisted_12, toDisplayString(unref(payload).query.env) + " TRANSFORM STACK", 1), createBaseVNode("button", {
  18816. class: "icon-btn",
  18817. title: "Toggle bailout plugins",
  18818. onClick: _cache[6] || (_cache[6] = ($event) => unref(options).view.showBailout = !unref(options).view.showBailout)
  18819. }, [createBaseVNode("div", { class: normalizeClass(unref(options).view.showBailout ? "opacity-100 i-carbon-view" : "opacity-75 i-carbon-view-off") }, null, 2)])]),
  18820. _cache[18] || (_cache[18] = createBaseVNode("div", { border: "b main" }, null, -1)),
  18821. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(filteredTransforms), (tr) => {
  18822. return openBlock(), createElementBlock("button", {
  18823. key: tr.index,
  18824. border: "b main",
  18825. flex: "~ gap-1 wrap",
  18826. "items-center": "",
  18827. "px-2": "",
  18828. "py-2": "",
  18829. "text-left": "",
  18830. "text-xs": "",
  18831. "font-mono": "",
  18832. class: normalizeClass(unref(currentIndex) === tr.index ? "bg-active" : tr.noChange || !tr.result ? "op75 saturate-50" : ""),
  18833. onClick: ($event) => index.value = tr.index.toString()
  18834. }, [
  18835. createBaseVNode("span", { class: normalizeClass(unref(currentIndex) !== tr.index && (tr.noChange || !tr.result) ? "" : "fw-600") }, [createVNode(_component_PluginName, { name: tr.name }, null, 8, ["name"])], 2),
  18836. !tr.result ? (openBlock(), createBlock(_component_Badge, {
  18837. key: 0,
  18838. text: "bailout",
  18839. "saturate-0": ""
  18840. })) : tr.noChange ? (openBlock(), createBlock(_component_Badge, {
  18841. key: 1,
  18842. text: "no change",
  18843. color: 20
  18844. })) : createCommentVNode("", true),
  18845. tr.load ? (openBlock(), createBlock(_component_Badge, {
  18846. key: 2,
  18847. text: "load"
  18848. })) : createCommentVNode("", true),
  18849. tr.order && tr.order !== "normal" ? (openBlock(), createBlock(_component_Badge, {
  18850. key: 3,
  18851. title: tr.order.includes("-") ? `Using object hooks ${tr.order}` : tr.order,
  18852. text: tr.order
  18853. }, null, 8, ["title", "text"])) : createCommentVNode("", true),
  18854. tr.error ? (openBlock(), createBlock(_component_Badge, {
  18855. key: 4,
  18856. text: "error"
  18857. }, {
  18858. default: withCtx(() => [_cache[17] || (_cache[17] = createBaseVNode("span", { "flex-auto": "" }, null, -1)), createVNode(_component_DurationDisplay, { duration: tr.end - tr.start }, null, 8, ["duration"])]),
  18859. _: 2
  18860. }, 1024)) : createCommentVNode("", true)
  18861. ], 10, _hoisted_13);
  18862. }), 128))
  18863. ]),
  18864. _: 1
  18865. }, 8, ["size"]), createVNode(unref(ge), { "min-size": "5" }, {
  18866. default: withCtx(() => [createBaseVNode("div", _hoisted_14, [unref(currentTransform)?.error ? (openBlock(), createBlock(_component_ErrorDisplay, {
  18867. key: `error-${unref(id)}`,
  18868. error: unref(currentTransform).error
  18869. }, null, 8, ["error"])) : (openBlock(), createBlock(_component_DiffEditor, {
  18870. key: 1,
  18871. "one-column": unref(options).view.showOneColumn || !!unref(currentTransform)?.error,
  18872. diff: unref(options).view.diff && !unref(currentTransform)?.error,
  18873. from: unref(from),
  18874. to: unref(to)
  18875. }, null, 8, [
  18876. "one-column",
  18877. "diff",
  18878. "from",
  18879. "to"
  18880. ]))])]),
  18881. _: 1
  18882. })]),
  18883. _: 1
  18884. })]),
  18885. _: 1
  18886. })) : createCommentVNode("", true)], 64);
  18887. };
  18888. }
  18889. });
  18890. var module_default = module_vue_vue_type_script_setup_true_lang_default;
  18891. export { module_default as default };