mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-12-12 06:15:27 +00:00
62485151c2
By default, this feature highlights unmatched brackets when the cursor is placed over it. This can be disabled, but seems useful so we'll add it as one of the new features in README and see how users react. Bug: T348019 Change-Id: Ie6af715e40aeb8217a7c4dfe0c6e6a3dcfa725d5
1 line
1.3 MiB
1 line
1.3 MiB
{"version":3,"file":"main.js","mappings":"mBAGA,MAAMA,EAIF,MAAAC,CAAOC,GACH,GAAIA,EAAM,GAAKA,EAAMC,KAAKC,OACtB,MAAM,IAAIC,WAAW,oBAAoBH,2BAA6BC,KAAKC,UAC/E,OAAOD,KAAKG,UAAUJ,GAAK,EAAO,EAAG,EACzC,CAIA,IAAAK,CAAKC,GACD,GAAIA,EAAI,GAAKA,EAAIL,KAAKM,MAClB,MAAM,IAAIJ,WAAW,uBAAuBG,QAAQL,KAAKM,uBAC7D,OAAON,KAAKG,UAAUE,GAAG,EAAM,EAAG,EACtC,CAIA,OAAAE,CAAQC,EAAMC,EAAIC,GACd,IAAIC,EAAQ,GAKZ,OAJAX,KAAKY,UAAU,EAAGJ,EAAMG,EAAO,GAC3BD,EAAKT,QACLS,EAAKE,UAAU,EAAGF,EAAKT,OAAQU,EAAO,GAC1CX,KAAKY,UAAUH,EAAIT,KAAKC,OAAQU,EAAO,GAChCE,EAASL,KAAKG,EAAOX,KAAKC,QAAUQ,EAAKD,GAAQE,EAAKT,OACjE,CAIA,MAAAa,CAAOC,GACH,OAAOf,KAAKO,QAAQP,KAAKC,OAAQD,KAAKC,OAAQc,EAClD,CAIA,KAAAC,CAAMR,EAAMC,EAAKT,KAAKC,QAClB,IAAIU,EAAQ,GAEZ,OADAX,KAAKY,UAAUJ,EAAMC,EAAIE,EAAO,GACzBE,EAASL,KAAKG,EAAOF,EAAKD,EACrC,CAIA,EAAAS,CAAGF,GACC,GAAIA,GAASf,KACT,OAAO,EACX,GAAIe,EAAMd,QAAUD,KAAKC,QAAUc,EAAMT,OAASN,K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AK2qB,KAAO,CAChB3qB,KAAKijF,yBAAyB,GAC9B,IAAMt6D,EAAY3oB,KAAK2qB,KAAKsY,UAAUta,UAChCgjB,EAAW3rC,KAAK2qB,KAAKghB,SAC3Bu3C,EAAqBljF,KAAK2qB,KAAKla,MAAMtB,UAAU3D,OAAQ,GAA/ChL,EAAI0iF,EAAJ1iF,KAAMC,EAAEyiF,EAAFziF,GACdg1D,EAAGz1D,KAAK2qB,KAAKtE,KAAMivC,cAAe,cAClCt1D,KAAKy0D,UAAUa,cAAe,cAC9Bt1D,KAAKy0D,UAAU3hD,IAAK9S,KAAK2qB,KAAKla,MAAM3F,IAAIxI,YACxCtC,KAAK2qB,KAAKgC,UACV3sB,KAAK2qB,KAAO,KACZ3qB,KAAKy0D,UAAU0uB,OACVx3C,GACJ3rC,KAAKy0D,UAAU2uB,QAAS,SAEzBpjF,KAAKy0D,UAAUl6C,KAAM,iBAAkBpY,KAAKuB,IAAKlD,EAAMC,IACrD8Z,KAAM,eAAgBpY,KAAKC,IAAK3B,EAAID,IACtCR,KAAKy0D,UAAU9rC,UAAWA,GAC1BksC,GAAGc,KAAM,yBAA0BC,MAAM,EAAO51D,KAAKy0D,UACtD,MACCz0D,KAAKwiF,mBACLxiF,KAAKijF,yBAAyB,GAE/BjjF,KAAKyiF,sBAELziF,KAAK0iF,SAAU,CACdC,OAAQ,WACRC,QAAS5iF,KAAKkhF,cACd2B,SAAS,EAETC,iBAA2E,IAAzD37E,SAAUsuD,EAAG,6BAA8B3iD,MAAO,KAAe,GAErF,M,qEAAC+tE,CAAA,CArLuC,CAASrsB,ICR7CK,GAAGwuB,OAAOC,SAAU,mBACxBzuB,GAAGc,KAAM,2BAA4B9vD,KAAK,SAAE4uD,GAC9B,IAAIosB,GAAsBpsB,GAClC8uB,2BACN,G","sources":["/w/extensions/CodeMirror/./node_modules/@codemirror/state/dist/index.js","/w/extensions/CodeMirror/./node_modules/style-mod/src/style-mod.js","/w/extensions/CodeMirror/./node_modules/w3c-keyname/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/view/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.js","/w/extensions/CodeMirror/./node_modules/@lezer/common/dist/index.js","/w/extensions/CodeMirror/./node_modules/@lezer/highlight/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/language/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/commands/dist/index.js","/w/extensions/CodeMirror/./node_modules/crelt/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/search/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.init.js"],"sourcesContent":["/**\nThe data structure for documents. @nonabstract\n*/\nclass Text {\n /**\n Get the line description around the given position.\n */\n lineAt(pos) {\n if (pos < 0 || pos > this.length)\n throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);\n return this.lineInner(pos, false, 1, 0);\n }\n /**\n Get the description for the given (1-based) line number.\n */\n line(n) {\n if (n < 1 || n > this.lines)\n throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);\n return this.lineInner(n, true, 1, 0);\n }\n /**\n Replace a range of the text with the given content.\n */\n replace(from, to, text) {\n let parts = [];\n this.decompose(0, from, parts, 2 /* Open.To */);\n if (text.length)\n text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);\n this.decompose(to, this.length, parts, 1 /* Open.From */);\n return TextNode.from(parts, this.length - (to - from) + text.length);\n }\n /**\n Append another document to this one.\n */\n append(other) {\n return this.replace(this.length, this.length, other);\n }\n /**\n Retrieve the text between the given points.\n */\n slice(from, to = this.length) {\n let parts = [];\n this.decompose(from, to, parts, 0);\n return TextNode.from(parts, to - from);\n }\n /**\n Test whether this text is equal to another instance.\n */\n eq(other) {\n if (other == this)\n return true;\n if (other.length != this.length || other.lines != this.lines)\n return false;\n let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);\n let a = new RawTextCursor(this), b = new RawTextCursor(other);\n for (let skip = start, pos = start;;) {\n a.next(skip);\n b.next(skip);\n skip = 0;\n if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)\n return false;\n pos += a.value.length;\n if (a.done || pos >= end)\n return true;\n }\n }\n /**\n Iterate over the text. When `dir` is `-1`, iteration happens\n from end to start. This will return lines and the breaks between\n them as separate strings.\n */\n iter(dir = 1) { return new RawTextCursor(this, dir); }\n /**\n Iterate over a range of the text. When `from` > `to`, the\n iterator will run in reverse.\n */\n iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }\n /**\n Return a cursor that iterates over the given range of lines,\n _without_ returning the line breaks between, and yielding empty\n strings for empty lines.\n \n When `from` and `to` are given, they should be 1-based line numbers.\n */\n iterLines(from, to) {\n let inner;\n if (from == null) {\n inner = this.iter();\n }\n else {\n if (to == null)\n to = this.lines + 1;\n let start = this.line(from).from;\n inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));\n }\n return new LineCursor(inner);\n }\n /**\n Return the document as a string, using newline characters to\n separate lines.\n */\n toString() { return this.sliceString(0); }\n /**\n Convert the document to an array of lines (which can be\n deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).\n */\n toJSON() {\n let lines = [];\n this.flatten(lines);\n return lines;\n }\n /**\n @internal\n */\n constructor() { }\n /**\n Create a `Text` instance for the given array of lines.\n */\n static of(text) {\n if (text.length == 0)\n throw new RangeError(\"A document must have at least one line\");\n if (text.length == 1 && !text[0])\n return Text.empty;\n return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));\n }\n}\n// Leaves store an array of line strings. There are always line breaks\n// between these strings. Leaves are limited in size and have to be\n// contained in TextNode instances for bigger documents.\nclass TextLeaf extends Text {\n constructor(text, length = textLength(text)) {\n super();\n this.text = text;\n this.length = length;\n }\n get lines() { return this.text.length; }\n get children() { return null; }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let string = this.text[i], end = offset + string.length;\n if ((isLine ? line : end) >= target)\n return new Line(offset, end, line, string);\n offset = end + 1;\n line++;\n }\n }\n decompose(from, to, target, open) {\n let text = from <= 0 && to >= this.length ? this\n : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));\n if (open & 1 /* Open.From */) {\n let prev = target.pop();\n let joined = appendText(text.text, prev.text.slice(), 0, text.length);\n if (joined.length <= 32 /* Tree.Branch */) {\n target.push(new TextLeaf(joined, prev.length + text.length));\n }\n else {\n let mid = joined.length >> 1;\n target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));\n }\n }\n else {\n target.push(text);\n }\n }\n replace(from, to, text) {\n if (!(text instanceof TextLeaf))\n return super.replace(from, to, text);\n let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);\n let newLen = this.length + text.length - (to - from);\n if (lines.length <= 32 /* Tree.Branch */)\n return new TextLeaf(lines, newLen);\n return TextNode.from(TextLeaf.split(lines, []), newLen);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {\n let line = this.text[i], end = pos + line.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += line.slice(Math.max(0, from - pos), to - pos);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let line of this.text)\n target.push(line);\n }\n scanIdentical() { return 0; }\n static split(text, target) {\n let part = [], len = -1;\n for (let line of text) {\n part.push(line);\n len += line.length + 1;\n if (part.length == 32 /* Tree.Branch */) {\n target.push(new TextLeaf(part, len));\n part = [];\n len = -1;\n }\n }\n if (len > -1)\n target.push(new TextLeaf(part, len));\n return target;\n }\n}\n// Nodes provide the tree structure of the `Text` type. They store a\n// number of other nodes or leaves, taking care to balance themselves\n// on changes. There are implied line breaks _between_ the children of\n// a node (but not before the first or after the last child).\nclass TextNode extends Text {\n constructor(children, length) {\n super();\n this.children = children;\n this.length = length;\n this.lines = 0;\n for (let child of children)\n this.lines += child.lines;\n }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;\n if ((isLine ? endLine : end) >= target)\n return child.lineInner(target, isLine, line, offset);\n offset = end + 1;\n line = endLine + 1;\n }\n }\n decompose(from, to, target, open) {\n for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (from <= end && to >= pos) {\n let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));\n if (pos >= from && end <= to && !childOpen)\n target.push(child);\n else\n child.decompose(from - pos, to - pos, target, childOpen);\n }\n pos = end + 1;\n }\n }\n replace(from, to, text) {\n if (text.lines < this.lines)\n for (let i = 0, pos = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n // Fast path: if the change only affects one child and the\n // child's size remains in the acceptable range, only update\n // that child\n if (from >= pos && to <= end) {\n let updated = child.replace(from - pos, to - pos, text);\n let totalLines = this.lines - child.lines + updated.lines;\n if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&\n updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {\n let copy = this.children.slice();\n copy[i] = updated;\n return new TextNode(copy, this.length - (to - from) + text.length);\n }\n return super.replace(pos, end, updated);\n }\n pos = end + 1;\n }\n return super.replace(from, to, text);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += child.sliceString(from - pos, to - pos, lineSep);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let child of this.children)\n child.flatten(target);\n }\n scanIdentical(other, dir) {\n if (!(other instanceof TextNode))\n return 0;\n let length = 0;\n let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]\n : [this.children.length - 1, other.children.length - 1, -1, -1];\n for (;; iA += dir, iB += dir) {\n if (iA == eA || iB == eB)\n return length;\n let chA = this.children[iA], chB = other.children[iB];\n if (chA != chB)\n return length + chA.scanIdentical(chB, dir);\n length += chA.length + 1;\n }\n }\n static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {\n let lines = 0;\n for (let ch of children)\n lines += ch.lines;\n if (lines < 32 /* Tree.Branch */) {\n let flat = [];\n for (let ch of children)\n ch.flatten(flat);\n return new TextLeaf(flat, length);\n }\n let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;\n let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];\n function add(child) {\n let last;\n if (child.lines > maxChunk && child instanceof TextNode) {\n for (let node of child.children)\n add(node);\n }\n else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {\n flush();\n chunked.push(child);\n }\n else if (child instanceof TextLeaf && currentLines &&\n (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&\n child.lines + last.lines <= 32 /* Tree.Branch */) {\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);\n }\n else {\n if (currentLines + child.lines > chunk)\n flush();\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk.push(child);\n }\n }\n function flush() {\n if (currentLines == 0)\n return;\n chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));\n currentLen = -1;\n currentLines = currentChunk.length = 0;\n }\n for (let child of children)\n add(child);\n flush();\n return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);\n }\n}\nText.empty = /*@__PURE__*/new TextLeaf([\"\"], 0);\nfunction textLength(text) {\n let length = -1;\n for (let line of text)\n length += line.length + 1;\n return length;\n}\nfunction appendText(text, target, from = 0, to = 1e9) {\n for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {\n let line = text[i], end = pos + line.length;\n if (end >= from) {\n if (end > to)\n line = line.slice(0, to - pos);\n if (pos < from)\n line = line.slice(from - pos);\n if (first) {\n target[target.length - 1] += line;\n first = false;\n }\n else\n target.push(line);\n }\n pos = end + 1;\n }\n return target;\n}\nfunction sliceText(text, from, to) {\n return appendText(text, [\"\"], from, to);\n}\nclass RawTextCursor {\n constructor(text, dir = 1) {\n this.dir = dir;\n this.done = false;\n this.lineBreak = false;\n this.value = \"\";\n this.nodes = [text];\n this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];\n }\n nextInner(skip, dir) {\n this.done = this.lineBreak = false;\n for (;;) {\n let last = this.nodes.length - 1;\n let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;\n let size = top instanceof TextLeaf ? top.text.length : top.children.length;\n if (offset == (dir > 0 ? size : 0)) {\n if (last == 0) {\n this.done = true;\n this.value = \"\";\n return this;\n }\n if (dir > 0)\n this.offsets[last - 1]++;\n this.nodes.pop();\n this.offsets.pop();\n }\n else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {\n this.offsets[last] += dir;\n if (skip == 0) {\n this.lineBreak = true;\n this.value = \"\\n\";\n return this;\n }\n skip--;\n }\n else if (top instanceof TextLeaf) {\n // Move to the next string\n let next = top.text[offset + (dir < 0 ? -1 : 0)];\n this.offsets[last] += dir;\n if (next.length > Math.max(0, skip)) {\n this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);\n return this;\n }\n skip -= next.length;\n }\n else {\n let next = top.children[offset + (dir < 0 ? -1 : 0)];\n if (skip > next.length) {\n skip -= next.length;\n this.offsets[last] += dir;\n }\n else {\n if (dir < 0)\n this.offsets[last]--;\n this.nodes.push(next);\n this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);\n }\n }\n }\n }\n next(skip = 0) {\n if (skip < 0) {\n this.nextInner(-skip, (-this.dir));\n skip = this.value.length;\n }\n return this.nextInner(skip, this.dir);\n }\n}\nclass PartialTextCursor {\n constructor(text, start, end) {\n this.value = \"\";\n this.done = false;\n this.cursor = new RawTextCursor(text, start > end ? -1 : 1);\n this.pos = start > end ? text.length : 0;\n this.from = Math.min(start, end);\n this.to = Math.max(start, end);\n }\n nextInner(skip, dir) {\n if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {\n this.value = \"\";\n this.done = true;\n return this;\n }\n skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);\n let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;\n if (skip > limit)\n skip = limit;\n limit -= skip;\n let { value } = this.cursor.next(skip);\n this.pos += (value.length + skip) * dir;\n this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);\n this.done = !this.value;\n return this;\n }\n next(skip = 0) {\n if (skip < 0)\n skip = Math.max(skip, this.from - this.pos);\n else if (skip > 0)\n skip = Math.min(skip, this.to - this.pos);\n return this.nextInner(skip, this.cursor.dir);\n }\n get lineBreak() { return this.cursor.lineBreak && this.value != \"\"; }\n}\nclass LineCursor {\n constructor(inner) {\n this.inner = inner;\n this.afterBreak = true;\n this.value = \"\";\n this.done = false;\n }\n next(skip = 0) {\n let { done, lineBreak, value } = this.inner.next(skip);\n if (done) {\n this.done = true;\n this.value = \"\";\n }\n else if (lineBreak) {\n if (this.afterBreak) {\n this.value = \"\";\n }\n else {\n this.afterBreak = true;\n this.next();\n }\n }\n else {\n this.value = value;\n this.afterBreak = false;\n }\n return this;\n }\n get lineBreak() { return false; }\n}\nif (typeof Symbol != \"undefined\") {\n Text.prototype[Symbol.iterator] = function () { return this.iter(); };\n RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =\n LineCursor.prototype[Symbol.iterator] = function () { return this; };\n}\n/**\nThis type describes a line in the document. It is created\non-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).\n*/\nclass Line {\n /**\n @internal\n */\n constructor(\n /**\n The position of the start of the line.\n */\n from, \n /**\n The position at the end of the line (_before_ the line break,\n or at the end of document for the last line).\n */\n to, \n /**\n This line's line number (1-based).\n */\n number, \n /**\n The line's content.\n */\n text) {\n this.from = from;\n this.to = to;\n this.number = number;\n this.text = text;\n }\n /**\n The length of the line (not including any line break after it).\n */\n get length() { return this.to - this.from; }\n}\n\n// Compressed representation of the Grapheme_Cluster_Break=Extend\n// information from\n// http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.\n// Each pair of elements represents a range, as an offet from the\n// previous range and a length. Numbers are in base-36, with the empty\n// string being a shorthand for 1.\nlet extend = /*@__PURE__*/\"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o\".split(\",\").map(s => s ? parseInt(s, 36) : 1);\n// Convert offsets into absolute values\nfor (let i = 1; i < extend.length; i++)\n extend[i] += extend[i - 1];\nfunction isExtendingChar(code) {\n for (let i = 1; i < extend.length; i += 2)\n if (extend[i] > code)\n return extend[i - 1] <= code;\n return false;\n}\nfunction isRegionalIndicator(code) {\n return code >= 0x1F1E6 && code <= 0x1F1FF;\n}\nconst ZWJ = 0x200d;\n/**\nReturns a next grapheme cluster break _after_ (not equal to)\n`pos`, if `forward` is true, or before otherwise. Returns `pos`\nitself if no further cluster break is available in the string.\nMoves across surrogate pairs, extending characters (when\n`includeExtending` is true), characters joined with zero-width\njoiners, and flag emoji.\n*/\nfunction findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending);\n}\nfunction nextClusterBreak(str, pos, includeExtending) {\n if (pos == str.length)\n return pos;\n // If pos is in the middle of a surrogate pair, move to its start\n if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1)))\n pos--;\n let prev = codePointAt(str, pos);\n pos += codePointSize(prev);\n while (pos < str.length) {\n let next = codePointAt(str, pos);\n if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {\n pos += codePointSize(next);\n prev = next;\n }\n else if (isRegionalIndicator(next)) {\n let countBefore = 0, i = pos - 2;\n while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) {\n countBefore++;\n i -= 2;\n }\n if (countBefore % 2 == 0)\n break;\n else\n pos += 2;\n }\n else {\n break;\n }\n }\n return pos;\n}\nfunction prevClusterBreak(str, pos, includeExtending) {\n while (pos > 0) {\n let found = nextClusterBreak(str, pos - 2, includeExtending);\n if (found < pos)\n return found;\n pos--;\n }\n return 0;\n}\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }\n/**\nFind the code point at the given position in a string (like the\n[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)\nstring method).\n*/\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos);\n if (!surrogateHigh(code0) || pos + 1 == str.length)\n return code0;\n let code1 = str.charCodeAt(pos + 1);\n if (!surrogateLow(code1))\n return code0;\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;\n}\n/**\nGiven a Unicode codepoint, return the JavaScript string that\nrespresents it (like\n[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).\n*/\nfunction fromCodePoint(code) {\n if (code <= 0xffff)\n return String.fromCharCode(code);\n code -= 0x10000;\n return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);\n}\n/**\nThe amount of positions a character takes up a JavaScript string.\n*/\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2; }\n\nconst DefaultSplit = /\\r\\n?|\\n/;\n/**\nDistinguishes different ways in which positions can be mapped.\n*/\nvar MapMode = /*@__PURE__*/(function (MapMode) {\n /**\n Map a position to a valid new position, even when its context\n was deleted.\n */\n MapMode[MapMode[\"Simple\"] = 0] = \"Simple\";\n /**\n Return null if deletion happens across the position.\n */\n MapMode[MapMode[\"TrackDel\"] = 1] = \"TrackDel\";\n /**\n Return null if the character _before_ the position is deleted.\n */\n MapMode[MapMode[\"TrackBefore\"] = 2] = \"TrackBefore\";\n /**\n Return null if the character _after_ the position is deleted.\n */\n MapMode[MapMode[\"TrackAfter\"] = 3] = \"TrackAfter\";\nreturn MapMode})(MapMode || (MapMode = {}));\n/**\nA change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)\nthat doesn't store the inserted text. As such, it can't be\napplied, but is cheaper to store and manipulate.\n*/\nclass ChangeDesc {\n // Sections are encoded as pairs of integers. The first is the\n // length in the current document, and the second is -1 for\n // unaffected sections, and the length of the replacement content\n // otherwise. So an insertion would be (0, n>0), a deletion (n>0,\n // 0), and a replacement two positive numbers.\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n sections) {\n this.sections = sections;\n }\n /**\n The length of the document before the change.\n */\n get length() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2)\n result += this.sections[i];\n return result;\n }\n /**\n The length of the document after the change.\n */\n get newLength() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2) {\n let ins = this.sections[i + 1];\n result += ins < 0 ? this.sections[i] : ins;\n }\n return result;\n }\n /**\n False when there are actual changes in this set.\n */\n get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }\n /**\n Iterate over the unchanged parts left by these changes. `posA`\n provides the position of the range in the old document, `posB`\n the new position in the changed document.\n */\n iterGaps(f) {\n for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0) {\n f(posA, posB, len);\n posB += len;\n }\n else {\n posB += ins;\n }\n posA += len;\n }\n }\n /**\n Iterate over the ranges changed by these changes. (See\n [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a\n variant that also provides you with the inserted text.)\n `fromA`/`toA` provides the extent of the change in the starting\n document, `fromB`/`toB` the extent of the replacement in the\n changed document.\n \n When `individual` is true, adjacent changes (which are kept\n separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are\n reported separately.\n */\n iterChangedRanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a description of the inverted form of these changes.\n */\n get invertedDesc() {\n let sections = [];\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0)\n sections.push(len, ins);\n else\n sections.push(ins, len);\n }\n return new ChangeDesc(sections);\n }\n /**\n Compute the combined effect of applying another set of changes\n after this one. The length of the document after this set should\n match the length before `other`.\n */\n composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }\n /**\n Map this description, which should start with the same document\n as `other`, over another set of changes, so that it can be\n applied after it. When `before` is true, map as if the changes\n in `other` happened before the ones in `this`.\n */\n mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }\n mapPos(pos, assoc = -1, mode = MapMode.Simple) {\n let posA = 0, posB = 0;\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;\n if (ins < 0) {\n if (endA > pos)\n return posB + (pos - posA);\n posB += len;\n }\n else {\n if (mode != MapMode.Simple && endA >= pos &&\n (mode == MapMode.TrackDel && posA < pos && endA > pos ||\n mode == MapMode.TrackBefore && posA < pos ||\n mode == MapMode.TrackAfter && endA > pos))\n return null;\n if (endA > pos || endA == pos && assoc < 0 && !len)\n return pos == posA || assoc < 0 ? posB : posB + ins;\n posB += ins;\n }\n posA = endA;\n }\n if (pos > posA)\n throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);\n return posB;\n }\n /**\n Check whether these changes touch a given range. When one of the\n changes entirely covers the range, the string `\"cover\"` is\n returned.\n */\n touchesRange(from, to = from) {\n for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {\n let len = this.sections[i++], ins = this.sections[i++], end = pos + len;\n if (ins >= 0 && pos <= to && end >= from)\n return pos < from && end > to ? \"cover\" : true;\n pos = end;\n }\n return false;\n }\n /**\n @internal\n */\n toString() {\n let result = \"\";\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n result += (result ? \" \" : \"\") + len + (ins >= 0 ? \":\" + ins : \"\");\n }\n return result;\n }\n /**\n Serialize this change desc to a JSON-representable value.\n */\n toJSON() { return this.sections; }\n /**\n Create a change desc from its JSON representation (as produced\n by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != \"number\"))\n throw new RangeError(\"Invalid JSON representation of ChangeDesc\");\n return new ChangeDesc(json);\n }\n /**\n @internal\n */\n static create(sections) { return new ChangeDesc(sections); }\n}\n/**\nA change set represents a group of modifications to a document. It\nstores the document length, and can only be applied to documents\nwith exactly that length.\n*/\nclass ChangeSet extends ChangeDesc {\n constructor(sections, \n /**\n @internal\n */\n inserted) {\n super(sections);\n this.inserted = inserted;\n }\n /**\n Apply the changes to a document, returning the modified\n document.\n */\n apply(doc) {\n if (this.length != doc.length)\n throw new RangeError(\"Applying change set to a document with the wrong length\");\n iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);\n return doc;\n }\n mapDesc(other, before = false) { return mapSet(this, other, before, true); }\n /**\n Given the document as it existed _before_ the changes, return a\n change set that represents the inverse of this set, which could\n be used to go from the document created by the changes back to\n the document as it existed before the changes.\n */\n invert(doc) {\n let sections = this.sections.slice(), inserted = [];\n for (let i = 0, pos = 0; i < sections.length; i += 2) {\n let len = sections[i], ins = sections[i + 1];\n if (ins >= 0) {\n sections[i] = ins;\n sections[i + 1] = len;\n let index = i >> 1;\n while (inserted.length < index)\n inserted.push(Text.empty);\n inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);\n }\n pos += len;\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n Combine two subsequent change sets into a single set. `other`\n must start in the document produced by `this`. If `this` goes\n `docA` → `docB` and `other` represents `docB` → `docC`, the\n returned value will represent the change `docA` → `docC`.\n */\n compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }\n /**\n Given another change set starting in the same document, maps this\n change set over the other, producing a new change set that can be\n applied to the document produced by applying `other`. When\n `before` is `true`, order changes as if `this` comes before\n `other`, otherwise (the default) treat `other` as coming first.\n \n Given two changes `A` and `B`, `A.compose(B.map(A))` and\n `B.compose(A.map(B, true))` will produce the same document. This\n provides a basic form of [operational\n transformation](https://en.wikipedia.org/wiki/Operational_transformation),\n and can be used for collaborative editing.\n */\n map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }\n /**\n Iterate over the changed ranges in the document, calling `f` for\n each, with the range in the original document (`fromA`-`toA`)\n and the range that replaces it in the new document\n (`fromB`-`toB`).\n \n When `individual` is true, adjacent changes are reported\n separately.\n */\n iterChanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change\n set.\n */\n get desc() { return ChangeDesc.create(this.sections); }\n /**\n @internal\n */\n filter(ranges) {\n let resultSections = [], resultInserted = [], filteredSections = [];\n let iter = new SectionIter(this);\n done: for (let i = 0, pos = 0;;) {\n let next = i == ranges.length ? 1e9 : ranges[i++];\n while (pos < next || pos == next && iter.len == 0) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, next - pos);\n addSection(filteredSections, len, -1);\n let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;\n addSection(resultSections, len, ins);\n if (ins > 0)\n addInsert(resultInserted, resultSections, iter.text);\n iter.forward(len);\n pos += len;\n }\n let end = ranges[i++];\n while (pos < end) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, end - pos);\n addSection(resultSections, len, -1);\n addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);\n iter.forward(len);\n pos += len;\n }\n }\n return { changes: new ChangeSet(resultSections, resultInserted),\n filtered: ChangeDesc.create(filteredSections) };\n }\n /**\n Serialize this change set to a JSON-representable value.\n */\n toJSON() {\n let parts = [];\n for (let i = 0; i < this.sections.length; i += 2) {\n let len = this.sections[i], ins = this.sections[i + 1];\n if (ins < 0)\n parts.push(len);\n else if (ins == 0)\n parts.push([len]);\n else\n parts.push([len].concat(this.inserted[i >> 1].toJSON()));\n }\n return parts;\n }\n /**\n Create a change set for the given changes, for a document of the\n given length, using `lineSep` as line separator.\n */\n static of(changes, length, lineSep) {\n let sections = [], inserted = [], pos = 0;\n let total = null;\n function flush(force = false) {\n if (!force && !sections.length)\n return;\n if (pos < length)\n addSection(sections, length - pos, -1);\n let set = new ChangeSet(sections, inserted);\n total = total ? total.compose(set.map(total)) : set;\n sections = [];\n inserted = [];\n pos = 0;\n }\n function process(spec) {\n if (Array.isArray(spec)) {\n for (let sub of spec)\n process(sub);\n }\n else if (spec instanceof ChangeSet) {\n if (spec.length != length)\n throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);\n flush();\n total = total ? total.compose(spec.map(total)) : spec;\n }\n else {\n let { from, to = from, insert } = spec;\n if (from > to || from < 0 || to > length)\n throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);\n let insText = !insert ? Text.empty : typeof insert == \"string\" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;\n let insLen = insText.length;\n if (from == to && insLen == 0)\n return;\n if (from < pos)\n flush();\n if (from > pos)\n addSection(sections, from - pos, -1);\n addSection(sections, to - from, insLen);\n addInsert(inserted, sections, insText);\n pos = to;\n }\n }\n process(changes);\n flush(!total);\n return total;\n }\n /**\n Create an empty changeset of the given length.\n */\n static empty(length) {\n return new ChangeSet(length ? [length, -1] : [], []);\n }\n /**\n Create a changeset from its JSON representation (as produced by\n [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json))\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n let sections = [], inserted = [];\n for (let i = 0; i < json.length; i++) {\n let part = json[i];\n if (typeof part == \"number\") {\n sections.push(part, -1);\n }\n else if (!Array.isArray(part) || typeof part[0] != \"number\" || part.some((e, i) => i && typeof e != \"string\")) {\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n }\n else if (part.length == 1) {\n sections.push(part[0], 0);\n }\n else {\n while (inserted.length < i)\n inserted.push(Text.empty);\n inserted[i] = Text.of(part.slice(1));\n sections.push(part[0], inserted[i].length);\n }\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n @internal\n */\n static createSet(sections, inserted) {\n return new ChangeSet(sections, inserted);\n }\n}\nfunction addSection(sections, len, ins, forceJoin = false) {\n if (len == 0 && ins <= 0)\n return;\n let last = sections.length - 2;\n if (last >= 0 && ins <= 0 && ins == sections[last + 1])\n sections[last] += len;\n else if (len == 0 && sections[last] == 0)\n sections[last + 1] += ins;\n else if (forceJoin) {\n sections[last] += len;\n sections[last + 1] += ins;\n }\n else\n sections.push(len, ins);\n}\nfunction addInsert(values, sections, value) {\n if (value.length == 0)\n return;\n let index = (sections.length - 2) >> 1;\n if (index < values.length) {\n values[values.length - 1] = values[values.length - 1].append(value);\n }\n else {\n while (values.length < index)\n values.push(Text.empty);\n values.push(value);\n }\n}\nfunction iterChanges(desc, f, individual) {\n let inserted = desc.inserted;\n for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {\n let len = desc.sections[i++], ins = desc.sections[i++];\n if (ins < 0) {\n posA += len;\n posB += len;\n }\n else {\n let endA = posA, endB = posB, text = Text.empty;\n for (;;) {\n endA += len;\n endB += ins;\n if (ins && inserted)\n text = text.append(inserted[(i - 2) >> 1]);\n if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)\n break;\n len = desc.sections[i++];\n ins = desc.sections[i++];\n }\n f(posA, endA, posB, endB, text);\n posA = endA;\n posB = endB;\n }\n }\n}\nfunction mapSet(setA, setB, before, mkSet = false) {\n // Produce a copy of setA that applies to the document after setB\n // has been applied (assuming both start at the same document).\n let sections = [], insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n // Iterate over both sets in parallel. inserted tracks, for changes\n // in A that have to be processed piece-by-piece, whether their\n // content has been inserted already, and refers to the section\n // index.\n for (let inserted = -1;;) {\n if (a.ins == -1 && b.ins == -1) {\n // Move across ranges skipped by both sets.\n let len = Math.min(a.len, b.len);\n addSection(sections, len, -1);\n a.forward(len);\n b.forward(len);\n }\n else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {\n // If there's a change in B that comes before the next change in\n // A (ordered by start pos, then len, then before flag), skip\n // that (and process any changes in A it covers).\n let len = b.len;\n addSection(sections, b.ins, -1);\n while (len) {\n let piece = Math.min(a.len, len);\n if (a.ins >= 0 && inserted < a.i && a.len <= piece) {\n addSection(sections, 0, a.ins);\n if (insert)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n }\n a.forward(piece);\n len -= piece;\n }\n b.next();\n }\n else if (a.ins >= 0) {\n // Process the part of a change in A up to the start of the next\n // non-deletion change in B (if overlapping).\n let len = 0, left = a.len;\n while (left) {\n if (b.ins == -1) {\n let piece = Math.min(left, b.len);\n len += piece;\n left -= piece;\n b.forward(piece);\n }\n else if (b.ins == 0 && b.len < left) {\n left -= b.len;\n b.next();\n }\n else {\n break;\n }\n }\n addSection(sections, len, inserted < a.i ? a.ins : 0);\n if (insert && inserted < a.i)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n a.forward(a.len - left);\n }\n else if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else {\n throw new Error(\"Mismatched change set lengths\");\n }\n }\n}\nfunction composeSets(setA, setB, mkSet = false) {\n let sections = [];\n let insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n for (let open = false;;) {\n if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else if (a.ins == 0) { // Deletion in A\n addSection(sections, a.len, 0, open);\n a.next();\n }\n else if (b.len == 0 && !b.done) { // Insertion in B\n addSection(sections, 0, b.ins, open);\n if (insert)\n addInsert(insert, sections, b.text);\n b.next();\n }\n else if (a.done || b.done) {\n throw new Error(\"Mismatched change set lengths\");\n }\n else {\n let len = Math.min(a.len2, b.len), sectionLen = sections.length;\n if (a.ins == -1) {\n let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;\n addSection(sections, len, insB, open);\n if (insert && insB)\n addInsert(insert, sections, b.text);\n }\n else if (b.ins == -1) {\n addSection(sections, a.off ? 0 : a.len, len, open);\n if (insert)\n addInsert(insert, sections, a.textBit(len));\n }\n else {\n addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);\n if (insert && !b.off)\n addInsert(insert, sections, b.text);\n }\n open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);\n a.forward2(len);\n b.forward(len);\n }\n }\n}\nclass SectionIter {\n constructor(set) {\n this.set = set;\n this.i = 0;\n this.next();\n }\n next() {\n let { sections } = this.set;\n if (this.i < sections.length) {\n this.len = sections[this.i++];\n this.ins = sections[this.i++];\n }\n else {\n this.len = 0;\n this.ins = -2;\n }\n this.off = 0;\n }\n get done() { return this.ins == -2; }\n get len2() { return this.ins < 0 ? this.len : this.ins; }\n get text() {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length ? Text.empty : inserted[index];\n }\n textBit(len) {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length && !len ? Text.empty\n : inserted[index].slice(this.off, len == null ? undefined : this.off + len);\n }\n forward(len) {\n if (len == this.len)\n this.next();\n else {\n this.len -= len;\n this.off += len;\n }\n }\n forward2(len) {\n if (this.ins == -1)\n this.forward(len);\n else if (len == this.ins)\n this.next();\n else {\n this.ins -= len;\n this.off += len;\n }\n }\n}\n\n/**\nA single selection range. When\n[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)\nis enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold\nmultiple ranges. By default, selections hold exactly one range.\n*/\nclass SelectionRange {\n constructor(\n /**\n The lower boundary of the range.\n */\n from, \n /**\n The upper boundary of the range.\n */\n to, flags) {\n this.from = from;\n this.to = to;\n this.flags = flags;\n }\n /**\n The anchor of the range—the side that doesn't move when you\n extend it.\n */\n get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }\n /**\n The head of the range, which is moved when the range is\n [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).\n */\n get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }\n /**\n True when `anchor` and `head` are at the same position.\n */\n get empty() { return this.from == this.to; }\n /**\n If this is a cursor that is explicitly associated with the\n character on one of its sides, this returns the side. -1 means\n the character before its position, 1 the character after, and 0\n means no association.\n */\n get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }\n /**\n The bidirectional text level associated with this cursor, if\n any.\n */\n get bidiLevel() {\n let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;\n return level == 3 ? null : level;\n }\n /**\n The goal column (stored vertical offset) associated with a\n cursor. This is used to preserve the vertical position when\n [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across\n lines of different length.\n */\n get goalColumn() {\n let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;\n return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;\n }\n /**\n Map this range through a change, producing a valid range in the\n updated document.\n */\n map(change, assoc = -1) {\n let from, to;\n if (this.empty) {\n from = to = change.mapPos(this.from, assoc);\n }\n else {\n from = change.mapPos(this.from, 1);\n to = change.mapPos(this.to, -1);\n }\n return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);\n }\n /**\n Extend this range to cover at least `from` to `to`.\n */\n extend(from, to = from) {\n if (from <= this.anchor && to >= this.anchor)\n return EditorSelection.range(from, to);\n let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;\n return EditorSelection.range(this.anchor, head);\n }\n /**\n Compare this range to another range.\n */\n eq(other) {\n return this.anchor == other.anchor && this.head == other.head;\n }\n /**\n Return a JSON-serializable object representing the range.\n */\n toJSON() { return { anchor: this.anchor, head: this.head }; }\n /**\n Convert a JSON representation of a range to a `SelectionRange`\n instance.\n */\n static fromJSON(json) {\n if (!json || typeof json.anchor != \"number\" || typeof json.head != \"number\")\n throw new RangeError(\"Invalid JSON representation for SelectionRange\");\n return EditorSelection.range(json.anchor, json.head);\n }\n /**\n @internal\n */\n static create(from, to, flags) {\n return new SelectionRange(from, to, flags);\n }\n}\n/**\nAn editor selection holds one or more selection ranges.\n*/\nclass EditorSelection {\n constructor(\n /**\n The ranges in the selection, sorted by position. Ranges cannot\n overlap (but they may touch, if they aren't empty).\n */\n ranges, \n /**\n The index of the _main_ range in the selection (which is\n usually the range that was added last).\n */\n mainIndex) {\n this.ranges = ranges;\n this.mainIndex = mainIndex;\n }\n /**\n Map a selection through a change. Used to adjust the selection\n position for changes.\n */\n map(change, assoc = -1) {\n if (change.empty)\n return this;\n return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);\n }\n /**\n Compare this selection to another selection.\n */\n eq(other) {\n if (this.ranges.length != other.ranges.length ||\n this.mainIndex != other.mainIndex)\n return false;\n for (let i = 0; i < this.ranges.length; i++)\n if (!this.ranges[i].eq(other.ranges[i]))\n return false;\n return true;\n }\n /**\n Get the primary selection range. Usually, you should make sure\n your code applies to _all_ ranges, by using methods like\n [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).\n */\n get main() { return this.ranges[this.mainIndex]; }\n /**\n Make sure the selection only has one range. Returns a selection\n holding only the main range from this selection.\n */\n asSingle() {\n return this.ranges.length == 1 ? this : new EditorSelection([this.main], 0);\n }\n /**\n Extend this selection with an extra range.\n */\n addRange(range, main = true) {\n return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);\n }\n /**\n Replace a given range with another range, and then normalize the\n selection to merge and sort ranges if necessary.\n */\n replaceRange(range, which = this.mainIndex) {\n let ranges = this.ranges.slice();\n ranges[which] = range;\n return EditorSelection.create(ranges, this.mainIndex);\n }\n /**\n Convert this selection to an object that can be serialized to\n JSON.\n */\n toJSON() {\n return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };\n }\n /**\n Create a selection from a JSON representation.\n */\n static fromJSON(json) {\n if (!json || !Array.isArray(json.ranges) || typeof json.main != \"number\" || json.main >= json.ranges.length)\n throw new RangeError(\"Invalid JSON representation for EditorSelection\");\n return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);\n }\n /**\n Create a selection holding a single range.\n */\n static single(anchor, head = anchor) {\n return new EditorSelection([EditorSelection.range(anchor, head)], 0);\n }\n /**\n Sort and merge the given set of ranges, creating a valid\n selection.\n */\n static create(ranges, mainIndex = 0) {\n if (ranges.length == 0)\n throw new RangeError(\"A selection needs at least one range\");\n for (let pos = 0, i = 0; i < ranges.length; i++) {\n let range = ranges[i];\n if (range.empty ? range.from <= pos : range.from < pos)\n return EditorSelection.normalized(ranges.slice(), mainIndex);\n pos = range.to;\n }\n return new EditorSelection(ranges, mainIndex);\n }\n /**\n Create a cursor selection range at the given position. You can\n safely ignore the optional arguments in most situations.\n */\n static cursor(pos, assoc = 0, bidiLevel, goalColumn) {\n return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |\n ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));\n }\n /**\n Create a selection range.\n */\n static range(anchor, head, goalColumn, bidiLevel) {\n let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel));\n return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)\n : SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);\n }\n /**\n @internal\n */\n static normalized(ranges, mainIndex = 0) {\n let main = ranges[mainIndex];\n ranges.sort((a, b) => a.from - b.from);\n mainIndex = ranges.indexOf(main);\n for (let i = 1; i < ranges.length; i++) {\n let range = ranges[i], prev = ranges[i - 1];\n if (range.empty ? range.from <= prev.to : range.from < prev.to) {\n let from = prev.from, to = Math.max(range.to, prev.to);\n if (i <= mainIndex)\n mainIndex--;\n ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));\n }\n }\n return new EditorSelection(ranges, mainIndex);\n }\n}\nfunction checkSelection(selection, docLength) {\n for (let range of selection.ranges)\n if (range.to > docLength)\n throw new RangeError(\"Selection points outside of document\");\n}\n\nlet nextID = 0;\n/**\nA facet is a labeled value that is associated with an editor\nstate. It takes inputs from any number of extensions, and combines\nthose into a single output value.\n\nExamples of uses of facets are the [tab\nsize](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor\nattributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update\nlisteners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).\n*/\nclass Facet {\n constructor(\n /**\n @internal\n */\n combine, \n /**\n @internal\n */\n compareInput, \n /**\n @internal\n */\n compare, isStatic, enables) {\n this.combine = combine;\n this.compareInput = compareInput;\n this.compare = compare;\n this.isStatic = isStatic;\n /**\n @internal\n */\n this.id = nextID++;\n this.default = combine([]);\n this.extensions = typeof enables == \"function\" ? enables(this) : enables;\n }\n /**\n Define a new facet.\n */\n static define(config = {}) {\n return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);\n }\n /**\n Returns an extension that adds the given value to this facet.\n */\n of(value) {\n return new FacetProvider([], this, 0 /* Provider.Static */, value);\n }\n /**\n Create an extension that computes a value for the facet from a\n state. You must take care to declare the parts of the state that\n this value depends on, since your function is only called again\n for a new state when one of those parts changed.\n \n In cases where your value depends only on a single field, you'll\n want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.\n */\n compute(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 1 /* Provider.Single */, get);\n }\n /**\n Create an extension that computes zero or more values for this\n facet from a state.\n */\n computeN(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);\n }\n from(field, get) {\n if (!get)\n get = x => x;\n return this.compute([field], state => get(state.field(field)));\n }\n}\nfunction sameArray(a, b) {\n return a == b || a.length == b.length && a.every((e, i) => e === b[i]);\n}\nclass FacetProvider {\n constructor(dependencies, facet, type, value) {\n this.dependencies = dependencies;\n this.facet = facet;\n this.type = type;\n this.value = value;\n this.id = nextID++;\n }\n dynamicSlot(addresses) {\n var _a;\n let getter = this.value;\n let compare = this.facet.compareInput;\n let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;\n let depDoc = false, depSel = false, depAddrs = [];\n for (let dep of this.dependencies) {\n if (dep == \"doc\")\n depDoc = true;\n else if (dep == \"selection\")\n depSel = true;\n else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)\n depAddrs.push(addresses[dep.id]);\n }\n return {\n create(state) {\n state.values[idx] = getter(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {\n let newVal = getter(state);\n if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n }\n return 0;\n },\n reconfigure: (state, oldState) => {\n let newVal, oldAddr = oldState.config.address[id];\n if (oldAddr != null) {\n let oldVal = getAddr(oldState, oldAddr);\n if (this.dependencies.every(dep => {\n return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :\n dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;\n }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {\n state.values[idx] = oldVal;\n return 0;\n }\n }\n else {\n newVal = getter(state);\n }\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n}\nfunction compareArray(a, b, compare) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!compare(a[i], b[i]))\n return false;\n return true;\n}\nfunction ensureAll(state, addrs) {\n let changed = false;\n for (let addr of addrs)\n if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)\n changed = true;\n return changed;\n}\nfunction dynamicFacetSlot(addresses, facet, providers) {\n let providerAddrs = providers.map(p => addresses[p.id]);\n let providerTypes = providers.map(p => p.type);\n let dynamic = providerAddrs.filter(p => !(p & 1));\n let idx = addresses[facet.id] >> 1;\n function get(state) {\n let values = [];\n for (let i = 0; i < providerAddrs.length; i++) {\n let value = getAddr(state, providerAddrs[i]);\n if (providerTypes[i] == 2 /* Provider.Multi */)\n for (let val of value)\n values.push(val);\n else\n values.push(value);\n }\n return facet.combine(values);\n }\n return {\n create(state) {\n for (let addr of providerAddrs)\n ensureAddr(state, addr);\n state.values[idx] = get(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if (!ensureAll(state, dynamic))\n return 0;\n let value = get(state);\n if (facet.compare(value, state.values[idx]))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure(state, oldState) {\n let depChanged = ensureAll(state, providerAddrs);\n let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);\n if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {\n state.values[idx] = oldValue;\n return 0;\n }\n let value = get(state);\n if (facet.compare(value, oldValue)) {\n state.values[idx] = oldValue;\n return 0;\n }\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n }\n };\n}\nconst initField = /*@__PURE__*/Facet.define({ static: true });\n/**\nFields can store additional information in an editor state, and\nkeep it in sync with the rest of the state.\n*/\nclass StateField {\n constructor(\n /**\n @internal\n */\n id, createF, updateF, compareF, \n /**\n @internal\n */\n spec) {\n this.id = id;\n this.createF = createF;\n this.updateF = updateF;\n this.compareF = compareF;\n this.spec = spec;\n /**\n @internal\n */\n this.provides = undefined;\n }\n /**\n Define a state field.\n */\n static define(config) {\n let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);\n if (config.provide)\n field.provides = config.provide(field);\n return field;\n }\n create(state) {\n let init = state.facet(initField).find(i => i.field == this);\n return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);\n }\n /**\n @internal\n */\n slot(addresses) {\n let idx = addresses[this.id] >> 1;\n return {\n create: (state) => {\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n },\n update: (state, tr) => {\n let oldVal = state.values[idx];\n let value = this.updateF(oldVal, tr);\n if (this.compareF(oldVal, value))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure: (state, oldState) => {\n if (oldState.config.address[this.id] != null) {\n state.values[idx] = oldState.field(this);\n return 0;\n }\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n /**\n Returns an extension that enables this field and overrides the\n way it is initialized. Can be useful when you need to provide a\n non-default starting value for the field.\n */\n init(create) {\n return [this, initField.of({ field: this, create })];\n }\n /**\n State field instances can be used as\n [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a\n given state.\n */\n get extension() { return this; }\n}\nconst Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };\nfunction prec(value) {\n return (ext) => new PrecExtension(ext, value);\n}\n/**\nBy default extensions are registered in the order they are found\nin the flattened form of nested array that was provided.\nIndividual extension values can be assigned a precedence to\noverride this. Extensions that do not have a precedence set get\nthe precedence of the nearest parent with a precedence, or\n[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The\nfinal ordering of extensions is determined by first sorting by\nprecedence and then by order within each precedence.\n*/\nconst Prec = {\n /**\n The highest precedence level, for extensions that should end up\n near the start of the precedence ordering.\n */\n highest: /*@__PURE__*/prec(Prec_.highest),\n /**\n A higher-than-default precedence, for extensions that should\n come before those with default precedence.\n */\n high: /*@__PURE__*/prec(Prec_.high),\n /**\n The default precedence, which is also used for extensions\n without an explicit precedence.\n */\n default: /*@__PURE__*/prec(Prec_.default),\n /**\n A lower-than-default precedence.\n */\n low: /*@__PURE__*/prec(Prec_.low),\n /**\n The lowest precedence level. Meant for things that should end up\n near the end of the extension order.\n */\n lowest: /*@__PURE__*/prec(Prec_.lowest)\n};\nclass PrecExtension {\n constructor(inner, prec) {\n this.inner = inner;\n this.prec = prec;\n }\n}\n/**\nExtension compartments can be used to make a configuration\ndynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your\nconfiguration in a compartment, you can later\n[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a\ntransaction.\n*/\nclass Compartment {\n /**\n Create an instance of this compartment to add to your [state\n configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).\n */\n of(ext) { return new CompartmentInstance(this, ext); }\n /**\n Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that\n reconfigures this compartment.\n */\n reconfigure(content) {\n return Compartment.reconfigure.of({ compartment: this, extension: content });\n }\n /**\n Get the current content of the compartment in the state, or\n `undefined` if it isn't present.\n */\n get(state) {\n return state.config.compartments.get(this);\n }\n}\nclass CompartmentInstance {\n constructor(compartment, inner) {\n this.compartment = compartment;\n this.inner = inner;\n }\n}\nclass Configuration {\n constructor(base, compartments, dynamicSlots, address, staticValues, facets) {\n this.base = base;\n this.compartments = compartments;\n this.dynamicSlots = dynamicSlots;\n this.address = address;\n this.staticValues = staticValues;\n this.facets = facets;\n this.statusTemplate = [];\n while (this.statusTemplate.length < dynamicSlots.length)\n this.statusTemplate.push(0 /* SlotStatus.Unresolved */);\n }\n staticFacet(facet) {\n let addr = this.address[facet.id];\n return addr == null ? facet.default : this.staticValues[addr >> 1];\n }\n static resolve(base, compartments, oldState) {\n let fields = [];\n let facets = Object.create(null);\n let newCompartments = new Map();\n for (let ext of flatten(base, compartments, newCompartments)) {\n if (ext instanceof StateField)\n fields.push(ext);\n else\n (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);\n }\n let address = Object.create(null);\n let staticValues = [];\n let dynamicSlots = [];\n for (let field of fields) {\n address[field.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => field.slot(a));\n }\n let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;\n for (let id in facets) {\n let providers = facets[id], facet = providers[0].facet;\n let oldProviders = oldFacets && oldFacets[id] || [];\n if (providers.every(p => p.type == 0 /* Provider.Static */)) {\n address[facet.id] = (staticValues.length << 1) | 1;\n if (sameArray(oldProviders, providers)) {\n staticValues.push(oldState.facet(facet));\n }\n else {\n let value = facet.combine(providers.map(p => p.value));\n staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);\n }\n }\n else {\n for (let p of providers) {\n if (p.type == 0 /* Provider.Static */) {\n address[p.id] = (staticValues.length << 1) | 1;\n staticValues.push(p.value);\n }\n else {\n address[p.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => p.dynamicSlot(a));\n }\n }\n address[facet.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));\n }\n }\n let dynamic = dynamicSlots.map(f => f(address));\n return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);\n }\n}\nfunction flatten(extension, compartments, newCompartments) {\n let result = [[], [], [], [], []];\n let seen = new Map();\n function inner(ext, prec) {\n let known = seen.get(ext);\n if (known != null) {\n if (known <= prec)\n return;\n let found = result[known].indexOf(ext);\n if (found > -1)\n result[known].splice(found, 1);\n if (ext instanceof CompartmentInstance)\n newCompartments.delete(ext.compartment);\n }\n seen.set(ext, prec);\n if (Array.isArray(ext)) {\n for (let e of ext)\n inner(e, prec);\n }\n else if (ext instanceof CompartmentInstance) {\n if (newCompartments.has(ext.compartment))\n throw new RangeError(`Duplicate use of compartment in extensions`);\n let content = compartments.get(ext.compartment) || ext.inner;\n newCompartments.set(ext.compartment, content);\n inner(content, prec);\n }\n else if (ext instanceof PrecExtension) {\n inner(ext.inner, ext.prec);\n }\n else if (ext instanceof StateField) {\n result[prec].push(ext);\n if (ext.provides)\n inner(ext.provides, prec);\n }\n else if (ext instanceof FacetProvider) {\n result[prec].push(ext);\n if (ext.facet.extensions)\n inner(ext.facet.extensions, Prec_.default);\n }\n else {\n let content = ext.extension;\n if (!content)\n throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);\n inner(content, prec);\n }\n }\n inner(extension, Prec_.default);\n return result.reduce((a, b) => a.concat(b));\n}\nfunction ensureAddr(state, addr) {\n if (addr & 1)\n return 2 /* SlotStatus.Computed */;\n let idx = addr >> 1;\n let status = state.status[idx];\n if (status == 4 /* SlotStatus.Computing */)\n throw new Error(\"Cyclic dependency between fields and/or facets\");\n if (status & 2 /* SlotStatus.Computed */)\n return status;\n state.status[idx] = 4 /* SlotStatus.Computing */;\n let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);\n return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;\n}\nfunction getAddr(state, addr) {\n return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];\n}\n\nconst languageData = /*@__PURE__*/Facet.define();\nconst allowMultipleSelections = /*@__PURE__*/Facet.define({\n combine: values => values.some(v => v),\n static: true\n});\nconst lineSeparator = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : undefined,\n static: true\n});\nconst changeFilter = /*@__PURE__*/Facet.define();\nconst transactionFilter = /*@__PURE__*/Facet.define();\nconst transactionExtender = /*@__PURE__*/Facet.define();\nconst readOnly = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : false\n});\n\n/**\nAnnotations are tagged values that are used to add metadata to\ntransactions in an extensible way. They should be used to model\nthings that effect the entire transaction (such as its [time\nstamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its\n[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen\n_alongside_ the other changes made by the transaction, [state\neffects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.\n*/\nclass Annotation {\n /**\n @internal\n */\n constructor(\n /**\n The annotation type.\n */\n type, \n /**\n The value of this annotation.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Define a new type of annotation.\n */\n static define() { return new AnnotationType(); }\n}\n/**\nMarker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).\n*/\nclass AnnotationType {\n /**\n Create an instance of this annotation.\n */\n of(value) { return new Annotation(this, value); }\n}\n/**\nRepresentation of a type of state effect. Defined with\n[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).\n*/\nclass StateEffectType {\n /**\n @internal\n */\n constructor(\n // The `any` types in these function types are there to work\n // around TypeScript issue #37631, where the type guard on\n // `StateEffect.is` mysteriously stops working when these properly\n // have type `Value`.\n /**\n @internal\n */\n map) {\n this.map = map;\n }\n /**\n Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this\n type.\n */\n of(value) { return new StateEffect(this, value); }\n}\n/**\nState effects can be used to represent additional effects\nassociated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They\nare often useful to model changes to custom [state\nfields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in\ndocument or selection changes.\n*/\nclass StateEffect {\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n type, \n /**\n The value of this effect.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Map this effect through a position mapping. Will return\n `undefined` when that ends up deleting the effect.\n */\n map(mapping) {\n let mapped = this.type.map(this.value, mapping);\n return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);\n }\n /**\n Tells you whether this effect object is of a given\n [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).\n */\n is(type) { return this.type == type; }\n /**\n Define a new effect type. The type parameter indicates the type\n of values that his effect holds. It should be a type that\n doesn't include `undefined`, since that is used in\n [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is\n removed.\n */\n static define(spec = {}) {\n return new StateEffectType(spec.map || (v => v));\n }\n /**\n Map an array of effects through a change set.\n */\n static mapEffects(effects, mapping) {\n if (!effects.length)\n return effects;\n let result = [];\n for (let effect of effects) {\n let mapped = effect.map(mapping);\n if (mapped)\n result.push(mapped);\n }\n return result;\n }\n}\n/**\nThis effect can be used to reconfigure the root extensions of\nthe editor. Doing this will discard any extensions\n[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset\nthe content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)\ncompartments.\n*/\nStateEffect.reconfigure = /*@__PURE__*/StateEffect.define();\n/**\nAppend extensions to the top-level configuration of the editor.\n*/\nStateEffect.appendConfig = /*@__PURE__*/StateEffect.define();\n/**\nChanges to the editor state are grouped into transactions.\nTypically, a user action creates a single transaction, which may\ncontain any number of document changes, may change the selection,\nor have other effects. Create a transaction by calling\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately\ndispatch one by calling\n[`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).\n*/\nclass Transaction {\n constructor(\n /**\n The state from which the transaction starts.\n */\n startState, \n /**\n The document changes made by this transaction.\n */\n changes, \n /**\n The selection set by this transaction, or undefined if it\n doesn't explicitly set a selection.\n */\n selection, \n /**\n The effects added to the transaction.\n */\n effects, \n /**\n @internal\n */\n annotations, \n /**\n Whether the selection should be scrolled into view after this\n transaction is dispatched.\n */\n scrollIntoView) {\n this.startState = startState;\n this.changes = changes;\n this.selection = selection;\n this.effects = effects;\n this.annotations = annotations;\n this.scrollIntoView = scrollIntoView;\n /**\n @internal\n */\n this._doc = null;\n /**\n @internal\n */\n this._state = null;\n if (selection)\n checkSelection(selection, changes.newLength);\n if (!annotations.some((a) => a.type == Transaction.time))\n this.annotations = annotations.concat(Transaction.time.of(Date.now()));\n }\n /**\n @internal\n */\n static create(startState, changes, selection, effects, annotations, scrollIntoView) {\n return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);\n }\n /**\n The new document produced by the transaction. Contrary to\n [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't\n force the entire new state to be computed right away, so it is\n recommended that [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter\n when they need to look at the new document.\n */\n get newDoc() {\n return this._doc || (this._doc = this.changes.apply(this.startState.doc));\n }\n /**\n The new selection produced by the transaction. If\n [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,\n this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's\n current selection through the changes made by the transaction.\n */\n get newSelection() {\n return this.selection || this.startState.selection.map(this.changes);\n }\n /**\n The new state created by the transaction. Computed on demand\n (but retained for subsequent access), so it is recommended not to\n access it in [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.\n */\n get state() {\n if (!this._state)\n this.startState.applyTransaction(this);\n return this._state;\n }\n /**\n Get the value of the given annotation type, if any.\n */\n annotation(type) {\n for (let ann of this.annotations)\n if (ann.type == type)\n return ann.value;\n return undefined;\n }\n /**\n Indicates whether the transaction changed the document.\n */\n get docChanged() { return !this.changes.empty; }\n /**\n Indicates whether this transaction reconfigures the state\n (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or\n with a top-level configuration\n [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).\n */\n get reconfigured() { return this.startState.config != this.state.config; }\n /**\n Returns true if the transaction has a [user\n event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to\n or more specific than `event`. For example, if the transaction\n has `\"select.pointer\"` as user event, `\"select\"` and\n `\"select.pointer\"` will match it.\n */\n isUserEvent(event) {\n let e = this.annotation(Transaction.userEvent);\n return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == \".\"));\n }\n}\n/**\nAnnotation used to store transaction timestamps. Automatically\nadded to every transaction, holding `Date.now()`.\n*/\nTransaction.time = /*@__PURE__*/Annotation.define();\n/**\nAnnotation used to associate a transaction with a user interface\nevent. Holds a string identifying the event, using a\ndot-separated format to support attaching more specific\ninformation. The events used by the core libraries are:\n\n - `\"input\"` when content is entered\n - `\"input.type\"` for typed input\n - `\"input.type.compose\"` for composition\n - `\"input.paste\"` for pasted input\n - `\"input.drop\"` when adding content with drag-and-drop\n - `\"input.complete\"` when autocompleting\n - `\"delete\"` when the user deletes content\n - `\"delete.selection\"` when deleting the selection\n - `\"delete.forward\"` when deleting forward from the selection\n - `\"delete.backward\"` when deleting backward from the selection\n - `\"delete.cut\"` when cutting to the clipboard\n - `\"move\"` when content is moved\n - `\"move.drop\"` when content is moved within the editor through drag-and-drop\n - `\"select\"` when explicitly changing the selection\n - `\"select.pointer\"` when selecting with a mouse or other pointing device\n - `\"undo\"` and `\"redo\"` for history actions\n\nUse [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check\nwhether the annotation matches a given event.\n*/\nTransaction.userEvent = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating whether a transaction should be added to\nthe undo history or not.\n*/\nTransaction.addToHistory = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating (when present and true) that a transaction\nrepresents a change made by some other actor, not the user. This\nis used, for example, to tag other people's changes in\ncollaborative editing.\n*/\nTransaction.remote = /*@__PURE__*/Annotation.define();\nfunction joinRanges(a, b) {\n let result = [];\n for (let iA = 0, iB = 0;;) {\n let from, to;\n if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {\n from = a[iA++];\n to = a[iA++];\n }\n else if (iB < b.length) {\n from = b[iB++];\n to = b[iB++];\n }\n else\n return result;\n if (!result.length || result[result.length - 1] < from)\n result.push(from, to);\n else if (result[result.length - 1] < to)\n result[result.length - 1] = to;\n }\n}\nfunction mergeTransaction(a, b, sequential) {\n var _a;\n let mapForA, mapForB, changes;\n if (sequential) {\n mapForA = b.changes;\n mapForB = ChangeSet.empty(b.changes.length);\n changes = a.changes.compose(b.changes);\n }\n else {\n mapForA = b.changes.map(a.changes);\n mapForB = a.changes.mapDesc(b.changes, true);\n changes = a.changes.compose(mapForA);\n }\n return {\n changes,\n selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),\n effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),\n annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,\n scrollIntoView: a.scrollIntoView || b.scrollIntoView\n };\n}\nfunction resolveTransactionInner(state, spec, docSize) {\n let sel = spec.selection, annotations = asArray(spec.annotations);\n if (spec.userEvent)\n annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));\n return {\n changes: spec.changes instanceof ChangeSet ? spec.changes\n : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),\n selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),\n effects: asArray(spec.effects),\n annotations,\n scrollIntoView: !!spec.scrollIntoView\n };\n}\nfunction resolveTransaction(state, specs, filter) {\n let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);\n if (specs.length && specs[0].filter === false)\n filter = false;\n for (let i = 1; i < specs.length; i++) {\n if (specs[i].filter === false)\n filter = false;\n let seq = !!specs[i].sequential;\n s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);\n }\n let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);\n return extendTransaction(filter ? filterTransaction(tr) : tr);\n}\n// Finish a transaction by applying filters if necessary.\nfunction filterTransaction(tr) {\n let state = tr.startState;\n // Change filters\n let result = true;\n for (let filter of state.facet(changeFilter)) {\n let value = filter(tr);\n if (value === false) {\n result = false;\n break;\n }\n if (Array.isArray(value))\n result = result === true ? value : joinRanges(result, value);\n }\n if (result !== true) {\n let changes, back;\n if (result === false) {\n back = tr.changes.invertedDesc;\n changes = ChangeSet.empty(state.doc.length);\n }\n else {\n let filtered = tr.changes.filter(result);\n changes = filtered.changes;\n back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;\n }\n tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);\n }\n // Transaction filters\n let filters = state.facet(transactionFilter);\n for (let i = filters.length - 1; i >= 0; i--) {\n let filtered = filters[i](tr);\n if (filtered instanceof Transaction)\n tr = filtered;\n else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)\n tr = filtered[0];\n else\n tr = resolveTransaction(state, asArray(filtered), false);\n }\n return tr;\n}\nfunction extendTransaction(tr) {\n let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;\n for (let i = extenders.length - 1; i >= 0; i--) {\n let extension = extenders[i](tr);\n if (extension && Object.keys(extension).length)\n spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);\n }\n return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);\n}\nconst none = [];\nfunction asArray(value) {\n return value == null ? none : Array.isArray(value) ? value : [value];\n}\n\n/**\nThe categories produced by a [character\ncategorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used\ndo things like selecting by word.\n*/\nvar CharCategory = /*@__PURE__*/(function (CharCategory) {\n /**\n Word characters.\n */\n CharCategory[CharCategory[\"Word\"] = 0] = \"Word\";\n /**\n Whitespace.\n */\n CharCategory[CharCategory[\"Space\"] = 1] = \"Space\";\n /**\n Anything else.\n */\n CharCategory[CharCategory[\"Other\"] = 2] = \"Other\";\nreturn CharCategory})(CharCategory || (CharCategory = {}));\nconst nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\nlet wordChar;\ntry {\n wordChar = /*@__PURE__*/new RegExp(\"[\\\\p{Alphabetic}\\\\p{Number}_]\", \"u\");\n}\ncatch (_) { }\nfunction hasWordChar(str) {\n if (wordChar)\n return wordChar.test(str);\n for (let i = 0; i < str.length; i++) {\n let ch = str[i];\n if (/\\w/.test(ch) || ch > \"\\x80\" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))\n return true;\n }\n return false;\n}\nfunction makeCategorizer(wordChars) {\n return (char) => {\n if (!/\\S/.test(char))\n return CharCategory.Space;\n if (hasWordChar(char))\n return CharCategory.Word;\n for (let i = 0; i < wordChars.length; i++)\n if (char.indexOf(wordChars[i]) > -1)\n return CharCategory.Word;\n return CharCategory.Other;\n };\n}\n\n/**\nThe editor state class is a persistent (immutable) data structure.\nTo update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a\n[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state\ninstance, without modifying the original object.\n\nAs such, _never_ mutate properties of a state directly. That'll\njust break things.\n*/\nclass EditorState {\n constructor(\n /**\n @internal\n */\n config, \n /**\n The current document.\n */\n doc, \n /**\n The current selection.\n */\n selection, \n /**\n @internal\n */\n values, computeSlot, tr) {\n this.config = config;\n this.doc = doc;\n this.selection = selection;\n this.values = values;\n this.status = config.statusTemplate.slice();\n this.computeSlot = computeSlot;\n // Fill in the computed state immediately, so that further queries\n // for it made during the update return this state\n if (tr)\n tr._state = this;\n for (let i = 0; i < this.config.dynamicSlots.length; i++)\n ensureAddr(this, i << 1);\n this.computeSlot = null;\n }\n field(field, require = true) {\n let addr = this.config.address[field.id];\n if (addr == null) {\n if (require)\n throw new RangeError(\"Field is not present in this state\");\n return undefined;\n }\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this\n state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)\n can be passed. Unless\n [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the\n [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec\n are assumed to start in the _current_ document (not the document\n produced by previous specs), and its\n [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and\n [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer\n to the document created by its _own_ changes. The resulting\n transaction contains the combined effect of all the different\n specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later\n specs take precedence over earlier ones.\n */\n update(...specs) {\n return resolveTransaction(this, specs, true);\n }\n /**\n @internal\n */\n applyTransaction(tr) {\n let conf = this.config, { base, compartments } = conf;\n for (let effect of tr.effects) {\n if (effect.is(Compartment.reconfigure)) {\n if (conf) {\n compartments = new Map;\n conf.compartments.forEach((val, key) => compartments.set(key, val));\n conf = null;\n }\n compartments.set(effect.value.compartment, effect.value.extension);\n }\n else if (effect.is(StateEffect.reconfigure)) {\n conf = null;\n base = effect.value;\n }\n else if (effect.is(StateEffect.appendConfig)) {\n conf = null;\n base = asArray(base).concat(effect.value);\n }\n }\n let startValues;\n if (!conf) {\n conf = Configuration.resolve(base, compartments, this);\n let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);\n startValues = intermediateState.values;\n }\n else {\n startValues = tr.startState.values.slice();\n }\n new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);\n }\n /**\n Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that\n replaces every selection range with the given content.\n */\n replaceSelection(text) {\n if (typeof text == \"string\")\n text = this.toText(text);\n return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },\n range: EditorSelection.cursor(range.from + text.length) }));\n }\n /**\n Create a set of changes and a new selection by running the given\n function for each range in the active selection. The function\n can return an optional set of changes (in the coordinate space\n of the start document), plus an updated range (in the coordinate\n space of the document produced by the call's own changes). This\n method will merge all the changes and ranges into a single\n changeset and selection, and return it as a [transaction\n spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to\n [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).\n */\n changeByRange(f) {\n let sel = this.selection;\n let result1 = f(sel.ranges[0]);\n let changes = this.changes(result1.changes), ranges = [result1.range];\n let effects = asArray(result1.effects);\n for (let i = 1; i < sel.ranges.length; i++) {\n let result = f(sel.ranges[i]);\n let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);\n for (let j = 0; j < i; j++)\n ranges[j] = ranges[j].map(newMapped);\n let mapBy = changes.mapDesc(newChanges, true);\n ranges.push(result.range.map(mapBy));\n changes = changes.compose(newMapped);\n effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray(result.effects), mapBy));\n }\n return {\n changes,\n selection: EditorSelection.create(ranges, sel.mainIndex),\n effects\n };\n }\n /**\n Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change\n description, taking the state's document length and line\n separator into account.\n */\n changes(spec = []) {\n if (spec instanceof ChangeSet)\n return spec;\n return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));\n }\n /**\n Using the state's [line\n separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a\n [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.\n */\n toText(string) {\n return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));\n }\n /**\n Return the given range of the document as a string.\n */\n sliceDoc(from = 0, to = this.doc.length) {\n return this.doc.sliceString(from, to, this.lineBreak);\n }\n /**\n Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).\n */\n facet(facet) {\n let addr = this.config.address[facet.id];\n if (addr == null)\n return facet.default;\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Convert this state to a JSON-serializable object. When custom\n fields should be serialized, you can pass them in as an object\n mapping property names (in the resulting object, which should\n not use `doc` or `selection`) to fields.\n */\n toJSON(fields) {\n let result = {\n doc: this.sliceDoc(),\n selection: this.selection.toJSON()\n };\n if (fields)\n for (let prop in fields) {\n let value = fields[prop];\n if (value instanceof StateField && this.config.address[value.id] != null)\n result[prop] = value.spec.toJSON(this.field(fields[prop]), this);\n }\n return result;\n }\n /**\n Deserialize a state from its JSON representation. When custom\n fields should be deserialized, pass the same object you passed\n to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as\n third argument.\n */\n static fromJSON(json, config = {}, fields) {\n if (!json || typeof json.doc != \"string\")\n throw new RangeError(\"Invalid JSON representation for EditorState\");\n let fieldInit = [];\n if (fields)\n for (let prop in fields) {\n if (Object.prototype.hasOwnProperty.call(json, prop)) {\n let field = fields[prop], value = json[prop];\n fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));\n }\n }\n return EditorState.create({\n doc: json.doc,\n selection: EditorSelection.fromJSON(json.selection),\n extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit\n });\n }\n /**\n Create a new state. You'll usually only need this when\n initializing an editor—updated states are created by applying\n transactions.\n */\n static create(config = {}) {\n let configuration = Configuration.resolve(config.extensions || [], new Map);\n let doc = config.doc instanceof Text ? config.doc\n : Text.of((config.doc || \"\").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));\n let selection = !config.selection ? EditorSelection.single(0)\n : config.selection instanceof EditorSelection ? config.selection\n : EditorSelection.single(config.selection.anchor, config.selection.head);\n checkSelection(selection, doc.length);\n if (!configuration.staticFacet(allowMultipleSelections))\n selection = selection.asSingle();\n return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);\n }\n /**\n The size (in columns) of a tab in the document, determined by\n the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.\n */\n get tabSize() { return this.facet(EditorState.tabSize); }\n /**\n Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)\n string for this state.\n */\n get lineBreak() { return this.facet(EditorState.lineSeparator) || \"\\n\"; }\n /**\n Returns true when the editor is\n [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.\n */\n get readOnly() { return this.facet(readOnly); }\n /**\n Look up a translation for the given phrase (via the\n [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the\n original string if no translation is found.\n \n If additional arguments are passed, they will be inserted in\n place of markers like `$1` (for the first value) and `$2`, etc.\n A single `$` is equivalent to `$1`, and `$$` will produce a\n literal dollar sign.\n */\n phrase(phrase, ...insert) {\n for (let map of this.facet(EditorState.phrases))\n if (Object.prototype.hasOwnProperty.call(map, phrase)) {\n phrase = map[phrase];\n break;\n }\n if (insert.length)\n phrase = phrase.replace(/\\$(\\$|\\d*)/g, (m, i) => {\n if (i == \"$\")\n return \"$\";\n let n = +(i || 1);\n return !n || n > insert.length ? m : insert[n - 1];\n });\n return phrase;\n }\n /**\n Find the values for a given language data field, provided by the\n the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.\n \n Examples of language data fields are...\n \n - [`\"commentTokens\"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying\n comment syntax.\n - [`\"autocomplete\"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)\n for providing language-specific completion sources.\n - [`\"wordChars\"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding\n characters that should be considered part of words in this\n language.\n - [`\"closeBrackets\"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls\n bracket closing behavior.\n */\n languageDataAt(name, pos, side = -1) {\n let values = [];\n for (let provider of this.facet(languageData)) {\n for (let result of provider(this, pos, side)) {\n if (Object.prototype.hasOwnProperty.call(result, name))\n values.push(result[name]);\n }\n }\n return values;\n }\n /**\n Return a function that can categorize strings (expected to\n represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))\n into one of:\n \n - Word (contains an alphanumeric character or a character\n explicitly listed in the local language's `\"wordChars\"`\n language data, which should be a string)\n - Space (contains only whitespace)\n - Other (anything else)\n */\n charCategorizer(at) {\n return makeCategorizer(this.languageDataAt(\"wordChars\", at).join(\"\"));\n }\n /**\n Find the word at the given position, meaning the range\n containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters\n around it. If no word characters are adjacent to the position,\n this returns null.\n */\n wordAt(pos) {\n let { text, from, length } = this.doc.lineAt(pos);\n let cat = this.charCategorizer(pos);\n let start = pos - from, end = pos - from;\n while (start > 0) {\n let prev = findClusterBreak(text, start, false);\n if (cat(text.slice(prev, start)) != CharCategory.Word)\n break;\n start = prev;\n }\n while (end < length) {\n let next = findClusterBreak(text, end);\n if (cat(text.slice(end, next)) != CharCategory.Word)\n break;\n end = next;\n }\n return start == end ? null : EditorSelection.range(start + from, end + from);\n }\n}\n/**\nA facet that, when enabled, causes the editor to allow multiple\nranges to be selected. Be careful though, because by default the\neditor relies on the native DOM selection, which cannot handle\nmultiple selections. An extension like\n[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make\nsecondary selections visible to the user.\n*/\nEditorState.allowMultipleSelections = allowMultipleSelections;\n/**\nConfigures the tab size to use in this state. The first\n(highest-precedence) value of the facet is used. If no value is\ngiven, this defaults to 4.\n*/\nEditorState.tabSize = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : 4\n});\n/**\nThe line separator to use. By default, any of `\"\\n\"`, `\"\\r\\n\"`\nand `\"\\r\"` is treated as a separator when splitting lines, and\nlines are joined with `\"\\n\"`.\n\nWhen you configure a value here, only that precise separator\nwill be used, allowing you to round-trip documents through the\neditor without normalizing line separators.\n*/\nEditorState.lineSeparator = lineSeparator;\n/**\nThis facet controls the value of the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is\nconsulted by commands and extensions that implement editing\nfunctionality to determine whether they should apply. It\ndefaults to false, but when its highest-precedence value is\n`true`, such functionality disables itself.\n\nNot to be confused with\n[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which\ncontrols whether the editor's DOM is set to be editable (and\nthus focusable).\n*/\nEditorState.readOnly = readOnly;\n/**\nRegisters translation phrases. The\n[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through\nall objects registered with this facet to find translations for\nits argument.\n*/\nEditorState.phrases = /*@__PURE__*/Facet.define({\n compare(a, b) {\n let kA = Object.keys(a), kB = Object.keys(b);\n return kA.length == kB.length && kA.every(k => a[k] == b[k]);\n }\n});\n/**\nA facet used to register [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.\n*/\nEditorState.languageData = languageData;\n/**\nFacet used to register change filters, which are called for each\ntransaction (unless explicitly\n[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress\npart of the transaction's changes.\n\nSuch a function can return `true` to indicate that it doesn't\nwant to do anything, `false` to completely stop the changes in\nthe transaction, or a set of ranges in which changes should be\nsuppressed. Such ranges are represented as an array of numbers,\nwith each pair of two numbers indicating the start and end of a\nrange. So for example `[10, 20, 100, 110]` suppresses changes\nbetween 10 and 20, and between 100 and 110.\n*/\nEditorState.changeFilter = changeFilter;\n/**\nFacet used to register a hook that gets a chance to update or\nreplace transaction specs before they are applied. This will\nonly be applied for transactions that don't have\n[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You\ncan either return a single transaction spec (possibly the input\ntransaction), or an array of specs (which will be combined in\nthe same way as the arguments to\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).\n\nWhen possible, it is recommended to avoid accessing\n[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,\nsince it will force creation of a state that will then be\ndiscarded again, if the transaction is actually filtered.\n\n(This functionality should be used with care. Indiscriminately\nmodifying transaction is likely to break something or degrade\nthe user experience.)\n*/\nEditorState.transactionFilter = transactionFilter;\n/**\nThis is a more limited form of\n[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),\nwhich can only add\n[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and\n[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type\nof filter runs even if the transaction has disabled regular\n[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable\nfor effects that don't need to touch the changes or selection,\nbut do want to process every transaction.\n\nExtenders run _after_ filters, when both are present.\n*/\nEditorState.transactionExtender = transactionExtender;\nCompartment.reconfigure = /*@__PURE__*/StateEffect.define();\n\n/**\nUtility function for combining behaviors to fill in a config\nobject from an array of provided configs. `defaults` should hold\ndefault values for all optional fields in `Config`.\n\nThe function will, by default, error\nwhen a field gets two values that aren't `===`-equal, but you can\nprovide combine functions per field to do something else.\n*/\nfunction combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that\ncombine = {}) {\n let result = {};\n for (let config of configs)\n for (let key of Object.keys(config)) {\n let value = config[key], current = result[key];\n if (current === undefined)\n result[key] = value;\n else if (current === value || value === undefined) ; // No conflict\n else if (Object.hasOwnProperty.call(combine, key))\n result[key] = combine[key](current, value);\n else\n throw new Error(\"Config merge conflict for field \" + key);\n }\n for (let key in defaults)\n if (result[key] === undefined)\n result[key] = defaults[key];\n return result;\n}\n\n/**\nEach range is associated with a value, which must inherit from\nthis class.\n*/\nclass RangeValue {\n /**\n Compare this value with another value. Used when comparing\n rangesets. The default implementation compares by identity.\n Unless you are only creating a fixed number of unique instances\n of your value type, it is a good idea to implement this\n properly.\n */\n eq(other) { return this == other; }\n /**\n Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.\n */\n range(from, to = from) { return Range.create(from, to, this); }\n}\nRangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;\nRangeValue.prototype.point = false;\nRangeValue.prototype.mapMode = MapMode.TrackDel;\n/**\nA range associates a value with a range of positions.\n*/\nclass Range {\n constructor(\n /**\n The range's start position.\n */\n from, \n /**\n Its end position.\n */\n to, \n /**\n The value associated with this range.\n */\n value) {\n this.from = from;\n this.to = to;\n this.value = value;\n }\n /**\n @internal\n */\n static create(from, to, value) {\n return new Range(from, to, value);\n }\n}\nfunction cmpRange(a, b) {\n return a.from - b.from || a.value.startSide - b.value.startSide;\n}\nclass Chunk {\n constructor(from, to, value, \n // Chunks are marked with the largest point that occurs\n // in them (or -1 for no points), so that scans that are\n // only interested in points (such as the\n // heightmap-related logic) can skip range-only chunks.\n maxPoint) {\n this.from = from;\n this.to = to;\n this.value = value;\n this.maxPoint = maxPoint;\n }\n get length() { return this.to[this.to.length - 1]; }\n // Find the index of the given position and side. Use the ranges'\n // `from` pos when `end == false`, `to` when `end == true`.\n findIndex(pos, side, end, startAt = 0) {\n let arr = end ? this.to : this.from;\n for (let lo = startAt, hi = arr.length;;) {\n if (lo == hi)\n return lo;\n let mid = (lo + hi) >> 1;\n let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;\n if (mid == lo)\n return diff >= 0 ? lo : hi;\n if (diff >= 0)\n hi = mid;\n else\n lo = mid + 1;\n }\n }\n between(offset, from, to, f) {\n for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)\n if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)\n return false;\n }\n map(offset, changes) {\n let value = [], from = [], to = [], newPos = -1, maxPoint = -1;\n for (let i = 0; i < this.value.length; i++) {\n let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;\n if (curFrom == curTo) {\n let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);\n if (mapped == null)\n continue;\n newFrom = newTo = mapped;\n if (val.startSide != val.endSide) {\n newTo = changes.mapPos(curFrom, val.endSide);\n if (newTo < newFrom)\n continue;\n }\n }\n else {\n newFrom = changes.mapPos(curFrom, val.startSide);\n newTo = changes.mapPos(curTo, val.endSide);\n if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)\n continue;\n }\n if ((newTo - newFrom || val.endSide - val.startSide) < 0)\n continue;\n if (newPos < 0)\n newPos = newFrom;\n if (val.point)\n maxPoint = Math.max(maxPoint, newTo - newFrom);\n value.push(val);\n from.push(newFrom - newPos);\n to.push(newTo - newPos);\n }\n return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };\n }\n}\n/**\nA range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a\nway that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and\n[update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data\nstructure.\n*/\nclass RangeSet {\n constructor(\n /**\n @internal\n */\n chunkPos, \n /**\n @internal\n */\n chunk, \n /**\n @internal\n */\n nextLayer, \n /**\n @internal\n */\n maxPoint) {\n this.chunkPos = chunkPos;\n this.chunk = chunk;\n this.nextLayer = nextLayer;\n this.maxPoint = maxPoint;\n }\n /**\n @internal\n */\n static create(chunkPos, chunk, nextLayer, maxPoint) {\n return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);\n }\n /**\n @internal\n */\n get length() {\n let last = this.chunk.length - 1;\n return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);\n }\n /**\n The number of ranges in the set.\n */\n get size() {\n if (this.isEmpty)\n return 0;\n let size = this.nextLayer.size;\n for (let chunk of this.chunk)\n size += chunk.value.length;\n return size;\n }\n /**\n @internal\n */\n chunkEnd(index) {\n return this.chunkPos[index] + this.chunk[index].length;\n }\n /**\n Update the range set, optionally adding new ranges or filtering\n out existing ones.\n \n (Note: The type parameter is just there as a kludge to work\n around TypeScript variance issues that prevented `RangeSet<X>`\n from being a subtype of `RangeSet<Y>` when `X` is a subtype of\n `Y`.)\n */\n update(updateSpec) {\n let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;\n let filter = updateSpec.filter;\n if (add.length == 0 && !filter)\n return this;\n if (sort)\n add = add.slice().sort(cmpRange);\n if (this.isEmpty)\n return add.length ? RangeSet.of(add) : this;\n let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];\n let builder = new RangeSetBuilder();\n while (cur.value || i < add.length) {\n if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {\n let range = add[i++];\n if (!builder.addInner(range.from, range.to, range.value))\n spill.push(range);\n }\n else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&\n (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&\n (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&\n builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {\n cur.nextChunk();\n }\n else {\n if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {\n if (!builder.addInner(cur.from, cur.to, cur.value))\n spill.push(Range.create(cur.from, cur.to, cur.value));\n }\n cur.next();\n }\n }\n return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty\n : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));\n }\n /**\n Map this range set through a set of changes, return the new set.\n */\n map(changes) {\n if (changes.empty || this.isEmpty)\n return this;\n let chunks = [], chunkPos = [], maxPoint = -1;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n let touch = changes.touchesRange(start, start + chunk.length);\n if (touch === false) {\n maxPoint = Math.max(maxPoint, chunk.maxPoint);\n chunks.push(chunk);\n chunkPos.push(changes.mapPos(start));\n }\n else if (touch === true) {\n let { mapped, pos } = chunk.map(start, changes);\n if (mapped) {\n maxPoint = Math.max(maxPoint, mapped.maxPoint);\n chunks.push(mapped);\n chunkPos.push(pos);\n }\n }\n }\n let next = this.nextLayer.map(changes);\n return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);\n }\n /**\n Iterate over the ranges that touch the region `from` to `to`,\n calling `f` for each. There is no guarantee that the ranges will\n be reported in any specific order. When the callback returns\n `false`, iteration stops.\n */\n between(from, to, f) {\n if (this.isEmpty)\n return;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n if (to >= start && from <= start + chunk.length &&\n chunk.between(start, from - start, to - start, f) === false)\n return;\n }\n this.nextLayer.between(from, to, f);\n }\n /**\n Iterate over the ranges in this set, in order, including all\n ranges that end at or after `from`.\n */\n iter(from = 0) {\n return HeapCursor.from([this]).goto(from);\n }\n /**\n @internal\n */\n get isEmpty() { return this.nextLayer == this; }\n /**\n Iterate over the ranges in a collection of sets, in order,\n starting from `from`.\n */\n static iter(sets, from = 0) {\n return HeapCursor.from(sets).goto(from);\n }\n /**\n Iterate over two groups of sets, calling methods on `comparator`\n to notify it of possible differences.\n */\n static compare(oldSets, newSets, \n /**\n This indicates how the underlying data changed between these\n ranges, and is needed to synchronize the iteration.\n */\n textDiff, comparator, \n /**\n Can be used to ignore all non-point ranges, and points below\n the given size. When -1, all ranges are compared.\n */\n minPointSize = -1) {\n let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let sharedChunks = findSharedChunks(a, b, textDiff);\n let sideA = new SpanCursor(a, sharedChunks, minPointSize);\n let sideB = new SpanCursor(b, sharedChunks, minPointSize);\n textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));\n if (textDiff.empty && textDiff.length == 0)\n compare(sideA, 0, sideB, 0, 0, comparator);\n }\n /**\n Compare the contents of two groups of range sets, returning true\n if they are equivalent in the given range.\n */\n static eq(oldSets, newSets, from = 0, to) {\n if (to == null)\n to = 1000000000 /* C.Far */ - 1;\n let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);\n let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);\n if (a.length != b.length)\n return false;\n if (!a.length)\n return true;\n let sharedChunks = findSharedChunks(a, b);\n let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);\n for (;;) {\n if (sideA.to != sideB.to ||\n !sameValues(sideA.active, sideB.active) ||\n sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))\n return false;\n if (sideA.to > to)\n return true;\n sideA.next();\n sideB.next();\n }\n }\n /**\n Iterate over a group of range sets at the same time, notifying\n the iterator about the ranges covering every given piece of\n content. Returns the open count (see\n [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end\n of the iteration.\n */\n static spans(sets, from, to, iterator, \n /**\n When given and greater than -1, only points of at least this\n size are taken into account.\n */\n minPointSize = -1) {\n let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;\n let openRanges = cursor.openStart;\n for (;;) {\n let curTo = Math.min(cursor.to, to);\n if (cursor.point) {\n let active = cursor.activeForPoint(cursor.to);\n let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);\n iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);\n openRanges = Math.min(cursor.openEnd(curTo), active.length);\n }\n else if (curTo > pos) {\n iterator.span(pos, curTo, cursor.active, openRanges);\n openRanges = cursor.openEnd(curTo);\n }\n if (cursor.to > to)\n return openRanges + (cursor.point && cursor.to > to ? 1 : 0);\n pos = cursor.to;\n cursor.next();\n }\n }\n /**\n Create a range set for the given range or array of ranges. By\n default, this expects the ranges to be _sorted_ (by start\n position and, if two start at the same position,\n `value.startSide`). You can pass `true` as second argument to\n cause the method to sort them.\n */\n static of(ranges, sort = false) {\n let build = new RangeSetBuilder();\n for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)\n build.add(range.from, range.to, range.value);\n return build.finish();\n }\n}\n/**\nThe empty set of ranges.\n*/\nRangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);\nfunction lazySort(ranges) {\n if (ranges.length > 1)\n for (let prev = ranges[0], i = 1; i < ranges.length; i++) {\n let cur = ranges[i];\n if (cmpRange(prev, cur) > 0)\n return ranges.slice().sort(cmpRange);\n prev = cur;\n }\n return ranges;\n}\nRangeSet.empty.nextLayer = RangeSet.empty;\n/**\nA range set builder is a data structure that helps build up a\n[range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating\nan array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.\n*/\nclass RangeSetBuilder {\n finishChunk(newArrays) {\n this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));\n this.chunkPos.push(this.chunkStart);\n this.chunkStart = -1;\n this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);\n this.maxPoint = -1;\n if (newArrays) {\n this.from = [];\n this.to = [];\n this.value = [];\n }\n }\n /**\n Create an empty builder.\n */\n constructor() {\n this.chunks = [];\n this.chunkPos = [];\n this.chunkStart = -1;\n this.last = null;\n this.lastFrom = -1000000000 /* C.Far */;\n this.lastTo = -1000000000 /* C.Far */;\n this.from = [];\n this.to = [];\n this.value = [];\n this.maxPoint = -1;\n this.setMaxPoint = -1;\n this.nextLayer = null;\n }\n /**\n Add a range. Ranges should be added in sorted (by `from` and\n `value.startSide`) order.\n */\n add(from, to, value) {\n if (!this.addInner(from, to, value))\n (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);\n }\n /**\n @internal\n */\n addInner(from, to, value) {\n let diff = from - this.lastTo || value.startSide - this.last.endSide;\n if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)\n throw new Error(\"Ranges must be added sorted by `from` position and `startSide`\");\n if (diff < 0)\n return false;\n if (this.from.length == 250 /* C.ChunkSize */)\n this.finishChunk(true);\n if (this.chunkStart < 0)\n this.chunkStart = from;\n this.from.push(from - this.chunkStart);\n this.to.push(to - this.chunkStart);\n this.last = value;\n this.lastFrom = from;\n this.lastTo = to;\n this.value.push(value);\n if (value.point)\n this.maxPoint = Math.max(this.maxPoint, to - from);\n return true;\n }\n /**\n @internal\n */\n addChunk(from, chunk) {\n if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)\n return false;\n if (this.from.length)\n this.finishChunk(true);\n this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);\n this.chunks.push(chunk);\n this.chunkPos.push(from);\n let last = chunk.value.length - 1;\n this.last = chunk.value[last];\n this.lastFrom = chunk.from[last] + from;\n this.lastTo = chunk.to[last] + from;\n return true;\n }\n /**\n Finish the range set. Returns the new set. The builder can't be\n used anymore after this has been called.\n */\n finish() { return this.finishInner(RangeSet.empty); }\n /**\n @internal\n */\n finishInner(next) {\n if (this.from.length)\n this.finishChunk(false);\n if (this.chunks.length == 0)\n return next;\n let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);\n this.from = null; // Make sure further `add` calls produce errors\n return result;\n }\n}\nfunction findSharedChunks(a, b, textDiff) {\n let inA = new Map();\n for (let set of a)\n for (let i = 0; i < set.chunk.length; i++)\n if (set.chunk[i].maxPoint <= 0)\n inA.set(set.chunk[i], set.chunkPos[i]);\n let shared = new Set();\n for (let set of b)\n for (let i = 0; i < set.chunk.length; i++) {\n let known = inA.get(set.chunk[i]);\n if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&\n !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))\n shared.add(set.chunk[i]);\n }\n return shared;\n}\nclass LayerCursor {\n constructor(layer, skip, minPoint, rank = 0) {\n this.layer = layer;\n this.skip = skip;\n this.minPoint = minPoint;\n this.rank = rank;\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n get endSide() { return this.value ? this.value.endSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.chunkIndex = this.rangeIndex = 0;\n this.gotoInner(pos, side, false);\n return this;\n }\n gotoInner(pos, side, forward) {\n while (this.chunkIndex < this.layer.chunk.length) {\n let next = this.layer.chunk[this.chunkIndex];\n if (!(this.skip && this.skip.has(next) ||\n this.layer.chunkEnd(this.chunkIndex) < pos ||\n next.maxPoint < this.minPoint))\n break;\n this.chunkIndex++;\n forward = false;\n }\n if (this.chunkIndex < this.layer.chunk.length) {\n let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);\n if (!forward || this.rangeIndex < rangeIndex)\n this.setRangeIndex(rangeIndex);\n }\n this.next();\n }\n forward(pos, side) {\n if ((this.to - pos || this.endSide - side) < 0)\n this.gotoInner(pos, side, true);\n }\n next() {\n for (;;) {\n if (this.chunkIndex == this.layer.chunk.length) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n break;\n }\n else {\n let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];\n let from = chunkPos + chunk.from[this.rangeIndex];\n this.from = from;\n this.to = chunkPos + chunk.to[this.rangeIndex];\n this.value = chunk.value[this.rangeIndex];\n this.setRangeIndex(this.rangeIndex + 1);\n if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)\n break;\n }\n }\n }\n setRangeIndex(index) {\n if (index == this.layer.chunk[this.chunkIndex].value.length) {\n this.chunkIndex++;\n if (this.skip) {\n while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))\n this.chunkIndex++;\n }\n this.rangeIndex = 0;\n }\n else {\n this.rangeIndex = index;\n }\n }\n nextChunk() {\n this.chunkIndex++;\n this.rangeIndex = 0;\n this.next();\n }\n compare(other) {\n return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||\n this.to - other.to || this.endSide - other.endSide;\n }\n}\nclass HeapCursor {\n constructor(heap) {\n this.heap = heap;\n }\n static from(sets, skip = null, minPoint = -1) {\n let heap = [];\n for (let i = 0; i < sets.length; i++) {\n for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {\n if (cur.maxPoint >= minPoint)\n heap.push(new LayerCursor(cur, skip, minPoint, i));\n }\n }\n return heap.length == 1 ? heap[0] : new HeapCursor(heap);\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n for (let cur of this.heap)\n cur.goto(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n this.next();\n return this;\n }\n forward(pos, side) {\n for (let cur of this.heap)\n cur.forward(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n if ((this.to - pos || this.value.endSide - side) < 0)\n this.next();\n }\n next() {\n if (this.heap.length == 0) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n this.rank = -1;\n }\n else {\n let top = this.heap[0];\n this.from = top.from;\n this.to = top.to;\n this.value = top.value;\n this.rank = top.rank;\n if (top.value)\n top.next();\n heapBubble(this.heap, 0);\n }\n }\n}\nfunction heapBubble(heap, index) {\n for (let cur = heap[index];;) {\n let childIndex = (index << 1) + 1;\n if (childIndex >= heap.length)\n break;\n let child = heap[childIndex];\n if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {\n child = heap[childIndex + 1];\n childIndex++;\n }\n if (cur.compare(child) < 0)\n break;\n heap[childIndex] = cur;\n heap[index] = child;\n index = childIndex;\n }\n}\nclass SpanCursor {\n constructor(sets, skip, minPoint) {\n this.minPoint = minPoint;\n this.active = [];\n this.activeTo = [];\n this.activeRank = [];\n this.minActive = -1;\n // A currently active point range, if any\n this.point = null;\n this.pointFrom = 0;\n this.pointRank = 0;\n this.to = -1000000000 /* C.Far */;\n this.endSide = 0;\n // The amount of open active ranges at the start of the iterator.\n // Not including points.\n this.openStart = -1;\n this.cursor = HeapCursor.from(sets, skip, minPoint);\n }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.cursor.goto(pos, side);\n this.active.length = this.activeTo.length = this.activeRank.length = 0;\n this.minActive = -1;\n this.to = pos;\n this.endSide = side;\n this.openStart = -1;\n this.next();\n return this;\n }\n forward(pos, side) {\n while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)\n this.removeActive(this.minActive);\n this.cursor.forward(pos, side);\n }\n removeActive(index) {\n remove(this.active, index);\n remove(this.activeTo, index);\n remove(this.activeRank, index);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n addActive(trackOpen) {\n let i = 0, { value, to, rank } = this.cursor;\n while (i < this.activeRank.length && this.activeRank[i] <= rank)\n i++;\n insert(this.active, i, value);\n insert(this.activeTo, i, to);\n insert(this.activeRank, i, rank);\n if (trackOpen)\n insert(trackOpen, i, this.cursor.from);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n // After calling this, if `this.point` != null, the next range is a\n // point. Otherwise, it's a regular range, covered by `this.active`.\n next() {\n let from = this.to, wasPoint = this.point;\n this.point = null;\n let trackOpen = this.openStart < 0 ? [] : null;\n for (;;) {\n let a = this.minActive;\n if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {\n if (this.activeTo[a] > from) {\n this.to = this.activeTo[a];\n this.endSide = this.active[a].endSide;\n break;\n }\n this.removeActive(a);\n if (trackOpen)\n remove(trackOpen, a);\n }\n else if (!this.cursor.value) {\n this.to = this.endSide = 1000000000 /* C.Far */;\n break;\n }\n else if (this.cursor.from > from) {\n this.to = this.cursor.from;\n this.endSide = this.cursor.startSide;\n break;\n }\n else {\n let nextVal = this.cursor.value;\n if (!nextVal.point) { // Opening a range\n this.addActive(trackOpen);\n this.cursor.next();\n }\n else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {\n // Ignore any non-empty points that end precisely at the end of the prev point\n this.cursor.next();\n }\n else { // New point\n this.point = nextVal;\n this.pointFrom = this.cursor.from;\n this.pointRank = this.cursor.rank;\n this.to = this.cursor.to;\n this.endSide = nextVal.endSide;\n this.cursor.next();\n this.forward(this.to, this.endSide);\n break;\n }\n }\n }\n if (trackOpen) {\n this.openStart = 0;\n for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)\n this.openStart++;\n }\n }\n activeForPoint(to) {\n if (!this.active.length)\n return this.active;\n let active = [];\n for (let i = this.active.length - 1; i >= 0; i--) {\n if (this.activeRank[i] < this.pointRank)\n break;\n if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)\n active.push(this.active[i]);\n }\n return active.reverse();\n }\n openEnd(to) {\n let open = 0;\n for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)\n open++;\n return open;\n }\n}\nfunction compare(a, startA, b, startB, length, comparator) {\n a.goto(startA);\n b.goto(startB);\n let endB = startB + length;\n let pos = startB, dPos = startB - startA;\n for (;;) {\n let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;\n let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);\n if (a.point || b.point) {\n if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&\n sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))\n comparator.comparePoint(pos, clipEnd, a.point, b.point);\n }\n else {\n if (clipEnd > pos && !sameValues(a.active, b.active))\n comparator.compareRange(pos, clipEnd, a.active, b.active);\n }\n if (end > endB)\n break;\n pos = end;\n if (diff <= 0)\n a.next();\n if (diff >= 0)\n b.next();\n }\n}\nfunction sameValues(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (a[i] != b[i] && !a[i].eq(b[i]))\n return false;\n return true;\n}\nfunction remove(array, index) {\n for (let i = index, e = array.length - 1; i < e; i++)\n array[i] = array[i + 1];\n array.pop();\n}\nfunction insert(array, index, value) {\n for (let i = array.length - 1; i >= index; i--)\n array[i + 1] = array[i];\n array[index] = value;\n}\nfunction findMinIndex(value, array) {\n let found = -1, foundPos = 1000000000 /* C.Far */;\n for (let i = 0; i < array.length; i++)\n if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {\n found = i;\n foundPos = array[i];\n }\n return found;\n}\n\n/**\nCount the column position at the given offset into the string,\ntaking extending characters and tab size into account.\n*/\nfunction countColumn(string, tabSize, to = string.length) {\n let n = 0;\n for (let i = 0; i < to;) {\n if (string.charCodeAt(i) == 9) {\n n += tabSize - (n % tabSize);\n i++;\n }\n else {\n n++;\n i = findClusterBreak(string, i);\n }\n }\n return n;\n}\n/**\nFind the offset that corresponds to the given column position in a\nstring, taking extending characters and tab size into account. By\ndefault, the string length is returned when it is too short to\nreach the column. Pass `strict` true to make it return -1 in that\nsituation.\n*/\nfunction findColumn(string, col, tabSize, strict) {\n for (let i = 0, n = 0;;) {\n if (n >= col)\n return i;\n if (i == string.length)\n break;\n n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;\n i = findClusterBreak(string, i);\n }\n return strict === true ? -1 : string.length;\n}\n\nexport { Annotation, AnnotationType, ChangeDesc, ChangeSet, CharCategory, Compartment, EditorSelection, EditorState, Facet, Line, MapMode, Prec, Range, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, StateEffect, StateEffectType, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };\n","const C = \"\\u037c\"\nconst COUNT = typeof Symbol == \"undefined\" ? \"__\" + C : Symbol.for(C)\nconst SET = typeof Symbol == \"undefined\" ? \"__styleSet\" + Math.floor(Math.random() * 1e8) : Symbol(\"styleSet\")\nconst top = typeof globalThis != \"undefined\" ? globalThis : typeof window != \"undefined\" ? window : {}\n\n// :: - Style modules encapsulate a set of CSS rules defined from\n// JavaScript. Their definitions are only available in a given DOM\n// root after it has been _mounted_ there with `StyleModule.mount`.\n//\n// Style modules should be created once and stored somewhere, as\n// opposed to re-creating them every time you need them. The amount of\n// CSS rules generated for a given DOM root is bounded by the amount\n// of style modules that were used. So to avoid leaking rules, don't\n// create these dynamically, but treat them as one-time allocations.\nexport class StyleModule {\n // :: (Object<Style>, ?{finish: ?(string) → string})\n // Create a style module from the given spec.\n //\n // When `finish` is given, it is called on regular (non-`@`)\n // selectors (after `&` expansion) to compute the final selector.\n constructor(spec, options) {\n this.rules = []\n let {finish} = options || {}\n\n function splitSelector(selector) {\n return /^@/.test(selector) ? [selector] : selector.split(/,\\s*/)\n }\n\n function render(selectors, spec, target, isKeyframes) {\n let local = [], isAt = /^@(\\w+)\\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == \"keyframes\"\n if (isAt && spec == null) return target.push(selectors[0] + \";\")\n for (let prop in spec) {\n let value = spec[prop]\n if (/&/.test(prop)) {\n render(prop.split(/,\\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),\n value, target)\n } else if (value && typeof value == \"object\") {\n if (!isAt) throw new RangeError(\"The value of a property (\" + prop + \") should be a primitive value.\")\n render(splitSelector(prop), value, local, keyframes)\n } else if (value != null) {\n local.push(prop.replace(/_.*/, \"\").replace(/[A-Z]/g, l => \"-\" + l.toLowerCase()) + \": \" + value + \";\")\n }\n }\n if (local.length || keyframes) {\n target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(\", \") +\n \" {\" + local.join(\" \") + \"}\")\n }\n }\n\n for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules)\n }\n\n // :: () → string\n // Returns a string containing the module's CSS rules.\n getRules() { return this.rules.join(\"\\n\") }\n\n // :: () → string\n // Generate a new unique CSS class name.\n static newName() {\n let id = top[COUNT] || 1\n top[COUNT] = id + 1\n return C + id.toString(36)\n }\n\n // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})\n //\n // Mount the given set of modules in the given DOM root, which ensures\n // that the CSS rules defined by the module are available in that\n // context.\n //\n // Rules are only added to the document once per root.\n //\n // Rule order will follow the order of the modules, so that rules from\n // modules later in the array take precedence of those from earlier\n // modules. If you call this function multiple times for the same root\n // in a way that changes the order of already mounted modules, the old\n // order will be changed.\n //\n // If a Content Security Policy nonce is provided, it is added to\n // the `<style>` tag generated by the library.\n static mount(root, modules, options) {\n let set = root[SET], nonce = options && options.nonce\n if (!set) set = new StyleSet(root, nonce)\n else if (nonce) set.setNonce(nonce)\n set.mount(Array.isArray(modules) ? modules : [modules])\n }\n}\n\nlet adoptedSet = new Map //<Document, StyleSet>\n\nclass StyleSet {\n constructor(root, nonce) {\n let doc = root.ownerDocument || root, win = doc.defaultView\n if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {\n let adopted = adoptedSet.get(doc)\n if (adopted) {\n root.adoptedStyleSheets = [adopted.sheet, ...root.adoptedStyleSheets]\n return root[SET] = adopted\n }\n this.sheet = new win.CSSStyleSheet\n root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets]\n adoptedSet.set(doc, this)\n } else {\n this.styleTag = doc.createElement(\"style\")\n if (nonce) this.styleTag.setAttribute(\"nonce\", nonce)\n let target = root.head || root\n target.insertBefore(this.styleTag, target.firstChild)\n }\n this.modules = []\n root[SET] = this\n }\n\n mount(modules) {\n let sheet = this.sheet\n let pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */\n for (let i = 0; i < modules.length; i++) {\n let mod = modules[i], index = this.modules.indexOf(mod)\n if (index < j && index > -1) { // Ordering conflict\n this.modules.splice(index, 1)\n j--\n index = -1\n }\n if (index == -1) {\n this.modules.splice(j++, 0, mod)\n if (sheet) for (let k = 0; k < mod.rules.length; k++)\n sheet.insertRule(mod.rules[k], pos++)\n } else {\n while (j < index) pos += this.modules[j++].rules.length\n pos += mod.rules.length\n j++\n }\n }\n\n if (!sheet) {\n let text = \"\"\n for (let i = 0; i < this.modules.length; i++)\n text += this.modules[i].getRules() + \"\\n\"\n this.styleTag.textContent = text\n }\n }\n\n setNonce(nonce) {\n if (this.styleTag && this.styleTag.getAttribute(\"nonce\") != nonce)\n this.styleTag.setAttribute(\"nonce\", nonce)\n }\n}\n\n// Style::Object<union<Style,string>>\n//\n// A style is an object that, in the simple case, maps CSS property\n// names to strings holding their values, as in `{color: \"red\",\n// fontWeight: \"bold\"}`. The property names can be given in\n// camel-case—the library will insert a dash before capital letters\n// when converting them to CSS.\n//\n// If you include an underscore in a property name, it and everything\n// after it will be removed from the output, which can be useful when\n// providing a property multiple times, for browser compatibility\n// reasons.\n//\n// A property in a style object can also be a sub-selector, which\n// extends the current context to add a pseudo-selector or a child\n// selector. Such a property should contain a `&` character, which\n// will be replaced by the current selector. For example `{\"&:before\":\n// {content: '\"hi\"'}}`. Sub-selectors and regular properties can\n// freely be mixed in a given object. Any property containing a `&` is\n// assumed to be a sub-selector.\n//\n// Finally, a property can specify an @-block to be wrapped around the\n// styles defined inside the object that's the property's value. For\n// example to create a media query you can do `{\"@media screen and\n// (min-width: 400px)\": {...}}`.\n","export var base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\"\n}\n\nexport var shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \":\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\"\n}\n\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform)\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent)\n\n// Fill in the digit keys\nfor (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i)\n\n// The function keys\nfor (var i = 1; i <= 24; i++) base[i + 111] = \"F\" + i\n\n// And the alphabetic keys\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32)\n shift[i] = String.fromCharCode(i)\n}\n\n// For each code that doesn't have a shift-equivalent, copy the base name\nfor (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code]\n\nexport function keyName(event) {\n // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.\n // On IE, shift effect is never included in `.key`.\n var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||\n ie && event.shiftKey && event.key && event.key.length == 1 ||\n event.key == \"Unidentified\"\n var name = (!ignoreKey && event.key) ||\n (event.shiftKey ? shift : base)[event.keyCode] ||\n event.key || \"Unidentified\"\n // Edge sometimes produces wrong names (Issue #3)\n if (name == \"Esc\") name = \"Escape\"\n if (name == \"Del\") name = \"Delete\"\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n if (name == \"Left\") name = \"ArrowLeft\"\n if (name == \"Up\") name = \"ArrowUp\"\n if (name == \"Right\") name = \"ArrowRight\"\n if (name == \"Down\") name = \"ArrowDown\"\n return name\n}\n","import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, findColumn, CharCategory, Annotation, EditorState, Transaction, Prec, codePointAt, codePointSize, combineConfig, StateField, RangeSetBuilder, countColumn } from '@codemirror/state';\nimport { StyleModule } from 'style-mod';\nimport { keyName, base, shift } from 'w3c-keyname';\n\nfunction getSelection(root) {\n let target;\n // Browsers differ on whether shadow roots have a getSelection\n // method. If it exists, use that, otherwise, call it on the\n // document.\n if (root.nodeType == 11) { // Shadow root\n target = root.getSelection ? root : root.ownerDocument;\n }\n else {\n target = root;\n }\n return target.getSelection();\n}\nfunction contains(dom, node) {\n return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;\n}\nfunction deepActiveElement(doc) {\n let elt = doc.activeElement;\n while (elt && elt.shadowRoot)\n elt = elt.shadowRoot.activeElement;\n return elt;\n}\nfunction hasSelection(dom, selection) {\n if (!selection.anchorNode)\n return false;\n try {\n // Firefox will raise 'permission denied' errors when accessing\n // properties of `sel.anchorNode` when it's in a generated CSS\n // element.\n return contains(dom, selection.anchorNode);\n }\n catch (_) {\n return false;\n }\n}\nfunction clientRectsFor(dom) {\n if (dom.nodeType == 3)\n return textRange(dom, 0, dom.nodeValue.length).getClientRects();\n else if (dom.nodeType == 1)\n return dom.getClientRects();\n else\n return [];\n}\n// Scans forward and backward through DOM positions equivalent to the\n// given one to see if the two are in the same place (i.e. after a\n// text node vs at the end of that text node)\nfunction isEquivalentPosition(node, off, targetNode, targetOff) {\n return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||\n scanFor(node, off, targetNode, targetOff, 1)) : false;\n}\nfunction domIndex(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n if (!node)\n return index;\n }\n}\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n for (;;) {\n if (node == targetNode && off == targetOff)\n return true;\n if (off == (dir < 0 ? 0 : maxOffset(node))) {\n if (node.nodeName == \"DIV\")\n return false;\n let parent = node.parentNode;\n if (!parent || parent.nodeType != 1)\n return false;\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n }\n else if (node.nodeType == 1) {\n node = node.childNodes[off + (dir < 0 ? -1 : 0)];\n if (node.nodeType == 1 && node.contentEditable == \"false\")\n return false;\n off = dir < 0 ? maxOffset(node) : 0;\n }\n else {\n return false;\n }\n }\n}\nfunction maxOffset(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\nfunction flattenRect(rect, left) {\n let x = left ? rect.left : rect.right;\n return { left: x, right: x, top: rect.top, bottom: rect.bottom };\n}\nfunction windowRect(win) {\n return { left: 0, right: win.innerWidth,\n top: 0, bottom: win.innerHeight };\n}\nfunction scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n for (let cur = dom, stop = false; cur && !stop;) {\n if (cur.nodeType == 1) { // Element\n let bounding, top = cur == doc.body;\n let scaleX = 1, scaleY = 1;\n if (top) {\n bounding = windowRect(win);\n }\n else {\n if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))\n stop = true;\n if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {\n cur = cur.assignedSlot || cur.parentNode;\n continue;\n }\n let rect = cur.getBoundingClientRect();\n scaleX = rect.width / cur.offsetWidth;\n scaleY = rect.height / cur.offsetHeight;\n // Make sure scrollbar width isn't included in the rectangle\n bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,\n top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };\n }\n let moveX = 0, moveY = 0;\n if (y == \"nearest\") {\n if (rect.top < bounding.top) {\n moveY = -(bounding.top - rect.top + yMargin);\n if (side > 0 && rect.bottom > bounding.bottom + moveY)\n moveY = rect.bottom - bounding.bottom + moveY + yMargin;\n }\n else if (rect.bottom > bounding.bottom) {\n moveY = rect.bottom - bounding.bottom + yMargin;\n if (side < 0 && (rect.top - moveY) < bounding.top)\n moveY = -(bounding.top + moveY - rect.top + yMargin);\n }\n }\n else {\n let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;\n let targetTop = y == \"center\" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :\n y == \"start\" || y == \"center\" && side < 0 ? rect.top - yMargin :\n rect.bottom - boundingHeight + yMargin;\n moveY = targetTop - bounding.top;\n }\n if (x == \"nearest\") {\n if (rect.left < bounding.left) {\n moveX = -(bounding.left - rect.left + xMargin);\n if (side > 0 && rect.right > bounding.right + moveX)\n moveX = rect.right - bounding.right + moveX + xMargin;\n }\n else if (rect.right > bounding.right) {\n moveX = rect.right - bounding.right + xMargin;\n if (side < 0 && rect.left < bounding.left + moveX)\n moveX = -(bounding.left + moveX - rect.left + xMargin);\n }\n }\n else {\n let targetLeft = x == \"center\" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :\n (x == \"start\") == ltr ? rect.left - xMargin :\n rect.right - (bounding.right - bounding.left) + xMargin;\n moveX = targetLeft - bounding.left;\n }\n if (moveX || moveY) {\n if (top) {\n win.scrollBy(moveX, moveY);\n }\n else {\n let movedX = 0, movedY = 0;\n if (moveY) {\n let start = cur.scrollTop;\n cur.scrollTop += moveY / scaleY;\n movedY = (cur.scrollTop - start) * scaleY;\n }\n if (moveX) {\n let start = cur.scrollLeft;\n cur.scrollLeft += moveX / scaleX;\n movedX = (cur.scrollLeft - start) * scaleX;\n }\n rect = { left: rect.left - movedX, top: rect.top - movedY,\n right: rect.right - movedX, bottom: rect.bottom - movedY };\n if (movedX && Math.abs(movedX - moveX) < 1)\n x = \"nearest\";\n if (movedY && Math.abs(movedY - moveY) < 1)\n y = \"nearest\";\n }\n }\n if (top)\n break;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) { // A shadow root\n cur = cur.host;\n }\n else {\n break;\n }\n }\n}\nfunction scrollableParent(dom) {\n let doc = dom.ownerDocument;\n for (let cur = dom.parentNode; cur;) {\n if (cur == doc.body) {\n break;\n }\n else if (cur.nodeType == 1) {\n if (cur.scrollHeight > cur.clientHeight || cur.scrollWidth > cur.clientWidth)\n return cur;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) {\n cur = cur.host;\n }\n else {\n break;\n }\n }\n return null;\n}\nclass DOMSelectionState {\n constructor() {\n this.anchorNode = null;\n this.anchorOffset = 0;\n this.focusNode = null;\n this.focusOffset = 0;\n }\n eq(domSel) {\n return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&\n this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;\n }\n setRange(range) {\n let { anchorNode, focusNode } = range;\n // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)\n this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));\n }\n set(anchorNode, anchorOffset, focusNode, focusOffset) {\n this.anchorNode = anchorNode;\n this.anchorOffset = anchorOffset;\n this.focusNode = focusNode;\n this.focusOffset = focusOffset;\n }\n}\nlet preventScrollSupported = null;\n// Feature-detects support for .focus({preventScroll: true}), and uses\n// a fallback kludge when not supported.\nfunction focusPreventScroll(dom) {\n if (dom.setActive)\n return dom.setActive(); // in IE\n if (preventScrollSupported)\n return dom.focus(preventScrollSupported);\n let stack = [];\n for (let cur = dom; cur; cur = cur.parentNode) {\n stack.push(cur, cur.scrollTop, cur.scrollLeft);\n if (cur == cur.ownerDocument)\n break;\n }\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = { preventScroll: true };\n return true;\n }\n } : undefined);\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n for (let i = 0; i < stack.length;) {\n let elt = stack[i++], top = stack[i++], left = stack[i++];\n if (elt.scrollTop != top)\n elt.scrollTop = top;\n if (elt.scrollLeft != left)\n elt.scrollLeft = left;\n }\n }\n}\nlet scratchRange;\nfunction textRange(node, from, to = from) {\n let range = scratchRange || (scratchRange = document.createRange());\n range.setEnd(node, to);\n range.setStart(node, from);\n return range;\n}\nfunction dispatchKey(elt, name, code) {\n let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };\n let down = new KeyboardEvent(\"keydown\", options);\n down.synthetic = true;\n elt.dispatchEvent(down);\n let up = new KeyboardEvent(\"keyup\", options);\n up.synthetic = true;\n elt.dispatchEvent(up);\n return down.defaultPrevented || up.defaultPrevented;\n}\nfunction getRoot(node) {\n while (node) {\n if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))\n return node;\n node = node.assignedSlot || node.parentNode;\n }\n return null;\n}\nfunction clearAttributes(node) {\n while (node.attributes.length)\n node.removeAttributeNode(node.attributes[0]);\n}\nfunction atElementStart(doc, selection) {\n let node = selection.focusNode, offset = selection.focusOffset;\n if (!node || selection.anchorNode != node || selection.anchorOffset != offset)\n return false;\n // Safari can report bogus offsets (#1152)\n offset = Math.min(offset, maxOffset(node));\n for (;;) {\n if (offset) {\n if (node.nodeType != 1)\n return false;\n let prev = node.childNodes[offset - 1];\n if (prev.contentEditable == \"false\")\n offset--;\n else {\n node = prev;\n offset = maxOffset(node);\n }\n }\n else if (node == doc) {\n return true;\n }\n else {\n offset = domIndex(node);\n node = node.parentNode;\n }\n }\n}\nfunction isScrolledToBottom(elt) {\n return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);\n}\n\nclass DOMPos {\n constructor(node, offset, precise = true) {\n this.node = node;\n this.offset = offset;\n this.precise = precise;\n }\n static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }\n static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }\n}\nconst noChildren = [];\nclass ContentView {\n constructor() {\n this.parent = null;\n this.dom = null;\n this.flags = 2 /* ViewFlag.NodeDirty */;\n }\n get overrideDOMText() { return null; }\n get posAtStart() {\n return this.parent ? this.parent.posBefore(this) : 0;\n }\n get posAtEnd() {\n return this.posAtStart + this.length;\n }\n posBefore(view) {\n let pos = this.posAtStart;\n for (let child of this.children) {\n if (child == view)\n return pos;\n pos += child.length + child.breakAfter;\n }\n throw new RangeError(\"Invalid child in posBefore\");\n }\n posAfter(view) {\n return this.posBefore(view) + view.length;\n }\n sync(view, track) {\n if (this.flags & 2 /* ViewFlag.NodeDirty */) {\n let parent = this.dom;\n let prev = null, next;\n for (let child of this.children) {\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {\n let contentView = ContentView.get(next);\n if (!contentView || !contentView.parent && contentView.canReuseDOM(child))\n child.reuseDOM(next);\n }\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (track && !track.written && track.node == parent && next != child.dom)\n track.written = true;\n if (child.dom.parentNode == parent) {\n while (next && next != child.dom)\n next = rm$1(next);\n }\n else {\n parent.insertBefore(child.dom, next);\n }\n prev = child.dom;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (next && track && track.node == parent)\n track.written = true;\n while (next)\n next = rm$1(next);\n }\n else if (this.flags & 1 /* ViewFlag.ChildDirty */) {\n for (let child of this.children)\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n }\n }\n reuseDOM(_dom) { }\n localPosFromDOM(node, offset) {\n let after;\n if (node == this.dom) {\n after = this.dom.childNodes[offset];\n }\n else {\n let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;\n for (;;) {\n let parent = node.parentNode;\n if (parent == this.dom)\n break;\n if (bias == 0 && parent.firstChild != parent.lastChild) {\n if (node == parent.firstChild)\n bias = -1;\n else\n bias = 1;\n }\n node = parent;\n }\n if (bias < 0)\n after = node;\n else\n after = node.nextSibling;\n }\n if (after == this.dom.firstChild)\n return 0;\n while (after && !ContentView.get(after))\n after = after.nextSibling;\n if (!after)\n return this.length;\n for (let i = 0, pos = 0;; i++) {\n let child = this.children[i];\n if (child.dom == after)\n return pos;\n pos += child.length + child.breakAfter;\n }\n }\n domBoundsAround(from, to, offset = 0) {\n let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;\n for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos < from && end > to)\n return child.domBoundsAround(from, to, pos);\n if (end >= from && fromI == -1) {\n fromI = i;\n fromStart = pos;\n }\n if (pos > to && child.dom.parentNode == this.dom) {\n toI = i;\n toEnd = prevEnd;\n break;\n }\n prevEnd = end;\n pos = end + child.breakAfter;\n }\n return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,\n startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,\n endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };\n }\n markDirty(andParent = false) {\n this.flags |= 2 /* ViewFlag.NodeDirty */;\n this.markParentsDirty(andParent);\n }\n markParentsDirty(childList) {\n for (let parent = this.parent; parent; parent = parent.parent) {\n if (childList)\n parent.flags |= 2 /* ViewFlag.NodeDirty */;\n if (parent.flags & 1 /* ViewFlag.ChildDirty */)\n return;\n parent.flags |= 1 /* ViewFlag.ChildDirty */;\n childList = false;\n }\n }\n setParent(parent) {\n if (this.parent != parent) {\n this.parent = parent;\n if (this.flags & 7 /* ViewFlag.Dirty */)\n this.markParentsDirty(true);\n }\n }\n setDOM(dom) {\n if (this.dom == dom)\n return;\n if (this.dom)\n this.dom.cmView = null;\n this.dom = dom;\n dom.cmView = this;\n }\n get rootView() {\n for (let v = this;;) {\n let parent = v.parent;\n if (!parent)\n return v;\n v = parent;\n }\n }\n replaceChildren(from, to, children = noChildren) {\n this.markDirty();\n for (let i = from; i < to; i++) {\n let child = this.children[i];\n if (child.parent == this)\n child.destroy();\n }\n this.children.splice(from, to - from, ...children);\n for (let i = 0; i < children.length; i++)\n children[i].setParent(this);\n }\n ignoreMutation(_rec) { return false; }\n ignoreEvent(_event) { return false; }\n childCursor(pos = this.length) {\n return new ChildCursor(this.children, pos, this.children.length);\n }\n childPos(pos, bias = 1) {\n return this.childCursor().findPos(pos, bias);\n }\n toString() {\n let name = this.constructor.name.replace(\"View\", \"\");\n return name + (this.children.length ? \"(\" + this.children.join() + \")\" :\n this.length ? \"[\" + (name == \"Text\" ? this.text : this.length) + \"]\" : \"\") +\n (this.breakAfter ? \"#\" : \"\");\n }\n static get(node) { return node.cmView; }\n get isEditable() { return true; }\n get isWidget() { return false; }\n get isHidden() { return false; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n return false;\n }\n become(other) { return false; }\n canReuseDOM(other) {\n return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n // When this is a zero-length view with a side, this should return a\n // number <= 0 to indicate it is before its position, or a\n // number > 0 when after its position.\n getSide() { return 0; }\n destroy() {\n this.parent = null;\n }\n}\nContentView.prototype.breakAfter = 0;\n// Remove a DOM node and return its next sibling.\nfunction rm$1(dom) {\n let next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next;\n}\nclass ChildCursor {\n constructor(children, pos, i) {\n this.children = children;\n this.pos = pos;\n this.i = i;\n this.off = 0;\n }\n findPos(pos, bias = 1) {\n for (;;) {\n if (pos > this.pos || pos == this.pos &&\n (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {\n this.off = pos - this.pos;\n return this;\n }\n let next = this.children[--this.i];\n this.pos -= next.length + next.breakAfter;\n }\n }\n}\nfunction replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {\n let { children } = parent;\n let before = children.length ? children[fromI] : null;\n let last = insert.length ? insert[insert.length - 1] : null;\n let breakAtEnd = last ? last.breakAfter : breakAtStart;\n // Change within a single child\n if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&\n before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))\n return;\n if (toI < children.length) {\n let after = children[toI];\n // Make sure the end of the child after the update is preserved in `after`\n if (after && toOff < after.length) {\n // If we're splitting a child, separate part of it to avoid that\n // being mangled when updating the child before the update.\n if (fromI == toI) {\n after = after.split(toOff);\n toOff = 0;\n }\n // If the element after the replacement should be merged with\n // the last replacing element, update `content`\n if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {\n insert[insert.length - 1] = after;\n }\n else {\n // Remove the start of the after element, if necessary, and\n // add it to `content`.\n if (toOff)\n after.merge(0, toOff, null, false, 0, openEnd);\n insert.push(after);\n }\n }\n else if (after === null || after === void 0 ? void 0 : after.breakAfter) {\n // The element at `toI` is entirely covered by this range.\n // Preserve its line break, if any.\n if (last)\n last.breakAfter = 1;\n else\n breakAtStart = 1;\n }\n // Since we've handled the next element from the current elements\n // now, make sure `toI` points after that.\n toI++;\n }\n if (before) {\n before.breakAfter = breakAtStart;\n if (fromOff > 0) {\n if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {\n before.breakAfter = insert.shift().breakAfter;\n }\n else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {\n before.merge(fromOff, before.length, null, false, openStart, 0);\n }\n fromI++;\n }\n }\n // Try to merge widgets on the boundaries of the replacement\n while (fromI < toI && insert.length) {\n if (children[toI - 1].become(insert[insert.length - 1])) {\n toI--;\n insert.pop();\n openEnd = insert.length ? 0 : openStart;\n }\n else if (children[fromI].become(insert[0])) {\n fromI++;\n insert.shift();\n openStart = insert.length ? 0 : openEnd;\n }\n else {\n break;\n }\n }\n if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&\n children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))\n fromI--;\n if (fromI < toI || insert.length)\n parent.replaceChildren(fromI, toI, insert);\n}\nfunction mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {\n let cur = parent.childCursor();\n let { i: toI, off: toOff } = cur.findPos(to, 1);\n let { i: fromI, off: fromOff } = cur.findPos(from, -1);\n let dLen = from - to;\n for (let view of insert)\n dLen += view.length;\n parent.length += dLen;\n replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);\n}\n\nlet nav = typeof navigator != \"undefined\" ? navigator : { userAgent: \"\", vendor: \"\", platform: \"\" };\nlet doc = typeof document != \"undefined\" ? document : { documentElement: { style: {} } };\nconst ie_edge = /*@__PURE__*//Edge\\/(\\d+)/.exec(nav.userAgent);\nconst ie_upto10 = /*@__PURE__*//MSIE \\d/.test(nav.userAgent);\nconst ie_11up = /*@__PURE__*//Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(nav.userAgent);\nconst ie = !!(ie_upto10 || ie_11up || ie_edge);\nconst gecko = !ie && /*@__PURE__*//gecko\\/(\\d+)/i.test(nav.userAgent);\nconst chrome = !ie && /*@__PURE__*//Chrome\\/(\\d+)/.exec(nav.userAgent);\nconst webkit = \"webkitFontSmoothing\" in doc.documentElement.style;\nconst safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);\nconst ios = safari && (/*@__PURE__*//Mobile\\/\\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);\nvar browser = {\n mac: ios || /*@__PURE__*//Mac/.test(nav.platform),\n windows: /*@__PURE__*//Win/.test(nav.platform),\n linux: /*@__PURE__*//Linux|X11/.test(nav.platform),\n ie,\n ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,\n gecko,\n gecko_version: gecko ? +(/*@__PURE__*//Firefox\\/(\\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,\n chrome: !!chrome,\n chrome_version: chrome ? +chrome[1] : 0,\n ios,\n android: /*@__PURE__*//Android\\b/.test(nav.userAgent),\n webkit,\n safari,\n webkit_version: webkit ? +(/*@__PURE__*//\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,\n tabSize: doc.documentElement.style.tabSize != null ? \"tab-size\" : \"-moz-tab-size\"\n};\n\nconst MaxJoinLen = 256;\nclass TextView extends ContentView {\n constructor(text) {\n super();\n this.text = text;\n }\n get length() { return this.text.length; }\n createDOM(textDOM) {\n this.setDOM(textDOM || document.createTextNode(this.text));\n }\n sync(view, track) {\n if (!this.dom)\n this.createDOM();\n if (this.dom.nodeValue != this.text) {\n if (track && track.node == this.dom)\n track.written = true;\n this.dom.nodeValue = this.text;\n }\n }\n reuseDOM(dom) {\n if (dom.nodeType == 3)\n this.createDOM(dom);\n }\n merge(from, to, source) {\n if ((this.flags & 8 /* ViewFlag.Composition */) ||\n source && (!(source instanceof TextView) ||\n this.length - (to - from) + source.length > MaxJoinLen ||\n (source.flags & 8 /* ViewFlag.Composition */)))\n return false;\n this.text = this.text.slice(0, from) + (source ? source.text : \"\") + this.text.slice(to);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = new TextView(this.text.slice(from));\n this.text = this.text.slice(0, from);\n this.markDirty();\n result.flags |= this.flags & 8 /* ViewFlag.Composition */;\n return result;\n }\n localPosFromDOM(node, offset) {\n return node == this.dom ? offset : offset ? this.text.length : 0;\n }\n domAtPos(pos) { return new DOMPos(this.dom, pos); }\n domBoundsAround(_from, _to, offset) {\n return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };\n }\n coordsAt(pos, side) {\n return textCoords(this.dom, pos, side);\n }\n}\nclass MarkView extends ContentView {\n constructor(mark, children = [], length = 0) {\n super();\n this.mark = mark;\n this.children = children;\n this.length = length;\n for (let ch of children)\n ch.setParent(this);\n }\n setAttrs(dom) {\n clearAttributes(dom);\n if (this.mark.class)\n dom.className = this.mark.class;\n if (this.mark.attrs)\n for (let name in this.mark.attrs)\n dom.setAttribute(name, this.mark.attrs[name]);\n return dom;\n }\n canReuseDOM(other) {\n return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n reuseDOM(node) {\n if (node.nodeName == this.mark.tagName.toUpperCase()) {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n if (!this.dom)\n this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */)\n this.setAttrs(this.dom);\n super.sync(view, track);\n }\n merge(from, to, source, _hasStart, openStart, openEnd) {\n if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||\n (from && openStart <= 0) || (to < this.length && openEnd <= 0)))\n return false;\n mergeChildrenInto(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = [], off = 0, detachFrom = -1, i = 0;\n for (let elt of this.children) {\n let end = off + elt.length;\n if (end > from)\n result.push(off < from ? elt.split(from - off) : elt);\n if (detachFrom < 0 && off >= from)\n detachFrom = i;\n off = end;\n i++;\n }\n let length = this.length - from;\n this.length = from;\n if (detachFrom > -1) {\n this.children.length = detachFrom;\n this.markDirty();\n }\n return new MarkView(this.mark, result, length);\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n coordsAt(pos, side) {\n return coordsInChildren(this, pos, side);\n }\n}\nfunction textCoords(text, pos, side) {\n let length = text.nodeValue.length;\n if (pos > length)\n pos = length;\n let from = pos, to = pos, flatten = 0;\n if (pos == 0 && side < 0 || pos == length && side >= 0) {\n if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges\n if (pos) {\n from--;\n flatten = 1;\n } // FIXME this is wrong in RTL text\n else if (to < length) {\n to++;\n flatten = -1;\n }\n }\n }\n else {\n if (side < 0)\n from--;\n else if (to < length)\n to++;\n }\n let rects = textRange(text, from, to).getClientRects();\n if (!rects.length)\n return null;\n let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];\n if (browser.safari && !flatten && rect.width == 0)\n rect = Array.prototype.find.call(rects, r => r.width) || rect;\n return flatten ? flattenRect(rect, flatten < 0) : rect || null;\n}\n// Also used for collapsed ranges that don't have a placeholder widget!\nclass WidgetView extends ContentView {\n static create(widget, length, side) {\n return new WidgetView(widget, length, side);\n }\n constructor(widget, length, side) {\n super();\n this.widget = widget;\n this.length = length;\n this.side = side;\n this.prevWidget = null;\n }\n split(from) {\n let result = WidgetView.create(this.widget, this.length - from, this.side);\n this.length -= from;\n return result;\n }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n getSide() { return this.side; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n become(other) {\n if (other instanceof WidgetView && other.side == this.side &&\n this.widget.constructor == other.widget.constructor) {\n if (!this.widget.compare(other.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get overrideDOMText() {\n if (this.length == 0)\n return Text.empty;\n let top = this;\n while (top.parent)\n top = top.parent;\n let { view } = top, text = view && view.state.doc, start = this.posAtStart;\n return text ? text.slice(start, start + this.length) : Text.empty;\n }\n domAtPos(pos) {\n return (this.length ? pos == 0 : this.side > 0)\n ? DOMPos.before(this.dom)\n : DOMPos.after(this.dom, pos == this.length);\n }\n domBoundsAround() { return null; }\n coordsAt(pos, side) {\n let custom = this.widget.coordsAt(this.dom, pos, side);\n if (custom)\n return custom;\n let rects = this.dom.getClientRects(), rect = null;\n if (!rects.length)\n return null;\n let fromBack = this.side ? this.side < 0 : pos > 0;\n for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {\n rect = rects[i];\n if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)\n break;\n }\n return flattenRect(rect, !fromBack);\n }\n get isEditable() { return false; }\n get isWidget() { return true; }\n get isHidden() { return this.widget.isHidden; }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n}\n// These are drawn around uneditable widgets to avoid a number of\n// browser bugs that show up when the cursor is directly next to\n// uneditable inline content.\nclass WidgetBufferView extends ContentView {\n constructor(side) {\n super();\n this.side = side;\n }\n get length() { return 0; }\n merge() { return false; }\n become(other) {\n return other instanceof WidgetBufferView && other.side == this.side;\n }\n split() { return new WidgetBufferView(this.side); }\n sync() {\n if (!this.dom) {\n let dom = document.createElement(\"img\");\n dom.className = \"cm-widgetBuffer\";\n dom.setAttribute(\"aria-hidden\", \"true\");\n this.setDOM(dom);\n }\n }\n getSide() { return this.side; }\n domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }\n localPosFromDOM() { return 0; }\n domBoundsAround() { return null; }\n coordsAt(pos) {\n return this.dom.getBoundingClientRect();\n }\n get overrideDOMText() {\n return Text.empty;\n }\n get isHidden() { return true; }\n}\nTextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;\nfunction inlineDOMAtPos(parent, pos) {\n let dom = parent.dom, { children } = parent, i = 0;\n for (let off = 0; i < children.length; i++) {\n let child = children[i], end = off + child.length;\n if (end == off && child.getSide() <= 0)\n continue;\n if (pos > off && pos < end && child.dom.parentNode == dom)\n return child.domAtPos(pos - off);\n if (pos <= off)\n break;\n off = end;\n }\n for (let j = i; j > 0; j--) {\n let prev = children[j - 1];\n if (prev.dom.parentNode == dom)\n return prev.domAtPos(prev.length);\n }\n for (let j = i; j < children.length; j++) {\n let next = children[j];\n if (next.dom.parentNode == dom)\n return next.domAtPos(0);\n }\n return new DOMPos(dom, 0);\n}\n// Assumes `view`, if a mark view, has precisely 1 child.\nfunction joinInlineInto(parent, view, open) {\n let last, { children } = parent;\n if (open > 0 && view instanceof MarkView && children.length &&\n (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {\n joinInlineInto(last, view.children[0], open - 1);\n }\n else {\n children.push(view);\n view.setParent(parent);\n }\n parent.length += view.length;\n}\nfunction coordsInChildren(view, pos, side) {\n let before = null, beforePos = -1, after = null, afterPos = -1;\n function scan(view, pos) {\n for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {\n let child = view.children[i], end = off + child.length;\n if (end >= pos) {\n if (child.children.length) {\n scan(child, pos - off);\n }\n else if ((!after || after.isHidden && side > 0) &&\n (end > pos || off == end && child.getSide() > 0)) {\n after = child;\n afterPos = pos - off;\n }\n else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {\n before = child;\n beforePos = pos - off;\n }\n }\n off = end;\n }\n }\n scan(view, pos);\n let target = (side < 0 ? before : after) || before || after;\n if (target)\n return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);\n return fallbackRect(view);\n}\nfunction fallbackRect(view) {\n let last = view.dom.lastChild;\n if (!last)\n return view.dom.getBoundingClientRect();\n let rects = clientRectsFor(last);\n return rects[rects.length - 1] || null;\n}\n\nfunction combineAttrs(source, target) {\n for (let name in source) {\n if (name == \"class\" && target.class)\n target.class += \" \" + source.class;\n else if (name == \"style\" && target.style)\n target.style += \";\" + source.style;\n else\n target[name] = source[name];\n }\n return target;\n}\nconst noAttrs = /*@__PURE__*/Object.create(null);\nfunction attrsEq(a, b, ignore) {\n if (a == b)\n return true;\n if (!a)\n a = noAttrs;\n if (!b)\n b = noAttrs;\n let keysA = Object.keys(a), keysB = Object.keys(b);\n if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=\n keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))\n return false;\n for (let key of keysA) {\n if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))\n return false;\n }\n return true;\n}\nfunction updateAttrs(dom, prev, attrs) {\n let changed = false;\n if (prev)\n for (let name in prev)\n if (!(attrs && name in attrs)) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = \"\";\n else\n dom.removeAttribute(name);\n }\n if (attrs)\n for (let name in attrs)\n if (!(prev && prev[name] == attrs[name])) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = attrs[name];\n else\n dom.setAttribute(name, attrs[name]);\n }\n return changed;\n}\nfunction getAttrs(dom) {\n let attrs = Object.create(null);\n for (let i = 0; i < dom.attributes.length; i++) {\n let attr = dom.attributes[i];\n attrs[attr.name] = attr.value;\n }\n return attrs;\n}\n\n/**\nWidgets added to the content are described by subclasses of this\nclass. Using a description object like that makes it possible to\ndelay creating of the DOM structure for a widget until it is\nneeded, and to avoid redrawing widgets even if the decorations\nthat define them are recreated.\n*/\nclass WidgetType {\n /**\n Compare this instance to another instance of the same type.\n (TypeScript can't express this, but only instances of the same\n specific class will be passed to this method.) This is used to\n avoid redrawing widgets when they are replaced by a new\n decoration of the same type. The default implementation just\n returns `false`, which will cause new instances of the widget to\n always be redrawn.\n */\n eq(widget) { return false; }\n /**\n Update a DOM element created by a widget of the same type (but\n different, non-`eq` content) to reflect this widget. May return\n true to indicate that it could update, false to indicate it\n couldn't (in which case the widget will be redrawn). The default\n implementation just returns false.\n */\n updateDOM(dom, view) { return false; }\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n The estimated height this widget will have, to be used when\n estimating the height of content that hasn't been drawn. May\n return -1 to indicate you don't know. The default implementation\n returns -1.\n */\n get estimatedHeight() { return -1; }\n /**\n For inline widgets that are displayed inline (as opposed to\n `inline-block`) and introduce line breaks (through `<br>` tags\n or textual newlines), this must indicate the amount of line\n breaks they introduce. Defaults to 0.\n */\n get lineBreaks() { return 0; }\n /**\n Can be used to configure which kinds of events inside the widget\n should be ignored by the editor. The default is to ignore all\n events.\n */\n ignoreEvent(event) { return true; }\n /**\n Override the way screen coordinates for positions at/in the\n widget are found. `pos` will be the offset into the widget, and\n `side` the side of the position that is being queried—less than\n zero for before, greater than zero for after, and zero for\n directly at that position.\n */\n coordsAt(dom, pos, side) { return null; }\n /**\n @internal\n */\n get isHidden() { return false; }\n /**\n This is called when the an instance of the widget is removed\n from the editor view.\n */\n destroy(dom) { }\n}\n/**\nThe different types of blocks that can occur in an editor view.\n*/\nvar BlockType = /*@__PURE__*/(function (BlockType) {\n /**\n A line of text.\n */\n BlockType[BlockType[\"Text\"] = 0] = \"Text\";\n /**\n A block widget associated with the position after it.\n */\n BlockType[BlockType[\"WidgetBefore\"] = 1] = \"WidgetBefore\";\n /**\n A block widget associated with the position before it.\n */\n BlockType[BlockType[\"WidgetAfter\"] = 2] = \"WidgetAfter\";\n /**\n A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.\n */\n BlockType[BlockType[\"WidgetRange\"] = 3] = \"WidgetRange\";\nreturn BlockType})(BlockType || (BlockType = {}));\n/**\nA decoration provides information on how to draw or style a piece\nof content. You'll usually use it wrapped in a\n[`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.\n@nonabstract\n*/\nclass Decoration extends RangeValue {\n constructor(\n /**\n @internal\n */\n startSide, \n /**\n @internal\n */\n endSide, \n /**\n @internal\n */\n widget, \n /**\n The config object used to create this decoration. You can\n include additional properties in there to store metadata about\n your decoration.\n */\n spec) {\n super();\n this.startSide = startSide;\n this.endSide = endSide;\n this.widget = widget;\n this.spec = spec;\n }\n /**\n @internal\n */\n get heightRelevant() { return false; }\n /**\n Create a mark decoration, which influences the styling of the\n content in its range. Nested mark decorations will cause nested\n DOM elements to be created. Nesting order is determined by\n precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with\n the higher-precedence decorations creating the inner DOM nodes.\n Such elements are split on line boundaries and on the boundaries\n of lower-precedence decorations.\n */\n static mark(spec) {\n return new MarkDecoration(spec);\n }\n /**\n Create a widget decoration, which displays a DOM element at the\n given position.\n */\n static widget(spec) {\n let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;\n side += (block && !spec.inlineOrder)\n ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)\n : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);\n return new PointDecoration(spec, side, side, block, spec.widget || null, false);\n }\n /**\n Create a replace decoration which replaces the given range with\n a widget, or simply hides it.\n */\n static replace(spec) {\n let block = !!spec.block, startSide, endSide;\n if (spec.isBlockGap) {\n startSide = -500000000 /* Side.GapStart */;\n endSide = 400000000 /* Side.GapEnd */;\n }\n else {\n let { start, end } = getInclusive(spec, block);\n startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;\n endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;\n }\n return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);\n }\n /**\n Create a line decoration, which can add DOM attributes to the\n line starting at the given position.\n */\n static line(spec) {\n return new LineDecoration(spec);\n }\n /**\n Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given\n decorated range or ranges. If the ranges aren't already sorted,\n pass `true` for `sort` to make the library sort them for you.\n */\n static set(of, sort = false) {\n return RangeSet.of(of, sort);\n }\n /**\n @internal\n */\n hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }\n}\n/**\nThe empty set of decorations.\n*/\nDecoration.none = RangeSet.empty;\nclass MarkDecoration extends Decoration {\n constructor(spec) {\n let { start, end } = getInclusive(spec);\n super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);\n this.tagName = spec.tagName || \"span\";\n this.class = spec.class || \"\";\n this.attrs = spec.attributes || null;\n }\n eq(other) {\n var _a, _b;\n return this == other ||\n other instanceof MarkDecoration &&\n this.tagName == other.tagName &&\n (this.class || ((_a = this.attrs) === null || _a === void 0 ? void 0 : _a.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) &&\n attrsEq(this.attrs, other.attrs, \"class\");\n }\n range(from, to = from) {\n if (from >= to)\n throw new RangeError(\"Mark decorations may not be empty\");\n return super.range(from, to);\n }\n}\nMarkDecoration.prototype.point = false;\nclass LineDecoration extends Decoration {\n constructor(spec) {\n super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);\n }\n eq(other) {\n return other instanceof LineDecoration &&\n this.spec.class == other.spec.class &&\n attrsEq(this.spec.attributes, other.spec.attributes);\n }\n range(from, to = from) {\n if (to != from)\n throw new RangeError(\"Line decoration ranges must be zero-length\");\n return super.range(from, to);\n }\n}\nLineDecoration.prototype.mapMode = MapMode.TrackBefore;\nLineDecoration.prototype.point = true;\nclass PointDecoration extends Decoration {\n constructor(spec, startSide, endSide, block, widget, isReplace) {\n super(startSide, endSide, widget, spec);\n this.block = block;\n this.isReplace = isReplace;\n this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;\n }\n // Only relevant when this.block == true\n get type() {\n return this.startSide < this.endSide ? BlockType.WidgetRange\n : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;\n }\n get heightRelevant() {\n return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);\n }\n eq(other) {\n return other instanceof PointDecoration &&\n widgetsEq(this.widget, other.widget) &&\n this.block == other.block &&\n this.startSide == other.startSide && this.endSide == other.endSide;\n }\n range(from, to = from) {\n if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))\n throw new RangeError(\"Invalid range for replacement decoration\");\n if (!this.isReplace && to != from)\n throw new RangeError(\"Widget decorations can only have zero-length ranges\");\n return super.range(from, to);\n }\n}\nPointDecoration.prototype.point = true;\nfunction getInclusive(spec, block = false) {\n let { inclusiveStart: start, inclusiveEnd: end } = spec;\n if (start == null)\n start = spec.inclusive;\n if (end == null)\n end = spec.inclusive;\n return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };\n}\nfunction widgetsEq(a, b) {\n return a == b || !!(a && b && a.compare(b));\n}\nfunction addRange(from, to, ranges, margin = 0) {\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last] + margin >= from)\n ranges[last] = Math.max(ranges[last], to);\n else\n ranges.push(from, to);\n}\n\nclass LineView extends ContentView {\n constructor() {\n super(...arguments);\n this.children = [];\n this.length = 0;\n this.prevAttrs = undefined;\n this.attrs = null;\n this.breakAfter = 0;\n }\n // Consumes source\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source) {\n if (!(source instanceof LineView))\n return false;\n if (!this.dom)\n source.transferDOM(this); // Reuse source.dom when appropriate\n }\n if (hasStart)\n this.setDeco(source ? source.attrs : null);\n mergeChildrenInto(this, from, to, source ? source.children : [], openStart, openEnd);\n return true;\n }\n split(at) {\n let end = new LineView;\n end.breakAfter = this.breakAfter;\n if (this.length == 0)\n return end;\n let { i, off } = this.childPos(at);\n if (off) {\n end.append(this.children[i].split(off), 0);\n this.children[i].merge(off, this.children[i].length, null, false, 0, 0);\n i++;\n }\n for (let j = i; j < this.children.length; j++)\n end.append(this.children[j], 0);\n while (i > 0 && this.children[i - 1].length == 0)\n this.children[--i].destroy();\n this.children.length = i;\n this.markDirty();\n this.length = at;\n return end;\n }\n transferDOM(other) {\n if (!this.dom)\n return;\n this.markDirty();\n other.setDOM(this.dom);\n other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;\n this.prevAttrs = undefined;\n this.dom = null;\n }\n setDeco(attrs) {\n if (!attrsEq(this.attrs, attrs)) {\n if (this.dom) {\n this.prevAttrs = this.attrs;\n this.markDirty();\n }\n this.attrs = attrs;\n }\n }\n append(child, openStart) {\n joinInlineInto(this, child, openStart);\n }\n // Only called when building a line view in ContentBuilder\n addLineDeco(deco) {\n let attrs = deco.spec.attributes, cls = deco.spec.class;\n if (attrs)\n this.attrs = combineAttrs(attrs, this.attrs || {});\n if (cls)\n this.attrs = combineAttrs({ class: cls }, this.attrs || {});\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n reuseDOM(node) {\n if (node.nodeName == \"DIV\") {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n var _a;\n if (!this.dom) {\n this.setDOM(document.createElement(\"div\"));\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {\n clearAttributes(this.dom);\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n if (this.prevAttrs !== undefined) {\n updateAttrs(this.dom, this.prevAttrs, this.attrs);\n this.dom.classList.add(\"cm-line\");\n this.prevAttrs = undefined;\n }\n super.sync(view, track);\n let last = this.dom.lastChild;\n while (last && ContentView.get(last) instanceof MarkView)\n last = last.lastChild;\n if (!last || !this.length ||\n last.nodeName != \"BR\" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&\n (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {\n let hack = document.createElement(\"BR\");\n hack.cmIgnore = true;\n this.dom.appendChild(hack);\n }\n }\n measureTextSize() {\n if (this.children.length == 0 || this.length > 20)\n return null;\n let totalWidth = 0, textHeight;\n for (let child of this.children) {\n if (!(child instanceof TextView) || /[^ -~]/.test(child.text))\n return null;\n let rects = clientRectsFor(child.dom);\n if (rects.length != 1)\n return null;\n totalWidth += rects[0].width;\n textHeight = rects[0].height;\n }\n return !totalWidth ? null : {\n lineHeight: this.dom.getBoundingClientRect().height,\n charWidth: totalWidth / this.length,\n textHeight\n };\n }\n coordsAt(pos, side) {\n let rect = coordsInChildren(this, pos, side);\n // Correct rectangle height for empty lines when the returned\n // height is larger than the text height.\n if (!this.children.length && rect && this.parent) {\n let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;\n if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {\n let dist = (height - heightOracle.textHeight) / 2;\n return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };\n }\n }\n return rect;\n }\n become(_other) { return false; }\n get type() { return BlockType.Text; }\n static find(docView, pos) {\n for (let i = 0, off = 0; i < docView.children.length; i++) {\n let block = docView.children[i], end = off + block.length;\n if (end >= pos) {\n if (block instanceof LineView)\n return block;\n if (end > pos)\n break;\n }\n off = end + block.breakAfter;\n }\n return null;\n }\n}\nclass BlockWidgetView extends ContentView {\n constructor(widget, length, type) {\n super();\n this.widget = widget;\n this.length = length;\n this.type = type;\n this.breakAfter = 0;\n this.prevWidget = null;\n }\n merge(from, to, source, _takeDeco, openStart, openEnd) {\n if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n domAtPos(pos) {\n return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);\n }\n split(at) {\n let len = this.length - at;\n this.length = at;\n let end = new BlockWidgetView(this.widget, len, this.type);\n end.breakAfter = this.breakAfter;\n return end;\n }\n get children() { return noChildren; }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n get overrideDOMText() {\n return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;\n }\n domBoundsAround() { return null; }\n become(other) {\n if (other instanceof BlockWidgetView &&\n other.widget.constructor == this.widget.constructor) {\n if (!other.widget.compare(this.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n this.type = other.type;\n this.breakAfter = other.breakAfter;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get isEditable() { return false; }\n get isWidget() { return true; }\n coordsAt(pos, side) {\n return this.widget.coordsAt(this.dom, pos, side);\n }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n}\n\nclass ContentBuilder {\n constructor(doc, pos, end, disallowBlockEffectsFor) {\n this.doc = doc;\n this.pos = pos;\n this.end = end;\n this.disallowBlockEffectsFor = disallowBlockEffectsFor;\n this.content = [];\n this.curLine = null;\n this.breakAtStart = 0;\n this.pendingBuffer = 0 /* Buf.No */;\n this.bufferMarks = [];\n // Set to false directly after a widget that covers the position after it\n this.atCursorPos = true;\n this.openStart = -1;\n this.openEnd = -1;\n this.text = \"\";\n this.textOff = 0;\n this.cursor = doc.iter();\n this.skip = pos;\n }\n posCovered() {\n if (this.content.length == 0)\n return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;\n let last = this.content[this.content.length - 1];\n return !last.breakAfter && !(last instanceof BlockWidgetView && last.type == BlockType.WidgetBefore);\n }\n getLine() {\n if (!this.curLine) {\n this.content.push(this.curLine = new LineView);\n this.atCursorPos = true;\n }\n return this.curLine;\n }\n flushBuffer(active = this.bufferMarks) {\n if (this.pendingBuffer) {\n this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);\n this.pendingBuffer = 0 /* Buf.No */;\n }\n }\n addBlockWidget(view) {\n this.flushBuffer();\n this.curLine = null;\n this.content.push(view);\n }\n finish(openEnd) {\n if (this.pendingBuffer && openEnd <= this.bufferMarks.length)\n this.flushBuffer();\n else\n this.pendingBuffer = 0 /* Buf.No */;\n if (!this.posCovered())\n this.getLine();\n }\n buildText(length, active, openStart) {\n while (length > 0) {\n if (this.textOff == this.text.length) {\n let { value, lineBreak, done } = this.cursor.next(this.skip);\n this.skip = 0;\n if (done)\n throw new Error(\"Ran out of text content when drawing inline views\");\n if (lineBreak) {\n if (!this.posCovered())\n this.getLine();\n if (this.content.length)\n this.content[this.content.length - 1].breakAfter = 1;\n else\n this.breakAtStart = 1;\n this.flushBuffer();\n this.curLine = null;\n this.atCursorPos = true;\n length--;\n continue;\n }\n else {\n this.text = value;\n this.textOff = 0;\n }\n }\n let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);\n this.flushBuffer(active.slice(active.length - openStart));\n this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);\n this.atCursorPos = true;\n this.textOff += take;\n length -= take;\n openStart = 0;\n }\n }\n span(from, to, active, openStart) {\n this.buildText(to - from, active, openStart);\n this.pos = to;\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n point(from, to, deco, active, openStart, index) {\n if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {\n if (deco.block)\n throw new RangeError(\"Block decorations may not be specified via plugins\");\n if (to > this.doc.lineAt(this.pos).to)\n throw new RangeError(\"Decorations that replace line breaks may not be specified via plugins\");\n }\n let len = to - from;\n if (deco instanceof PointDecoration) {\n if (deco.block) {\n let { type } = deco;\n if (type == BlockType.WidgetAfter && !this.posCovered())\n this.getLine();\n this.addBlockWidget(new BlockWidgetView(deco.widget || new NullWidget(\"div\"), len, type));\n }\n else {\n let view = WidgetView.create(deco.widget || new NullWidget(\"span\"), len, len ? 0 : deco.startSide);\n let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&\n (from < to || deco.startSide > 0);\n let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);\n let line = this.getLine();\n if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)\n this.pendingBuffer = 0 /* Buf.No */;\n this.flushBuffer(active);\n if (cursorBefore) {\n line.append(wrapMarks(new WidgetBufferView(1), active), openStart);\n openStart = active.length + Math.max(0, openStart - active.length);\n }\n line.append(wrapMarks(view, active), openStart);\n this.atCursorPos = cursorAfter;\n this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;\n if (this.pendingBuffer)\n this.bufferMarks = active.slice();\n }\n }\n else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration\n this.getLine().addLineDeco(deco);\n }\n if (len) {\n // Advance the iterator past the replaced content\n if (this.textOff + len <= this.text.length) {\n this.textOff += len;\n }\n else {\n this.skip += len - (this.text.length - this.textOff);\n this.text = \"\";\n this.textOff = 0;\n }\n this.pos = to;\n }\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n static build(text, from, to, decorations, dynamicDecorationMap) {\n let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);\n builder.openEnd = RangeSet.spans(decorations, from, to, builder);\n if (builder.openStart < 0)\n builder.openStart = builder.openEnd;\n builder.finish(builder.openEnd);\n return builder;\n }\n}\nfunction wrapMarks(view, active) {\n for (let mark of active)\n view = new MarkView(mark, [view], view.length);\n return view;\n}\nclass NullWidget extends WidgetType {\n constructor(tag) {\n super();\n this.tag = tag;\n }\n eq(other) { return other.tag == this.tag; }\n toDOM() { return document.createElement(this.tag); }\n updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }\n get isHidden() { return true; }\n}\n\nconst clickAddsSelectionRange = /*@__PURE__*/Facet.define();\nconst dragMovesSelection$1 = /*@__PURE__*/Facet.define();\nconst mouseSelectionStyle = /*@__PURE__*/Facet.define();\nconst exceptionSink = /*@__PURE__*/Facet.define();\nconst updateListener = /*@__PURE__*/Facet.define();\nconst inputHandler = /*@__PURE__*/Facet.define();\nconst focusChangeEffect = /*@__PURE__*/Facet.define();\nconst perLineTextDirection = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nconst nativeSelectionHidden = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nclass ScrollTarget {\n constructor(range, y = \"nearest\", x = \"nearest\", yMargin = 5, xMargin = 5) {\n this.range = range;\n this.y = y;\n this.x = x;\n this.yMargin = yMargin;\n this.xMargin = xMargin;\n }\n map(changes) {\n return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);\n }\n}\nconst scrollIntoView = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });\n/**\nLog or report an unhandled exception in client code. Should\nprobably only be used by extension code that allows client code to\nprovide functions, and calls those functions in a context where an\nexception can't be propagated to calling code in a reasonable way\n(for example when in an event handler).\n\nEither calls a handler registered with\n[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),\n`window.onerror`, if defined, or `console.error` (in which case\nit'll pass `context`, when given, as first argument).\n*/\nfunction logException(state, exception, context) {\n let handler = state.facet(exceptionSink);\n if (handler.length)\n handler[0](exception);\n else if (window.onerror)\n window.onerror(String(exception), context, undefined, undefined, exception);\n else if (context)\n console.error(context + \":\", exception);\n else\n console.error(exception);\n}\nconst editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });\nlet nextPluginID = 0;\nconst viewPlugin = /*@__PURE__*/Facet.define();\n/**\nView plugins associate stateful values with a view. They can\ninfluence the way the content is drawn, and are notified of things\nthat happen in the view.\n*/\nclass ViewPlugin {\n constructor(\n /**\n @internal\n */\n id, \n /**\n @internal\n */\n create, \n /**\n @internal\n */\n domEventHandlers, buildExtensions) {\n this.id = id;\n this.create = create;\n this.domEventHandlers = domEventHandlers;\n this.extension = buildExtensions(this);\n }\n /**\n Define a plugin from a constructor function that creates the\n plugin's value, given an editor view.\n */\n static define(create, spec) {\n const { eventHandlers, provide, decorations: deco } = spec || {};\n return new ViewPlugin(nextPluginID++, create, eventHandlers, plugin => {\n let ext = [viewPlugin.of(plugin)];\n if (deco)\n ext.push(decorations.of(view => {\n let pluginInst = view.plugin(plugin);\n return pluginInst ? deco(pluginInst) : Decoration.none;\n }));\n if (provide)\n ext.push(provide(plugin));\n return ext;\n });\n }\n /**\n Create a plugin for a class whose constructor takes a single\n editor view as argument.\n */\n static fromClass(cls, spec) {\n return ViewPlugin.define(view => new cls(view), spec);\n }\n}\nclass PluginInstance {\n constructor(spec) {\n this.spec = spec;\n // When starting an update, all plugins have this field set to the\n // update object, indicating they need to be updated. When finished\n // updating, it is set to `false`. Retrieving a plugin that needs to\n // be updated with `view.plugin` forces an eager update.\n this.mustUpdate = null;\n // This is null when the plugin is initially created, but\n // initialized on the first update.\n this.value = null;\n }\n update(view) {\n if (!this.value) {\n if (this.spec) {\n try {\n this.value = this.spec.create(view);\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n this.deactivate();\n }\n }\n }\n else if (this.mustUpdate) {\n let update = this.mustUpdate;\n this.mustUpdate = null;\n if (this.value.update) {\n try {\n this.value.update(update);\n }\n catch (e) {\n logException(update.state, e, \"CodeMirror plugin crashed\");\n if (this.value.destroy)\n try {\n this.value.destroy();\n }\n catch (_) { }\n this.deactivate();\n }\n }\n }\n return this;\n }\n destroy(view) {\n var _a;\n if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {\n try {\n this.value.destroy();\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n }\n }\n }\n deactivate() {\n this.spec = this.value = null;\n }\n}\nconst editorAttributes = /*@__PURE__*/Facet.define();\nconst contentAttributes = /*@__PURE__*/Facet.define();\n// Provide decorations\nconst decorations = /*@__PURE__*/Facet.define();\nconst atomicRanges = /*@__PURE__*/Facet.define();\nconst bidiIsolatedRanges = /*@__PURE__*/Facet.define();\nfunction getIsolatedRanges(view, from, to) {\n let isolates = view.state.facet(bidiIsolatedRanges);\n if (!isolates.length)\n return isolates;\n let sets = isolates.map(i => i instanceof Function ? i(view) : i);\n let result = [];\n RangeSet.spans(sets, from, to, {\n point() { },\n span(from, to, active, open) {\n let level = result;\n for (let i = active.length - 1; i >= 0; i--, open--) {\n let iso = active[i].spec.bidiIsolate, update;\n if (iso == null)\n continue;\n if (open > 0 && level.length &&\n (update = level[level.length - 1]).to == from && update.direction == iso) {\n update.to = to;\n level = update.inner;\n }\n else {\n let add = { from, to, direction: iso, inner: [] };\n level.push(add);\n level = add.inner;\n }\n }\n }\n });\n return result;\n}\nconst scrollMargins = /*@__PURE__*/Facet.define();\nfunction getScrollMargins(view) {\n let left = 0, right = 0, top = 0, bottom = 0;\n for (let source of view.state.facet(scrollMargins)) {\n let m = source(view);\n if (m) {\n if (m.left != null)\n left = Math.max(left, m.left);\n if (m.right != null)\n right = Math.max(right, m.right);\n if (m.top != null)\n top = Math.max(top, m.top);\n if (m.bottom != null)\n bottom = Math.max(bottom, m.bottom);\n }\n }\n return { left, right, top, bottom };\n}\nconst styleModule = /*@__PURE__*/Facet.define();\nclass ChangedRange {\n constructor(fromA, toA, fromB, toB) {\n this.fromA = fromA;\n this.toA = toA;\n this.fromB = fromB;\n this.toB = toB;\n }\n join(other) {\n return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));\n }\n addToSet(set) {\n let i = set.length, me = this;\n for (; i > 0; i--) {\n let range = set[i - 1];\n if (range.fromA > me.toA)\n continue;\n if (range.toA < me.fromA)\n break;\n me = me.join(range);\n set.splice(i - 1, 1);\n }\n set.splice(i, 0, me);\n return set;\n }\n static extendWithRanges(diff, ranges) {\n if (ranges.length == 0)\n return diff;\n let result = [];\n for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {\n let next = dI == diff.length ? null : diff[dI], off = posA - posB;\n let end = next ? next.fromB : 1e9;\n while (rI < ranges.length && ranges[rI] < end) {\n let from = ranges[rI], to = ranges[rI + 1];\n let fromB = Math.max(posB, from), toB = Math.min(end, to);\n if (fromB <= toB)\n new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);\n if (to > end)\n break;\n else\n rI += 2;\n }\n if (!next)\n return result;\n new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);\n posA = next.toA;\n posB = next.toB;\n }\n }\n}\n/**\nView [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this\nclass, which describe what happened, whenever the view is updated.\n*/\nclass ViewUpdate {\n constructor(\n /**\n The editor view that the update is associated with.\n */\n view, \n /**\n The new editor state.\n */\n state, \n /**\n The transactions involved in the update. May be empty.\n */\n transactions) {\n this.view = view;\n this.state = state;\n this.transactions = transactions;\n /**\n @internal\n */\n this.flags = 0;\n this.startState = view.state;\n this.changes = ChangeSet.empty(this.startState.doc.length);\n for (let tr of transactions)\n this.changes = this.changes.compose(tr.changes);\n let changedRanges = [];\n this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));\n this.changedRanges = changedRanges;\n }\n /**\n @internal\n */\n static create(view, state, transactions) {\n return new ViewUpdate(view, state, transactions);\n }\n /**\n Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or\n [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this\n update.\n */\n get viewportChanged() {\n return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;\n }\n /**\n Indicates whether the height of a block element in the editor\n changed in this update.\n */\n get heightChanged() {\n return (this.flags & 2 /* UpdateFlag.Height */) > 0;\n }\n /**\n Returns true when the document was modified or the size of the\n editor, or elements within the editor, changed.\n */\n get geometryChanged() {\n return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;\n }\n /**\n True when this update indicates a focus change.\n */\n get focusChanged() {\n return (this.flags & 1 /* UpdateFlag.Focus */) > 0;\n }\n /**\n Whether the document changed in this update.\n */\n get docChanged() {\n return !this.changes.empty;\n }\n /**\n Whether the selection was explicitly set in this update.\n */\n get selectionSet() {\n return this.transactions.some(tr => tr.selection);\n }\n /**\n @internal\n */\n get empty() { return this.flags == 0 && this.transactions.length == 0; }\n}\n\n/**\nUsed to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n*/\nvar Direction = /*@__PURE__*/(function (Direction) {\n // (These are chosen to match the base levels, in bidi algorithm\n // terms, of spans in that direction.)\n /**\n Left-to-right.\n */\n Direction[Direction[\"LTR\"] = 0] = \"LTR\";\n /**\n Right-to-left.\n */\n Direction[Direction[\"RTL\"] = 1] = \"RTL\";\nreturn Direction})(Direction || (Direction = {}));\nconst LTR = Direction.LTR, RTL = Direction.RTL;\n// Decode a string with each type encoded as log2(type)\nfunction dec(str) {\n let result = [];\n for (let i = 0; i < str.length; i++)\n result.push(1 << +str[i]);\n return result;\n}\n// Character types for codepoints 0 to 0xf8\nconst LowTypes = /*@__PURE__*/dec(\"88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008\");\n// Character types for codepoints 0x600 to 0x6f9\nconst ArabicTypes = /*@__PURE__*/dec(\"4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333\");\nconst Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];\n// There's a lot more in\n// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,\n// which are left out to keep code size down.\nfor (let p of [\"()\", \"[]\", \"{}\"]) {\n let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);\n Brackets[l] = r;\n Brackets[r] = -l;\n}\nfunction charType(ch) {\n return ch <= 0xf7 ? LowTypes[ch] :\n 0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :\n 0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :\n 0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :\n 0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :\n 0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :\n ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;\n}\nconst BidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac\\ufb50-\\ufdff]/;\n/**\nRepresents a contiguous range of text that has a single direction\n(as in left-to-right or right-to-left).\n*/\nclass BidiSpan {\n /**\n The direction of this span.\n */\n get dir() { return this.level % 2 ? RTL : LTR; }\n /**\n @internal\n */\n constructor(\n /**\n The start of the span (relative to the start of the line).\n */\n from, \n /**\n The end of the span.\n */\n to, \n /**\n The [\"bidi\n level\"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)\n of the span (in this context, 0 means\n left-to-right, 1 means right-to-left, 2 means left-to-right\n number inside right-to-left text).\n */\n level) {\n this.from = from;\n this.to = to;\n this.level = level;\n }\n /**\n @internal\n */\n side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }\n /**\n @internal\n */\n static find(order, index, level, assoc) {\n let maybe = -1;\n for (let i = 0; i < order.length; i++) {\n let span = order[i];\n if (span.from <= index && span.to >= index) {\n if (span.level == level)\n return i;\n // When multiple spans match, if assoc != 0, take the one that\n // covers that side, otherwise take the one with the minimum\n // level.\n if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))\n maybe = i;\n }\n }\n if (maybe < 0)\n throw new RangeError(\"Index out of range\");\n return maybe;\n }\n}\nfunction isolatesEq(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let iA = a[i], iB = b[i];\n if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))\n return false;\n }\n return true;\n}\n// Reused array of character types\nconst types = [];\n// Fill in the character types (in `types`) from `from` to `to` and\n// apply W normalization rules.\nfunction computeCharTypes(line, rFrom, rTo, isolates, outerType) {\n for (let iI = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n let prevType = iI ? 256 /* T.NI */ : outerType;\n // W1. Examine each non-spacing mark (NSM) in the level run, and\n // change the type of the NSM to the type of the previous\n // character. If the NSM is at the start of the level run, it will\n // get the type of sor.\n // W2. Search backwards from each instance of a European number\n // until the first strong type (R, L, AL, or sor) is found. If an\n // AL is found, change the type of the European number to Arabic\n // number.\n // W3. Change all ALs to R.\n // (Left after this: L, R, EN, AN, ET, CS, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = charType(line.charCodeAt(i));\n if (type == 512 /* T.NSM */)\n type = prev;\n else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)\n type = 16 /* T.AN */;\n types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n prev = type;\n }\n // W5. A sequence of European terminators adjacent to European\n // numbers changes to all European numbers.\n // W6. Otherwise, separators and terminators change to Other\n // Neutral.\n // W7. Search backwards from each instance of a European number\n // until the first strong type (R, L, or sor) is found. If an L is\n // found, then change the type of the European number to L.\n // (Left after this: L, R, EN+AN, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = types[i];\n if (type == 128 /* T.CS */) {\n if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))\n type = types[i] = prev;\n else\n types[i] = 256 /* T.NI */;\n }\n else if (type == 64 /* T.ET */) {\n let end = i + 1;\n while (end < to && types[end] == 64 /* T.ET */)\n end++;\n let replace = (i && prev == 8 /* T.EN */) || (end < rTo && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;\n for (let j = i; j < end; j++)\n types[j] = replace;\n i = end - 1;\n }\n else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {\n types[i] = 1 /* T.L */;\n }\n prev = type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n }\n }\n}\n// Process brackets throughout a run sequence.\nfunction processBracketPairs(line, rFrom, rTo, isolates, outerType) {\n let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;\n for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N0. Process bracket pairs in an isolating run sequence\n // sequentially in the logical order of the text positions of the\n // opening paired brackets using the logic given below. Within this\n // scope, bidirectional types EN and AN are treated as R.\n for (let i = from, ch, br, type; i < to; i++) {\n // Keeps [startIndex, type, strongSeen] triples for each open\n // bracket on BracketStack.\n if (br = Brackets[ch = line.charCodeAt(i)]) {\n if (br < 0) { // Closing bracket\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n if (BracketStack[sJ + 1] == -br) {\n let flags = BracketStack[sJ + 2];\n let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :\n !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :\n (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;\n if (type)\n types[i] = types[BracketStack[sJ]] = type;\n sI = sJ;\n break;\n }\n }\n }\n else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {\n break;\n }\n else {\n BracketStack[sI++] = i;\n BracketStack[sI++] = ch;\n BracketStack[sI++] = context;\n }\n }\n else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {\n let embed = type == outerType;\n context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n let cur = BracketStack[sJ + 2];\n if (cur & 2 /* Bracketed.EmbedInside */)\n break;\n if (embed) {\n BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;\n }\n else {\n if (cur & 4 /* Bracketed.OppositeInside */)\n break;\n BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;\n }\n }\n }\n }\n }\n}\nfunction processNeutrals(rFrom, rTo, isolates, outerType) {\n for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N1. A sequence of neutrals takes the direction of the\n // surrounding strong text if the text on both sides has the same\n // direction. European and Arabic numbers act as if they were R in\n // terms of their influence on neutrals. Start-of-level-run (sor)\n // and end-of-level-run (eor) are used at level run boundaries.\n // N2. Any remaining neutrals take the embedding direction.\n // (Left after this: L, R, EN+AN)\n for (let i = from; i < to;) {\n let type = types[i];\n if (type == 256 /* T.NI */) {\n let end = i + 1;\n for (;;) {\n if (end == to) {\n if (iI == isolates.length)\n break;\n end = isolates[iI++].to;\n to = iI < isolates.length ? isolates[iI].from : rTo;\n }\n else if (types[end] == 256 /* T.NI */) {\n end++;\n }\n else {\n break;\n }\n }\n let beforeL = prev == 1 /* T.L */;\n let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;\n let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;\n for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {\n if (j == fromJ) {\n j = isolates[--jI].from;\n fromJ = jI ? isolates[jI - 1].to : rFrom;\n }\n types[--j] = replace;\n }\n i = end;\n }\n else {\n prev = type;\n i++;\n }\n }\n }\n}\n// Find the contiguous ranges of character types in a given range, and\n// emit spans for them. Flip the order of the spans as appropriate\n// based on the level, and call through to compute the spans for\n// isolates at the proper point.\nfunction emitSpans(line, from, to, level, baseLevel, isolates, order) {\n let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;\n if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip\n for (let iCh = from, iI = 0; iCh < to;) {\n // Scan a section of characters in direction ourType, unless\n // there's another type of char right after iCh, in which case\n // we scan a section of other characters (which, if ourType ==\n // T.L, may contain both T.R and T.AN chars).\n let sameDir = true, isNum = false;\n if (iI == isolates.length || iCh < isolates[iI].from) {\n let next = types[iCh];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n // Holds an array of isolates to pass to a recursive call if we\n // must recurse (to distinguish T.AN inside an RTL section in\n // LTR text), null if we can emit directly\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI < isolates.length && iScan == isolates[iI].from) {\n if (isNum)\n break run;\n let iso = isolates[iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.to, jI = iI + 1;;) {\n if (upto == to)\n break run;\n if (jI < isolates.length && isolates[jI].from == upto)\n upto = isolates[jI++].to;\n else if (types[upto] == ourType)\n break run;\n else\n break;\n }\n iI++;\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.from > iCh)\n order.push(new BidiSpan(iCh, iso.from, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.to;\n }\n iScan = iso.to;\n }\n else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {\n break;\n }\n else {\n iScan++;\n }\n }\n if (recurse)\n emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);\n else if (iCh < iScan)\n order.push(new BidiSpan(iCh, iScan, localLevel));\n iCh = iScan;\n }\n }\n else {\n // Iterate in reverse to flip the span order. Same code again, but\n // going from the back of the section to the front\n for (let iCh = to, iI = isolates.length; iCh > from;) {\n let sameDir = true, isNum = false;\n if (!iI || iCh > isolates[iI - 1].to) {\n let next = types[iCh - 1];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI && iScan == isolates[iI - 1].to) {\n if (isNum)\n break run;\n let iso = isolates[--iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.from, jI = iI;;) {\n if (upto == from)\n break run;\n if (jI && isolates[jI - 1].to == upto)\n upto = isolates[--jI].from;\n else if (types[upto - 1] == ourType)\n break run;\n else\n break;\n }\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.to < iCh)\n order.push(new BidiSpan(iso.to, iCh, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.from;\n }\n iScan = iso.from;\n }\n else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {\n break;\n }\n else {\n iScan--;\n }\n }\n if (recurse)\n emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);\n else if (iScan < iCh)\n order.push(new BidiSpan(iScan, iCh, localLevel));\n iCh = iScan;\n }\n }\n}\nfunction computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {\n let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);\n computeCharTypes(line, from, to, isolates, outerType);\n processBracketPairs(line, from, to, isolates, outerType);\n processNeutrals(from, to, isolates, outerType);\n emitSpans(line, from, to, level, baseLevel, isolates, order);\n}\nfunction computeOrder(line, direction, isolates) {\n if (!line)\n return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];\n if (direction == LTR && !isolates.length && !BidiRE.test(line))\n return trivialOrder(line.length);\n if (isolates.length)\n while (line.length > types.length)\n types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps\n let order = [], level = direction == LTR ? 0 : 1;\n computeSectionOrder(line, level, level, isolates, 0, line.length, order);\n return order;\n}\nfunction trivialOrder(length) {\n return [new BidiSpan(0, length, 0)];\n}\nlet movedOver = \"\";\nfunction moveVisually(line, order, dir, start, forward) {\n var _a;\n let startIndex = start.head - line.from, spanI = -1;\n if (startIndex == 0) {\n if (!forward || !line.length)\n return null;\n if (order[0].level != dir) {\n startIndex = order[0].side(false, dir);\n spanI = 0;\n }\n }\n else if (startIndex == line.length) {\n if (forward)\n return null;\n let last = order[order.length - 1];\n if (last.level != dir) {\n startIndex = last.side(true, dir);\n spanI = order.length - 1;\n }\n }\n if (spanI < 0)\n spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);\n let span = order[spanI];\n // End of span. (But not end of line--that was checked for above.)\n if (startIndex == span.side(forward, dir)) {\n span = order[spanI += forward ? 1 : -1];\n startIndex = span.side(!forward, dir);\n }\n let indexForward = forward == (span.dir == dir);\n let nextIndex = findClusterBreak(line.text, startIndex, indexForward);\n movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));\n if (nextIndex != span.side(forward, dir))\n return EditorSelection.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);\n let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];\n if (!nextSpan && span.level != dir)\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);\n if (nextSpan && nextSpan.level < span.level)\n return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);\n return EditorSelection.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);\n}\n\nclass DocView extends ContentView {\n get length() { return this.view.state.doc.length; }\n constructor(view) {\n super();\n this.view = view;\n this.decorations = [];\n this.dynamicDecorationMap = [];\n this.domChanged = null;\n this.hasComposition = null;\n this.markedForComposition = new Set;\n // Track a minimum width for the editor. When measuring sizes in\n // measureVisibleLineHeights, this is updated to point at the width\n // of a given element and its extent in the document. When a change\n // happens in that range, these are reset. That way, once we've seen\n // a line/element of a given length, we keep the editor wide enough\n // to fit at least that element, until it is changed, at which point\n // we forget it again.\n this.minWidth = 0;\n this.minWidthFrom = 0;\n this.minWidthTo = 0;\n // Track whether the DOM selection was set in a lossy way, so that\n // we don't mess it up when reading it back it\n this.impreciseAnchor = null;\n this.impreciseHead = null;\n this.forceSelection = false;\n // Used by the resize observer to ignore resizes that we caused\n // ourselves\n this.lastUpdate = Date.now();\n this.setDOM(view.contentDOM);\n this.children = [new LineView];\n this.children[0].setParent(this);\n this.updateDeco();\n this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);\n }\n // Update the document view to a given state.\n update(update) {\n var _a;\n let changedRanges = update.changedRanges;\n if (this.minWidth > 0 && changedRanges.length) {\n if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {\n this.minWidth = this.minWidthFrom = this.minWidthTo = 0;\n }\n else {\n this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);\n this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);\n }\n }\n let readCompositionAt = -1;\n if (this.view.inputState.composing >= 0) {\n if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)\n readCompositionAt = this.domChanged.newSel.head;\n else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)\n readCompositionAt = update.state.selection.main.head;\n }\n let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;\n this.domChanged = null;\n if (this.hasComposition) {\n this.markedForComposition.clear();\n let { from, to } = this.hasComposition;\n changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))\n .addToSet(changedRanges.slice());\n }\n this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;\n // When the DOM nodes around the selection are moved to another\n // parent, Chrome sometimes reports a different selection through\n // getSelection than the one that it actually shows to the user.\n // This forces a selection update when lines are joined to work\n // around that. Issue #54\n if ((browser.ie || browser.chrome) && !composition && update &&\n update.state.doc.lines != update.startState.doc.lines)\n this.forceSelection = true;\n let prevDeco = this.decorations, deco = this.updateDeco();\n let decoDiff = findChangedDeco(prevDeco, deco, update.changes);\n changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);\n if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {\n return false;\n }\n else {\n this.updateInner(changedRanges, update.startState.doc.length, composition);\n if (update.transactions.length)\n this.lastUpdate = Date.now();\n return true;\n }\n }\n // Used by update and the constructor do perform the actual DOM\n // update\n updateInner(changes, oldLength, composition) {\n this.view.viewState.mustMeasureContent = true;\n this.updateChildren(changes, oldLength, composition);\n let { observer } = this.view;\n observer.ignore(() => {\n // Lock the height during redrawing, since Chrome sometimes\n // messes with the scroll position during DOM mutation (though\n // no relayout is triggered and I cannot imagine how it can\n // recompute the scroll position without a layout)\n this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + \"px\";\n this.dom.style.flexBasis = this.minWidth ? this.minWidth + \"px\" : \"\";\n // Chrome will sometimes, when DOM mutations occur directly\n // around the selection, get confused and report a different\n // selection from the one it displays (issue #218). This tries\n // to detect that situation.\n let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;\n this.sync(this.view, track);\n this.flags &= ~7 /* ViewFlag.Dirty */;\n if (track && (track.written || observer.selectionRange.focusNode != track.node))\n this.forceSelection = true;\n this.dom.style.height = \"\";\n });\n this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);\n let gaps = [];\n if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)\n for (let child of this.children)\n if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)\n gaps.push(child.dom);\n observer.updateGaps(gaps);\n }\n updateChildren(changes, oldLength, composition) {\n let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;\n let cursor = this.childCursor(oldLength);\n for (let i = ranges.length - 1;; i--) {\n let next = i >= 0 ? ranges[i] : null;\n if (!next)\n break;\n let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;\n if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {\n let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);\n let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);\n breakAtStart = before.breakAtStart;\n openStart = before.openStart;\n openEnd = after.openEnd;\n let compLine = this.compositionView(composition);\n if (after.breakAtStart) {\n compLine.breakAfter = 1;\n }\n else if (after.content.length &&\n compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {\n compLine.breakAfter = after.content[0].breakAfter;\n after.content.shift();\n }\n if (before.content.length &&\n compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {\n before.content.pop();\n }\n content = before.content.concat(compLine).concat(after.content);\n }\n else {\n ({ content, breakAtStart, openStart, openEnd } =\n ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));\n }\n let { i: toI, off: toOff } = cursor.findPos(toA, 1);\n let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);\n replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);\n }\n if (composition)\n this.fixCompositionDOM(composition);\n }\n compositionView(composition) {\n let cur = new TextView(composition.text.nodeValue);\n cur.flags |= 8 /* ViewFlag.Composition */;\n for (let { deco } of composition.marks)\n cur = new MarkView(deco, [cur], cur.length);\n let line = new LineView;\n line.append(cur, 0);\n return line;\n }\n fixCompositionDOM(composition) {\n let fix = (dom, cView) => {\n cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);\n this.markedForComposition.add(cView);\n let prev = ContentView.get(dom);\n if (prev && prev != cView)\n prev.dom = null;\n cView.setDOM(dom);\n };\n let pos = this.childPos(composition.range.fromB, 1);\n let cView = this.children[pos.i];\n fix(composition.line, cView);\n for (let i = composition.marks.length - 1; i >= -1; i--) {\n pos = cView.childPos(pos.off, 1);\n cView = cView.children[pos.i];\n fix(i >= 0 ? composition.marks[i].node : composition.text, cView);\n }\n }\n // Sync the DOM selection to this.state.selection\n updateSelection(mustRead = false, fromPointer = false) {\n if (mustRead || !this.view.observer.selectionRange.focusNode)\n this.view.observer.readSelectionRange();\n let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;\n let selectionNotFocus = !focused &&\n hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));\n if (!(focused || fromPointer || selectionNotFocus))\n return;\n let force = this.forceSelection;\n this.forceSelection = false;\n let main = this.view.state.selection.main;\n let anchor = this.moveToLine(this.domAtPos(main.anchor));\n let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));\n // Always reset on Firefox when next to an uneditable node to\n // avoid invisible cursor bugs (#111)\n if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {\n let dummy = document.createTextNode(\"\");\n this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));\n anchor = head = new DOMPos(dummy, 0);\n force = true;\n }\n let domSel = this.view.observer.selectionRange;\n // If the selection is already here, or in an equivalent position, don't touch it\n if (force || !domSel.focusNode ||\n !isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||\n !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {\n this.view.observer.ignore(() => {\n // Chrome Android will hide the virtual keyboard when tapping\n // inside an uneditable node, and not bring it back when we\n // move the cursor to its proper position. This tries to\n // restore the keyboard by cycling focus.\n if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&\n inUneditable(domSel.focusNode, this.dom)) {\n this.dom.blur();\n this.dom.focus({ preventScroll: true });\n }\n let rawSel = getSelection(this.view.root);\n if (!rawSel) ;\n else if (main.empty) {\n // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076\n if (browser.gecko) {\n let nextTo = nextToUneditable(anchor.node, anchor.offset);\n if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {\n let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);\n if (text)\n anchor = new DOMPos(text.node, text.offset);\n }\n }\n rawSel.collapse(anchor.node, anchor.offset);\n if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)\n rawSel.caretBidiLevel = main.bidiLevel;\n }\n else if (rawSel.extend) {\n // Selection.extend can be used to create an 'inverted' selection\n // (one where the focus is before the anchor), but not all\n // browsers support it yet.\n rawSel.collapse(anchor.node, anchor.offset);\n // Safari will ignore the call above when the editor is\n // hidden, and then raise an error on the call to extend\n // (#940).\n try {\n rawSel.extend(head.node, head.offset);\n }\n catch (_) { }\n }\n else {\n // Primitive (IE) way\n let range = document.createRange();\n if (main.anchor > main.head)\n [anchor, head] = [head, anchor];\n range.setEnd(head.node, head.offset);\n range.setStart(anchor.node, anchor.offset);\n rawSel.removeAllRanges();\n rawSel.addRange(range);\n }\n if (selectionNotFocus && this.view.root.activeElement == this.dom) {\n this.dom.blur();\n if (activeElt)\n activeElt.focus();\n }\n });\n this.view.observer.setSelectionRange(anchor, head);\n }\n this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);\n this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);\n }\n enforceCursorAssoc() {\n if (this.hasComposition)\n return;\n let { view } = this, cursor = view.state.selection.main;\n let sel = getSelection(view.root);\n let { anchorNode, anchorOffset } = view.observer.selectionRange;\n if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)\n return;\n let line = LineView.find(this, cursor.head);\n if (!line)\n return;\n let lineStart = line.posAtStart;\n if (cursor.head == lineStart || cursor.head == lineStart + line.length)\n return;\n let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);\n if (!before || !after || before.bottom > after.top)\n return;\n let dom = this.domAtPos(cursor.head + cursor.assoc);\n sel.collapse(dom.node, dom.offset);\n sel.modify(\"move\", cursor.assoc < 0 ? \"forward\" : \"backward\", \"lineboundary\");\n // This can go wrong in corner cases like single-character lines,\n // so check and reset if necessary.\n view.observer.readSelectionRange();\n let newRange = view.observer.selectionRange;\n if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)\n sel.collapse(anchorNode, anchorOffset);\n }\n // If a position is in/near a block widget, move it to a nearby text\n // line, since we don't want the cursor inside a block widget.\n moveToLine(pos) {\n // Block widgets will return positions before/after them, which\n // are thus directly in the document DOM element.\n let dom = this.dom, newPos;\n if (pos.node != dom)\n return pos;\n for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(0);\n }\n for (let i = pos.offset - 1; !newPos && i >= 0; i--) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(view.length);\n }\n return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;\n }\n nearest(dom) {\n for (let cur = dom; cur;) {\n let domView = ContentView.get(cur);\n if (domView && domView.rootView == this)\n return domView;\n cur = cur.parentNode;\n }\n return null;\n }\n posFromDOM(node, offset) {\n let view = this.nearest(node);\n if (!view)\n throw new RangeError(\"Trying to find position for a DOM position outside of the document\");\n return view.localPosFromDOM(node, offset) + view.posAtStart;\n }\n domAtPos(pos) {\n let { i, off } = this.childCursor().findPos(pos, -1);\n for (; i < this.children.length - 1;) {\n let child = this.children[i];\n if (off < child.length || child instanceof LineView)\n break;\n i++;\n off = 0;\n }\n return this.children[i].domAtPos(off);\n }\n coordsAt(pos, side) {\n for (let off = this.length, i = this.children.length - 1;; i--) {\n let child = this.children[i], start = off - child.breakAfter - child.length;\n if (pos > start ||\n (pos == start && child.type != BlockType.WidgetBefore && child.type != BlockType.WidgetAfter &&\n (!i || side == 2 || this.children[i - 1].breakAfter ||\n (this.children[i - 1].type == BlockType.WidgetBefore && side > -2))))\n return child.coordsAt(pos - start, side);\n off = start;\n }\n }\n coordsForChar(pos) {\n let { i, off } = this.childPos(pos, 1), child = this.children[i];\n if (!(child instanceof LineView))\n return null;\n while (child.children.length) {\n let { i, off: childOff } = child.childPos(off, 1);\n for (;; i++) {\n if (i == child.children.length)\n return null;\n if ((child = child.children[i]).length)\n break;\n }\n off = childOff;\n }\n if (!(child instanceof TextView))\n return null;\n let end = findClusterBreak(child.text, off);\n if (end == off)\n return null;\n let rects = textRange(child.dom, off, end).getClientRects();\n return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0];\n }\n measureVisibleLineHeights(viewport) {\n let result = [], { from, to } = viewport;\n let contentWidth = this.view.contentDOM.clientWidth;\n let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;\n let widest = -1, ltr = this.view.textDirection == Direction.LTR;\n for (let pos = 0, i = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (end > to)\n break;\n if (pos >= from) {\n let childRect = child.dom.getBoundingClientRect();\n result.push(childRect.height);\n if (isWider) {\n let last = child.dom.lastChild;\n let rects = last ? clientRectsFor(last) : [];\n if (rects.length) {\n let rect = rects[rects.length - 1];\n let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;\n if (width > widest) {\n widest = width;\n this.minWidth = contentWidth;\n this.minWidthFrom = pos;\n this.minWidthTo = end;\n }\n }\n }\n }\n pos = end + child.breakAfter;\n }\n return result;\n }\n textDirectionAt(pos) {\n let { i } = this.childPos(pos, 1);\n return getComputedStyle(this.children[i].dom).direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n }\n measureTextSize() {\n for (let child of this.children) {\n if (child instanceof LineView) {\n let measure = child.measureTextSize();\n if (measure)\n return measure;\n }\n }\n // If no workable line exists, force a layout of a measurable element\n let dummy = document.createElement(\"div\"), lineHeight, charWidth, textHeight;\n dummy.className = \"cm-line\";\n dummy.style.width = \"99999px\";\n dummy.style.position = \"absolute\";\n dummy.textContent = \"abc def ghi jkl mno pqr stu\";\n this.view.observer.ignore(() => {\n this.dom.appendChild(dummy);\n let rect = clientRectsFor(dummy.firstChild)[0];\n lineHeight = dummy.getBoundingClientRect().height;\n charWidth = rect ? rect.width / 27 : 7;\n textHeight = rect ? rect.height : lineHeight;\n dummy.remove();\n });\n return { lineHeight, charWidth, textHeight };\n }\n childCursor(pos = this.length) {\n // Move back to start of last element when possible, so that\n // `ChildCursor.findPos` doesn't have to deal with the edge case\n // of being after the last element.\n let i = this.children.length;\n if (i)\n pos -= this.children[--i].length;\n return new ChildCursor(this.children, pos, i);\n }\n computeBlockGapDeco() {\n let deco = [], vs = this.view.viewState;\n for (let pos = 0, i = 0;; i++) {\n let next = i == vs.viewports.length ? null : vs.viewports[i];\n let end = next ? next.from - 1 : this.length;\n if (end > pos) {\n let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;\n deco.push(Decoration.replace({\n widget: new BlockGapWidget(height),\n block: true,\n inclusive: true,\n isBlockGap: true,\n }).range(pos, end));\n }\n if (!next)\n break;\n pos = next.to + 1;\n }\n return Decoration.set(deco);\n }\n updateDeco() {\n let allDeco = this.view.state.facet(decorations).map((d, i) => {\n let dynamic = this.dynamicDecorationMap[i] = typeof d == \"function\";\n return dynamic ? d(this.view) : d;\n });\n for (let i = allDeco.length; i < allDeco.length + 3; i++)\n this.dynamicDecorationMap[i] = false;\n return this.decorations = [\n ...allDeco,\n this.computeBlockGapDeco(),\n this.view.viewState.lineGapDeco\n ];\n }\n scrollIntoView(target) {\n let { range } = target;\n let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;\n if (!rect)\n return;\n if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))\n rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),\n right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };\n let margins = getScrollMargins(this.view);\n let targetRect = {\n left: rect.left - margins.left, top: rect.top - margins.top,\n right: rect.right + margins.right, bottom: rect.bottom + margins.bottom\n };\n scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction.LTR);\n }\n}\nfunction betweenUneditable(pos) {\n return pos.node.nodeType == 1 && pos.node.firstChild &&\n (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == \"false\") &&\n (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == \"false\");\n}\nclass BlockGapWidget extends WidgetType {\n constructor(height) {\n super();\n this.height = height;\n }\n toDOM() {\n let elt = document.createElement(\"div\");\n this.updateDOM(elt);\n return elt;\n }\n eq(other) { return other.height == this.height; }\n updateDOM(elt) {\n elt.style.height = this.height + \"px\";\n return true;\n }\n get estimatedHeight() { return this.height; }\n}\nfunction findCompositionNode(view, headPos) {\n let sel = view.observer.selectionRange;\n let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);\n if (!textNode)\n return null;\n let from = headPos - textNode.offset;\n return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };\n}\nfunction findCompositionRange(view, changes, headPos) {\n let found = findCompositionNode(view, headPos);\n if (!found)\n return null;\n let { node: textNode, from, to } = found, text = textNode.nodeValue;\n // Don't try to preserve multi-line compositions\n if (/[\\n\\r]/.test(text))\n return null;\n if (view.state.doc.sliceString(found.from, found.to) != text)\n return null;\n let inv = changes.invertedDesc;\n let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);\n let marks = [];\n for (let parent = textNode.parentNode;; parent = parent.parentNode) {\n let parentView = ContentView.get(parent);\n if (parentView instanceof MarkView)\n marks.push({ node: parent, deco: parentView.mark });\n else if (parentView instanceof LineView || parent.nodeName == \"DIV\" && parent.parentNode == view.contentDOM)\n return { range, text: textNode, marks, line: parent };\n else if (parent != view.contentDOM)\n marks.push({ node: parent, deco: new MarkDecoration({\n inclusive: true,\n attributes: getAttrs(parent),\n tagName: parent.tagName.toLowerCase()\n }) });\n else\n return null;\n }\n}\nfunction nearbyTextNode(startNode, startOffset, side) {\n if (side <= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset > 0) {\n node = node.childNodes[offset - 1];\n offset = maxOffset(node);\n }\n else {\n break;\n }\n }\n if (side >= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {\n node = node.childNodes[offset];\n offset = 0;\n }\n else {\n break;\n }\n }\n return null;\n}\nfunction nextToUneditable(node, offset) {\n if (node.nodeType != 1)\n return 0;\n return (offset && node.childNodes[offset - 1].contentEditable == \"false\" ? 1 /* NextTo.Before */ : 0) |\n (offset < node.childNodes.length && node.childNodes[offset].contentEditable == \"false\" ? 2 /* NextTo.After */ : 0);\n}\nlet DecorationComparator$1 = class DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange(from, to) { addRange(from, to, this.changes); }\n comparePoint(from, to) { addRange(from, to, this.changes); }\n};\nfunction findChangedDeco(a, b, diff) {\n let comp = new DecorationComparator$1;\n RangeSet.compare(a, b, diff, comp);\n return comp.changes;\n}\nfunction inUneditable(node, inside) {\n for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {\n if (cur.nodeType == 1 && cur.contentEditable == 'false') {\n return true;\n }\n }\n return false;\n}\nfunction touchesComposition(changes, composition) {\n let touched = false;\n if (composition)\n changes.iterChangedRanges((from, to) => {\n if (from < composition.to && to > composition.from)\n touched = true;\n });\n return touched;\n}\n\nfunction groupAt(state, pos, bias = 1) {\n let categorize = state.charCategorizer(pos);\n let line = state.doc.lineAt(pos), linePos = pos - line.from;\n if (line.length == 0)\n return EditorSelection.cursor(pos);\n if (linePos == 0)\n bias = 1;\n else if (linePos == line.length)\n bias = -1;\n let from = linePos, to = linePos;\n if (bias < 0)\n from = findClusterBreak(line.text, linePos, false);\n else\n to = findClusterBreak(line.text, linePos);\n let cat = categorize(line.text.slice(from, to));\n while (from > 0) {\n let prev = findClusterBreak(line.text, from, false);\n if (categorize(line.text.slice(prev, from)) != cat)\n break;\n from = prev;\n }\n while (to < line.length) {\n let next = findClusterBreak(line.text, to);\n if (categorize(line.text.slice(to, next)) != cat)\n break;\n to = next;\n }\n return EditorSelection.range(from + line.from, to + line.from);\n}\n// Search the DOM for the {node, offset} position closest to the given\n// coordinates. Very inefficient and crude, but can usually be avoided\n// by calling caret(Position|Range)FromPoint instead.\nfunction getdx(x, rect) {\n return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);\n}\nfunction getdy(y, rect) {\n return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);\n}\nfunction yOverlap(a, b) {\n return a.top < b.bottom - 1 && a.bottom > b.top + 1;\n}\nfunction upTop(rect, top) {\n return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;\n}\nfunction upBot(rect, bottom) {\n return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;\n}\nfunction domPosAtCoords(parent, x, y) {\n let closest, closestRect, closestX, closestY, closestOverlap = false;\n let above, below, aboveRect, belowRect;\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n let rects = clientRectsFor(child);\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (closestRect && yOverlap(closestRect, rect))\n rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);\n let dx = getdx(x, rect), dy = getdy(y, rect);\n if (dx == 0 && dy == 0)\n return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);\n if (!closest || closestY > dy || closestY == dy && closestX > dx) {\n closest = child;\n closestRect = rect;\n closestX = dx;\n closestY = dy;\n let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;\n closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);\n }\n if (dx == 0) {\n if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {\n above = child;\n aboveRect = rect;\n }\n else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {\n below = child;\n belowRect = rect;\n }\n }\n else if (aboveRect && yOverlap(aboveRect, rect)) {\n aboveRect = upBot(aboveRect, rect.bottom);\n }\n else if (belowRect && yOverlap(belowRect, rect)) {\n belowRect = upTop(belowRect, rect.top);\n }\n }\n }\n if (aboveRect && aboveRect.bottom >= y) {\n closest = above;\n closestRect = aboveRect;\n }\n else if (belowRect && belowRect.top <= y) {\n closest = below;\n closestRect = belowRect;\n }\n if (!closest)\n return { node: parent, offset: 0 };\n let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));\n if (closest.nodeType == 3)\n return domPosInText(closest, clipX, y);\n if (closestOverlap && closest.contentEditable != \"false\")\n return domPosAtCoords(closest, clipX, y);\n let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +\n (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);\n return { node: parent, offset };\n}\nfunction domPosInText(node, x, y) {\n let len = node.nodeValue.length;\n let closestOffset = -1, closestDY = 1e9, generalSide = 0;\n for (let i = 0; i < len; i++) {\n let rects = textRange(node, i, i + 1).getClientRects();\n for (let j = 0; j < rects.length; j++) {\n let rect = rects[j];\n if (rect.top == rect.bottom)\n continue;\n if (!generalSide)\n generalSide = x - rect.left;\n let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;\n if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {\n let right = x >= (rect.left + rect.right) / 2, after = right;\n if (browser.chrome || browser.gecko) {\n // Check for RTL on browsers that support getting client\n // rects for empty ranges.\n let rectBefore = textRange(node, i).getBoundingClientRect();\n if (rectBefore.left == rect.right)\n after = !right;\n }\n if (dy <= 0)\n return { node, offset: i + (after ? 1 : 0) };\n closestOffset = i + (after ? 1 : 0);\n closestDY = dy;\n }\n }\n }\n return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };\n}\nfunction posAtCoords(view, coords, precise, bias = -1) {\n var _a, _b;\n let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;\n let block, { docHeight } = view.viewState;\n let { x, y } = coords, yOffset = y - docTop;\n if (yOffset < 0)\n return 0;\n if (yOffset > docHeight)\n return view.state.doc.length;\n // Scan for a text block near the queried y position\n for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {\n block = view.elementAtHeight(yOffset);\n if (block.type == BlockType.Text)\n break;\n for (;;) {\n // Move the y position out of this block\n yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;\n if (yOffset >= 0 && yOffset <= docHeight)\n break;\n // If the document consists entirely of replaced widgets, we\n // won't find a text block, so return 0\n if (bounced)\n return precise ? null : 0;\n bounced = true;\n bias = -bias;\n }\n }\n y = docTop + yOffset;\n let lineStart = block.from;\n // If this is outside of the rendered viewport, we can't determine a position\n if (lineStart < view.viewport.from)\n return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n if (lineStart > view.viewport.to)\n return view.viewport.to == view.state.doc.length ? view.state.doc.length :\n precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not\n let doc = view.dom.ownerDocument;\n let root = view.root.elementFromPoint ? view.root : doc;\n let element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n // If the element is unexpected, clip x at the sides of the content area and try again\n if (!element) {\n x = Math.max(content.left + 1, Math.min(content.right - 1, x));\n element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n }\n // There's visible editor content under the point, so we can try\n // using caret(Position|Range)FromPoint as a shortcut\n let node, offset = -1;\n if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {\n if (doc.caretPositionFromPoint) {\n let pos = doc.caretPositionFromPoint(x, y);\n if (pos)\n ({ offsetNode: node, offset } = pos);\n }\n else if (doc.caretRangeFromPoint) {\n let range = doc.caretRangeFromPoint(x, y);\n if (range) {\n ({ startContainer: node, startOffset: offset } = range);\n if (!view.contentDOM.contains(node) ||\n browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||\n browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))\n node = undefined;\n }\n }\n }\n // No luck, do our own (potentially expensive) search\n if (!node || !view.docView.dom.contains(node)) {\n let line = LineView.find(view.docView, lineStart);\n if (!line)\n return yOffset > block.top + block.height / 2 ? block.to : block.from;\n ({ node, offset } = domPosAtCoords(line.dom, x, y));\n }\n let nearest = view.docView.nearest(node);\n if (!nearest)\n return null;\n if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {\n let rect = nearest.dom.getBoundingClientRect();\n return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2\n ? nearest.posAtStart : nearest.posAtEnd;\n }\n else {\n return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;\n }\n}\nfunction posAtCoordsImprecise(view, contentRect, block, x, y) {\n let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);\n if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {\n let textHeight = view.viewState.heightOracle.textHeight;\n let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);\n into += line * view.viewState.heightOracle.lineLength;\n }\n let content = view.state.sliceDoc(block.from, block.to);\n return block.from + findColumn(content, into, view.state.tabSize);\n}\n// In case of a high line height, Safari's caretRangeFromPoint treats\n// the space between lines as belonging to the last character of the\n// line before. This is used to detect such a result so that it can be\n// ignored (issue #401).\nfunction isSuspiciousSafariCaretResult(node, offset, x) {\n let len;\n if (node.nodeType != 3 || offset != (len = node.nodeValue.length))\n return false;\n for (let next = node.nextSibling; next; next = next.nextSibling)\n if (next.nodeType != 1 || next.nodeName != \"BR\")\n return false;\n return textRange(node, len - 1, len).getBoundingClientRect().left > x;\n}\n// Chrome will move positions between lines to the start of the next line\nfunction isSuspiciousChromeCaretResult(node, offset, x) {\n if (offset != 0)\n return false;\n for (let cur = node;;) {\n let parent = cur.parentNode;\n if (!parent || parent.nodeType != 1 || parent.firstChild != cur)\n return false;\n if (parent.classList.contains(\"cm-line\"))\n break;\n cur = parent;\n }\n let rect = node.nodeType == 1 ? node.getBoundingClientRect()\n : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();\n return x - rect.left > 5;\n}\nfunction blockAt(view, pos) {\n let line = view.lineBlockAt(pos);\n if (Array.isArray(line.type))\n for (let l of line.type) {\n if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))\n return l;\n }\n return line;\n}\nfunction moveToLineBoundary(view, start, forward, includeWrap) {\n let line = blockAt(view, start.head);\n let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null\n : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);\n if (coords) {\n let editorRect = view.dom.getBoundingClientRect();\n let direction = view.textDirectionAt(line.from);\n let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,\n y: (coords.top + coords.bottom) / 2 });\n if (pos != null)\n return EditorSelection.cursor(pos, forward ? -1 : 1);\n }\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);\n}\nfunction moveByChar(view, start, forward, by) {\n let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);\n let direction = view.textDirectionAt(line.from);\n for (let cur = start, check = null;;) {\n let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;\n if (!next) {\n if (line.number == (forward ? view.state.doc.lines : 1))\n return cur;\n char = \"\\n\";\n line = view.state.doc.line(line.number + (forward ? 1 : -1));\n spans = view.bidiSpans(line);\n next = EditorSelection.cursor(forward ? line.from : line.to);\n }\n if (!check) {\n if (!by)\n return next;\n check = by(char);\n }\n else if (!check(char)) {\n return cur;\n }\n cur = next;\n }\n}\nfunction byGroup(view, pos, start) {\n let categorize = view.state.charCategorizer(pos);\n let cat = categorize(start);\n return (next) => {\n let nextCat = categorize(next);\n if (cat == CharCategory.Space)\n cat = nextCat;\n return cat == nextCat;\n };\n}\nfunction moveVertically(view, start, forward, distance) {\n let startPos = start.head, dir = forward ? 1 : -1;\n if (startPos == (forward ? view.state.doc.length : 0))\n return EditorSelection.cursor(startPos, start.assoc);\n let goal = start.goalColumn, startY;\n let rect = view.contentDOM.getBoundingClientRect();\n let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;\n if (startCoords) {\n if (goal == null)\n goal = startCoords.left - rect.left;\n startY = dir < 0 ? startCoords.top : startCoords.bottom;\n }\n else {\n let line = view.viewState.lineBlockAt(startPos);\n if (goal == null)\n goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));\n startY = (dir < 0 ? line.top : line.bottom) + docTop;\n }\n let resolvedGoal = rect.left + goal;\n let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);\n for (let extra = 0;; extra += 10) {\n let curY = startY + (dist + extra) * dir;\n let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);\n if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))\n return EditorSelection.cursor(pos, start.assoc, undefined, goal);\n }\n}\nfunction skipAtomicRanges(atoms, pos, bias) {\n for (;;) {\n let moved = 0;\n for (let set of atoms) {\n set.between(pos - 1, pos + 1, (from, to, value) => {\n if (pos > from && pos < to) {\n let side = moved || bias || (pos - from < to - pos ? -1 : 1);\n pos = side < 0 ? from : to;\n moved = side;\n }\n });\n }\n if (!moved)\n return pos;\n }\n}\nfunction skipAtoms(view, oldPos, pos) {\n let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);\n return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);\n}\n\n// This will also be where dragging info and such goes\nclass InputState {\n setSelectionOrigin(origin) {\n this.lastSelectionOrigin = origin;\n this.lastSelectionTime = Date.now();\n }\n constructor(view) {\n this.lastKeyCode = 0;\n this.lastKeyTime = 0;\n this.lastTouchTime = 0;\n this.lastFocusTime = 0;\n this.lastScrollTop = 0;\n this.lastScrollLeft = 0;\n this.chromeScrollHack = -1;\n // On iOS, some keys need to have their default behavior happen\n // (after which we retroactively handle them and reset the DOM) to\n // avoid messing up the virtual keyboard state.\n this.pendingIOSKey = undefined;\n this.lastSelectionOrigin = null;\n this.lastSelectionTime = 0;\n this.lastEscPress = 0;\n this.lastContextMenu = 0;\n this.scrollHandlers = [];\n this.registeredEvents = [];\n this.customHandlers = [];\n // -1 means not in a composition. Otherwise, this counts the number\n // of changes made during the composition. The count is used to\n // avoid treating the start state of the composition, before any\n // changes have been made, as part of the composition.\n this.composing = -1;\n // Tracks whether the next change should be marked as starting the\n // composition (null means no composition, true means next is the\n // first, false means first has already been marked for this\n // composition)\n this.compositionFirstChange = null;\n // End time of the previous composition\n this.compositionEndedAt = 0;\n // Used in a kludge to detect when an Enter keypress should be\n // considered part of the composition on Safari, which fires events\n // in the wrong order\n this.compositionPendingKey = false;\n // Used to categorize changes as part of a composition, even when\n // the mutation events fire shortly after the compositionend event\n this.compositionPendingChange = false;\n this.mouseSelection = null;\n let handleEvent = (handler, event) => {\n if (this.ignoreDuringComposition(event))\n return;\n if (event.type == \"keydown\" && this.keydown(view, event))\n return;\n if (this.mustFlushObserver(event))\n view.observer.forceFlush();\n if (this.runCustomHandlers(event.type, view, event))\n event.preventDefault();\n else\n handler(view, event);\n };\n for (let type in handlers) {\n let handler = handlers[type];\n view.contentDOM.addEventListener(type, event => {\n if (eventBelongsToEditor(view, event))\n handleEvent(handler, event);\n }, handlerOptions[type]);\n this.registeredEvents.push(type);\n }\n view.scrollDOM.addEventListener(\"mousedown\", (event) => {\n if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {\n handleEvent(handlers.mousedown, event);\n if (!event.defaultPrevented && event.button == 2) {\n // Make sure the content covers the entire scroller height, in order\n // to catch a native context menu click below it\n let start = view.contentDOM.style.minHeight;\n view.contentDOM.style.minHeight = \"100%\";\n setTimeout(() => view.contentDOM.style.minHeight = start, 200);\n }\n }\n });\n view.scrollDOM.addEventListener(\"drop\", (event) => {\n if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)\n handleEvent(handlers.drop, event);\n });\n if (browser.chrome && browser.chrome_version == 102) { // FIXME remove at some point\n // On Chrome 102, viewport updates somehow stop wheel-based\n // scrolling. Turning off pointer events during the scroll seems\n // to avoid the issue.\n view.scrollDOM.addEventListener(\"wheel\", () => {\n if (this.chromeScrollHack < 0)\n view.contentDOM.style.pointerEvents = \"none\";\n else\n window.clearTimeout(this.chromeScrollHack);\n this.chromeScrollHack = setTimeout(() => {\n this.chromeScrollHack = -1;\n view.contentDOM.style.pointerEvents = \"\";\n }, 100);\n }, { passive: true });\n }\n this.notifiedFocused = view.hasFocus;\n // On Safari adding an input event handler somehow prevents an\n // issue where the composition vanishes when you press enter.\n if (browser.safari)\n view.contentDOM.addEventListener(\"input\", () => null);\n if (browser.gecko)\n firefoxCopyCutHack(view.contentDOM.ownerDocument);\n }\n ensureHandlers(view, plugins) {\n var _a;\n let handlers;\n this.customHandlers = [];\n for (let plugin of plugins)\n if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {\n this.customHandlers.push({ plugin: plugin.value, handlers });\n for (let type in handlers)\n if (this.registeredEvents.indexOf(type) < 0 && type != \"scroll\") {\n this.registeredEvents.push(type);\n view.contentDOM.addEventListener(type, (event) => {\n if (!eventBelongsToEditor(view, event))\n return;\n if (this.runCustomHandlers(type, view, event))\n event.preventDefault();\n });\n }\n }\n }\n runCustomHandlers(type, view, event) {\n for (let set of this.customHandlers) {\n let handler = set.handlers[type];\n if (handler) {\n try {\n if (handler.call(set.plugin, event, view) || event.defaultPrevented)\n return true;\n }\n catch (e) {\n logException(view.state, e);\n }\n }\n }\n return false;\n }\n runScrollHandlers(view, event) {\n this.lastScrollTop = view.scrollDOM.scrollTop;\n this.lastScrollLeft = view.scrollDOM.scrollLeft;\n for (let set of this.customHandlers) {\n let handler = set.handlers.scroll;\n if (handler) {\n try {\n handler.call(set.plugin, event, view);\n }\n catch (e) {\n logException(view.state, e);\n }\n }\n }\n }\n keydown(view, event) {\n // Must always run, even if a custom handler handled the event\n this.lastKeyCode = event.keyCode;\n this.lastKeyTime = Date.now();\n if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)\n return true;\n if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)\n view.inputState.lastEscPress = 0;\n // Chrome for Android usually doesn't fire proper key events, but\n // occasionally does, usually surrounded by a bunch of complicated\n // composition changes. When an enter or backspace key event is\n // seen, hold off on handling DOM events for a bit, and then\n // dispatch it.\n if (browser.android && browser.chrome && !event.synthetic &&\n (event.keyCode == 13 || event.keyCode == 8)) {\n view.observer.delayAndroidKey(event.key, event.keyCode);\n return true;\n }\n // Prevent the default behavior of Enter on iOS makes the\n // virtual keyboard get stuck in the wrong (lowercase)\n // state. So we let it go through, and then, in\n // applyDOMChange, notify key handlers of it and reset to\n // the state they produce.\n let pending;\n if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&\n ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||\n EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {\n this.pendingIOSKey = pending || event;\n setTimeout(() => this.flushIOSKey(view), 250);\n return true;\n }\n return false;\n }\n flushIOSKey(view) {\n let key = this.pendingIOSKey;\n if (!key)\n return false;\n this.pendingIOSKey = undefined;\n return dispatchKey(view.contentDOM, key.key, key.keyCode);\n }\n ignoreDuringComposition(event) {\n if (!/^key/.test(event.type))\n return false;\n if (this.composing > 0)\n return true;\n // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.\n // On some input method editors (IMEs), the Enter key is used to\n // confirm character selection. On Safari, when Enter is pressed,\n // compositionend and keydown events are sometimes emitted in the\n // wrong order. The key event should still be ignored, even when\n // it happens after the compositionend event.\n if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {\n this.compositionPendingKey = false;\n return true;\n }\n return false;\n }\n mustFlushObserver(event) {\n return event.type == \"keydown\" && event.keyCode != 229;\n }\n startMouseSelection(mouseSelection) {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n this.mouseSelection = mouseSelection;\n }\n update(update) {\n if (this.mouseSelection)\n this.mouseSelection.update(update);\n if (update.transactions.length)\n this.lastKeyCode = this.lastSelectionTime = 0;\n }\n destroy() {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n }\n}\nconst PendingKeys = [\n { key: \"Backspace\", keyCode: 8, inputType: \"deleteContentBackward\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertParagraph\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertLineBreak\" },\n { key: \"Delete\", keyCode: 46, inputType: \"deleteContentForward\" }\n];\nconst EmacsyPendingKeys = \"dthko\";\n// Key codes for modifier keys\nconst modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];\nconst dragScrollMargin = 6;\nfunction dragScrollSpeed(dist) {\n return Math.max(0, dist) * 0.7 + 8;\n}\nfunction dist(a, b) {\n return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));\n}\nclass MouseSelection {\n constructor(view, startEvent, style, mustSelect) {\n this.view = view;\n this.startEvent = startEvent;\n this.style = style;\n this.mustSelect = mustSelect;\n this.scrollSpeed = { x: 0, y: 0 };\n this.scrolling = -1;\n this.lastEvent = startEvent;\n this.scrollParent = scrollableParent(view.contentDOM);\n this.atoms = view.state.facet(atomicRanges).map(f => f(view));\n let doc = view.contentDOM.ownerDocument;\n doc.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n doc.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n this.extend = startEvent.shiftKey;\n this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);\n this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;\n }\n start(event) {\n // When clicking outside of the selection, immediately apply the\n // effect of starting the selection\n if (this.dragging === false) {\n event.preventDefault();\n this.select(event);\n }\n }\n move(event) {\n var _a;\n if (event.buttons == 0)\n return this.destroy();\n if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)\n return;\n this.select(this.lastEvent = event);\n let sx = 0, sy = 0;\n let rect = ((_a = this.scrollParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect())\n || { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };\n let margins = getScrollMargins(this.view);\n if (event.clientX - margins.left <= rect.left + dragScrollMargin)\n sx = -dragScrollSpeed(rect.left - event.clientX);\n else if (event.clientX + margins.right >= rect.right - dragScrollMargin)\n sx = dragScrollSpeed(event.clientX - rect.right);\n if (event.clientY - margins.top <= rect.top + dragScrollMargin)\n sy = -dragScrollSpeed(rect.top - event.clientY);\n else if (event.clientY + margins.bottom >= rect.bottom - dragScrollMargin)\n sy = dragScrollSpeed(event.clientY - rect.bottom);\n this.setScrollSpeed(sx, sy);\n }\n up(event) {\n if (this.dragging == null)\n this.select(this.lastEvent);\n if (!this.dragging)\n event.preventDefault();\n this.destroy();\n }\n destroy() {\n this.setScrollSpeed(0, 0);\n let doc = this.view.contentDOM.ownerDocument;\n doc.removeEventListener(\"mousemove\", this.move);\n doc.removeEventListener(\"mouseup\", this.up);\n this.view.inputState.mouseSelection = null;\n }\n setScrollSpeed(sx, sy) {\n this.scrollSpeed = { x: sx, y: sy };\n if (sx || sy) {\n if (this.scrolling < 0)\n this.scrolling = setInterval(() => this.scroll(), 50);\n }\n else if (this.scrolling > -1) {\n clearInterval(this.scrolling);\n this.scrolling = -1;\n }\n }\n scroll() {\n if (this.scrollParent) {\n this.scrollParent.scrollLeft += this.scrollSpeed.x;\n this.scrollParent.scrollTop += this.scrollSpeed.y;\n }\n else {\n this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y);\n }\n if (this.dragging === false)\n this.select(this.lastEvent);\n }\n skipAtoms(sel) {\n let ranges = null;\n for (let i = 0; i < sel.ranges.length; i++) {\n let range = sel.ranges[i], updated = null;\n if (range.empty) {\n let pos = skipAtomicRanges(this.atoms, range.from, 0);\n if (pos != range.from)\n updated = EditorSelection.cursor(pos, -1);\n }\n else {\n let from = skipAtomicRanges(this.atoms, range.from, -1);\n let to = skipAtomicRanges(this.atoms, range.to, 1);\n if (from != range.from || to != range.to)\n updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);\n }\n if (updated) {\n if (!ranges)\n ranges = sel.ranges.slice();\n ranges[i] = updated;\n }\n }\n return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;\n }\n select(event) {\n let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));\n if (this.mustSelect || !selection.eq(view.state.selection) ||\n selection.main.assoc != view.state.selection.main.assoc && this.dragging === false)\n this.view.dispatch({\n selection,\n userEvent: \"select.pointer\"\n });\n this.mustSelect = false;\n }\n update(update) {\n if (update.docChanged && this.dragging)\n this.dragging = this.dragging.map(update.changes);\n if (this.style.update(update))\n setTimeout(() => this.select(this.lastEvent), 20);\n }\n}\nfunction addsSelectionRange(view, event) {\n let facet = view.state.facet(clickAddsSelectionRange);\n return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;\n}\nfunction dragMovesSelection(view, event) {\n let facet = view.state.facet(dragMovesSelection$1);\n return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;\n}\nfunction isInPrimarySelection(view, event) {\n let { main } = view.state.selection;\n if (main.empty)\n return false;\n // On boundary clicks, check whether the coordinates are inside the\n // selection's client rectangles\n let sel = getSelection(view.root);\n if (!sel || sel.rangeCount == 0)\n return true;\n let rects = sel.getRangeAt(0).getClientRects();\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (rect.left <= event.clientX && rect.right >= event.clientX &&\n rect.top <= event.clientY && rect.bottom >= event.clientY)\n return true;\n }\n return false;\n}\nfunction eventBelongsToEditor(view, event) {\n if (!event.bubbles)\n return true;\n if (event.defaultPrevented)\n return false;\n for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)\n if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))\n return false;\n return true;\n}\nconst handlers = /*@__PURE__*/Object.create(null);\nconst handlerOptions = /*@__PURE__*/Object.create(null);\n// This is very crude, but unfortunately both these browsers _pretend_\n// that they have a clipboard API—all the objects and methods are\n// there, they just don't work, and they are hard to test.\nconst brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||\n (browser.ios && browser.webkit_version < 604);\nfunction capturePaste(view) {\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n setTimeout(() => {\n view.focus();\n target.remove();\n doPaste(view, target.value);\n }, 50);\n}\nfunction doPaste(view, input) {\n let { state } = view, changes, i = 1, text = state.toText(input);\n let byLine = text.lines == state.selection.ranges.length;\n let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();\n if (linewise) {\n let lastLine = -1;\n changes = state.changeByRange(range => {\n let line = state.doc.lineAt(range.from);\n if (line.from == lastLine)\n return { range };\n lastLine = line.from;\n let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);\n return { changes: { from: line.from, insert },\n range: EditorSelection.cursor(range.from + insert.length) };\n });\n }\n else if (byLine) {\n changes = state.changeByRange(range => {\n let line = text.line(i++);\n return { changes: { from: range.from, to: range.to, insert: line.text },\n range: EditorSelection.cursor(range.from + line.length) };\n });\n }\n else {\n changes = state.replaceSelection(text);\n }\n view.dispatch(changes, {\n userEvent: \"input.paste\",\n scrollIntoView: true\n });\n}\nhandlers.keydown = (view, event) => {\n view.inputState.setSelectionOrigin(\"select\");\n if (event.keyCode == 27)\n view.inputState.lastEscPress = Date.now();\n};\nhandlers.touchstart = (view, e) => {\n view.inputState.lastTouchTime = Date.now();\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nhandlers.touchmove = view => {\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nhandlerOptions.touchstart = handlerOptions.touchmove = { passive: true };\nhandlers.mousedown = (view, event) => {\n view.observer.flush();\n if (view.inputState.lastTouchTime > Date.now() - 2000)\n return; // Ignore touch interaction\n let style = null;\n for (let makeStyle of view.state.facet(mouseSelectionStyle)) {\n style = makeStyle(view, event);\n if (style)\n break;\n }\n if (!style && event.button == 0)\n style = basicMouseSelection(view, event);\n if (style) {\n let mustFocus = !view.hasFocus;\n view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));\n if (mustFocus)\n view.observer.ignore(() => focusPreventScroll(view.contentDOM));\n if (view.inputState.mouseSelection)\n view.inputState.mouseSelection.start(event);\n }\n};\nfunction rangeForClick(view, pos, bias, type) {\n if (type == 1) { // Single click\n return EditorSelection.cursor(pos, bias);\n }\n else if (type == 2) { // Double click\n return groupAt(view.state, pos, bias);\n }\n else { // Triple click\n let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);\n let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;\n if (to < view.state.doc.length && to == line.to)\n to++;\n return EditorSelection.range(from, to);\n }\n}\nlet insideY = (y, rect) => y >= rect.top && y <= rect.bottom;\nlet inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;\n// Try to determine, for the given coordinates, associated with the\n// given position, whether they are related to the element before or\n// the element after the position.\nfunction findPositionSide(view, pos, x, y) {\n let line = LineView.find(view.docView, pos);\n if (!line)\n return 1;\n let off = pos - line.posAtStart;\n // Line boundaries point into the line\n if (off == 0)\n return 1;\n if (off == line.length)\n return -1;\n // Positions on top of an element point at that element\n let before = line.coordsAt(off, -1);\n if (before && inside(x, y, before))\n return -1;\n let after = line.coordsAt(off, 1);\n if (after && inside(x, y, after))\n return 1;\n // This is probably a line wrap point. Pick before if the point is\n // beside it.\n return before && insideY(y, before) ? -1 : 1;\n}\nfunction queryPos(view, event) {\n let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };\n}\nconst BadMouseDetail = browser.ie && browser.ie_version <= 11;\nlet lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;\nfunction getClickType(event) {\n if (!BadMouseDetail)\n return event.detail;\n let last = lastMouseDown, lastTime = lastMouseDownTime;\n lastMouseDown = event;\n lastMouseDownTime = Date.now();\n return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&\n Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;\n}\nfunction basicMouseSelection(view, event) {\n let start = queryPos(view, event), type = getClickType(event);\n let startSel = view.state.selection;\n return {\n update(update) {\n if (update.docChanged) {\n start.pos = update.changes.mapPos(start.pos);\n startSel = startSel.map(update.changes);\n }\n },\n get(event, extend, multiple) {\n let cur = queryPos(view, event), removed;\n let range = rangeForClick(view, cur.pos, cur.bias, type);\n if (start.pos != cur.pos && !extend) {\n let startRange = rangeForClick(view, start.pos, start.bias, type);\n let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);\n range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);\n }\n if (extend)\n return startSel.replaceRange(startSel.main.extend(range.from, range.to));\n else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))\n return removed;\n else if (multiple)\n return startSel.addRange(range);\n else\n return EditorSelection.create([range]);\n }\n };\n}\nfunction removeRangeAround(sel, pos) {\n for (let i = 0; i < sel.ranges.length; i++) {\n let { from, to } = sel.ranges[i];\n if (from <= pos && to >= pos)\n return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));\n }\n return null;\n}\nhandlers.dragstart = (view, event) => {\n let { selection: { main } } = view.state;\n let { mouseSelection } = view.inputState;\n if (mouseSelection)\n mouseSelection.dragging = main;\n if (event.dataTransfer) {\n event.dataTransfer.setData(\"Text\", view.state.sliceDoc(main.from, main.to));\n event.dataTransfer.effectAllowed = \"copyMove\";\n }\n};\nfunction dropText(view, event, text, direct) {\n if (!text)\n return;\n let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n event.preventDefault();\n let { mouseSelection } = view.inputState;\n let del = direct && mouseSelection && mouseSelection.dragging && dragMovesSelection(view, event) ?\n { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;\n let ins = { from: dropPos, insert: text };\n let changes = view.state.changes(del ? [del, ins] : ins);\n view.focus();\n view.dispatch({\n changes,\n selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },\n userEvent: del ? \"move.drop\" : \"input.drop\"\n });\n}\nhandlers.drop = (view, event) => {\n if (!event.dataTransfer)\n return;\n if (view.state.readOnly)\n return event.preventDefault();\n let files = event.dataTransfer.files;\n if (files && files.length) { // For a file drop, read the file's text.\n event.preventDefault();\n let text = Array(files.length), read = 0;\n let finishFile = () => {\n if (++read == files.length)\n dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);\n };\n for (let i = 0; i < files.length; i++) {\n let reader = new FileReader;\n reader.onerror = finishFile;\n reader.onload = () => {\n if (!/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(reader.result))\n text[i] = reader.result;\n finishFile();\n };\n reader.readAsText(files[i]);\n }\n }\n else {\n dropText(view, event, event.dataTransfer.getData(\"Text\"), true);\n }\n};\nhandlers.paste = (view, event) => {\n if (view.state.readOnly)\n return event.preventDefault();\n view.observer.flush();\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n doPaste(view, data.getData(\"text/plain\") || data.getData(\"text/uri-text\"));\n event.preventDefault();\n }\n else {\n capturePaste(view);\n }\n};\nfunction captureCopy(view, text) {\n // The extra wrapper is somehow necessary on IE/Edge to prevent the\n // content from being mangled when it is put onto the clipboard\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.value = text;\n target.focus();\n target.selectionEnd = text.length;\n target.selectionStart = 0;\n setTimeout(() => {\n target.remove();\n view.focus();\n }, 50);\n}\nfunction copiedRange(state) {\n let content = [], ranges = [], linewise = false;\n for (let range of state.selection.ranges)\n if (!range.empty) {\n content.push(state.sliceDoc(range.from, range.to));\n ranges.push(range);\n }\n if (!content.length) {\n // Nothing selected, do a line-wise copy\n let upto = -1;\n for (let { from } of state.selection.ranges) {\n let line = state.doc.lineAt(from);\n if (line.number > upto) {\n content.push(line.text);\n ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });\n }\n upto = line.number;\n }\n linewise = true;\n }\n return { text: content.join(state.lineBreak), ranges, linewise };\n}\nlet lastLinewiseCopy = null;\nhandlers.copy = handlers.cut = (view, event) => {\n let { text, ranges, linewise } = copiedRange(view.state);\n if (!text && !linewise)\n return;\n lastLinewiseCopy = linewise ? text : null;\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n event.preventDefault();\n data.clearData();\n data.setData(\"text/plain\", text);\n }\n else {\n captureCopy(view, text);\n }\n if (event.type == \"cut\" && !view.state.readOnly)\n view.dispatch({\n changes: ranges,\n scrollIntoView: true,\n userEvent: \"delete.cut\"\n });\n};\nconst isFocusChange = /*@__PURE__*/Annotation.define();\nfunction focusChangeTransaction(state, focus) {\n let effects = [];\n for (let getEffect of state.facet(focusChangeEffect)) {\n let effect = getEffect(state, focus);\n if (effect)\n effects.push(effect);\n }\n return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;\n}\nfunction updateForFocusChange(view) {\n setTimeout(() => {\n let focus = view.hasFocus;\n if (focus != view.inputState.notifiedFocused) {\n let tr = focusChangeTransaction(view.state, focus);\n if (tr)\n view.dispatch(tr);\n else\n view.update([]);\n }\n }, 10);\n}\nhandlers.focus = view => {\n view.inputState.lastFocusTime = Date.now();\n // When focusing reset the scroll position, move it back to where it was\n if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {\n view.scrollDOM.scrollTop = view.inputState.lastScrollTop;\n view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;\n }\n updateForFocusChange(view);\n};\nhandlers.blur = view => {\n view.observer.clearSelectionRange();\n updateForFocusChange(view);\n};\nhandlers.compositionstart = handlers.compositionupdate = view => {\n if (view.inputState.compositionFirstChange == null)\n view.inputState.compositionFirstChange = true;\n if (view.inputState.composing < 0) {\n // FIXME possibly set a timeout to clear it again on Android\n view.inputState.composing = 0;\n }\n};\nhandlers.compositionend = view => {\n view.inputState.composing = -1;\n view.inputState.compositionEndedAt = Date.now();\n view.inputState.compositionPendingKey = true;\n view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;\n view.inputState.compositionFirstChange = null;\n if (browser.chrome && browser.android) {\n // Delay flushing for a bit on Android because it'll often fire a\n // bunch of contradictory changes in a row at end of compositon\n view.observer.flushSoon();\n }\n else if (view.inputState.compositionPendingChange) {\n // If we found pending records, schedule a flush.\n Promise.resolve().then(() => view.observer.flush());\n }\n else {\n // Otherwise, make sure that, if no changes come in soon, the\n // composition view is cleared.\n setTimeout(() => {\n if (view.inputState.composing < 0 && view.docView.hasComposition)\n view.update([]);\n }, 50);\n }\n};\nhandlers.contextmenu = view => {\n view.inputState.lastContextMenu = Date.now();\n};\nhandlers.beforeinput = (view, event) => {\n var _a;\n // Because Chrome Android doesn't fire useful key events, use\n // beforeinput to detect backspace (and possibly enter and delete,\n // but those usually don't even seem to fire beforeinput events at\n // the moment) and fake a key event for it.\n //\n // (preventDefault on beforeinput, though supported in the spec,\n // seems to do nothing at all on Chrome).\n let pending;\n if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {\n view.observer.delayAndroidKey(pending.key, pending.keyCode);\n if (pending.key == \"Backspace\" || pending.key == \"Delete\") {\n let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;\n setTimeout(() => {\n var _a;\n // Backspacing near uneditable nodes on Chrome Android sometimes\n // closes the virtual keyboard. This tries to crudely detect\n // that and refocus to get it back.\n if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {\n view.contentDOM.blur();\n view.focus();\n }\n }, 100);\n }\n }\n};\nconst appliedFirefoxHack = /*@__PURE__*/new Set;\n// In Firefox, when cut/copy handlers are added to the document, that\n// somehow avoids a bug where those events aren't fired when the\n// selection is empty. See https://github.com/codemirror/dev/issues/1082\n// and https://bugzilla.mozilla.org/show_bug.cgi?id=995961\nfunction firefoxCopyCutHack(doc) {\n if (!appliedFirefoxHack.has(doc)) {\n appliedFirefoxHack.add(doc);\n doc.addEventListener(\"copy\", () => { });\n doc.addEventListener(\"cut\", () => { });\n }\n}\n\nconst wrappingWhiteSpace = [\"pre-wrap\", \"normal\", \"pre-line\", \"break-spaces\"];\nclass HeightOracle {\n constructor(lineWrapping) {\n this.lineWrapping = lineWrapping;\n this.doc = Text.empty;\n this.heightSamples = {};\n this.lineHeight = 14; // The height of an entire line (line-height)\n this.charWidth = 7;\n this.textHeight = 14; // The height of the actual font (font-size)\n this.lineLength = 30;\n // Used to track, during updateHeight, if any actual heights changed\n this.heightChanged = false;\n }\n heightForGap(from, to) {\n let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;\n if (this.lineWrapping)\n lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));\n return this.lineHeight * lines;\n }\n heightForLine(length) {\n if (!this.lineWrapping)\n return this.lineHeight;\n let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));\n return lines * this.lineHeight;\n }\n setDoc(doc) { this.doc = doc; return this; }\n mustRefreshForWrapping(whiteSpace) {\n return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;\n }\n mustRefreshForHeights(lineHeights) {\n let newHeight = false;\n for (let i = 0; i < lineHeights.length; i++) {\n let h = lineHeights[i];\n if (h < 0) {\n i++;\n }\n else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels\n newHeight = true;\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return newHeight;\n }\n refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {\n let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;\n let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;\n this.lineWrapping = lineWrapping;\n this.lineHeight = lineHeight;\n this.charWidth = charWidth;\n this.textHeight = textHeight;\n this.lineLength = lineLength;\n if (changed) {\n this.heightSamples = {};\n for (let i = 0; i < knownHeights.length; i++) {\n let h = knownHeights[i];\n if (h < 0)\n i++;\n else\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return changed;\n }\n}\n// This object is used by `updateHeight` to make DOM measurements\n// arrive at the right nides. The `heights` array is a sequence of\n// block heights, starting from position `from`.\nclass MeasuredHeights {\n constructor(from, heights) {\n this.from = from;\n this.heights = heights;\n this.index = 0;\n }\n get more() { return this.index < this.heights.length; }\n}\n/**\nRecord used to represent information about a block-level element\nin the editor view.\n*/\nclass BlockInfo {\n /**\n @internal\n */\n constructor(\n /**\n The start of the element in the document.\n */\n from, \n /**\n The length of the element.\n */\n length, \n /**\n The top position of the element (relative to the top of the\n document).\n */\n top, \n /**\n Its height.\n */\n height, \n /**\n @internal Weird packed field that holds an array of children\n for composite blocks, a decoration for block widgets, and a\n number indicating the amount of widget-create line breaks for\n text blocks.\n */\n _content) {\n this.from = from;\n this.length = length;\n this.top = top;\n this.height = height;\n this._content = _content;\n }\n /**\n The type of element this is. When querying lines, this may be\n an array of all the blocks that make up the line.\n */\n get type() {\n return typeof this._content == \"number\" ? BlockType.Text :\n Array.isArray(this._content) ? this._content : this._content.type;\n }\n /**\n The end of the element as a document position.\n */\n get to() { return this.from + this.length; }\n /**\n The bottom position of the element.\n */\n get bottom() { return this.top + this.height; }\n /**\n If this is a widget block, this will return the widget\n associated with it.\n */\n get widget() {\n return this._content instanceof PointDecoration ? this._content.widget : null;\n }\n /**\n If this is a textblock, this holds the number of line breaks\n that appear in widgets inside the block.\n */\n get widgetLineBreaks() {\n return typeof this._content == \"number\" ? this._content : 0;\n }\n /**\n @internal\n */\n join(other) {\n let content = (Array.isArray(this._content) ? this._content : [this])\n .concat(Array.isArray(other._content) ? other._content : [other]);\n return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);\n }\n}\nvar QueryType = /*@__PURE__*/(function (QueryType) {\n QueryType[QueryType[\"ByPos\"] = 0] = \"ByPos\";\n QueryType[QueryType[\"ByHeight\"] = 1] = \"ByHeight\";\n QueryType[QueryType[\"ByPosNoHeight\"] = 2] = \"ByPosNoHeight\";\nreturn QueryType})(QueryType || (QueryType = {}));\nconst Epsilon = 1e-3;\nclass HeightMap {\n constructor(length, // The number of characters covered\n height, // Height of this part of the document\n flags = 2 /* Flag.Outdated */) {\n this.length = length;\n this.height = height;\n this.flags = flags;\n }\n get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }\n set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }\n setHeight(oracle, height) {\n if (this.height != height) {\n if (Math.abs(this.height - height) > Epsilon)\n oracle.heightChanged = true;\n this.height = height;\n }\n }\n // Base case is to replace a leaf node, which simply builds a tree\n // from the new nodes and returns that (HeightMapBranch and\n // HeightMapGap override this to actually use from/to)\n replace(_from, _to, nodes) {\n return HeightMap.of(nodes);\n }\n // Again, these are base cases, and are overridden for branch and gap nodes.\n decomposeLeft(_to, result) { result.push(this); }\n decomposeRight(_from, result) { result.push(this); }\n applyChanges(decorations, oldDoc, oracle, changes) {\n let me = this, doc = oracle.doc;\n for (let i = changes.length - 1; i >= 0; i--) {\n let { fromA, toA, fromB, toB } = changes[i];\n let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);\n let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oracle, 0, 0);\n toB += end.to - toA;\n toA = end.to;\n while (i > 0 && start.from <= changes[i - 1].toA) {\n fromA = changes[i - 1].fromA;\n fromB = changes[i - 1].fromB;\n i--;\n if (fromA < start.from)\n start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle, 0, 0);\n }\n fromB += start.from - fromA;\n fromA = start.from;\n let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);\n me = me.replace(fromA, toA, nodes);\n }\n return me.updateHeight(oracle, 0);\n }\n static empty() { return new HeightMapText(0, 0); }\n // nodes uses null values to indicate the position of line breaks.\n // There are never line breaks at the start or end of the array, or\n // two line breaks next to each other, and the array isn't allowed\n // to be empty (same restrictions as return value from the builder).\n static of(nodes) {\n if (nodes.length == 1)\n return nodes[0];\n let i = 0, j = nodes.length, before = 0, after = 0;\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1];\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right);\n else\n nodes.splice(--i, 1, split.left, split.right);\n j += 1 + split.break;\n before -= split.size;\n }\n else if (after > before * 2) {\n let split = nodes[j];\n if (split.break)\n nodes.splice(j, 1, split.left, null, split.right);\n else\n nodes.splice(j, 1, split.left, split.right);\n j += 2 + split.break;\n after -= split.size;\n }\n else {\n break;\n }\n }\n else if (before < after) {\n let next = nodes[i++];\n if (next)\n before += next.size;\n }\n else {\n let next = nodes[--j];\n if (next)\n after += next.size;\n }\n }\n let brk = 0;\n if (nodes[i - 1] == null) {\n brk = 1;\n i--;\n }\n else if (nodes[i] == null) {\n brk = 1;\n j++;\n }\n return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));\n }\n}\nHeightMap.prototype.size = 1;\nclass HeightMapBlock extends HeightMap {\n constructor(length, height, deco) {\n super(length, height);\n this.deco = deco;\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);\n }\n lineAt(_value, _type, oracle, top, offset) {\n return this.blockAt(0, oracle, top, offset);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n if (from <= offset + this.length && to >= offset)\n f(this.blockAt(0, oracle, top, offset));\n }\n updateHeight(oracle, offset = 0, _force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n this.outdated = false;\n return this;\n }\n toString() { return `block(${this.length})`; }\n}\nclass HeightMapText extends HeightMapBlock {\n constructor(length, height) {\n super(length, height, null);\n this.collapsed = 0; // Amount of collapsed content in the line\n this.widgetHeight = 0; // Maximum inline widget height\n this.breaks = 0; // Number of widget-introduced line breaks on the line\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.breaks);\n }\n replace(_from, _to, nodes) {\n let node = nodes[0];\n if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&\n Math.abs(this.length - node.length) < 10) {\n if (node instanceof HeightMapGap)\n node = new HeightMapText(node.length, this.height);\n else\n node.height = this.height;\n if (!this.outdated)\n node.outdated = false;\n return node;\n }\n else {\n return HeightMap.of(nodes);\n }\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n else if (force || this.outdated)\n this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +\n this.breaks * oracle.lineHeight);\n this.outdated = false;\n return this;\n }\n toString() {\n return `line(${this.length}${this.collapsed ? -this.collapsed : \"\"}${this.widgetHeight ? \":\" + this.widgetHeight : \"\"})`;\n }\n}\nclass HeightMapGap extends HeightMap {\n constructor(length) { super(length, 0); }\n heightMetrics(oracle, offset) {\n let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;\n let lines = lastLine - firstLine + 1;\n let perLine, perChar = 0;\n if (oracle.lineWrapping) {\n let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);\n perLine = totalPerLine / lines;\n if (this.length > lines + 1)\n perChar = (this.height - totalPerLine) / (this.length - lines - 1);\n }\n else {\n perLine = this.height / lines;\n }\n return { firstLine, lastLine, perLine, perChar };\n }\n blockAt(height, oracle, top, offset) {\n let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n if (oracle.lineWrapping) {\n let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);\n let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;\n let lineTop = Math.max(top, height - lineHeight / 2);\n return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);\n }\n else {\n let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));\n let { from, length } = oracle.doc.line(firstLine + line);\n return new BlockInfo(from, length, top + perLine * line, perLine, 0);\n }\n }\n lineAt(value, type, oracle, top, offset) {\n if (type == QueryType.ByHeight)\n return this.blockAt(value, oracle, top, offset);\n if (type == QueryType.ByPosNoHeight) {\n let { from, to } = oracle.doc.lineAt(value);\n return new BlockInfo(from, to - from, 0, 0, 0);\n }\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;\n let linesAbove = line.number - firstLine;\n let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);\n return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n from = Math.max(from, offset);\n to = Math.min(to, offset + this.length);\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n for (let pos = from, lineTop = top; pos <= to;) {\n let line = oracle.doc.lineAt(pos);\n if (pos == from) {\n let linesAbove = line.number - firstLine;\n lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);\n }\n let lineHeight = perLine + perChar * line.length;\n f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));\n lineTop += lineHeight;\n pos = line.to + 1;\n }\n }\n replace(from, to, nodes) {\n let after = this.length - to;\n if (after > 0) {\n let last = nodes[nodes.length - 1];\n if (last instanceof HeightMapGap)\n nodes[nodes.length - 1] = new HeightMapGap(last.length + after);\n else\n nodes.push(null, new HeightMapGap(after - 1));\n }\n if (from > 0) {\n let first = nodes[0];\n if (first instanceof HeightMapGap)\n nodes[0] = new HeightMapGap(from + first.length);\n else\n nodes.unshift(new HeightMapGap(from - 1), null);\n }\n return HeightMap.of(nodes);\n }\n decomposeLeft(to, result) {\n result.push(new HeightMapGap(to - 1), null);\n }\n decomposeRight(from, result) {\n result.push(null, new HeightMapGap(this.length - from - 1));\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let end = offset + this.length;\n if (measured && measured.from <= offset + this.length && measured.more) {\n // Fill in part of this gap with measured lines. We know there\n // can't be widgets or collapsed ranges in those lines, because\n // they would already have been added to the heightmap (gaps\n // only contain plain text).\n let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;\n if (measured.from > offset)\n nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));\n while (pos <= end && measured.more) {\n let len = oracle.doc.lineAt(pos).length;\n if (nodes.length)\n nodes.push(null);\n let height = measured.heights[measured.index++];\n if (singleHeight == -1)\n singleHeight = height;\n else if (Math.abs(height - singleHeight) >= Epsilon)\n singleHeight = -2;\n let line = new HeightMapText(len, height);\n line.outdated = false;\n nodes.push(line);\n pos += len + 1;\n }\n if (pos <= end)\n nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));\n let result = HeightMap.of(nodes);\n if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||\n Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)\n oracle.heightChanged = true;\n return result;\n }\n else if (force || this.outdated) {\n this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));\n this.outdated = false;\n }\n return this;\n }\n toString() { return `gap(${this.length})`; }\n}\nclass HeightMapBranch extends HeightMap {\n constructor(left, brk, right) {\n super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));\n this.left = left;\n this.right = right;\n this.size = left.size + right.size;\n }\n get break() { return this.flags & 1 /* Flag.Break */; }\n blockAt(height, oracle, top, offset) {\n let mid = top + this.left.height;\n return height < mid ? this.left.blockAt(height, oracle, top, offset)\n : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);\n }\n lineAt(value, type, oracle, top, offset) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;\n let base = left ? this.left.lineAt(value, type, oracle, top, offset)\n : this.right.lineAt(value, type, oracle, rightTop, rightOffset);\n if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))\n return base;\n let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;\n if (left)\n return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));\n else\n return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n if (this.break) {\n if (from < rightOffset)\n this.left.forEachLine(from, to, oracle, top, offset, f);\n if (to >= rightOffset)\n this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);\n }\n else {\n let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);\n if (from < mid.from)\n this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);\n if (mid.to >= from && mid.from <= to)\n f(mid);\n if (to > mid.to)\n this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);\n }\n }\n replace(from, to, nodes) {\n let rightStart = this.left.length + this.break;\n if (to < rightStart)\n return this.balanced(this.left.replace(from, to, nodes), this.right);\n if (from > this.left.length)\n return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));\n let result = [];\n if (from > 0)\n this.decomposeLeft(from, result);\n let left = result.length;\n for (let node of nodes)\n result.push(node);\n if (from > 0)\n mergeGaps(result, left - 1);\n if (to < this.length) {\n let right = result.length;\n this.decomposeRight(to, result);\n mergeGaps(result, right);\n }\n return HeightMap.of(result);\n }\n decomposeLeft(to, result) {\n let left = this.left.length;\n if (to <= left)\n return this.left.decomposeLeft(to, result);\n result.push(this.left);\n if (this.break) {\n left++;\n if (to >= left)\n result.push(null);\n }\n if (to > left)\n this.right.decomposeLeft(to - left, result);\n }\n decomposeRight(from, result) {\n let left = this.left.length, right = left + this.break;\n if (from >= right)\n return this.right.decomposeRight(from - right, result);\n if (from < left)\n this.left.decomposeRight(from, result);\n if (this.break && from < right)\n result.push(null);\n result.push(this.right);\n }\n balanced(left, right) {\n if (left.size > 2 * right.size || right.size > 2 * left.size)\n return HeightMap.of(this.break ? [left, null, right] : [left, right]);\n this.left = left;\n this.right = right;\n this.height = left.height + right.height;\n this.outdated = left.outdated || right.outdated;\n this.size = left.size + right.size;\n this.length = left.length + this.break + right.length;\n return this;\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;\n if (measured && measured.from <= offset + left.length && measured.more)\n rebalance = left = left.updateHeight(oracle, offset, force, measured);\n else\n left.updateHeight(oracle, offset, force);\n if (measured && measured.from <= rightStart + right.length && measured.more)\n rebalance = right = right.updateHeight(oracle, rightStart, force, measured);\n else\n right.updateHeight(oracle, rightStart, force);\n if (rebalance)\n return this.balanced(left, right);\n this.height = this.left.height + this.right.height;\n this.outdated = false;\n return this;\n }\n toString() { return this.left + (this.break ? \" \" : \"-\") + this.right; }\n}\nfunction mergeGaps(nodes, around) {\n let before, after;\n if (nodes[around] == null &&\n (before = nodes[around - 1]) instanceof HeightMapGap &&\n (after = nodes[around + 1]) instanceof HeightMapGap)\n nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));\n}\nconst relevantWidgetHeight = 5;\nclass NodeBuilder {\n constructor(pos, oracle) {\n this.pos = pos;\n this.oracle = oracle;\n this.nodes = [];\n this.lineStart = -1;\n this.lineEnd = -1;\n this.covering = null;\n this.writtenTo = pos;\n }\n get isCovered() {\n return this.covering && this.nodes[this.nodes.length - 1] == this.covering;\n }\n span(_from, to) {\n if (this.lineStart > -1) {\n let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];\n if (last instanceof HeightMapText)\n last.length += end - this.pos;\n else if (end > this.pos || !this.isCovered)\n this.nodes.push(new HeightMapText(end - this.pos, -1));\n this.writtenTo = end;\n if (to > end) {\n this.nodes.push(null);\n this.writtenTo++;\n this.lineStart = -1;\n }\n }\n this.pos = to;\n }\n point(from, to, deco) {\n if (from < to || deco.heightRelevant) {\n let height = deco.widget ? deco.widget.estimatedHeight : 0;\n let breaks = deco.widget ? deco.widget.lineBreaks : 0;\n if (height < 0)\n height = this.oracle.lineHeight;\n let len = to - from;\n if (deco.block) {\n this.addBlock(new HeightMapBlock(len, height, deco));\n }\n else if (len || breaks || height >= relevantWidgetHeight) {\n this.addLineDeco(height, breaks, len);\n }\n }\n else if (to > from) {\n this.span(from, to);\n }\n if (this.lineEnd > -1 && this.lineEnd < this.pos)\n this.lineEnd = this.oracle.doc.lineAt(this.pos).to;\n }\n enterLine() {\n if (this.lineStart > -1)\n return;\n let { from, to } = this.oracle.doc.lineAt(this.pos);\n this.lineStart = from;\n this.lineEnd = to;\n if (this.writtenTo < from) {\n if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)\n this.nodes.push(this.blankContent(this.writtenTo, from - 1));\n this.nodes.push(null);\n }\n if (this.pos > from)\n this.nodes.push(new HeightMapText(this.pos - from, -1));\n this.writtenTo = this.pos;\n }\n blankContent(from, to) {\n let gap = new HeightMapGap(to - from);\n if (this.oracle.doc.lineAt(from).to == to)\n gap.flags |= 4 /* Flag.SingleLine */;\n return gap;\n }\n ensureLine() {\n this.enterLine();\n let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;\n if (last instanceof HeightMapText)\n return last;\n let line = new HeightMapText(0, -1);\n this.nodes.push(line);\n return line;\n }\n addBlock(block) {\n var _a;\n this.enterLine();\n let type = (_a = block.deco) === null || _a === void 0 ? void 0 : _a.type;\n if (type == BlockType.WidgetAfter && !this.isCovered)\n this.ensureLine();\n this.nodes.push(block);\n this.writtenTo = this.pos = this.pos + block.length;\n if (type != BlockType.WidgetBefore)\n this.covering = block;\n }\n addLineDeco(height, breaks, length) {\n let line = this.ensureLine();\n line.length += length;\n line.collapsed += length;\n line.widgetHeight = Math.max(line.widgetHeight, height);\n line.breaks += breaks;\n this.writtenTo = this.pos = this.pos + length;\n }\n finish(from) {\n let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];\n if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)\n this.nodes.push(new HeightMapText(0, -1));\n else if (this.writtenTo < this.pos || last == null)\n this.nodes.push(this.blankContent(this.writtenTo, this.pos));\n let pos = from;\n for (let node of this.nodes) {\n if (node instanceof HeightMapText)\n node.updateHeight(this.oracle, pos);\n pos += node ? node.length : 1;\n }\n return this.nodes;\n }\n // Always called with a region that on both sides either stretches\n // to a line break or the end of the document.\n // The returned array uses null to indicate line breaks, but never\n // starts or ends in a line break, or has multiple line breaks next\n // to each other.\n static build(oracle, decorations, from, to) {\n let builder = new NodeBuilder(from, oracle);\n RangeSet.spans(decorations, from, to, builder, 0);\n return builder.finish(from);\n }\n}\nfunction heightRelevantDecoChanges(a, b, diff) {\n let comp = new DecorationComparator;\n RangeSet.compare(a, b, diff, comp, 0);\n return comp.changes;\n}\nclass DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange() { }\n comparePoint(from, to, a, b) {\n if (from < to || a && a.heightRelevant || b && b.heightRelevant)\n addRange(from, to, this.changes, 5);\n }\n}\n\nfunction visiblePixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);\n let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);\n for (let parent = dom.parentNode; parent && parent != doc.body;) {\n if (parent.nodeType == 1) {\n let elt = parent;\n let style = window.getComputedStyle(elt);\n if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&\n style.overflow != \"visible\") {\n let parentRect = elt.getBoundingClientRect();\n left = Math.max(left, parentRect.left);\n right = Math.min(right, parentRect.right);\n top = Math.max(top, parentRect.top);\n bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);\n }\n parent = style.position == \"absolute\" || style.position == \"fixed\" ? elt.offsetParent : elt.parentNode;\n }\n else if (parent.nodeType == 11) { // Shadow root\n parent = parent.host;\n }\n else {\n break;\n }\n }\n return { left: left - rect.left, right: Math.max(left, right) - rect.left,\n top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };\n}\nfunction fullPixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n return { left: 0, right: rect.right - rect.left,\n top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };\n}\n// Line gaps are placeholder widgets used to hide pieces of overlong\n// lines within the viewport, as a kludge to keep the editor\n// responsive when a ridiculously long line is loaded into it.\nclass LineGap {\n constructor(from, to, size) {\n this.from = from;\n this.to = to;\n this.size = size;\n }\n static same(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let gA = a[i], gB = b[i];\n if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)\n return false;\n }\n return true;\n }\n draw(viewState, wrapping) {\n return Decoration.replace({\n widget: new LineGapWidget(this.size * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)\n }).range(this.from, this.to);\n }\n}\nclass LineGapWidget extends WidgetType {\n constructor(size, vertical) {\n super();\n this.size = size;\n this.vertical = vertical;\n }\n eq(other) { return other.size == this.size && other.vertical == this.vertical; }\n toDOM() {\n let elt = document.createElement(\"div\");\n if (this.vertical) {\n elt.style.height = this.size + \"px\";\n }\n else {\n elt.style.width = this.size + \"px\";\n elt.style.height = \"2px\";\n elt.style.display = \"inline-block\";\n }\n return elt;\n }\n get estimatedHeight() { return this.vertical ? this.size : -1; }\n}\nclass ViewState {\n constructor(state) {\n this.state = state;\n // These are contentDOM-local coordinates\n this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };\n this.inView = true;\n this.paddingTop = 0; // Padding above the document, scaled\n this.paddingBottom = 0; // Padding below the document, scaled\n this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width\n this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height\n this.editorHeight = 0; // scrollDOM.clientHeight, unscaled\n this.editorWidth = 0; // scrollDOM.clientWidth, unscaled\n this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled\n this.scrolledToBottom = true;\n // The CSS-transformation scale of the editor (transformed size /\n // concrete size)\n this.scaleX = 1;\n this.scaleY = 1;\n // The vertical position (document-relative) to which to anchor the\n // scroll position. -1 means anchor to the end of the document.\n this.scrollAnchorPos = 0;\n // The height at the anchor position. Set by the DOM update phase.\n // -1 means no height available.\n this.scrollAnchorHeight = -1;\n // See VP.MaxDOMHeight\n this.scaler = IdScaler;\n this.scrollTarget = null;\n // Briefly set to true when printing, to disable viewport limiting\n this.printing = false;\n // Flag set when editor content was redrawn, so that the next\n // measure stage knows it must read DOM layout\n this.mustMeasureContent = true;\n this.defaultTextDirection = Direction.LTR;\n this.visibleRanges = [];\n // Cursor 'assoc' is only significant when the cursor is on a line\n // wrap point, where it must stick to the character that it is\n // associated with. Since browsers don't provide a reasonable\n // interface to set or query this, when a selection is set that\n // might cause this to be significant, this flag is set. The next\n // measure phase will check whether the cursor is on a line-wrapping\n // boundary and, if so, reset it to make sure it is positioned in\n // the right place.\n this.mustEnforceCursorAssoc = false;\n let guessWrapping = state.facet(contentAttributes).some(v => typeof v != \"function\" && v.class == \"cm-lineWrapping\");\n this.heightOracle = new HeightOracle(guessWrapping);\n this.stateDeco = state.facet(decorations).filter(d => typeof d != \"function\");\n this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);\n this.viewport = this.getViewport(0, null);\n this.updateViewportLines();\n this.updateForViewport();\n this.lineGaps = this.ensureLineGaps([]);\n this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));\n this.computeVisibleRanges();\n }\n updateForViewport() {\n let viewports = [this.viewport], { main } = this.state.selection;\n for (let i = 0; i <= 1; i++) {\n let pos = i ? main.head : main.anchor;\n if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {\n let { from, to } = this.lineBlockAt(pos);\n viewports.push(new Viewport(from, to));\n }\n }\n this.viewports = viewports.sort((a, b) => a.from - b.from);\n this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :\n new BigScaler(this.heightOracle, this.heightMap, this.viewports);\n }\n updateViewportLines() {\n this.viewportLines = [];\n this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {\n this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock(block, this.scaler));\n });\n }\n update(update, scrollTarget = null) {\n this.state = update.state;\n let prevDeco = this.stateDeco;\n this.stateDeco = this.state.facet(decorations).filter(d => typeof d != \"function\");\n let contentChanges = update.changedRanges;\n let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));\n let prevHeight = this.heightMap.height;\n let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);\n this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);\n if (this.heightMap.height != prevHeight)\n update.flags |= 2 /* UpdateFlag.Height */;\n if (scrollAnchor) {\n this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);\n this.scrollAnchorHeight = scrollAnchor.top;\n }\n else {\n this.scrollAnchorPos = -1;\n this.scrollAnchorHeight = this.heightMap.height;\n }\n let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;\n if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||\n !this.viewportIsAppropriate(viewport))\n viewport = this.getViewport(0, scrollTarget);\n let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||\n viewport.from != this.viewport.from || viewport.to != this.viewport.to;\n this.viewport = viewport;\n this.updateForViewport();\n if (updateLines)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));\n update.flags |= this.computeVisibleRanges();\n if (scrollTarget)\n this.scrollTarget = scrollTarget;\n if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&\n update.state.selection.main.empty && update.state.selection.main.assoc &&\n !update.state.facet(nativeSelectionHidden))\n this.mustEnforceCursorAssoc = true;\n }\n measure(view) {\n let dom = view.contentDOM, style = window.getComputedStyle(dom);\n let oracle = this.heightOracle;\n let whiteSpace = style.whiteSpace;\n this.defaultTextDirection = style.direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);\n let domRect = dom.getBoundingClientRect();\n let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;\n this.contentDOMHeight = domRect.height;\n this.mustMeasureContent = false;\n let result = 0, bias = 0;\n if (domRect.width && domRect.height) {\n let scaleX = domRect.width / dom.offsetWidth;\n let scaleY = domRect.height / dom.offsetHeight;\n if (scaleX > 0.995 && scaleX < 1.005)\n scaleX = 1;\n if (scaleY > 0.995 && scaleY < 1.005)\n scaleY = 1;\n if (this.scaleX != scaleX || this.scaleY != scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n result |= 8 /* UpdateFlag.Geometry */;\n refresh = measureContent = true;\n }\n }\n // Vertical padding\n let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;\n let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;\n if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {\n this.paddingTop = paddingTop;\n this.paddingBottom = paddingBottom;\n result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;\n }\n if (this.editorWidth != view.scrollDOM.clientWidth) {\n if (oracle.lineWrapping)\n measureContent = true;\n this.editorWidth = view.scrollDOM.clientWidth;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n let scrollTop = view.scrollDOM.scrollTop * this.scaleY;\n if (this.scrollTop != scrollTop) {\n this.scrollAnchorHeight = -1;\n this.scrollTop = scrollTop;\n }\n this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);\n // Pixel viewport\n let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);\n let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;\n this.pixelViewport = pixelViewport;\n let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;\n if (inView != this.inView) {\n this.inView = inView;\n if (inView)\n measureContent = true;\n }\n if (!this.inView && !this.scrollTarget)\n return 0;\n let contentWidth = domRect.width;\n if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {\n this.contentDOMWidth = domRect.width;\n this.editorHeight = view.scrollDOM.clientHeight;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n if (measureContent) {\n let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);\n if (oracle.mustRefreshForHeights(lineHeights))\n refresh = true;\n if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {\n let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();\n refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);\n if (refresh) {\n view.docView.minWidth = 0;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n }\n if (dTop > 0 && dBottom > 0)\n bias = Math.max(dTop, dBottom);\n else if (dTop < 0 && dBottom < 0)\n bias = Math.min(dTop, dBottom);\n oracle.heightChanged = false;\n for (let vp of this.viewports) {\n let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);\n this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));\n }\n if (oracle.heightChanged)\n result |= 2 /* UpdateFlag.Height */;\n }\n let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||\n this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||\n this.scrollTarget.range.head > this.viewport.to);\n if (viewportChange)\n this.viewport = this.getViewport(bias, this.scrollTarget);\n this.updateForViewport();\n if ((result & 2 /* UpdateFlag.Height */) || viewportChange)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));\n result |= this.computeVisibleRanges();\n if (this.mustEnforceCursorAssoc) {\n this.mustEnforceCursorAssoc = false;\n // This is done in the read stage, because moving the selection\n // to a line end is going to trigger a layout anyway, so it\n // can't be a pure write. It should be rare that it does any\n // writing.\n view.docView.enforceCursorAssoc();\n }\n return result;\n }\n get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }\n get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }\n getViewport(bias, scrollTarget) {\n // This will divide VP.Margin between the top and the\n // bottom, depending on the bias (the change in viewport position\n // since the last update). It'll hold a number between 0 and 1\n let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));\n let map = this.heightMap, oracle = this.heightOracle;\n let { visibleTop, visibleBottom } = this;\n let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).to);\n // If scrollTarget is given, make sure the viewport includes that position\n if (scrollTarget) {\n let { head } = scrollTarget.range;\n if (head < viewport.from || head > viewport.to) {\n let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);\n let block = map.lineAt(head, QueryType.ByPos, oracle, 0, 0), topPos;\n if (scrollTarget.y == \"center\")\n topPos = (block.top + block.bottom) / 2 - viewHeight / 2;\n else if (scrollTarget.y == \"start\" || scrollTarget.y == \"nearest\" && head < viewport.from)\n topPos = block.top;\n else\n topPos = block.bottom - viewHeight;\n viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).to);\n }\n }\n return viewport;\n }\n mapViewport(viewport, changes) {\n let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);\n return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0).to);\n }\n // Checks if a given viewport covers the visible part of the\n // document and not too much beyond that.\n viewportIsAppropriate({ from, to }, bias = 0) {\n if (!this.inView)\n return true;\n let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);\n let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);\n let { visibleTop, visibleBottom } = this;\n return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&\n (to == this.state.doc.length ||\n bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&\n (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);\n }\n mapLineGaps(gaps, changes) {\n if (!gaps.length || changes.empty)\n return gaps;\n let mapped = [];\n for (let gap of gaps)\n if (!changes.touchesRange(gap.from, gap.to))\n mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));\n return mapped;\n }\n // Computes positions in the viewport where the start or end of a\n // line should be hidden, trying to reuse existing line gaps when\n // appropriate to avoid unneccesary redraws.\n // Uses crude character-counting for the positioning and sizing,\n // since actual DOM coordinates aren't always available and\n // predictable. Relies on generous margins (see LG.Margin) to hide\n // the artifacts this might produce from the user.\n ensureLineGaps(current, mayMeasure) {\n let wrapping = this.heightOracle.lineWrapping;\n let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;\n // The non-wrapping logic won't work at all in predominantly right-to-left text.\n if (this.defaultTextDirection != Direction.LTR && !wrapping)\n return [];\n let gaps = [];\n let addGap = (from, to, line, structure) => {\n if (to - from < halfMargin)\n return;\n let sel = this.state.selection.main, avoid = [sel.from];\n if (!sel.empty)\n avoid.push(sel.to);\n for (let pos of avoid) {\n if (pos > from && pos < to) {\n addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);\n addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);\n return;\n }\n }\n let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&\n Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&\n !avoid.some(pos => gap.from < pos && gap.to > pos));\n if (!gap) {\n // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping\n if (to < line.to && mayMeasure && wrapping &&\n mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {\n let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;\n if (lineStart > from)\n to = lineStart;\n }\n gap = new LineGap(from, to, this.gapSize(line, from, to, structure));\n }\n gaps.push(gap);\n };\n for (let line of this.viewportLines) {\n if (line.length < doubleMargin)\n continue;\n let structure = lineStructure(line.from, line.to, this.stateDeco);\n if (structure.total < doubleMargin)\n continue;\n let target = this.scrollTarget ? this.scrollTarget.range.head : null;\n let viewFrom, viewTo;\n if (wrapping) {\n let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;\n let top, bot;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;\n top = targetFrac - spaceFrac;\n bot = targetFrac + spaceFrac;\n }\n else {\n top = (this.visibleTop - line.top - marginHeight) / line.height;\n bot = (this.visibleBottom - line.top + marginHeight) / line.height;\n }\n viewFrom = findPosition(structure, top);\n viewTo = findPosition(structure, bot);\n }\n else {\n let totalWidth = structure.total * this.heightOracle.charWidth;\n let marginWidth = margin * this.heightOracle.charWidth;\n let left, right;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.pixelViewport.right - this.pixelViewport.left) / 2 + marginWidth) / totalWidth;\n left = targetFrac - spaceFrac;\n right = targetFrac + spaceFrac;\n }\n else {\n left = (this.pixelViewport.left - marginWidth) / totalWidth;\n right = (this.pixelViewport.right + marginWidth) / totalWidth;\n }\n viewFrom = findPosition(structure, left);\n viewTo = findPosition(structure, right);\n }\n if (viewFrom > line.from)\n addGap(line.from, viewFrom, line, structure);\n if (viewTo < line.to)\n addGap(viewTo, line.to, line, structure);\n }\n return gaps;\n }\n gapSize(line, from, to, structure) {\n let fraction = findFraction(structure, to) - findFraction(structure, from);\n if (this.heightOracle.lineWrapping) {\n return line.height * fraction;\n }\n else {\n return structure.total * this.heightOracle.charWidth * fraction;\n }\n }\n updateLineGaps(gaps) {\n if (!LineGap.same(gaps, this.lineGaps)) {\n this.lineGaps = gaps;\n this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));\n }\n }\n computeVisibleRanges() {\n let deco = this.stateDeco;\n if (this.lineGaps.length)\n deco = deco.concat(this.lineGapDeco);\n let ranges = [];\n RangeSet.spans(deco, this.viewport.from, this.viewport.to, {\n span(from, to) { ranges.push({ from, to }); },\n point() { }\n }, 20);\n let changed = ranges.length != this.visibleRanges.length ||\n this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);\n this.visibleRanges = ranges;\n return changed ? 4 /* UpdateFlag.Viewport */ : 0;\n }\n lineBlockAt(pos) {\n return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||\n scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.heightOracle, 0, 0), this.scaler);\n }\n lineBlockAtHeight(height) {\n return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);\n }\n scrollAnchorAt(scrollTop) {\n let block = this.lineBlockAtHeight(scrollTop + 8);\n return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];\n }\n elementAtHeight(height) {\n return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);\n }\n get docHeight() {\n return this.scaler.toDOM(this.heightMap.height);\n }\n get contentHeight() {\n return this.docHeight + this.paddingTop + this.paddingBottom;\n }\n}\nclass Viewport {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\nfunction lineStructure(from, to, stateDeco) {\n let ranges = [], pos = from, total = 0;\n RangeSet.spans(stateDeco, from, to, {\n span() { },\n point(from, to) {\n if (from > pos) {\n ranges.push({ from: pos, to: from });\n total += from - pos;\n }\n pos = to;\n }\n }, 20); // We're only interested in collapsed ranges of a significant size\n if (pos < to) {\n ranges.push({ from: pos, to });\n total += to - pos;\n }\n return { total, ranges };\n}\nfunction findPosition({ total, ranges }, ratio) {\n if (ratio <= 0)\n return ranges[0].from;\n if (ratio >= 1)\n return ranges[ranges.length - 1].to;\n let dist = Math.floor(total * ratio);\n for (let i = 0;; i++) {\n let { from, to } = ranges[i], size = to - from;\n if (dist <= size)\n return from + dist;\n dist -= size;\n }\n}\nfunction findFraction(structure, pos) {\n let counted = 0;\n for (let { from, to } of structure.ranges) {\n if (pos <= to) {\n counted += pos - from;\n break;\n }\n counted += to - from;\n }\n return counted / structure.total;\n}\nfunction find(array, f) {\n for (let val of array)\n if (f(val))\n return val;\n return undefined;\n}\n// Don't scale when the document height is within the range of what\n// the DOM can handle.\nconst IdScaler = {\n toDOM(n) { return n; },\n fromDOM(n) { return n; },\n scale: 1\n};\n// When the height is too big (> VP.MaxDOMHeight), scale down the\n// regions outside the viewports so that the total height is\n// VP.MaxDOMHeight.\nclass BigScaler {\n constructor(oracle, heightMap, viewports) {\n let vpHeight = 0, base = 0, domBase = 0;\n this.viewports = viewports.map(({ from, to }) => {\n let top = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;\n let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;\n vpHeight += bottom - top;\n return { from, to, top, bottom, domTop: 0, domBottom: 0 };\n });\n this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);\n for (let obj of this.viewports) {\n obj.domTop = domBase + (obj.top - base) * this.scale;\n domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);\n base = obj.bottom;\n }\n }\n toDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.top)\n return domBase + (n - base) * this.scale;\n if (n <= vp.bottom)\n return vp.domTop + (n - vp.top);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n fromDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.domTop)\n return base + (n - domBase) / this.scale;\n if (n <= vp.domBottom)\n return vp.top + (n - vp.domTop);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n}\nfunction scaleBlock(block, scaler) {\n if (scaler.scale == 1)\n return block;\n let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);\n return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);\n}\n\nconst theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(\" \") });\nconst darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });\nconst baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();\nconst lightDarkIDs = { \"&light\": \".\" + baseLightID, \"&dark\": \".\" + baseDarkID };\nfunction buildTheme(main, spec, scopes) {\n return new StyleModule(spec, {\n finish(sel) {\n return /&/.test(sel) ? sel.replace(/&\\w*/, m => {\n if (m == \"&\")\n return main;\n if (!scopes || !scopes[m])\n throw new RangeError(`Unsupported selector: ${m}`);\n return scopes[m];\n }) : main + \" \" + sel;\n }\n });\n}\nconst baseTheme$1 = /*@__PURE__*/buildTheme(\".\" + baseThemeID, {\n \"&\": {\n position: \"relative !important\",\n boxSizing: \"border-box\",\n \"&.cm-focused\": {\n // Provide a simple default outline to make sure a focused\n // editor is visually distinct. Can't leave the default behavior\n // because that will apply to the content element, which is\n // inside the scrollable container and doesn't include the\n // gutters. We also can't use an 'auto' outline, since those\n // are, for some reason, drawn behind the element content, which\n // will cause things like the active line background to cover\n // the outline (#297).\n outline: \"1px dotted #212121\"\n },\n display: \"flex !important\",\n flexDirection: \"column\"\n },\n \".cm-scroller\": {\n display: \"flex !important\",\n alignItems: \"flex-start !important\",\n fontFamily: \"monospace\",\n lineHeight: 1.4,\n height: \"100%\",\n overflowX: \"auto\",\n position: \"relative\",\n zIndex: 0\n },\n \".cm-content\": {\n margin: 0,\n flexGrow: 2,\n flexShrink: 0,\n display: \"block\",\n whiteSpace: \"pre\",\n wordWrap: \"normal\",\n boxSizing: \"border-box\",\n padding: \"4px 0\",\n outline: \"none\",\n \"&[contenteditable=true]\": {\n WebkitUserModify: \"read-write-plaintext-only\",\n }\n },\n \".cm-lineWrapping\": {\n whiteSpace_fallback: \"pre-wrap\",\n whiteSpace: \"break-spaces\",\n wordBreak: \"break-word\",\n overflowWrap: \"anywhere\",\n flexShrink: 1\n },\n \"&light .cm-content\": { caretColor: \"black\" },\n \"&dark .cm-content\": { caretColor: \"white\" },\n \".cm-line\": {\n display: \"block\",\n padding: \"0 2px 0 6px\"\n },\n \".cm-layer\": {\n position: \"absolute\",\n left: 0,\n top: 0,\n contain: \"size style\",\n \"& > *\": {\n position: \"absolute\"\n }\n },\n \"&light .cm-selectionBackground\": {\n background: \"#d9d9d9\"\n },\n \"&dark .cm-selectionBackground\": {\n background: \"#222\"\n },\n \"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#d7d4f0\"\n },\n \"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#233\"\n },\n \".cm-cursorLayer\": {\n pointerEvents: \"none\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer\": {\n animation: \"steps(1) cm-blink 1.2s infinite\"\n },\n // Two animations defined so that we can switch between them to\n // restart the animation without forcing another style\n // recomputation.\n \"@keyframes cm-blink\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \"@keyframes cm-blink2\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \".cm-cursor, .cm-dropCursor\": {\n borderLeft: \"1.2px solid black\",\n marginLeft: \"-0.6px\",\n pointerEvents: \"none\",\n },\n \".cm-cursor\": {\n display: \"none\"\n },\n \"&dark .cm-cursor\": {\n borderLeftColor: \"#444\"\n },\n \".cm-dropCursor\": {\n position: \"absolute\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor\": {\n display: \"block\"\n },\n \"&light .cm-activeLine\": { backgroundColor: \"#cceeff44\" },\n \"&dark .cm-activeLine\": { backgroundColor: \"#99eeff33\" },\n \"&light .cm-specialChar\": { color: \"red\" },\n \"&dark .cm-specialChar\": { color: \"#f78\" },\n \".cm-gutters\": {\n flexShrink: 0,\n display: \"flex\",\n height: \"100%\",\n boxSizing: \"border-box\",\n insetInlineStart: 0,\n zIndex: 200\n },\n \"&light .cm-gutters\": {\n backgroundColor: \"#f5f5f5\",\n color: \"#6c6c6c\",\n borderRight: \"1px solid #ddd\"\n },\n \"&dark .cm-gutters\": {\n backgroundColor: \"#333338\",\n color: \"#ccc\"\n },\n \".cm-gutter\": {\n display: \"flex !important\",\n flexDirection: \"column\",\n flexShrink: 0,\n boxSizing: \"border-box\",\n minHeight: \"100%\",\n overflow: \"hidden\"\n },\n \".cm-gutterElement\": {\n boxSizing: \"border-box\"\n },\n \".cm-lineNumbers .cm-gutterElement\": {\n padding: \"0 3px 0 5px\",\n minWidth: \"20px\",\n textAlign: \"right\",\n whiteSpace: \"nowrap\"\n },\n \"&light .cm-activeLineGutter\": {\n backgroundColor: \"#e2f2ff\"\n },\n \"&dark .cm-activeLineGutter\": {\n backgroundColor: \"#222227\"\n },\n \".cm-panels\": {\n boxSizing: \"border-box\",\n position: \"sticky\",\n left: 0,\n right: 0\n },\n \"&light .cm-panels\": {\n backgroundColor: \"#f5f5f5\",\n color: \"black\"\n },\n \"&light .cm-panels-top\": {\n borderBottom: \"1px solid #ddd\"\n },\n \"&light .cm-panels-bottom\": {\n borderTop: \"1px solid #ddd\"\n },\n \"&dark .cm-panels\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tab\": {\n display: \"inline-block\",\n overflow: \"hidden\",\n verticalAlign: \"bottom\"\n },\n \".cm-widgetBuffer\": {\n verticalAlign: \"text-top\",\n height: \"1em\",\n width: 0,\n display: \"inline\"\n },\n \".cm-placeholder\": {\n color: \"#888\",\n display: \"inline-block\",\n verticalAlign: \"top\",\n },\n \".cm-highlightSpace:before\": {\n content: \"attr(data-display)\",\n position: \"absolute\",\n pointerEvents: \"none\",\n color: \"#888\"\n },\n \".cm-highlightTab\": {\n backgroundImage: `url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"20\"><path stroke=\"%23888\" stroke-width=\"1\" fill=\"none\" d=\"M1 10H196L190 5M190 15L196 10M197 4L197 16\"/></svg>')`,\n backgroundSize: \"auto 100%\",\n backgroundPosition: \"right 90%\",\n backgroundRepeat: \"no-repeat\"\n },\n \".cm-trailingSpace\": {\n backgroundColor: \"#ff332255\"\n },\n \".cm-button\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n padding: \".2em 1em\",\n borderRadius: \"1px\"\n },\n \"&light .cm-button\": {\n backgroundImage: \"linear-gradient(#eff1f5, #d9d9df)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#b4b4b4, #d0d3d6)\"\n }\n },\n \"&dark .cm-button\": {\n backgroundImage: \"linear-gradient(#393939, #111)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#111, #333)\"\n }\n },\n \".cm-textfield\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n border: \"1px solid silver\",\n padding: \".2em .5em\"\n },\n \"&light .cm-textfield\": {\n backgroundColor: \"white\"\n },\n \"&dark .cm-textfield\": {\n border: \"1px solid #555\",\n backgroundColor: \"inherit\"\n }\n}, lightDarkIDs);\n\nconst LineBreakPlaceholder = \"\\uffff\";\nclass DOMReader {\n constructor(points, state) {\n this.points = points;\n this.text = \"\";\n this.lineSeparator = state.facet(EditorState.lineSeparator);\n }\n append(text) {\n this.text += text;\n }\n lineBreak() {\n this.text += LineBreakPlaceholder;\n }\n readRange(start, end) {\n if (!start)\n return this;\n let parent = start.parentNode;\n for (let cur = start;;) {\n this.findPointBefore(parent, cur);\n let oldLen = this.text.length;\n this.readNode(cur);\n let next = cur.nextSibling;\n if (next == end)\n break;\n let view = ContentView.get(cur), nextView = ContentView.get(next);\n if (view && nextView ? view.breakAfter :\n (view ? view.breakAfter : isBlockElement(cur)) ||\n (isBlockElement(next) && (cur.nodeName != \"BR\" || cur.cmIgnore) && this.text.length > oldLen))\n this.lineBreak();\n cur = next;\n }\n this.findPointBefore(parent, end);\n return this;\n }\n readTextNode(node) {\n let text = node.nodeValue;\n for (let point of this.points)\n if (point.node == node)\n point.pos = this.text.length + Math.min(point.offset, text.length);\n for (let off = 0, re = this.lineSeparator ? null : /\\r\\n?|\\n/g;;) {\n let nextBreak = -1, breakSize = 1, m;\n if (this.lineSeparator) {\n nextBreak = text.indexOf(this.lineSeparator, off);\n breakSize = this.lineSeparator.length;\n }\n else if (m = re.exec(text)) {\n nextBreak = m.index;\n breakSize = m[0].length;\n }\n this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));\n if (nextBreak < 0)\n break;\n this.lineBreak();\n if (breakSize > 1)\n for (let point of this.points)\n if (point.node == node && point.pos > this.text.length)\n point.pos -= breakSize - 1;\n off = nextBreak + breakSize;\n }\n }\n readNode(node) {\n if (node.cmIgnore)\n return;\n let view = ContentView.get(node);\n let fromView = view && view.overrideDOMText;\n if (fromView != null) {\n this.findPointInside(node, fromView.length);\n for (let i = fromView.iter(); !i.next().done;) {\n if (i.lineBreak)\n this.lineBreak();\n else\n this.append(i.value);\n }\n }\n else if (node.nodeType == 3) {\n this.readTextNode(node);\n }\n else if (node.nodeName == \"BR\") {\n if (node.nextSibling)\n this.lineBreak();\n }\n else if (node.nodeType == 1) {\n this.readRange(node.firstChild, null);\n }\n }\n findPointBefore(node, next) {\n for (let point of this.points)\n if (point.node == node && node.childNodes[point.offset] == next)\n point.pos = this.text.length;\n }\n findPointInside(node, maxLen) {\n for (let point of this.points)\n if (node.nodeType == 3 ? point.node == node : node.contains(point.node))\n point.pos = this.text.length + Math.min(maxLen, point.offset);\n }\n}\nfunction isBlockElement(node) {\n return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\\d|SECTION|PRE)$/.test(node.nodeName);\n}\nclass DOMPoint {\n constructor(node, offset) {\n this.node = node;\n this.offset = offset;\n this.pos = -1;\n }\n}\n\nclass DOMChange {\n constructor(view, start, end, typeOver) {\n this.typeOver = typeOver;\n this.bounds = null;\n this.text = \"\";\n let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;\n if (view.state.readOnly && start > -1) {\n // Ignore changes when the editor is read-only\n this.newSel = null;\n }\n else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {\n let selPoints = iHead || iAnchor ? [] : selectionPoints(view);\n let reader = new DOMReader(selPoints, view.state);\n reader.readRange(this.bounds.startDOM, this.bounds.endDOM);\n this.text = reader.text;\n this.newSel = selectionFromPoints(selPoints, this.bounds.from);\n }\n else {\n let domSel = view.observer.selectionRange;\n let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||\n !contains(view.contentDOM, domSel.focusNode)\n ? view.state.selection.main.head\n : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||\n !contains(view.contentDOM, domSel.anchorNode)\n ? view.state.selection.main.anchor\n : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);\n this.newSel = EditorSelection.single(anchor, head);\n }\n }\n}\nfunction applyDOMChange(view, domChange) {\n let change;\n let { newSel } = domChange, sel = view.state.selection.main;\n let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;\n if (domChange.bounds) {\n let { from, to } = domChange.bounds;\n let preferredPos = sel.from, preferredSide = null;\n // Prefer anchoring to end when Backspace is pressed (or, on\n // Android, when something was deleted)\n if (lastKey === 8 || browser.android && domChange.text.length < to - from) {\n preferredPos = sel.to;\n preferredSide = \"end\";\n }\n let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);\n if (diff) {\n // Chrome inserts two newlines when pressing shift-enter at the\n // end of a line. DomChange drops one of those.\n if (browser.chrome && lastKey == 13 &&\n diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)\n diff.toB--;\n change = { from: from + diff.from, to: from + diff.toA,\n insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };\n }\n }\n else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {\n newSel = null;\n }\n if (!change && !newSel)\n return false;\n if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {\n // Heuristic to notice typing over a selected character\n change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };\n }\n else if (change && change.from >= sel.from && change.to <= sel.to &&\n (change.from != sel.from || change.to != sel.to) &&\n (sel.to - sel.from) - (change.to - change.from) <= 4) {\n // If the change is inside the selection and covers most of it,\n // assume it is a selection replace (with identical characters at\n // the start/end not included in the diff)\n change = {\n from: sel.from, to: sel.to,\n insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))\n };\n }\n else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&\n /^\\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute(\"autocorrect\") == \"off\") {\n // Detect insert-period-on-double-space Mac and Android behavior,\n // and transform it into a regular space insert.\n if (newSel && change.insert.length == 2)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&\n change.insert.toString() == \"\\n \" && view.lineWrapping) {\n // In Chrome, if you insert a space at the start of a wrapped\n // line, it will actually insert a newline and a space, causing a\n // bogus new line to be created in CodeMirror (#968)\n if (newSel)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n if (change) {\n if (browser.ios && view.inputState.flushIOSKey(view))\n return true;\n // Android browsers don't fire reasonable key events for enter,\n // backspace, or delete. So this detects changes that look like\n // they're caused by those keys, and reinterprets them as key\n // events. (Some of these keys are also handled by beforeinput\n // events and the pendingAndroidKey mechanism, but that's not\n // reliable in all situations.)\n if (browser.android &&\n ((change.from == sel.from && change.to == sel.to &&\n change.insert.length == 1 && change.insert.lines == 2 &&\n dispatchKey(view.contentDOM, \"Enter\", 13)) ||\n ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||\n lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&\n dispatchKey(view.contentDOM, \"Backspace\", 8)) ||\n (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&\n dispatchKey(view.contentDOM, \"Delete\", 46))))\n return true;\n let text = change.insert.toString();\n if (view.inputState.composing >= 0)\n view.inputState.composing++;\n let defaultTr;\n let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));\n if (!view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text, defaultInsert)))\n view.dispatch(defaultInsert());\n return true;\n }\n else if (newSel && !newSel.main.eq(sel)) {\n let scrollIntoView = false, userEvent = \"select\";\n if (view.inputState.lastSelectionTime > Date.now() - 50) {\n if (view.inputState.lastSelectionOrigin == \"select\")\n scrollIntoView = true;\n userEvent = view.inputState.lastSelectionOrigin;\n }\n view.dispatch({ selection: newSel, scrollIntoView, userEvent });\n return true;\n }\n else {\n return false;\n }\n}\nfunction applyDefaultInsert(view, change, newSel) {\n let tr, startState = view.state, sel = startState.selection.main;\n if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&\n (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&\n view.inputState.composing < 0) {\n let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : \"\";\n let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : \"\";\n tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));\n }\n else {\n let changes = startState.changes(change);\n let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;\n // Try to apply a composition change to all cursors\n if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&\n change.to <= sel.to && change.to >= sel.to - 10) {\n let replaced = view.state.sliceDoc(change.from, change.to);\n let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);\n if (composition) {\n let dLen = change.insert.length - (change.to - change.from);\n compositionRange = { from: composition.from, to: composition.to - dLen };\n }\n else {\n compositionRange = view.state.doc.lineAt(sel.head);\n }\n let offset = sel.to - change.to, size = sel.to - sel.from;\n tr = startState.changeByRange(range => {\n if (range.from == sel.from && range.to == sel.to)\n return { changes, range: mainSel || range.map(changes) };\n let to = range.to - offset, from = to - replaced.length;\n if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||\n // Unfortunately, there's no way to make multiple\n // changes in the same node work without aborting\n // composition, so cursors in the composition range are\n // ignored.\n range.to >= compositionRange.from && range.from <= compositionRange.to)\n return { range };\n let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;\n return {\n changes: rangeChanges,\n range: !mainSel ? range.map(rangeChanges) :\n EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))\n };\n });\n }\n else {\n tr = {\n changes,\n selection: mainSel && startState.selection.replaceRange(mainSel)\n };\n }\n }\n let userEvent = \"input.type\";\n if (view.composing ||\n view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {\n view.inputState.compositionPendingChange = false;\n userEvent += \".compose\";\n if (view.inputState.compositionFirstChange) {\n userEvent += \".start\";\n view.inputState.compositionFirstChange = false;\n }\n }\n return startState.update(tr, { userEvent, scrollIntoView: true });\n}\nfunction findDiff(a, b, preferredPos, preferredSide) {\n let minLen = Math.min(a.length, b.length);\n let from = 0;\n while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))\n from++;\n if (from == minLen && a.length == b.length)\n return null;\n let toA = a.length, toB = b.length;\n while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {\n toA--;\n toB--;\n }\n if (preferredSide == \"end\") {\n let adjust = Math.max(0, from - Math.min(toA, toB));\n preferredPos -= toA + adjust - from;\n }\n if (toA < from && a.length < b.length) {\n let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;\n from -= move;\n toB = from + (toB - toA);\n toA = from;\n }\n else if (toB < from) {\n let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;\n from -= move;\n toA = from + (toA - toB);\n toB = from;\n }\n return { from, toA, toB };\n}\nfunction selectionPoints(view) {\n let result = [];\n if (view.root.activeElement != view.contentDOM)\n return result;\n let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;\n if (anchorNode) {\n result.push(new DOMPoint(anchorNode, anchorOffset));\n if (focusNode != anchorNode || focusOffset != anchorOffset)\n result.push(new DOMPoint(focusNode, focusOffset));\n }\n return result;\n}\nfunction selectionFromPoints(points, base) {\n if (points.length == 0)\n return null;\n let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;\n return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;\n}\n\nconst observeOptions = {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n characterDataOldValue: true\n};\n// IE11 has very broken mutation observers, so we also listen to\n// DOMCharacterDataModified there\nconst useCharData = browser.ie && browser.ie_version <= 11;\nclass DOMObserver {\n constructor(view) {\n this.view = view;\n this.active = false;\n // The known selection. Kept in our own object, as opposed to just\n // directly accessing the selection because:\n // - Safari doesn't report the right selection in shadow DOM\n // - Reading from the selection forces a DOM layout\n // - This way, we can ignore selectionchange events if we have\n // already seen the 'new' selection\n this.selectionRange = new DOMSelectionState;\n // Set when a selection change is detected, cleared on flush\n this.selectionChanged = false;\n this.delayedFlush = -1;\n this.resizeTimeout = -1;\n this.queue = [];\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n this.lastChange = 0;\n this.scrollTargets = [];\n this.intersection = null;\n this.resizeScroll = null;\n this.resizeContent = null;\n this.intersecting = false;\n this.gapIntersection = null;\n this.gaps = [];\n // Timeout for scheduling check of the parents that need scroll handlers\n this.parentCheck = -1;\n this.dom = view.contentDOM;\n this.observer = new MutationObserver(mutations => {\n for (let mut of mutations)\n this.queue.push(mut);\n // IE11 will sometimes (on typing over a selection or\n // backspacing out a single character text node) call the\n // observer callback before actually updating the DOM.\n //\n // Unrelatedly, iOS Safari will, when ending a composition,\n // sometimes first clear it, deliver the mutations, and then\n // reinsert the finished text. CodeMirror's handling of the\n // deletion will prevent the reinsertion from happening,\n // breaking composition.\n if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&\n mutations.some(m => m.type == \"childList\" && m.removedNodes.length ||\n m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length))\n this.flushSoon();\n else\n this.flush();\n });\n if (useCharData)\n this.onCharData = (event) => {\n this.queue.push({ target: event.target,\n type: \"characterData\",\n oldValue: event.prevValue });\n this.flushSoon();\n };\n this.onSelectionChange = this.onSelectionChange.bind(this);\n this.onResize = this.onResize.bind(this);\n this.onPrint = this.onPrint.bind(this);\n this.onScroll = this.onScroll.bind(this);\n if (typeof ResizeObserver == \"function\") {\n this.resizeScroll = new ResizeObserver(() => {\n var _a;\n if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)\n this.onResize();\n });\n this.resizeScroll.observe(view.scrollDOM);\n this.resizeContent = new ResizeObserver(() => this.view.requestMeasure());\n this.resizeContent.observe(view.contentDOM);\n }\n this.addWindowListeners(this.win = view.win);\n this.start();\n if (typeof IntersectionObserver == \"function\") {\n this.intersection = new IntersectionObserver(entries => {\n if (this.parentCheck < 0)\n this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);\n if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {\n this.intersecting = !this.intersecting;\n if (this.intersecting != this.view.inView)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }\n }, { threshold: [0, .001] });\n this.intersection.observe(this.dom);\n this.gapIntersection = new IntersectionObserver(entries => {\n if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }, {});\n }\n this.listenForScroll();\n this.readSelectionRange();\n }\n onScrollChanged(e) {\n this.view.inputState.runScrollHandlers(this.view, e);\n if (this.intersecting)\n this.view.measure();\n }\n onScroll(e) {\n if (this.intersecting)\n this.flush(false);\n this.onScrollChanged(e);\n }\n onResize() {\n if (this.resizeTimeout < 0)\n this.resizeTimeout = setTimeout(() => {\n this.resizeTimeout = -1;\n this.view.requestMeasure();\n }, 50);\n }\n onPrint() {\n this.view.viewState.printing = true;\n this.view.measure();\n setTimeout(() => {\n this.view.viewState.printing = false;\n this.view.requestMeasure();\n }, 500);\n }\n updateGaps(gaps) {\n if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {\n this.gapIntersection.disconnect();\n for (let gap of gaps)\n this.gapIntersection.observe(gap);\n this.gaps = gaps;\n }\n }\n onSelectionChange(event) {\n let wasChanged = this.selectionChanged;\n if (!this.readSelectionRange() || this.delayedAndroidKey)\n return;\n let { view } = this, sel = this.selectionRange;\n if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))\n return;\n let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);\n if (context && context.ignoreEvent(event)) {\n if (!wasChanged)\n this.selectionChanged = false;\n return;\n }\n // Deletions on IE11 fire their events in the wrong order, giving\n // us a selection change event before the DOM changes are\n // reported.\n // Chrome Android has a similar issue when backspacing out a\n // selection (#645).\n if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&\n // (Selection.isCollapsed isn't reliable on IE)\n sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))\n this.flushSoon();\n else\n this.flush(false);\n }\n readSelectionRange() {\n let { view } = this;\n // The Selection object is broken in shadow roots in Safari. See\n // https://github.com/codemirror/dev/issues/414\n let range = browser.safari && view.root.nodeType == 11 &&\n deepActiveElement(this.dom.ownerDocument) == this.dom &&\n safariSelectionRangeHack(this.view) || getSelection(view.root);\n if (!range || this.selectionRange.eq(range))\n return false;\n let local = hasSelection(this.dom, range);\n // Detect the situation where the browser has, on focus, moved the\n // selection to the start of the content element. Reset it to the\n // position from the editor state.\n if (local && !this.selectionChanged &&\n view.inputState.lastFocusTime > Date.now() - 200 &&\n view.inputState.lastTouchTime < Date.now() - 300 &&\n atElementStart(this.dom, range)) {\n this.view.inputState.lastFocusTime = 0;\n view.docView.updateSelection();\n return false;\n }\n this.selectionRange.setRange(range);\n if (local)\n this.selectionChanged = true;\n return true;\n }\n setSelectionRange(anchor, head) {\n this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);\n this.selectionChanged = false;\n }\n clearSelectionRange() {\n this.selectionRange.set(null, 0, null, 0);\n }\n listenForScroll() {\n this.parentCheck = -1;\n let i = 0, changed = null;\n for (let dom = this.dom; dom;) {\n if (dom.nodeType == 1) {\n if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)\n i++;\n else if (!changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed)\n changed.push(dom);\n dom = dom.assignedSlot || dom.parentNode;\n }\n else if (dom.nodeType == 11) { // Shadow root\n dom = dom.host;\n }\n else {\n break;\n }\n }\n if (i < this.scrollTargets.length && !changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed) {\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n for (let dom of this.scrollTargets = changed)\n dom.addEventListener(\"scroll\", this.onScroll);\n }\n }\n ignore(f) {\n if (!this.active)\n return f();\n try {\n this.stop();\n return f();\n }\n finally {\n this.start();\n this.clear();\n }\n }\n start() {\n if (this.active)\n return;\n this.observer.observe(this.dom, observeOptions);\n if (useCharData)\n this.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData);\n this.active = true;\n }\n stop() {\n if (!this.active)\n return;\n this.active = false;\n this.observer.disconnect();\n if (useCharData)\n this.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData);\n }\n // Throw away any pending changes\n clear() {\n this.processRecords();\n this.queue.length = 0;\n this.selectionChanged = false;\n }\n // Chrome Android, especially in combination with GBoard, not only\n // doesn't reliably fire regular key events, but also often\n // surrounds the effect of enter or backspace with a bunch of\n // composition events that, when interrupted, cause text duplication\n // or other kinds of corruption. This hack makes the editor back off\n // from handling DOM changes for a moment when such a key is\n // detected (via beforeinput or keydown), and then tries to flush\n // them or, if that has no effect, dispatches the given key.\n delayAndroidKey(key, keyCode) {\n var _a;\n if (!this.delayedAndroidKey) {\n let flush = () => {\n let key = this.delayedAndroidKey;\n if (key) {\n this.clearDelayedAndroidKey();\n this.view.inputState.lastKeyCode = key.keyCode;\n this.view.inputState.lastKeyTime = Date.now();\n let flushed = this.flush();\n if (!flushed && key.force)\n dispatchKey(this.dom, key.key, key.keyCode);\n }\n };\n this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);\n }\n // Since backspace beforeinput is sometimes signalled spuriously,\n // Enter always takes precedence.\n if (!this.delayedAndroidKey || key == \"Enter\")\n this.delayedAndroidKey = {\n key, keyCode,\n // Only run the key handler when no changes are detected if\n // this isn't coming right after another change, in which case\n // it is probably part of a weird chain of updates, and should\n // be ignored if it returns the DOM to its previous state.\n force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)\n };\n }\n clearDelayedAndroidKey() {\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n }\n flushSoon() {\n if (this.delayedFlush < 0)\n this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });\n }\n forceFlush() {\n if (this.delayedFlush >= 0) {\n this.view.win.cancelAnimationFrame(this.delayedFlush);\n this.delayedFlush = -1;\n }\n this.flush();\n }\n pendingRecords() {\n for (let mut of this.observer.takeRecords())\n this.queue.push(mut);\n return this.queue;\n }\n processRecords() {\n let records = this.pendingRecords();\n if (records.length)\n this.queue = [];\n let from = -1, to = -1, typeOver = false;\n for (let record of records) {\n let range = this.readMutation(record);\n if (!range)\n continue;\n if (range.typeOver)\n typeOver = true;\n if (from == -1) {\n ({ from, to } = range);\n }\n else {\n from = Math.min(range.from, from);\n to = Math.max(range.to, to);\n }\n }\n return { from, to, typeOver };\n }\n readChange() {\n let { from, to, typeOver } = this.processRecords();\n let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);\n if (from < 0 && !newSel)\n return null;\n if (from > -1)\n this.lastChange = Date.now();\n this.view.inputState.lastFocusTime = 0;\n this.selectionChanged = false;\n let change = new DOMChange(this.view, from, to, typeOver);\n this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };\n return change;\n }\n // Apply pending changes, if any\n flush(readSelection = true) {\n // Completely hold off flushing when pending keys are set—the code\n // managing those will make sure processRecords is called and the\n // view is resynchronized after\n if (this.delayedFlush >= 0 || this.delayedAndroidKey)\n return false;\n if (readSelection)\n this.readSelectionRange();\n let domChange = this.readChange();\n if (!domChange)\n return false;\n let startState = this.view.state;\n let handled = applyDOMChange(this.view, domChange);\n // The view wasn't updated\n if (this.view.state == startState)\n this.view.update([]);\n return handled;\n }\n readMutation(rec) {\n let cView = this.view.docView.nearest(rec.target);\n if (!cView || cView.ignoreMutation(rec))\n return null;\n cView.markDirty(rec.type == \"attributes\");\n if (rec.type == \"attributes\")\n cView.flags |= 4 /* ViewFlag.AttrsDirty */;\n if (rec.type == \"childList\") {\n let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);\n let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);\n return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,\n to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };\n }\n else if (rec.type == \"characterData\") {\n return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };\n }\n else {\n return null;\n }\n }\n setWindow(win) {\n if (win != this.win) {\n this.removeWindowListeners(this.win);\n this.win = win;\n this.addWindowListeners(this.win);\n }\n }\n addWindowListeners(win) {\n win.addEventListener(\"resize\", this.onResize);\n win.addEventListener(\"beforeprint\", this.onPrint);\n win.addEventListener(\"scroll\", this.onScroll);\n win.document.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n removeWindowListeners(win) {\n win.removeEventListener(\"scroll\", this.onScroll);\n win.removeEventListener(\"resize\", this.onResize);\n win.removeEventListener(\"beforeprint\", this.onPrint);\n win.document.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n destroy() {\n var _a, _b, _c, _d;\n this.stop();\n (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();\n (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();\n (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();\n (_d = this.resizeContent) === null || _d === void 0 ? void 0 : _d.disconnect();\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n this.removeWindowListeners(this.win);\n clearTimeout(this.parentCheck);\n clearTimeout(this.resizeTimeout);\n this.win.cancelAnimationFrame(this.delayedFlush);\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n }\n}\nfunction findChild(cView, dom, dir) {\n while (dom) {\n let curView = ContentView.get(dom);\n if (curView && curView.parent == cView)\n return curView;\n let parent = dom.parentNode;\n dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;\n }\n return null;\n}\n// Used to work around a Safari Selection/shadow DOM bug (#414)\nfunction safariSelectionRangeHack(view) {\n let found = null;\n // Because Safari (at least in 2018-2021) doesn't provide regular\n // access to the selection inside a shadowroot, we have to perform a\n // ridiculous hack to get at it—using `execCommand` to trigger a\n // `beforeInput` event so that we can read the target range from the\n // event.\n function read(event) {\n event.preventDefault();\n event.stopImmediatePropagation();\n found = event.getTargetRanges()[0];\n }\n view.contentDOM.addEventListener(\"beforeinput\", read, true);\n view.dom.ownerDocument.execCommand(\"indent\");\n view.contentDOM.removeEventListener(\"beforeinput\", read, true);\n if (!found)\n return null;\n let anchorNode = found.startContainer, anchorOffset = found.startOffset;\n let focusNode = found.endContainer, focusOffset = found.endOffset;\n let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);\n // Since such a range doesn't distinguish between anchor and head,\n // use a heuristic that flips it around if its end matches the\n // current anchor.\n if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))\n [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];\n return { anchorNode, anchorOffset, focusNode, focusOffset };\n}\n\n// The editor's update state machine looks something like this:\n//\n// Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle\n// ↑ ↓\n// Updating (measure)\n//\n// The difference between 'Idle' and 'Idle (unchecked)' lies in\n// whether a layout check has been scheduled. A regular update through\n// the `update` method updates the DOM in a write-only fashion, and\n// relies on a check (scheduled with `requestAnimationFrame`) to make\n// sure everything is where it should be and the viewport covers the\n// visible code. That check continues to measure and then optionally\n// update until it reaches a coherent state.\n/**\nAn editor view represents the editor's user interface. It holds\nthe editable DOM surface, and possibly other elements such as the\nline number gutter. It handles events and dispatches state\ntransactions for editing actions.\n*/\nclass EditorView {\n /**\n The current editor state.\n */\n get state() { return this.viewState.state; }\n /**\n To be able to display large documents without consuming too much\n memory or overloading the browser, CodeMirror only draws the\n code that is visible (plus a margin around it) to the DOM. This\n property tells you the extent of the current drawn viewport, in\n document positions.\n */\n get viewport() { return this.viewState.viewport; }\n /**\n When there are, for example, large collapsed ranges in the\n viewport, its size can be a lot bigger than the actual visible\n content. Thus, if you are doing something like styling the\n content in the viewport, it is preferable to only do so for\n these ranges, which are the subset of the viewport that is\n actually drawn.\n */\n get visibleRanges() { return this.viewState.visibleRanges; }\n /**\n Returns false when the editor is entirely scrolled out of view\n or otherwise hidden.\n */\n get inView() { return this.viewState.inView; }\n /**\n Indicates whether the user is currently composing text via\n [IME](https://en.wikipedia.org/wiki/Input_method), and at least\n one change has been made in the current composition.\n */\n get composing() { return this.inputState.composing > 0; }\n /**\n Indicates whether the user is currently in composing state. Note\n that on some platforms, like Android, this will be the case a\n lot, since just putting the cursor on a word starts a\n composition there.\n */\n get compositionStarted() { return this.inputState.composing >= 0; }\n /**\n The document or shadow root that the view lives in.\n */\n get root() { return this._root; }\n /**\n @internal\n */\n get win() { return this.dom.ownerDocument.defaultView || window; }\n /**\n Construct a new view. You'll want to either provide a `parent`\n option, or put `view.dom` into your document after creating a\n view, so that the user can see the editor.\n */\n constructor(config = {}) {\n this.plugins = [];\n this.pluginMap = new Map;\n this.editorAttrs = {};\n this.contentAttrs = {};\n this.bidiCache = [];\n this.destroyed = false;\n /**\n @internal\n */\n this.updateState = 2 /* UpdateState.Updating */;\n /**\n @internal\n */\n this.measureScheduled = -1;\n /**\n @internal\n */\n this.measureRequests = [];\n this.contentDOM = document.createElement(\"div\");\n this.scrollDOM = document.createElement(\"div\");\n this.scrollDOM.tabIndex = -1;\n this.scrollDOM.className = \"cm-scroller\";\n this.scrollDOM.appendChild(this.contentDOM);\n this.announceDOM = document.createElement(\"div\");\n this.announceDOM.style.cssText = \"position: fixed; top: -10000px\";\n this.announceDOM.setAttribute(\"aria-live\", \"polite\");\n this.dom = document.createElement(\"div\");\n this.dom.appendChild(this.announceDOM);\n this.dom.appendChild(this.scrollDOM);\n let { dispatch } = config;\n this.dispatchTransactions = config.dispatchTransactions ||\n (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||\n ((trs) => this.update(trs));\n this.dispatch = this.dispatch.bind(this);\n this._root = (config.root || getRoot(config.parent) || document);\n this.viewState = new ViewState(config.state || EditorState.create(config));\n this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));\n for (let plugin of this.plugins)\n plugin.update(this);\n this.observer = new DOMObserver(this);\n this.inputState = new InputState(this);\n this.inputState.ensureHandlers(this, this.plugins);\n this.docView = new DocView(this);\n this.mountStyles();\n this.updateAttrs();\n this.updateState = 0 /* UpdateState.Idle */;\n this.requestMeasure();\n if (config.parent)\n config.parent.appendChild(this.dom);\n }\n dispatch(...input) {\n let trs = input.length == 1 && input[0] instanceof Transaction ? input\n : input.length == 1 && Array.isArray(input[0]) ? input[0]\n : [this.state.update(...input)];\n this.dispatchTransactions(trs, this);\n }\n /**\n Update the view for the given array of transactions. This will\n update the visible document and selection to match the state\n produced by the transactions, and notify view plugins of the\n change. You should usually call\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this\n as a primitive.\n */\n update(transactions) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.update are not allowed while an update is in progress\");\n let redrawn = false, attrsChanged = false, update;\n let state = this.state;\n for (let tr of transactions) {\n if (tr.startState != state)\n throw new RangeError(\"Trying to update state with a transaction that doesn't start from the previous state.\");\n state = tr.state;\n }\n if (this.destroyed) {\n this.viewState.state = state;\n return;\n }\n let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;\n if (transactions.some(tr => tr.annotation(isFocusChange))) {\n this.inputState.notifiedFocused = focus;\n // If a focus-change transaction is being dispatched, set this update flag.\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n else if (focus != this.inputState.notifiedFocused) {\n this.inputState.notifiedFocused = focus;\n // Schedule a separate focus transaction if necessary, otherwise\n // add a flag to this update\n dispatchFocus = focusChangeTransaction(state, focus);\n if (!dispatchFocus)\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n // If there was a pending DOM change, eagerly read it and try to\n // apply it after the given transactions.\n let pendingKey = this.observer.delayedAndroidKey, domChange = null;\n if (pendingKey) {\n this.observer.clearDelayedAndroidKey();\n domChange = this.observer.readChange();\n // Only try to apply DOM changes if the transactions didn't\n // change the doc or selection.\n if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))\n domChange = null;\n }\n else {\n this.observer.clear();\n }\n // When the phrases change, redraw the editor\n if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))\n return this.setState(state);\n update = ViewUpdate.create(this, state, transactions);\n update.flags |= focusFlag;\n let scrollTarget = this.viewState.scrollTarget;\n try {\n this.updateState = 2 /* UpdateState.Updating */;\n for (let tr of transactions) {\n if (scrollTarget)\n scrollTarget = scrollTarget.map(tr.changes);\n if (tr.scrollIntoView) {\n let { main } = tr.state.selection;\n scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));\n }\n for (let e of tr.effects)\n if (e.is(scrollIntoView))\n scrollTarget = e.value;\n }\n this.viewState.update(update, scrollTarget);\n this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n }\n redrawn = this.docView.update(update);\n if (this.state.facet(styleModule) != this.styleModules)\n this.mountStyles();\n attrsChanged = this.updateAttrs();\n this.showAnnouncements(transactions);\n this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent(\"select.pointer\")));\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (update.startState.facet(theme) != update.state.facet(theme))\n this.viewState.mustMeasureContent = true;\n if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)\n this.requestMeasure();\n if (!update.empty)\n for (let listener of this.state.facet(updateListener))\n listener(update);\n if (dispatchFocus || domChange)\n Promise.resolve().then(() => {\n if (dispatchFocus && this.state == dispatchFocus.startState)\n this.dispatch(dispatchFocus);\n if (domChange) {\n if (!applyDOMChange(this, domChange) && pendingKey.force)\n dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);\n }\n });\n }\n /**\n Reset the view to the given state. (This will cause the entire\n document to be redrawn and all view plugins to be reinitialized,\n so you should probably only use it when the new state isn't\n derived from the old state. Otherwise, use\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)\n */\n setState(newState) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.setState are not allowed while an update is in progress\");\n if (this.destroyed) {\n this.viewState.state = newState;\n return;\n }\n this.updateState = 2 /* UpdateState.Updating */;\n let hadFocus = this.hasFocus;\n try {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.viewState = new ViewState(newState);\n this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));\n this.pluginMap.clear();\n for (let plugin of this.plugins)\n plugin.update(this);\n this.docView = new DocView(this);\n this.inputState.ensureHandlers(this, this.plugins);\n this.mountStyles();\n this.updateAttrs();\n this.bidiCache = [];\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (hadFocus)\n this.focus();\n this.requestMeasure();\n }\n updatePlugins(update) {\n let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);\n if (prevSpecs != specs) {\n let newPlugins = [];\n for (let spec of specs) {\n let found = prevSpecs.indexOf(spec);\n if (found < 0) {\n newPlugins.push(new PluginInstance(spec));\n }\n else {\n let plugin = this.plugins[found];\n plugin.mustUpdate = update;\n newPlugins.push(plugin);\n }\n }\n for (let plugin of this.plugins)\n if (plugin.mustUpdate != update)\n plugin.destroy(this);\n this.plugins = newPlugins;\n this.pluginMap.clear();\n this.inputState.ensureHandlers(this, this.plugins);\n }\n else {\n for (let p of this.plugins)\n p.mustUpdate = update;\n }\n for (let i = 0; i < this.plugins.length; i++)\n this.plugins[i].update(this);\n }\n /**\n @internal\n */\n measure(flush = true) {\n if (this.destroyed)\n return;\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n if (this.observer.delayedAndroidKey) {\n this.measureScheduled = -1;\n this.requestMeasure();\n return;\n }\n this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame\n if (flush)\n this.observer.forceFlush();\n let updated = null;\n let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;\n let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;\n if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)\n scrollAnchorHeight = -1;\n this.viewState.scrollAnchorHeight = -1;\n try {\n for (let i = 0;; i++) {\n if (scrollAnchorHeight < 0) {\n if (isScrolledToBottom(sDOM)) {\n scrollAnchorPos = -1;\n scrollAnchorHeight = this.viewState.heightMap.height;\n }\n else {\n let block = this.viewState.scrollAnchorAt(scrollTop);\n scrollAnchorPos = block.from;\n scrollAnchorHeight = block.top;\n }\n }\n this.updateState = 1 /* UpdateState.Measuring */;\n let changed = this.viewState.measure(this);\n if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)\n break;\n if (i > 5) {\n console.warn(this.measureRequests.length\n ? \"Measure loop restarted more than 5 times\"\n : \"Viewport failed to stabilize\");\n break;\n }\n let measuring = [];\n // Only run measure requests in this cycle when the viewport didn't change\n if (!(changed & 4 /* UpdateFlag.Viewport */))\n [this.measureRequests, measuring] = [measuring, this.measureRequests];\n let measured = measuring.map(m => {\n try {\n return m.read(this);\n }\n catch (e) {\n logException(this.state, e);\n return BadMeasure;\n }\n });\n let update = ViewUpdate.create(this, this.state, []), redrawn = false;\n update.flags |= changed;\n if (!updated)\n updated = update;\n else\n updated.flags |= changed;\n this.updateState = 2 /* UpdateState.Updating */;\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n this.updateAttrs();\n redrawn = this.docView.update(update);\n }\n for (let i = 0; i < measuring.length; i++)\n if (measured[i] != BadMeasure) {\n try {\n let m = measuring[i];\n if (m.write)\n m.write(measured[i], this);\n }\n catch (e) {\n logException(this.state, e);\n }\n }\n if (redrawn)\n this.docView.updateSelection(true);\n if (!update.viewportChanged && this.measureRequests.length == 0) {\n if (this.viewState.editorHeight) {\n if (this.viewState.scrollTarget) {\n this.docView.scrollIntoView(this.viewState.scrollTarget);\n this.viewState.scrollTarget = null;\n continue;\n }\n else {\n let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :\n this.viewState.lineBlockAt(scrollAnchorPos).top;\n let diff = newAnchorHeight - scrollAnchorHeight;\n if (diff > 1 || diff < -1) {\n scrollTop = scrollTop + diff;\n sDOM.scrollTop = scrollTop / this.scaleY;\n scrollAnchorHeight = -1;\n continue;\n }\n }\n }\n break;\n }\n }\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n this.measureScheduled = -1;\n }\n if (updated && !updated.empty)\n for (let listener of this.state.facet(updateListener))\n listener(updated);\n }\n /**\n Get the CSS classes for the currently active editor themes.\n */\n get themeClasses() {\n return baseThemeID + \" \" +\n (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + \" \" +\n this.state.facet(theme);\n }\n updateAttrs() {\n let editorAttrs = attrsFromFacet(this, editorAttributes, {\n class: \"cm-editor\" + (this.hasFocus ? \" cm-focused \" : \" \") + this.themeClasses\n });\n let contentAttrs = {\n spellcheck: \"false\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n translate: \"no\",\n contenteditable: !this.state.facet(editable) ? \"false\" : \"true\",\n class: \"cm-content\",\n style: `${browser.tabSize}: ${this.state.tabSize}`,\n role: \"textbox\",\n \"aria-multiline\": \"true\"\n };\n if (this.state.readOnly)\n contentAttrs[\"aria-readonly\"] = \"true\";\n attrsFromFacet(this, contentAttributes, contentAttrs);\n let changed = this.observer.ignore(() => {\n let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);\n let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);\n return changedContent || changedEditor;\n });\n this.editorAttrs = editorAttrs;\n this.contentAttrs = contentAttrs;\n return changed;\n }\n showAnnouncements(trs) {\n let first = true;\n for (let tr of trs)\n for (let effect of tr.effects)\n if (effect.is(EditorView.announce)) {\n if (first)\n this.announceDOM.textContent = \"\";\n first = false;\n let div = this.announceDOM.appendChild(document.createElement(\"div\"));\n div.textContent = effect.value;\n }\n }\n mountStyles() {\n this.styleModules = this.state.facet(styleModule);\n let nonce = this.state.facet(EditorView.cspNonce);\n StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse(), nonce ? { nonce } : undefined);\n }\n readMeasured() {\n if (this.updateState == 2 /* UpdateState.Updating */)\n throw new Error(\"Reading the editor layout isn't allowed during an update\");\n if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)\n this.measure(false);\n }\n /**\n Schedule a layout measurement, optionally providing callbacks to\n do custom DOM measuring followed by a DOM write phase. Using\n this is preferable reading DOM layout directly from, for\n example, an event handler, because it'll make sure measuring and\n drawing done by other components is synchronized, avoiding\n unnecessary DOM layout computations.\n */\n requestMeasure(request) {\n if (this.measureScheduled < 0)\n this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());\n if (request) {\n if (this.measureRequests.indexOf(request) > -1)\n return;\n if (request.key != null)\n for (let i = 0; i < this.measureRequests.length; i++) {\n if (this.measureRequests[i].key === request.key) {\n this.measureRequests[i] = request;\n return;\n }\n }\n this.measureRequests.push(request);\n }\n }\n /**\n Get the value of a specific plugin, if present. Note that\n plugins that crash can be dropped from a view, so even when you\n know you registered a given plugin, it is recommended to check\n the return value of this method.\n */\n plugin(plugin) {\n let known = this.pluginMap.get(plugin);\n if (known === undefined || known && known.spec != plugin)\n this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);\n return known && known.update(this).value;\n }\n /**\n The top position of the document, in screen coordinates. This\n may be negative when the editor is scrolled down. Points\n directly to the top of the first line, not above the padding.\n */\n get documentTop() {\n return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;\n }\n /**\n Reports the padding above and below the document.\n */\n get documentPadding() {\n return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };\n }\n /**\n If the editor is transformed with CSS, this provides the scale\n along the X axis. Otherwise, it will just be 1. Note that\n transforms other than translation and scaling are not supported.\n */\n get scaleX() { return this.viewState.scaleX; }\n /**\n Provide the CSS transformed scale along the Y axis.\n */\n get scaleY() { return this.viewState.scaleY; }\n /**\n Find the text line or block widget at the given vertical\n position (which is interpreted as relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).\n */\n elementAtHeight(height) {\n this.readMeasured();\n return this.viewState.elementAtHeight(height);\n }\n /**\n Find the line block (see\n [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given\n height, again interpreted relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).\n */\n lineBlockAtHeight(height) {\n this.readMeasured();\n return this.viewState.lineBlockAtHeight(height);\n }\n /**\n Get the extent and vertical position of all [line\n blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions\n are relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);\n */\n get viewportLineBlocks() {\n return this.viewState.viewportLines;\n }\n /**\n Find the line block around the given document position. A line\n block is a range delimited on both sides by either a\n non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the\n start/end of the document. It will usually just hold a line of\n text, but may be broken into multiple textblocks by block\n widgets.\n */\n lineBlockAt(pos) {\n return this.viewState.lineBlockAt(pos);\n }\n /**\n The editor's total content height.\n */\n get contentHeight() {\n return this.viewState.contentHeight;\n }\n /**\n Move a cursor position by [grapheme\n cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether\n the motion is away from the line start, or towards it. In\n bidirectional text, the line is traversed in visual order, using\n the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n When the start position was the last one on the line, the\n returned position will be across the line break. If there is no\n further line, the original position is returned.\n \n By default, this method moves over a single cluster. The\n optional `by` argument can be used to move across more. It will\n be called with the first cluster as argument, and should return\n a predicate that determines, for each subsequent cluster,\n whether it should also be moved over.\n */\n moveByChar(start, forward, by) {\n return skipAtoms(this, start, moveByChar(this, start, forward, by));\n }\n /**\n Move a cursor position across the next group of either\n [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter\n non-whitespace characters.\n */\n moveByGroup(start, forward) {\n return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));\n }\n /**\n Move to the next line boundary in the given direction. If\n `includeWrap` is true, line wrapping is on, and there is a\n further wrap point on the current line, the wrap point will be\n returned. Otherwise this function will return the start or end\n of the line.\n */\n moveToLineBoundary(start, forward, includeWrap = true) {\n return moveToLineBoundary(this, start, forward, includeWrap);\n }\n /**\n Move a cursor position vertically. When `distance` isn't given,\n it defaults to moving to the next line (including wrapped\n lines). Otherwise, `distance` should provide a positive distance\n in pixels.\n \n When `start` has a\n [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical\n motion will use that as a target horizontal position. Otherwise,\n the cursor's own horizontal position is used. The returned\n cursor will have its goal column set to whichever column was\n used.\n */\n moveVertically(start, forward, distance) {\n return skipAtoms(this, start, moveVertically(this, start, forward, distance));\n }\n /**\n Find the DOM parent node and offset (child offset if `node` is\n an element, character offset when it is a text node) at the\n given document position.\n \n Note that for positions that aren't currently in\n `visibleRanges`, the resulting DOM position isn't necessarily\n meaningful (it may just point before or after a placeholder\n element).\n */\n domAtPos(pos) {\n return this.docView.domAtPos(pos);\n }\n /**\n Find the document position at the given DOM node. Can be useful\n for associating positions with DOM events. Will raise an error\n when `node` isn't part of the editor content.\n */\n posAtDOM(node, offset = 0) {\n return this.docView.posFromDOM(node, offset);\n }\n posAtCoords(coords, precise = true) {\n this.readMeasured();\n return posAtCoords(this, coords, precise);\n }\n /**\n Get the screen coordinates at the given document position.\n `side` determines whether the coordinates are based on the\n element before (-1) or after (1) the position (if no element is\n available on the given side, the method will transparently use\n another strategy to get reasonable coordinates).\n */\n coordsAtPos(pos, side = 1) {\n this.readMeasured();\n let rect = this.docView.coordsAt(pos, side);\n if (!rect || rect.left == rect.right)\n return rect;\n let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);\n let span = order[BidiSpan.find(order, pos - line.from, -1, side)];\n return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));\n }\n /**\n Return the rectangle around a given character. If `pos` does not\n point in front of a character that is in the viewport and\n rendered (i.e. not replaced, not a line break), this will return\n null. For space characters that are a line wrap point, this will\n return the position before the line break.\n */\n coordsForChar(pos) {\n this.readMeasured();\n return this.docView.coordsForChar(pos);\n }\n /**\n The default width of a character in the editor. May not\n accurately reflect the width of all characters (given variable\n width fonts or styling of invididual ranges).\n */\n get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }\n /**\n The default height of a line in the editor. May not be accurate\n for all lines.\n */\n get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }\n /**\n The text direction\n ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)\n CSS property) of the editor's content element.\n */\n get textDirection() { return this.viewState.defaultTextDirection; }\n /**\n Find the text direction of the block at the given position, as\n assigned by CSS. If\n [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)\n isn't enabled, or the given position is outside of the viewport,\n this will always return the same as\n [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that\n this may trigger a DOM layout.\n */\n textDirectionAt(pos) {\n let perLine = this.state.facet(perLineTextDirection);\n if (!perLine || pos < this.viewport.from || pos > this.viewport.to)\n return this.textDirection;\n this.readMeasured();\n return this.docView.textDirectionAt(pos);\n }\n /**\n Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)\n (as determined by the\n [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)\n CSS property of its content element).\n */\n get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }\n /**\n Returns the bidirectional text structure of the given line\n (which should be in the current document) as an array of span\n objects. The order of these spans matches the [text\n direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is\n left-to-right, the leftmost spans come first, otherwise the\n rightmost spans come first.\n */\n bidiSpans(line) {\n if (line.length > MaxBidiLine)\n return trivialOrder(line.length);\n let dir = this.textDirectionAt(line.from), isolates;\n for (let entry of this.bidiCache) {\n if (entry.from == line.from && entry.dir == dir &&\n (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line.from, line.to))))\n return entry.order;\n }\n if (!isolates)\n isolates = getIsolatedRanges(this, line.from, line.to);\n let order = computeOrder(line.text, dir, isolates);\n this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));\n return order;\n }\n /**\n Check whether the editor has focus.\n */\n get hasFocus() {\n var _a;\n // Safari return false for hasFocus when the context menu is open\n // or closing, which leads us to ignore selection changes from the\n // context menu because it looks like the editor isn't focused.\n // This kludges around that.\n return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&\n this.root.activeElement == this.contentDOM;\n }\n /**\n Put focus on the editor.\n */\n focus() {\n this.observer.ignore(() => {\n focusPreventScroll(this.contentDOM);\n this.docView.updateSelection();\n });\n }\n /**\n Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only\n necessary when moving the editor's existing DOM to a new window or shadow root.\n */\n setRoot(root) {\n if (this._root != root) {\n this._root = root;\n this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);\n this.mountStyles();\n }\n }\n /**\n Clean up this editor view, removing its element from the\n document, unregistering event handlers, and notifying\n plugins. The view instance can no longer be used after\n calling this.\n */\n destroy() {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.plugins = [];\n this.inputState.destroy();\n this.dom.remove();\n this.observer.destroy();\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n this.destroyed = true;\n }\n /**\n Returns an effect that can be\n [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to\n cause it to scroll the given position or range into view.\n */\n static scrollIntoView(pos, options = {}) {\n return scrollIntoView.of(new ScrollTarget(typeof pos == \"number\" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));\n }\n /**\n Returns an extension that can be used to add DOM event handlers.\n The value should be an object mapping event names to handler\n functions. For any given event, such functions are ordered by\n extension precedence, and the first handler to return true will\n be assumed to have handled that event, and no other handlers or\n built-in behavior will be activated for it. These are registered\n on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except\n for `scroll` handlers, which will be called any time the\n editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of\n its parent nodes is scrolled.\n */\n static domEventHandlers(handlers) {\n return ViewPlugin.define(() => ({}), { eventHandlers: handlers });\n }\n /**\n Create a theme extension. The first argument can be a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)\n style spec providing the styles for the theme. These will be\n prefixed with a generated class for the style.\n \n Because the selectors will be prefixed with a scope class, rule\n that directly match the editor's [wrapper\n element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be\n added—need to be explicitly differentiated by adding an `&` to\n the selector for that element—for example\n `&.cm-focused`.\n \n When `dark` is set to true, the theme will be marked as dark,\n which will cause the `&dark` rules from [base\n themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to\n `&light` when a light theme is active).\n */\n static theme(spec, options) {\n let prefix = StyleModule.newName();\n let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];\n if (options && options.dark)\n result.push(darkTheme.of(true));\n return result;\n }\n /**\n Create an extension that adds styles to the base theme. Like\n with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the\n place of the editor wrapper element when directly targeting\n that. You can also use `&dark` or `&light` instead to only\n target editors with a dark or light theme.\n */\n static baseTheme(spec) {\n return Prec.lowest(styleModule.of(buildTheme(\".\" + baseThemeID, spec, lightDarkIDs)));\n }\n /**\n Retrieve an editor view instance from the view's DOM\n representation.\n */\n static findFromDOM(dom) {\n var _a;\n let content = dom.querySelector(\".cm-content\");\n let cView = content && ContentView.get(content) || ContentView.get(dom);\n return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;\n }\n}\n/**\nFacet to add a [style\nmodule](https://github.com/marijnh/style-mod#documentation) to\nan editor view. The view will ensure that the module is\nmounted in its [document\nroot](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).\n*/\nEditorView.styleModule = styleModule;\n/**\nAn input handler can override the way changes to the editable\nDOM content are handled. Handlers are passed the document\npositions between which the change was found, and the new\ncontent. When one returns true, no further input handlers are\ncalled and the default behavior is prevented.\n\nThe `insert` argument can be used to get the default transaction\nthat would be applied for this input. This can be useful when\ndispatching the custom behavior as a separate transaction.\n*/\nEditorView.inputHandler = inputHandler;\n/**\nThis facet can be used to provide functions that create effects\nto be dispatched when the editor's focus state changes.\n*/\nEditorView.focusChangeEffect = focusChangeEffect;\n/**\nBy default, the editor assumes all its content has the same\n[text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`\nvalue to make it read the text direction of every (rendered)\nline separately.\n*/\nEditorView.perLineTextDirection = perLineTextDirection;\n/**\nAllows you to provide a function that should be called when the\nlibrary catches an exception from an extension (mostly from view\nplugins, but may be used by other extensions to route exceptions\nfrom user-code-provided callbacks). This is mostly useful for\ndebugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).\n*/\nEditorView.exceptionSink = exceptionSink;\n/**\nA facet that can be used to register a function to be called\nevery time the view updates.\n*/\nEditorView.updateListener = updateListener;\n/**\nFacet that controls whether the editor content DOM is editable.\nWhen its highest-precedence value is `false`, the element will\nnot have its `contenteditable` attribute set. (Note that this\ndoesn't affect API calls that change the editor content, even\nwhen those are bound to keys or buttons. See the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)\n*/\nEditorView.editable = editable;\n/**\nAllows you to influence the way mouse selection happens. The\nfunctions in this facet will be called for a `mousedown` event\non the editor, and can return an object that overrides the way a\nselection is computed from that mouse click or drag.\n*/\nEditorView.mouseSelectionStyle = mouseSelectionStyle;\n/**\nFacet used to configure whether a given selection drag event\nshould move or copy the selection. The given predicate will be\ncalled with the `mousedown` event, and can return `true` when\nthe drag should move the content.\n*/\nEditorView.dragMovesSelection = dragMovesSelection$1;\n/**\nFacet used to configure whether a given selecting click adds a\nnew range to the existing selection or replaces it entirely. The\ndefault behavior is to check `event.metaKey` on macOS, and\n`event.ctrlKey` elsewhere.\n*/\nEditorView.clickAddsSelectionRange = clickAddsSelectionRange;\n/**\nA facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)\nare shown in the view. Decorations can be provided in two\nways—directly, or via a function that takes an editor view.\n\nOnly decoration sets provided directly are allowed to influence\nthe editor's vertical layout structure. The ones provided as\nfunctions are called _after_ the new viewport has been computed,\nand thus **must not** introduce block widgets or replacing\ndecorations that cover line breaks.\n\nIf you want decorated ranges to behave like atomic units for\ncursor motion and deletion purposes, also provide the range set\ncontaining the decorations to\n[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).\n*/\nEditorView.decorations = decorations;\n/**\nUsed to provide ranges that should be treated as atoms as far as\ncursor motion is concerned. This causes methods like\n[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and\n[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the\ncommands built on top of them) to skip across such regions when\na selection endpoint would enter them. This does _not_ prevent\ndirect programmatic [selection\nupdates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such\nregions.\n*/\nEditorView.atomicRanges = atomicRanges;\n/**\nWhen range decorations add a `unicode-bidi: isolate` style, they\nshould also include a\n[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property\nin their decoration spec, and be exposed through this facet, so\nthat the editor can compute the proper text order. (Other values\nfor `unicode-bidi`, except of course `normal`, are not\nsupported.)\n*/\nEditorView.bidiIsolatedRanges = bidiIsolatedRanges;\n/**\nFacet that allows extensions to provide additional scroll\nmargins (space around the sides of the scrolling element that\nshould be considered invisible). This can be useful when the\nplugin introduces elements that cover part of that element (for\nexample a horizontally fixed gutter).\n*/\nEditorView.scrollMargins = scrollMargins;\n/**\nThis facet records whether a dark theme is active. The extension\nreturned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically\nincludes an instance of this when the `dark` option is set to\ntrue.\n*/\nEditorView.darkTheme = darkTheme;\n/**\nProvides a Content Security Policy nonce to use when creating\nthe style sheets for the editor. Holds the empty string when no\nnonce has been provided.\n*/\nEditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : \"\" });\n/**\nFacet that provides additional DOM attributes for the editor's\neditable DOM element.\n*/\nEditorView.contentAttributes = contentAttributes;\n/**\nFacet that provides DOM attributes for the editor's outer\nelement.\n*/\nEditorView.editorAttributes = editorAttributes;\n/**\nAn extension that enables line wrapping in the editor (by\nsetting CSS `white-space` to `pre-wrap` in the content).\n*/\nEditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ \"class\": \"cm-lineWrapping\" });\n/**\nState effect used to include screen reader announcements in a\ntransaction. These will be added to the DOM in a visually hidden\nelement with `aria-live=\"polite\"` set, and should be used to\ndescribe effects that are visually obvious but may not be\nnoticed by screen reader users (such as moving to the next\nsearch match).\n*/\nEditorView.announce = /*@__PURE__*/StateEffect.define();\n// Maximum line length for which we compute accurate bidi info\nconst MaxBidiLine = 4096;\nconst BadMeasure = {};\nclass CachedOrder {\n constructor(from, to, dir, isolates, fresh, order) {\n this.from = from;\n this.to = to;\n this.dir = dir;\n this.isolates = isolates;\n this.fresh = fresh;\n this.order = order;\n }\n static update(cache, changes) {\n if (changes.empty && !cache.some(c => c.fresh))\n return cache;\n let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;\n for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {\n let entry = cache[i];\n if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))\n result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));\n }\n return result;\n }\n}\nfunction attrsFromFacet(view, facet, base) {\n for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {\n let source = sources[i], value = typeof source == \"function\" ? source(view) : source;\n if (value)\n combineAttrs(value, base);\n }\n return base;\n}\n\nconst currentPlatform = browser.mac ? \"mac\" : browser.windows ? \"win\" : browser.linux ? \"linux\" : \"key\";\nfunction normalizeKeyName(name, platform) {\n const parts = name.split(/-(?!$)/);\n let result = parts[parts.length - 1];\n if (result == \"Space\")\n result = \" \";\n let alt, ctrl, shift, meta;\n for (let i = 0; i < parts.length - 1; ++i) {\n const mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod))\n meta = true;\n else if (/^a(lt)?$/i.test(mod))\n alt = true;\n else if (/^(c|ctrl|control)$/i.test(mod))\n ctrl = true;\n else if (/^s(hift)?$/i.test(mod))\n shift = true;\n else if (/^mod$/i.test(mod)) {\n if (platform == \"mac\")\n meta = true;\n else\n ctrl = true;\n }\n else\n throw new Error(\"Unrecognized modifier name: \" + mod);\n }\n if (alt)\n result = \"Alt-\" + result;\n if (ctrl)\n result = \"Ctrl-\" + result;\n if (meta)\n result = \"Meta-\" + result;\n if (shift)\n result = \"Shift-\" + result;\n return result;\n}\nfunction modifiers(name, event, shift) {\n if (event.altKey)\n name = \"Alt-\" + name;\n if (event.ctrlKey)\n name = \"Ctrl-\" + name;\n if (event.metaKey)\n name = \"Meta-\" + name;\n if (shift !== false && event.shiftKey)\n name = \"Shift-\" + name;\n return name;\n}\nconst handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({\n keydown(event, view) {\n return runHandlers(getKeymap(view.state), event, view, \"editor\");\n }\n}));\n/**\nFacet used for registering keymaps.\n\nYou can add multiple keymaps to an editor. Their priorities\ndetermine their precedence (the ones specified early or with high\npriority get checked first). When a handler has returned `true`\nfor a given key, no further handlers are called.\n*/\nconst keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });\nconst Keymaps = /*@__PURE__*/new WeakMap();\n// This is hidden behind an indirection, rather than directly computed\n// by the facet, to keep internal types out of the facet's type.\nfunction getKeymap(state) {\n let bindings = state.facet(keymap);\n let map = Keymaps.get(bindings);\n if (!map)\n Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));\n return map;\n}\n/**\nRun the key handlers registered for a given scope. The event\nobject should be a `\"keydown\"` event. Returns true if any of the\nhandlers handled it.\n*/\nfunction runScopeHandlers(view, event, scope) {\n return runHandlers(getKeymap(view.state), event, view, scope);\n}\nlet storedPrefix = null;\nconst PrefixTimeout = 4000;\nfunction buildKeymap(bindings, platform = currentPlatform) {\n let bound = Object.create(null);\n let isPrefix = Object.create(null);\n let checkPrefix = (name, is) => {\n let current = isPrefix[name];\n if (current == null)\n isPrefix[name] = is;\n else if (current != is)\n throw new Error(\"Key binding \" + name + \" is used both as a regular binding and as a multi-stroke prefix\");\n };\n let add = (scope, key, command, preventDefault, stopPropagation) => {\n var _a, _b;\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));\n for (let i = 1; i < parts.length; i++) {\n let prefix = parts.slice(0, i).join(\" \");\n checkPrefix(prefix, true);\n if (!scopeObj[prefix])\n scopeObj[prefix] = {\n preventDefault: true,\n stopPropagation: false,\n run: [(view) => {\n let ourObj = storedPrefix = { view, prefix, scope };\n setTimeout(() => { if (storedPrefix == ourObj)\n storedPrefix = null; }, PrefixTimeout);\n return true;\n }]\n };\n }\n let full = parts.join(\" \");\n checkPrefix(full, false);\n let binding = scopeObj[full] || (scopeObj[full] = {\n preventDefault: false,\n stopPropagation: false,\n run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []\n });\n if (command)\n binding.run.push(command);\n if (preventDefault)\n binding.preventDefault = true;\n if (stopPropagation)\n binding.stopPropagation = true;\n };\n for (let b of bindings) {\n let scopes = b.scope ? b.scope.split(\" \") : [\"editor\"];\n if (b.any)\n for (let scope of scopes) {\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n if (!scopeObj._any)\n scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };\n for (let key in scopeObj)\n scopeObj[key].run.push(b.any);\n }\n let name = b[platform] || b.key;\n if (!name)\n continue;\n for (let scope of scopes) {\n add(scope, name, b.run, b.preventDefault, b.stopPropagation);\n if (b.shift)\n add(scope, \"Shift-\" + name, b.shift, b.preventDefault, b.stopPropagation);\n }\n }\n return bound;\n}\nfunction runHandlers(map, event, view, scope) {\n let name = keyName(event);\n let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != \" \";\n let prefix = \"\", handled = false, prevented = false, stopPropagation = false;\n if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {\n prefix = storedPrefix.prefix + \" \";\n if (modifierCodes.indexOf(event.keyCode) < 0) {\n prevented = true;\n storedPrefix = null;\n }\n }\n let ran = new Set;\n let runFor = (binding) => {\n if (binding) {\n for (let cmd of binding.run)\n if (!ran.has(cmd)) {\n ran.add(cmd);\n if (cmd(view, event)) {\n if (binding.stopPropagation)\n stopPropagation = true;\n return true;\n }\n }\n if (binding.preventDefault) {\n if (binding.stopPropagation)\n stopPropagation = true;\n prevented = true;\n }\n }\n return false;\n };\n let scopeObj = map[scope], baseName, shiftName;\n if (scopeObj) {\n if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {\n handled = true;\n }\n else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&\n // Ctrl-Alt may be used for AltGr on Windows\n !(browser.windows && event.ctrlKey && event.altKey) &&\n (baseName = base[event.keyCode]) && baseName != name) {\n if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {\n handled = true;\n }\n else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&\n runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {\n handled = true;\n }\n }\n else if (isChar && event.shiftKey &&\n runFor(scopeObj[prefix + modifiers(name, event, true)])) {\n handled = true;\n }\n if (!handled && runFor(scopeObj._any))\n handled = true;\n }\n if (prevented)\n handled = true;\n if (handled && stopPropagation)\n event.stopPropagation();\n return handled;\n}\n\n/**\nImplementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates\na rectangle at a given set of coordinates.\n*/\nclass RectangleMarker {\n /**\n Create a marker with the given class and dimensions. If `width`\n is null, the DOM element will get no width style.\n */\n constructor(className, left, top, width, height) {\n this.className = className;\n this.left = left;\n this.top = top;\n this.width = width;\n this.height = height;\n }\n draw() {\n let elt = document.createElement(\"div\");\n elt.className = this.className;\n this.adjust(elt);\n return elt;\n }\n update(elt, prev) {\n if (prev.className != this.className)\n return false;\n this.adjust(elt);\n return true;\n }\n adjust(elt) {\n elt.style.left = this.left + \"px\";\n elt.style.top = this.top + \"px\";\n if (this.width != null)\n elt.style.width = this.width + \"px\";\n elt.style.height = this.height + \"px\";\n }\n eq(p) {\n return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&\n this.className == p.className;\n }\n /**\n Create a set of rectangles for the given selection range,\n assigning them theclass`className`. Will create a single\n rectangle for empty ranges, and a set of selection-style\n rectangles covering the range's content (in a bidi-aware\n way) for non-empty ones.\n */\n static forRange(view, className, range) {\n if (range.empty) {\n let pos = view.coordsAtPos(range.head, range.assoc || 1);\n if (!pos)\n return [];\n let base = getBase(view);\n return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];\n }\n else {\n return rectanglesForRange(view, className, range);\n }\n }\n}\nfunction getBase(view) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;\n return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };\n}\nfunction wrappedLine(view, pos, inside) {\n let range = EditorSelection.cursor(pos);\n return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),\n to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),\n type: BlockType.Text };\n}\nfunction rectanglesForRange(view, className, range) {\n if (range.to <= view.viewport.from || range.from >= view.viewport.to)\n return [];\n let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);\n let ltr = view.textDirection == Direction.LTR;\n let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);\n let lineElt = content.querySelector(\".cm-line\"), lineStyle = lineElt && window.getComputedStyle(lineElt);\n let leftSide = contentRect.left +\n (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);\n let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);\n let startBlock = blockAt(view, from), endBlock = blockAt(view, to);\n let visualStart = startBlock.type == BlockType.Text ? startBlock : null;\n let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;\n if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))\n visualStart = wrappedLine(view, from, visualStart);\n if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))\n visualEnd = wrappedLine(view, to, visualEnd);\n if (visualStart && visualEnd && visualStart.from == visualEnd.from) {\n return pieces(drawForLine(range.from, range.to, visualStart));\n }\n else {\n let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);\n let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);\n let between = [];\n if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||\n startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)\n between.push(piece(leftSide, top.bottom, rightSide, bottom.top));\n else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)\n top.bottom = bottom.top = (top.bottom + bottom.top) / 2;\n return pieces(top).concat(between).concat(pieces(bottom));\n }\n function piece(left, top, right, bottom) {\n return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);\n }\n function pieces({ top, bottom, horizontal }) {\n let pieces = [];\n for (let i = 0; i < horizontal.length; i += 2)\n pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));\n return pieces;\n }\n // Gets passed from/to in line-local positions\n function drawForLine(from, to, line) {\n let top = 1e9, bottom = -1e9, horizontal = [];\n function addSpan(from, fromOpen, to, toOpen, dir) {\n // Passing 2/-2 is a kludge to force the view to return\n // coordinates on the proper side of block widgets, since\n // normalizing the side there, though appropriate for most\n // coordsAtPos queries, would break selection drawing.\n let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));\n let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));\n if (!fromCoords || !toCoords)\n return;\n top = Math.min(fromCoords.top, toCoords.top, top);\n bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);\n if (dir == Direction.LTR)\n horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);\n else\n horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);\n }\n let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;\n // Split the range by visible range and document line\n for (let r of view.visibleRanges)\n if (r.to > start && r.from < end) {\n for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {\n let docLine = view.state.doc.lineAt(pos);\n for (let span of view.bidiSpans(docLine)) {\n let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;\n if (spanFrom >= endPos)\n break;\n if (spanTo > pos)\n addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);\n }\n pos = docLine.to + 1;\n if (pos >= endPos)\n break;\n }\n }\n if (horizontal.length == 0)\n addSpan(start, from == null, end, to == null, view.textDirection);\n return { top, bottom, horizontal };\n }\n function drawForWidget(block, top) {\n let y = contentRect.top + (top ? block.top : block.bottom);\n return { top: y, bottom: y, horizontal: [] };\n }\n}\nfunction sameMarker(a, b) {\n return a.constructor == b.constructor && a.eq(b);\n}\nclass LayerView {\n constructor(view, layer) {\n this.view = view;\n this.layer = layer;\n this.drawn = [];\n this.scaleX = 1;\n this.scaleY = 1;\n this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };\n this.dom = view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.dom.classList.add(\"cm-layer\");\n if (layer.above)\n this.dom.classList.add(\"cm-layer-above\");\n if (layer.class)\n this.dom.classList.add(layer.class);\n this.scale();\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.setOrder(view.state);\n view.requestMeasure(this.measureReq);\n if (layer.mount)\n layer.mount(this.dom, view);\n }\n update(update) {\n if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))\n this.setOrder(update.state);\n if (this.layer.update(update, this.dom) || update.geometryChanged) {\n this.scale();\n update.view.requestMeasure(this.measureReq);\n }\n }\n setOrder(state) {\n let pos = 0, order = state.facet(layerOrder);\n while (pos < order.length && order[pos] != this.layer)\n pos++;\n this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);\n }\n measure() {\n return this.layer.markers(this.view);\n }\n scale() {\n let { scaleX, scaleY } = this.view;\n if (scaleX != this.scaleX || scaleY != this.scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;\n }\n }\n draw(markers) {\n if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {\n let old = this.dom.firstChild, oldI = 0;\n for (let marker of markers) {\n if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&\n marker.update(old, this.drawn[oldI])) {\n old = old.nextSibling;\n oldI++;\n }\n else {\n this.dom.insertBefore(marker.draw(), old);\n }\n }\n while (old) {\n let next = old.nextSibling;\n old.remove();\n old = next;\n }\n this.drawn = markers;\n }\n }\n destroy() {\n if (this.layer.destroy)\n this.layer.destroy(this.dom, this.view);\n this.dom.remove();\n }\n}\nconst layerOrder = /*@__PURE__*/Facet.define();\n/**\nDefine a layer.\n*/\nfunction layer(config) {\n return [\n ViewPlugin.define(v => new LayerView(v, config)),\n layerOrder.of(config)\n ];\n}\n\nconst CanHidePrimary = !browser.ios; // FIXME test IE\nconst selectionConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n cursorBlinkRate: 1200,\n drawRangeCursor: true\n }, {\n cursorBlinkRate: (a, b) => Math.min(a, b),\n drawRangeCursor: (a, b) => a || b\n });\n }\n});\n/**\nReturns an extension that hides the browser's native selection and\ncursor, replacing the selection with a background behind the text\n(with the `cm-selectionBackground` class), and the\ncursors with elements overlaid over the code (using\n`cm-cursor-primary` and `cm-cursor-secondary`).\n\nThis allows the editor to display secondary selection ranges, and\ntends to produce a type of selection more in line with that users\nexpect in a text editor (the native selection styling will often\nleave gaps between lines and won't fill the horizontal space after\na line when the selection continues past it).\n\nIt does have a performance cost, in that it requires an extra DOM\nlayout cycle for many updates (the selection is drawn based on DOM\nlayout information that's only available after laying out the\ncontent).\n*/\nfunction drawSelection(config = {}) {\n return [\n selectionConfig.of(config),\n cursorLayer,\n selectionLayer,\n hideNativeSelection,\n nativeSelectionHidden.of(true)\n ];\n}\nfunction configChanged(update) {\n return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);\n}\nconst cursorLayer = /*@__PURE__*/layer({\n above: true,\n markers(view) {\n let { state } = view, conf = state.facet(selectionConfig);\n let cursors = [];\n for (let r of state.selection.ranges) {\n let prim = r == state.selection.main;\n if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {\n let className = prim ? \"cm-cursor cm-cursor-primary\" : \"cm-cursor cm-cursor-secondary\";\n let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);\n for (let piece of RectangleMarker.forRange(view, className, cursor))\n cursors.push(piece);\n }\n }\n return cursors;\n },\n update(update, dom) {\n if (update.transactions.some(tr => tr.selection))\n dom.style.animationName = dom.style.animationName == \"cm-blink\" ? \"cm-blink2\" : \"cm-blink\";\n let confChange = configChanged(update);\n if (confChange)\n setBlinkRate(update.state, dom);\n return update.docChanged || update.selectionSet || confChange;\n },\n mount(dom, view) {\n setBlinkRate(view.state, dom);\n },\n class: \"cm-cursorLayer\"\n});\nfunction setBlinkRate(state, dom) {\n dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + \"ms\";\n}\nconst selectionLayer = /*@__PURE__*/layer({\n above: false,\n markers(view) {\n return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, \"cm-selectionBackground\", r))\n .reduce((a, b) => a.concat(b));\n },\n update(update, dom) {\n return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);\n },\n class: \"cm-selectionLayer\"\n});\nconst themeSpec = {\n \".cm-line\": {\n \"& ::selection\": { backgroundColor: \"transparent !important\" },\n \"&::selection\": { backgroundColor: \"transparent !important\" }\n }\n};\nif (CanHidePrimary)\n themeSpec[\".cm-line\"].caretColor = \"transparent !important\";\nconst hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));\n\nconst setDropCursorPos = /*@__PURE__*/StateEffect.define({\n map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }\n});\nconst dropCursorPos = /*@__PURE__*/StateField.define({\n create() { return null; },\n update(pos, tr) {\n if (pos != null)\n pos = tr.changes.mapPos(pos);\n return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);\n }\n});\nconst drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.cursor = null;\n this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };\n }\n update(update) {\n var _a;\n let cursorPos = update.state.field(dropCursorPos);\n if (cursorPos == null) {\n if (this.cursor != null) {\n (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();\n this.cursor = null;\n }\n }\n else {\n if (!this.cursor) {\n this.cursor = this.view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.cursor.className = \"cm-dropCursor\";\n }\n if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)\n this.view.requestMeasure(this.measureReq);\n }\n }\n readPos() {\n let { view } = this;\n let pos = view.state.field(dropCursorPos);\n let rect = pos != null && view.coordsAtPos(pos);\n if (!rect)\n return null;\n let outer = view.scrollDOM.getBoundingClientRect();\n return {\n left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,\n top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,\n height: rect.bottom - rect.top\n };\n }\n drawCursor(pos) {\n if (this.cursor) {\n let { scaleX, scaleY } = this.view;\n if (pos) {\n this.cursor.style.left = pos.left / scaleX + \"px\";\n this.cursor.style.top = pos.top / scaleY + \"px\";\n this.cursor.style.height = pos.height / scaleY + \"px\";\n }\n else {\n this.cursor.style.left = \"-100000px\";\n }\n }\n }\n destroy() {\n if (this.cursor)\n this.cursor.remove();\n }\n setDropPos(pos) {\n if (this.view.state.field(dropCursorPos) != pos)\n this.view.dispatch({ effects: setDropCursorPos.of(pos) });\n }\n}, {\n eventHandlers: {\n dragover(event) {\n this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));\n },\n dragleave(event) {\n if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))\n this.setDropPos(null);\n },\n dragend() {\n this.setDropPos(null);\n },\n drop() {\n this.setDropPos(null);\n }\n }\n});\n/**\nDraws a cursor at the current drop position when something is\ndragged over the editor.\n*/\nfunction dropCursor() {\n return [dropCursorPos, drawDropCursor];\n}\n\nfunction iterMatches(doc, re, from, to, f) {\n re.lastIndex = 0;\n for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {\n if (!cursor.lineBreak)\n while (m = re.exec(cursor.value))\n f(pos + m.index, m);\n }\n}\nfunction matchRanges(view, maxLength) {\n let visible = view.visibleRanges;\n if (visible.length == 1 && visible[0].from == view.viewport.from &&\n visible[0].to == view.viewport.to)\n return visible;\n let result = [];\n for (let { from, to } of visible) {\n from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);\n to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);\n if (result.length && result[result.length - 1].to >= from)\n result[result.length - 1].to = to;\n else\n result.push({ from, to });\n }\n return result;\n}\n/**\nHelper class used to make it easier to maintain decorations on\nvisible code that matches a given regular expression. To be used\nin a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object\nrepresent a matching configuration.\n*/\nclass MatchDecorator {\n /**\n Create a decorator.\n */\n constructor(config) {\n const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;\n if (!regexp.global)\n throw new RangeError(\"The regular expression given to MatchDecorator should have its 'g' flag set\");\n this.regexp = regexp;\n if (decorate) {\n this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);\n }\n else if (typeof decoration == \"function\") {\n this.addMatch = (match, view, from, add) => {\n let deco = decoration(match, view, from);\n if (deco)\n add(from, from + match[0].length, deco);\n };\n }\n else if (decoration) {\n this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);\n }\n else {\n throw new RangeError(\"Either 'decorate' or 'decoration' should be provided to MatchDecorator\");\n }\n this.boundary = boundary;\n this.maxLength = maxLength;\n }\n /**\n Compute the full set of decorations for matches in the given\n view's viewport. You'll want to call this when initializing your\n plugin.\n */\n createDeco(view) {\n let build = new RangeSetBuilder(), add = build.add.bind(build);\n for (let { from, to } of matchRanges(view, this.maxLength))\n iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));\n return build.finish();\n }\n /**\n Update a set of decorations for a view update. `deco` _must_ be\n the set of decorations produced by _this_ `MatchDecorator` for\n the view state before the update.\n */\n updateDeco(update, deco) {\n let changeFrom = 1e9, changeTo = -1;\n if (update.docChanged)\n update.changes.iterChanges((_f, _t, from, to) => {\n if (to > update.view.viewport.from && from < update.view.viewport.to) {\n changeFrom = Math.min(from, changeFrom);\n changeTo = Math.max(to, changeTo);\n }\n });\n if (update.viewportChanged || changeTo - changeFrom > 1000)\n return this.createDeco(update.view);\n if (changeTo > -1)\n return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);\n return deco;\n }\n updateRange(view, deco, updateFrom, updateTo) {\n for (let r of view.visibleRanges) {\n let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);\n if (to > from) {\n let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;\n let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);\n if (this.boundary) {\n for (; from > fromLine.from; from--)\n if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {\n start = from;\n break;\n }\n for (; to < toLine.to; to++)\n if (this.boundary.test(toLine.text[to - toLine.from])) {\n end = to;\n break;\n }\n }\n let ranges = [], m;\n let add = (from, to, deco) => ranges.push(deco.range(from, to));\n if (fromLine == toLine) {\n this.regexp.lastIndex = start - fromLine.from;\n while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)\n this.addMatch(m, view, m.index + fromLine.from, add);\n }\n else {\n iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));\n }\n deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });\n }\n }\n return deco;\n }\n}\n\nconst UnicodeRegexpSupport = /x/.unicode != null ? \"gu\" : \"g\";\nconst Specials = /*@__PURE__*/new RegExp(\"[\\u0000-\\u0008\\u000a-\\u001f\\u007f-\\u009f\\u00ad\\u061c\\u200b\\u200e\\u200f\\u2028\\u2029\\u202d\\u202e\\u2066\\u2067\\u2069\\ufeff\\ufff9-\\ufffc]\", UnicodeRegexpSupport);\nconst Names = {\n 0: \"null\",\n 7: \"bell\",\n 8: \"backspace\",\n 10: \"newline\",\n 11: \"vertical tab\",\n 13: \"carriage return\",\n 27: \"escape\",\n 8203: \"zero width space\",\n 8204: \"zero width non-joiner\",\n 8205: \"zero width joiner\",\n 8206: \"left-to-right mark\",\n 8207: \"right-to-left mark\",\n 8232: \"line separator\",\n 8237: \"left-to-right override\",\n 8238: \"right-to-left override\",\n 8294: \"left-to-right isolate\",\n 8295: \"right-to-left isolate\",\n 8297: \"pop directional isolate\",\n 8233: \"paragraph separator\",\n 65279: \"zero width no-break space\",\n 65532: \"object replacement\"\n};\nlet _supportsTabSize = null;\nfunction supportsTabSize() {\n var _a;\n if (_supportsTabSize == null && typeof document != \"undefined\" && document.body) {\n let styles = document.body.style;\n _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;\n }\n return _supportsTabSize || false;\n}\nconst specialCharConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let config = combineConfig(configs, {\n render: null,\n specialChars: Specials,\n addSpecialChars: null\n });\n if (config.replaceTabs = !supportsTabSize())\n config.specialChars = new RegExp(\"\\t|\" + config.specialChars.source, UnicodeRegexpSupport);\n if (config.addSpecialChars)\n config.specialChars = new RegExp(config.specialChars.source + \"|\" + config.addSpecialChars.source, UnicodeRegexpSupport);\n return config;\n }\n});\n/**\nReturns an extension that installs highlighting of special\ncharacters.\n*/\nfunction highlightSpecialChars(\n/**\nConfiguration options.\n*/\nconfig = {}) {\n return [specialCharConfig.of(config), specialCharPlugin()];\n}\nlet _plugin = null;\nfunction specialCharPlugin() {\n return _plugin || (_plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = Decoration.none;\n this.decorationCache = Object.create(null);\n this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));\n this.decorations = this.decorator.createDeco(view);\n }\n makeDecorator(conf) {\n return new MatchDecorator({\n regexp: conf.specialChars,\n decoration: (m, view, pos) => {\n let { doc } = view.state;\n let code = codePointAt(m[0], 0);\n if (code == 9) {\n let line = doc.lineAt(pos);\n let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);\n return Decoration.replace({\n widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)\n });\n }\n return this.decorationCache[code] ||\n (this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));\n },\n boundary: conf.replaceTabs ? undefined : /[^]/\n });\n }\n update(update) {\n let conf = update.state.facet(specialCharConfig);\n if (update.startState.facet(specialCharConfig) != conf) {\n this.decorator = this.makeDecorator(conf);\n this.decorations = this.decorator.createDeco(update.view);\n }\n else {\n this.decorations = this.decorator.updateDeco(update, this.decorations);\n }\n }\n }, {\n decorations: v => v.decorations\n }));\n}\nconst DefaultPlaceholder = \"\\u2022\";\n// Assigns placeholder characters from the Control Pictures block to\n// ASCII control characters\nfunction placeholder$1(code) {\n if (code >= 32)\n return DefaultPlaceholder;\n if (code == 10)\n return \"\\u2424\";\n return String.fromCharCode(9216 + code);\n}\nclass SpecialCharWidget extends WidgetType {\n constructor(options, code) {\n super();\n this.options = options;\n this.code = code;\n }\n eq(other) { return other.code == this.code; }\n toDOM(view) {\n let ph = placeholder$1(this.code);\n let desc = view.state.phrase(\"Control character\") + \" \" + (Names[this.code] || \"0x\" + this.code.toString(16));\n let custom = this.options.render && this.options.render(this.code, desc, ph);\n if (custom)\n return custom;\n let span = document.createElement(\"span\");\n span.textContent = ph;\n span.title = desc;\n span.setAttribute(\"aria-label\", desc);\n span.className = \"cm-specialChar\";\n return span;\n }\n ignoreEvent() { return false; }\n}\nclass TabWidget extends WidgetType {\n constructor(width) {\n super();\n this.width = width;\n }\n eq(other) { return other.width == this.width; }\n toDOM() {\n let span = document.createElement(\"span\");\n span.textContent = \"\\t\";\n span.className = \"cm-tab\";\n span.style.width = this.width + \"px\";\n return span;\n }\n ignoreEvent() { return false; }\n}\n\nconst plugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor() {\n this.height = 1000;\n this.attrs = { style: \"padding-bottom: 1000px\" };\n }\n update(update) {\n let { view } = update;\n let height = view.viewState.editorHeight * view.scaleY -\n view.defaultLineHeight - view.documentPadding.top - 0.5;\n if (height >= 0 && height != this.height) {\n this.height = height;\n this.attrs = { style: `padding-bottom: ${height}px` };\n }\n }\n});\n/**\nReturns an extension that makes sure the content has a bottom\nmargin equivalent to the height of the editor, minus one line\nheight, so that every line in the document can be scrolled to the\ntop of the editor.\n\nThis is only meaningful when the editor is scrollable, and should\nnot be enabled in editors that take the size of their content.\n*/\nfunction scrollPastEnd() {\n return [plugin, contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.attrs) || null; })];\n}\n\n/**\nMark lines that have a cursor on them with the `\"cm-activeLine\"`\nDOM class.\n*/\nfunction highlightActiveLine() {\n return activeLineHighlighter;\n}\nconst lineDeco = /*@__PURE__*/Decoration.line({ class: \"cm-activeLine\" });\nconst activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.docChanged || update.selectionSet)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let lastLineStart = -1, deco = [];\n for (let r of view.state.selection.ranges) {\n let line = view.lineBlockAt(r.head);\n if (line.from > lastLineStart) {\n deco.push(lineDeco.range(line.from));\n lastLineStart = line.from;\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\n\nclass Placeholder extends WidgetType {\n constructor(content) {\n super();\n this.content = content;\n }\n toDOM() {\n let wrap = document.createElement(\"span\");\n wrap.className = \"cm-placeholder\";\n wrap.style.pointerEvents = \"none\";\n wrap.appendChild(typeof this.content == \"string\" ? document.createTextNode(this.content) : this.content);\n if (typeof this.content == \"string\")\n wrap.setAttribute(\"aria-label\", \"placeholder \" + this.content);\n else\n wrap.setAttribute(\"aria-hidden\", \"true\");\n return wrap;\n }\n coordsAt(dom) {\n let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];\n if (!rects.length)\n return null;\n let style = window.getComputedStyle(dom.parentNode);\n let rect = flattenRect(rects[0], style.direction != \"rtl\");\n let lineHeight = parseInt(style.lineHeight);\n if (rect.bottom - rect.top > lineHeight * 1.5)\n return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };\n return rect;\n }\n ignoreEvent() { return false; }\n}\n/**\nExtension that enables a placeholder—a piece of example content\nto show when the editor is empty.\n*/\nfunction placeholder(content) {\n return ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.placeholder = content\n ? Decoration.set([Decoration.widget({ widget: new Placeholder(content), side: 1 }).range(0)])\n : Decoration.none;\n }\n get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }\n }, { decorations: v => v.decorations });\n}\n\n// Don't compute precise column positions for line offsets above this\n// (since it could get expensive). Assume offset==column for them.\nconst MaxOff = 2000;\nfunction rectangleFor(state, a, b) {\n let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);\n let ranges = [];\n if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {\n let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n if (line.length <= endOff)\n ranges.push(EditorSelection.range(line.from + startOff, line.to + endOff));\n }\n }\n else {\n let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n let start = findColumn(line.text, startCol, state.tabSize, true);\n if (start < 0) {\n ranges.push(EditorSelection.cursor(line.to));\n }\n else {\n let end = findColumn(line.text, endCol, state.tabSize);\n ranges.push(EditorSelection.range(line.from + start, line.from + end));\n }\n }\n }\n return ranges;\n}\nfunction absoluteColumn(view, x) {\n let ref = view.coordsAtPos(view.viewport.from);\n return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;\n}\nfunction getPos(view, event) {\n let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n let line = view.state.doc.lineAt(offset), off = offset - line.from;\n let col = off > MaxOff ? -1\n : off == line.length ? absoluteColumn(view, event.clientX)\n : countColumn(line.text, view.state.tabSize, offset - line.from);\n return { line: line.number, col, off };\n}\nfunction rectangleSelectionStyle(view, event) {\n let start = getPos(view, event), startSel = view.state.selection;\n if (!start)\n return null;\n return {\n update(update) {\n if (update.docChanged) {\n let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);\n let newLine = update.state.doc.lineAt(newStart);\n start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };\n startSel = startSel.map(update.changes);\n }\n },\n get(event, _extend, multiple) {\n let cur = getPos(view, event);\n if (!cur)\n return startSel;\n let ranges = rectangleFor(view.state, start, cur);\n if (!ranges.length)\n return startSel;\n if (multiple)\n return EditorSelection.create(ranges.concat(startSel.ranges));\n else\n return EditorSelection.create(ranges);\n }\n };\n}\n/**\nCreate an extension that enables rectangular selections. By\ndefault, it will react to left mouse drag with the Alt key held\ndown. When such a selection occurs, the text within the rectangle\nthat was dragged over will be selected, as one selection\n[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.\n*/\nfunction rectangularSelection(options) {\n let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);\n return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);\n}\nconst keys = {\n Alt: [18, e => !!e.altKey],\n Control: [17, e => !!e.ctrlKey],\n Shift: [16, e => !!e.shiftKey],\n Meta: [91, e => !!e.metaKey]\n};\nconst showCrosshair = { style: \"cursor: crosshair\" };\n/**\nReturns an extension that turns the pointer cursor into a\ncrosshair when a given modifier key, defaulting to Alt, is held\ndown. Can serve as a visual hint that rectangular selection is\ngoing to happen when paired with\n[`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).\n*/\nfunction crosshairCursor(options = {}) {\n let [code, getter] = keys[options.key || \"Alt\"];\n let plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.isDown = false;\n }\n set(isDown) {\n if (this.isDown != isDown) {\n this.isDown = isDown;\n this.view.update([]);\n }\n }\n }, {\n eventHandlers: {\n keydown(e) {\n this.set(e.keyCode == code || getter(e));\n },\n keyup(e) {\n if (e.keyCode == code || !getter(e))\n this.set(false);\n },\n mousemove(e) {\n this.set(getter(e));\n }\n }\n });\n return [\n plugin,\n EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })\n ];\n}\n\nconst Outside = \"-10000px\";\nclass TooltipViewManager {\n constructor(view, facet, createTooltipView) {\n this.facet = facet;\n this.createTooltipView = createTooltipView;\n this.input = view.state.facet(facet);\n this.tooltips = this.input.filter(t => t);\n this.tooltipViews = this.tooltips.map(createTooltipView);\n }\n update(update) {\n var _a;\n let input = update.state.facet(this.facet);\n let tooltips = input.filter(x => x);\n if (input === this.input) {\n for (let t of this.tooltipViews)\n if (t.update)\n t.update(update);\n return false;\n }\n let tooltipViews = [];\n for (let i = 0; i < tooltips.length; i++) {\n let tip = tooltips[i], known = -1;\n if (!tip)\n continue;\n for (let i = 0; i < this.tooltips.length; i++) {\n let other = this.tooltips[i];\n if (other && other.create == tip.create)\n known = i;\n }\n if (known < 0) {\n tooltipViews[i] = this.createTooltipView(tip);\n }\n else {\n let tooltipView = tooltipViews[i] = this.tooltipViews[known];\n if (tooltipView.update)\n tooltipView.update(update);\n }\n }\n for (let t of this.tooltipViews)\n if (tooltipViews.indexOf(t) < 0) {\n t.dom.remove();\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n this.input = input;\n this.tooltips = tooltips;\n this.tooltipViews = tooltipViews;\n return true;\n }\n}\n/**\nCreates an extension that configures tooltip behavior.\n*/\nfunction tooltips(config = {}) {\n return tooltipConfig.of(config);\n}\nfunction windowSpace(view) {\n let { win } = view;\n return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };\n}\nconst tooltipConfig = /*@__PURE__*/Facet.define({\n combine: values => {\n var _a, _b, _c;\n return ({\n position: browser.ios ? \"absolute\" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || \"fixed\",\n parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,\n tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,\n });\n }\n});\nconst knownHeight = /*@__PURE__*/new WeakMap();\nconst tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.inView = true;\n this.madeAbsolute = false;\n this.lastTransaction = 0;\n this.measureTimeout = -1;\n let config = view.state.facet(tooltipConfig);\n this.position = config.position;\n this.parent = config.parent;\n this.classes = view.themeClasses;\n this.createContainer();\n this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };\n this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));\n this.intersectionObserver = typeof IntersectionObserver == \"function\" ? new IntersectionObserver(entries => {\n if (Date.now() > this.lastTransaction - 50 &&\n entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)\n this.measureSoon();\n }, { threshold: [1] }) : null;\n this.observeIntersection();\n view.win.addEventListener(\"resize\", this.measureSoon = this.measureSoon.bind(this));\n this.maybeMeasure();\n }\n createContainer() {\n if (this.parent) {\n this.container = document.createElement(\"div\");\n this.container.style.position = \"relative\";\n this.container.className = this.view.themeClasses;\n this.parent.appendChild(this.container);\n }\n else {\n this.container = this.view.dom;\n }\n }\n observeIntersection() {\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n for (let tooltip of this.manager.tooltipViews)\n this.intersectionObserver.observe(tooltip.dom);\n }\n }\n measureSoon() {\n if (this.measureTimeout < 0)\n this.measureTimeout = setTimeout(() => {\n this.measureTimeout = -1;\n this.maybeMeasure();\n }, 50);\n }\n update(update) {\n if (update.transactions.length)\n this.lastTransaction = Date.now();\n let updated = this.manager.update(update);\n if (updated)\n this.observeIntersection();\n let shouldMeasure = updated || update.geometryChanged;\n let newConfig = update.state.facet(tooltipConfig);\n if (newConfig.position != this.position && !this.madeAbsolute) {\n this.position = newConfig.position;\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = this.position;\n shouldMeasure = true;\n }\n if (newConfig.parent != this.parent) {\n if (this.parent)\n this.container.remove();\n this.parent = newConfig.parent;\n this.createContainer();\n for (let t of this.manager.tooltipViews)\n this.container.appendChild(t.dom);\n shouldMeasure = true;\n }\n else if (this.parent && this.view.themeClasses != this.classes) {\n this.classes = this.container.className = this.view.themeClasses;\n }\n if (shouldMeasure)\n this.maybeMeasure();\n }\n createTooltip(tooltip) {\n let tooltipView = tooltip.create(this.view);\n tooltipView.dom.classList.add(\"cm-tooltip\");\n if (tooltip.arrow && !tooltipView.dom.querySelector(\".cm-tooltip > .cm-tooltip-arrow\")) {\n let arrow = document.createElement(\"div\");\n arrow.className = \"cm-tooltip-arrow\";\n tooltipView.dom.appendChild(arrow);\n }\n tooltipView.dom.style.position = this.position;\n tooltipView.dom.style.top = Outside;\n this.container.appendChild(tooltipView.dom);\n if (tooltipView.mount)\n tooltipView.mount(this.view);\n return tooltipView;\n }\n destroy() {\n var _a, _b;\n this.view.win.removeEventListener(\"resize\", this.measureSoon);\n for (let tooltipView of this.manager.tooltipViews) {\n tooltipView.dom.remove();\n (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);\n }\n (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n clearTimeout(this.measureTimeout);\n }\n readMeasure() {\n let editor = this.view.dom.getBoundingClientRect();\n let scaleX = 1, scaleY = 1, makeAbsolute = false;\n if (this.position == \"fixed\") {\n let views = this.manager.tooltipViews;\n // When the dialog's offset parent isn't the body, we are\n // probably in a transformed container, and should use absolute\n // positioning instead, since fixed positioning inside a\n // transform works in a very broken way.\n makeAbsolute = views.length > 0 && views[0].dom.offsetParent != this.container.ownerDocument.body;\n }\n if (makeAbsolute || this.position == \"absolute\") {\n if (this.parent) {\n let rect = this.parent.getBoundingClientRect();\n if (rect.width && rect.height) {\n scaleX = rect.width / this.parent.offsetWidth;\n scaleY = rect.height / this.parent.offsetHeight;\n }\n }\n else {\n ({ scaleX, scaleY } = this.view.viewState);\n }\n }\n return {\n editor,\n parent: this.parent ? this.container.getBoundingClientRect() : editor,\n pos: this.manager.tooltips.map((t, i) => {\n let tv = this.manager.tooltipViews[i];\n return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);\n }),\n size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),\n space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),\n scaleX, scaleY, makeAbsolute\n };\n }\n writeMeasure(measured) {\n var _a;\n if (measured.makeAbsolute) {\n this.madeAbsolute = true;\n this.position = \"absolute\";\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = \"absolute\";\n }\n let { editor, space, scaleX, scaleY } = measured;\n let others = [];\n for (let i = 0; i < this.manager.tooltips.length; i++) {\n let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;\n let pos = measured.pos[i], size = measured.size[i];\n // Hide tooltips that are outside of the editor.\n if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||\n pos.top >= Math.min(editor.bottom, space.bottom) ||\n pos.right < Math.max(editor.left, space.left) - .1 ||\n pos.left > Math.min(editor.right, space.right) + .1) {\n dom.style.top = Outside;\n continue;\n }\n let arrow = tooltip.arrow ? tView.dom.querySelector(\".cm-tooltip-arrow\") : null;\n let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;\n let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;\n let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;\n let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)\n : ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)\n : Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);\n let above = !!tooltip.above;\n if (!tooltip.strictSide && (above\n ? pos.top - (size.bottom - size.top) - offset.y < space.top\n : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&\n above == (space.bottom - pos.bottom > pos.top - space.top))\n above = !above;\n let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;\n if (spaceVert < height && tView.resize !== false) {\n if (spaceVert < this.view.defaultLineHeight) {\n dom.style.top = Outside;\n continue;\n }\n knownHeight.set(tView, height);\n dom.style.height = (height = spaceVert) / scaleY + \"px\";\n }\n else if (dom.style.height) {\n dom.style.height = \"\";\n }\n let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;\n let right = left + width;\n if (tView.overlap !== true)\n for (let r of others)\n if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)\n top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;\n if (this.position == \"absolute\") {\n dom.style.top = (top - measured.parent.top) / scaleY + \"px\";\n dom.style.left = (left - measured.parent.left) / scaleX + \"px\";\n }\n else {\n dom.style.top = top / scaleY + \"px\";\n dom.style.left = left / scaleX + \"px\";\n }\n if (arrow) {\n let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);\n arrow.style.left = arrowLeft / scaleX + \"px\";\n }\n if (tView.overlap !== true)\n others.push({ left, top, right, bottom: top + height });\n dom.classList.toggle(\"cm-tooltip-above\", above);\n dom.classList.toggle(\"cm-tooltip-below\", !above);\n if (tView.positioned)\n tView.positioned(measured.space);\n }\n }\n maybeMeasure() {\n if (this.manager.tooltips.length) {\n if (this.view.inView)\n this.view.requestMeasure(this.measureReq);\n if (this.inView != this.view.inView) {\n this.inView = this.view.inView;\n if (!this.inView)\n for (let tv of this.manager.tooltipViews)\n tv.dom.style.top = Outside;\n }\n }\n }\n}, {\n eventHandlers: {\n scroll() { this.maybeMeasure(); }\n }\n});\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-tooltip\": {\n zIndex: 100,\n boxSizing: \"border-box\"\n },\n \"&light .cm-tooltip\": {\n border: \"1px solid #bbb\",\n backgroundColor: \"#f5f5f5\"\n },\n \"&light .cm-tooltip-section:not(:first-child)\": {\n borderTop: \"1px solid #bbb\",\n },\n \"&dark .cm-tooltip\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tooltip-arrow\": {\n height: `${7 /* Arrow.Size */}px`,\n width: `${7 /* Arrow.Size */ * 2}px`,\n position: \"absolute\",\n zIndex: -1,\n overflow: \"hidden\",\n \"&:before, &:after\": {\n content: \"''\",\n position: \"absolute\",\n width: 0,\n height: 0,\n borderLeft: `${7 /* Arrow.Size */}px solid transparent`,\n borderRight: `${7 /* Arrow.Size */}px solid transparent`,\n },\n \".cm-tooltip-above &\": {\n bottom: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderTop: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n bottom: \"1px\"\n }\n },\n \".cm-tooltip-below &\": {\n top: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n top: \"1px\"\n }\n },\n },\n \"&dark .cm-tooltip .cm-tooltip-arrow\": {\n \"&:before\": {\n borderTopColor: \"#333338\",\n borderBottomColor: \"#333338\"\n },\n \"&:after\": {\n borderTopColor: \"transparent\",\n borderBottomColor: \"transparent\"\n }\n }\n});\nconst noOffset = { x: 0, y: 0 };\n/**\nFacet to which an extension can add a value to show a tooltip.\n*/\nconst showTooltip = /*@__PURE__*/Facet.define({\n enables: [tooltipPlugin, baseTheme]\n});\nconst showHoverTooltip = /*@__PURE__*/Facet.define();\nclass HoverTooltipHost {\n // Needs to be static so that host tooltip instances always match\n static create(view) {\n return new HoverTooltipHost(view);\n }\n constructor(view) {\n this.view = view;\n this.mounted = false;\n this.dom = document.createElement(\"div\");\n this.dom.classList.add(\"cm-tooltip-hover\");\n this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));\n }\n createHostedView(tooltip) {\n let hostedView = tooltip.create(this.view);\n hostedView.dom.classList.add(\"cm-tooltip-section\");\n this.dom.appendChild(hostedView.dom);\n if (this.mounted && hostedView.mount)\n hostedView.mount(this.view);\n return hostedView;\n }\n mount(view) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.mount)\n hostedView.mount(view);\n }\n this.mounted = true;\n }\n positioned(space) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.positioned)\n hostedView.positioned(space);\n }\n }\n update(update) {\n this.manager.update(update);\n }\n destroy() {\n var _a;\n for (let t of this.manager.tooltipViews)\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n}\nconst showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {\n let tooltips = state.facet(showHoverTooltip).filter(t => t);\n if (tooltips.length === 0)\n return null;\n return {\n pos: Math.min(...tooltips.map(t => t.pos)),\n end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),\n create: HoverTooltipHost.create,\n above: tooltips[0].above,\n arrow: tooltips.some(t => t.arrow),\n };\n});\nclass HoverPlugin {\n constructor(view, source, field, setHover, hoverTime) {\n this.view = view;\n this.source = source;\n this.field = field;\n this.setHover = setHover;\n this.hoverTime = hoverTime;\n this.hoverTimeout = -1;\n this.restartTimeout = -1;\n this.pending = null;\n this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };\n this.checkHover = this.checkHover.bind(this);\n view.dom.addEventListener(\"mouseleave\", this.mouseleave = this.mouseleave.bind(this));\n view.dom.addEventListener(\"mousemove\", this.mousemove = this.mousemove.bind(this));\n }\n update() {\n if (this.pending) {\n this.pending = null;\n clearTimeout(this.restartTimeout);\n this.restartTimeout = setTimeout(() => this.startHover(), 20);\n }\n }\n get active() {\n return this.view.state.field(this.field);\n }\n checkHover() {\n this.hoverTimeout = -1;\n if (this.active)\n return;\n let hovered = Date.now() - this.lastMove.time;\n if (hovered < this.hoverTime)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);\n else\n this.startHover();\n }\n startHover() {\n clearTimeout(this.restartTimeout);\n let { view, lastMove } = this;\n let desc = view.docView.nearest(lastMove.target);\n if (!desc)\n return;\n let pos, side = 1;\n if (desc instanceof WidgetView) {\n pos = desc.posAtStart;\n }\n else {\n pos = view.posAtCoords(lastMove);\n if (pos == null)\n return;\n let posCoords = view.coordsAtPos(pos);\n if (!posCoords ||\n lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||\n lastMove.x < posCoords.left - view.defaultCharacterWidth ||\n lastMove.x > posCoords.right + view.defaultCharacterWidth)\n return;\n let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);\n let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;\n side = (lastMove.x < posCoords.left ? -rtl : rtl);\n }\n let open = this.source(view, pos, side);\n if (open === null || open === void 0 ? void 0 : open.then) {\n let pending = this.pending = { pos };\n open.then(result => {\n if (this.pending == pending) {\n this.pending = null;\n if (result)\n view.dispatch({ effects: this.setHover.of(result) });\n }\n }, e => logException(view.state, e, \"hover tooltip\"));\n }\n else if (open) {\n view.dispatch({ effects: this.setHover.of(open) });\n }\n }\n mousemove(event) {\n var _a;\n this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };\n if (this.hoverTimeout < 0)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);\n let tooltip = this.active;\n if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {\n let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;\n if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos\n : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {\n this.view.dispatch({ effects: this.setHover.of(null) });\n this.pending = null;\n }\n }\n }\n mouseleave(e) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = -1;\n if (this.active && !isInTooltip(e.relatedTarget))\n this.view.dispatch({ effects: this.setHover.of(null) });\n }\n destroy() {\n clearTimeout(this.hoverTimeout);\n this.view.dom.removeEventListener(\"mouseleave\", this.mouseleave);\n this.view.dom.removeEventListener(\"mousemove\", this.mousemove);\n }\n}\nfunction isInTooltip(elt) {\n for (let cur = elt; cur; cur = cur.parentNode)\n if (cur.nodeType == 1 && cur.classList.contains(\"cm-tooltip\"))\n return true;\n return false;\n}\nfunction isOverRange(view, from, to, x, y, margin) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;\n if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)\n return false;\n let pos = view.posAtCoords({ x, y }, false);\n return pos >= from && pos <= to;\n}\n/**\nSet up a hover tooltip, which shows up when the pointer hovers\nover ranges of text. The callback is called when the mouse hovers\nover the document text. It should, if there is a tooltip\nassociated with position `pos`, return the tooltip description\n(either directly or in a promise). The `side` argument indicates\non which side of the position the pointer is—it will be -1 if the\npointer is before the position, 1 if after the position.\n\nNote that all hover tooltips are hosted within a single tooltip\ncontainer element. This allows multiple tooltips over the same\nrange to be \"merged\" together without overlapping.\n*/\nfunction hoverTooltip(source, options = {}) {\n let setHover = StateEffect.define();\n let hoverState = StateField.define({\n create() { return null; },\n update(value, tr) {\n if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||\n options.hideOn && options.hideOn(tr, value)))\n return null;\n if (value && tr.docChanged) {\n let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);\n if (newPos == null)\n return null;\n let copy = Object.assign(Object.create(null), value);\n copy.pos = newPos;\n if (value.end != null)\n copy.end = tr.changes.mapPos(value.end);\n value = copy;\n }\n for (let effect of tr.effects) {\n if (effect.is(setHover))\n value = effect.value;\n if (effect.is(closeHoverTooltipEffect))\n value = null;\n }\n return value;\n },\n provide: f => showHoverTooltip.from(f)\n });\n return [\n hoverState,\n ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),\n showHoverTooltipHost\n ];\n}\n/**\nGet the active tooltip view for a given tooltip, if available.\n*/\nfunction getTooltip(view, tooltip) {\n let plugin = view.plugin(tooltipPlugin);\n if (!plugin)\n return null;\n let found = plugin.manager.tooltips.indexOf(tooltip);\n return found < 0 ? null : plugin.manager.tooltipViews[found];\n}\n/**\nReturns true if any hover tooltips are currently active.\n*/\nfunction hasHoverTooltips(state) {\n return state.facet(showHoverTooltip).some(x => x);\n}\nconst closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();\n/**\nTransaction effect that closes all hover tooltips.\n*/\nconst closeHoverTooltips = /*@__PURE__*/closeHoverTooltipEffect.of(null);\n/**\nTell the tooltip extension to recompute the position of the active\ntooltips. This can be useful when something happens (such as a\nre-positioning or CSS change affecting the editor) that could\ninvalidate the existing tooltip positions.\n*/\nfunction repositionTooltips(view) {\n var _a;\n (_a = view.plugin(tooltipPlugin)) === null || _a === void 0 ? void 0 : _a.maybeMeasure();\n}\n\nconst panelConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let topContainer, bottomContainer;\n for (let c of configs) {\n topContainer = topContainer || c.topContainer;\n bottomContainer = bottomContainer || c.bottomContainer;\n }\n return { topContainer, bottomContainer };\n }\n});\n/**\nConfigures the panel-managing extension.\n*/\nfunction panels(config) {\n return config ? [panelConfig.of(config)] : [];\n}\n/**\nGet the active panel created by the given constructor, if any.\nThis can be useful when you need access to your panels' DOM\nstructure.\n*/\nfunction getPanel(view, panel) {\n let plugin = view.plugin(panelPlugin);\n let index = plugin ? plugin.specs.indexOf(panel) : -1;\n return index > -1 ? plugin.panels[index] : null;\n}\nconst panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.input = view.state.facet(showPanel);\n this.specs = this.input.filter(s => s);\n this.panels = this.specs.map(spec => spec(view));\n let conf = view.state.facet(panelConfig);\n this.top = new PanelGroup(view, true, conf.topContainer);\n this.bottom = new PanelGroup(view, false, conf.bottomContainer);\n this.top.sync(this.panels.filter(p => p.top));\n this.bottom.sync(this.panels.filter(p => !p.top));\n for (let p of this.panels) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n update(update) {\n let conf = update.state.facet(panelConfig);\n if (this.top.container != conf.topContainer) {\n this.top.sync([]);\n this.top = new PanelGroup(update.view, true, conf.topContainer);\n }\n if (this.bottom.container != conf.bottomContainer) {\n this.bottom.sync([]);\n this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);\n }\n this.top.syncClasses();\n this.bottom.syncClasses();\n let input = update.state.facet(showPanel);\n if (input != this.input) {\n let specs = input.filter(x => x);\n let panels = [], top = [], bottom = [], mount = [];\n for (let spec of specs) {\n let known = this.specs.indexOf(spec), panel;\n if (known < 0) {\n panel = spec(update.view);\n mount.push(panel);\n }\n else {\n panel = this.panels[known];\n if (panel.update)\n panel.update(update);\n }\n panels.push(panel);\n (panel.top ? top : bottom).push(panel);\n }\n this.specs = specs;\n this.panels = panels;\n this.top.sync(top);\n this.bottom.sync(bottom);\n for (let p of mount) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n else {\n for (let p of this.panels)\n if (p.update)\n p.update(update);\n }\n }\n destroy() {\n this.top.sync([]);\n this.bottom.sync([]);\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };\n })\n});\nclass PanelGroup {\n constructor(view, top, container) {\n this.view = view;\n this.top = top;\n this.container = container;\n this.dom = undefined;\n this.classes = \"\";\n this.panels = [];\n this.syncClasses();\n }\n sync(panels) {\n for (let p of this.panels)\n if (p.destroy && panels.indexOf(p) < 0)\n p.destroy();\n this.panels = panels;\n this.syncDOM();\n }\n syncDOM() {\n if (this.panels.length == 0) {\n if (this.dom) {\n this.dom.remove();\n this.dom = undefined;\n }\n return;\n }\n if (!this.dom) {\n this.dom = document.createElement(\"div\");\n this.dom.className = this.top ? \"cm-panels cm-panels-top\" : \"cm-panels cm-panels-bottom\";\n this.dom.style[this.top ? \"top\" : \"bottom\"] = \"0\";\n let parent = this.container || this.view.dom;\n parent.insertBefore(this.dom, this.top ? parent.firstChild : null);\n }\n let curDOM = this.dom.firstChild;\n for (let panel of this.panels) {\n if (panel.dom.parentNode == this.dom) {\n while (curDOM != panel.dom)\n curDOM = rm(curDOM);\n curDOM = curDOM.nextSibling;\n }\n else {\n this.dom.insertBefore(panel.dom, curDOM);\n }\n }\n while (curDOM)\n curDOM = rm(curDOM);\n }\n scrollMargin() {\n return !this.dom || this.container ? 0\n : Math.max(0, this.top ?\n this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :\n Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);\n }\n syncClasses() {\n if (!this.container || this.classes == this.view.themeClasses)\n return;\n for (let cls of this.classes.split(\" \"))\n if (cls)\n this.container.classList.remove(cls);\n for (let cls of (this.classes = this.view.themeClasses).split(\" \"))\n if (cls)\n this.container.classList.add(cls);\n }\n}\nfunction rm(node) {\n let next = node.nextSibling;\n node.remove();\n return next;\n}\n/**\nOpening a panel is done by providing a constructor function for\nthe panel through this facet. (The panel is closed again when its\nconstructor is no longer provided.) Values of `null` are ignored.\n*/\nconst showPanel = /*@__PURE__*/Facet.define({\n enables: panelPlugin\n});\n\n/**\nA gutter marker represents a bit of information attached to a line\nin a specific gutter. Your own custom markers have to extend this\nclass.\n*/\nclass GutterMarker extends RangeValue {\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n Compare this marker to another marker of the same type.\n */\n eq(other) { return false; }\n /**\n Called if the marker has a `toDOM` method and its representation\n was removed from a gutter.\n */\n destroy(dom) { }\n}\nGutterMarker.prototype.elementClass = \"\";\nGutterMarker.prototype.toDOM = undefined;\nGutterMarker.prototype.mapMode = MapMode.TrackBefore;\nGutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;\nGutterMarker.prototype.point = true;\n/**\nFacet used to add a class to all gutter elements for a given line.\nMarkers given to this facet should _only_ define an\n[`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a\n[`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear\nin all gutters for the line).\n*/\nconst gutterLineClass = /*@__PURE__*/Facet.define();\nconst defaults = {\n class: \"\",\n renderEmptyElements: false,\n elementStyle: \"\",\n markers: () => RangeSet.empty,\n lineMarker: () => null,\n widgetMarker: () => null,\n lineMarkerChange: null,\n initialSpacer: null,\n updateSpacer: null,\n domEventHandlers: {}\n};\nconst activeGutters = /*@__PURE__*/Facet.define();\n/**\nDefine an editor gutter. The order in which the gutters appear is\ndetermined by their extension priority.\n*/\nfunction gutter(config) {\n return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];\n}\nconst unfixGutters = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\n/**\nThe gutter-drawing plugin is automatically enabled when you add a\ngutter, but you can use this function to explicitly configure it.\n\nUnless `fixed` is explicitly set to `false`, the gutters are\nfixed, meaning they don't scroll along with the content\nhorizontally (except on Internet Explorer, which doesn't support\nCSS [`position:\nsticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).\n*/\nfunction gutters(config) {\n let result = [\n gutterView,\n ];\n if (config && config.fixed === false)\n result.push(unfixGutters.of(true));\n return result;\n}\nconst gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.prevViewport = view.viewport;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutters\";\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + \"px\";\n this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));\n for (let gutter of this.gutters)\n this.dom.appendChild(gutter.dom);\n this.fixed = !view.state.facet(unfixGutters);\n if (this.fixed) {\n // FIXME IE11 fallback, which doesn't support position: sticky,\n // by using position: relative + event handlers that realign the\n // gutter (or just force fixed=false on IE11?)\n this.dom.style.position = \"sticky\";\n }\n this.syncGutters(false);\n view.scrollDOM.insertBefore(this.dom, view.contentDOM);\n }\n update(update) {\n if (this.updateGutters(update)) {\n // Detach during sync when the viewport changed significantly\n // (such as during scrolling), since for large updates that is\n // faster.\n let vpA = this.prevViewport, vpB = update.view.viewport;\n let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);\n this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);\n }\n if (update.geometryChanged)\n this.dom.style.minHeight = this.view.contentHeight + \"px\";\n if (this.view.state.facet(unfixGutters) != !this.fixed) {\n this.fixed = !this.fixed;\n this.dom.style.position = this.fixed ? \"sticky\" : \"\";\n }\n this.prevViewport = update.view.viewport;\n }\n syncGutters(detach) {\n let after = this.dom.nextSibling;\n if (detach)\n this.dom.remove();\n let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);\n let classSet = [];\n let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));\n for (let line of this.view.viewportLineBlocks) {\n if (classSet.length)\n classSet = [];\n if (Array.isArray(line.type)) {\n let first = true;\n for (let b of line.type) {\n if (b.type == BlockType.Text && first) {\n advanceCursor(lineClasses, classSet, b.from);\n for (let cx of contexts)\n cx.line(this.view, b, classSet);\n first = false;\n }\n else if (b.widget) {\n for (let cx of contexts)\n cx.widget(this.view, b);\n }\n }\n }\n else if (line.type == BlockType.Text) {\n advanceCursor(lineClasses, classSet, line.from);\n for (let cx of contexts)\n cx.line(this.view, line, classSet);\n }\n else if (line.widget) {\n for (let cx of contexts)\n cx.widget(this.view, line);\n }\n }\n for (let cx of contexts)\n cx.finish();\n if (detach)\n this.view.scrollDOM.insertBefore(this.dom, after);\n }\n updateGutters(update) {\n let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);\n let change = update.docChanged || update.heightChanged || update.viewportChanged ||\n !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);\n if (prev == cur) {\n for (let gutter of this.gutters)\n if (gutter.update(update))\n change = true;\n }\n else {\n change = true;\n let gutters = [];\n for (let conf of cur) {\n let known = prev.indexOf(conf);\n if (known < 0) {\n gutters.push(new SingleGutterView(this.view, conf));\n }\n else {\n this.gutters[known].update(update);\n gutters.push(this.gutters[known]);\n }\n }\n for (let g of this.gutters) {\n g.dom.remove();\n if (gutters.indexOf(g) < 0)\n g.destroy();\n }\n for (let g of gutters)\n this.dom.appendChild(g.dom);\n this.gutters = gutters;\n }\n return change;\n }\n destroy() {\n for (let view of this.gutters)\n view.destroy();\n this.dom.remove();\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n if (!value || value.gutters.length == 0 || !value.fixed)\n return null;\n return view.textDirection == Direction.LTR\n ? { left: value.dom.offsetWidth * view.scaleX }\n : { right: value.dom.offsetWidth * view.scaleX };\n })\n});\nfunction asArray(val) { return (Array.isArray(val) ? val : [val]); }\nfunction advanceCursor(cursor, collect, pos) {\n while (cursor.value && cursor.from <= pos) {\n if (cursor.from == pos)\n collect.push(cursor.value);\n cursor.next();\n }\n}\nclass UpdateContext {\n constructor(gutter, viewport, height) {\n this.gutter = gutter;\n this.height = height;\n this.i = 0;\n this.cursor = RangeSet.iter(gutter.markers, viewport.from);\n }\n addElement(view, block, markers) {\n let { gutter } = this, above = block.top - this.height;\n if (this.i == gutter.elements.length) {\n let newElt = new GutterElement(view, block.height, above, markers);\n gutter.elements.push(newElt);\n gutter.dom.appendChild(newElt.dom);\n }\n else {\n gutter.elements[this.i].update(view, block.height, above, markers);\n }\n this.height = block.bottom;\n this.i++;\n }\n line(view, line, extraMarkers) {\n let localMarkers = [];\n advanceCursor(this.cursor, localMarkers, line.from);\n if (extraMarkers.length)\n localMarkers = localMarkers.concat(extraMarkers);\n let forLine = this.gutter.config.lineMarker(view, line, localMarkers);\n if (forLine)\n localMarkers.unshift(forLine);\n let gutter = this.gutter;\n if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)\n return;\n this.addElement(view, line, localMarkers);\n }\n widget(view, block) {\n let marker = this.gutter.config.widgetMarker(view, block.widget, block);\n if (marker)\n this.addElement(view, block, [marker]);\n }\n finish() {\n let gutter = this.gutter;\n while (gutter.elements.length > this.i) {\n let last = gutter.elements.pop();\n gutter.dom.removeChild(last.dom);\n last.destroy();\n }\n }\n}\nclass SingleGutterView {\n constructor(view, config) {\n this.view = view;\n this.config = config;\n this.elements = [];\n this.spacer = null;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutter\" + (this.config.class ? \" \" + this.config.class : \"\");\n for (let prop in config.domEventHandlers) {\n this.dom.addEventListener(prop, (event) => {\n let target = event.target, y;\n if (target != this.dom && this.dom.contains(target)) {\n while (target.parentNode != this.dom)\n target = target.parentNode;\n let rect = target.getBoundingClientRect();\n y = (rect.top + rect.bottom) / 2;\n }\n else {\n y = event.clientY;\n }\n let line = view.lineBlockAtHeight(y - view.documentTop);\n if (config.domEventHandlers[prop](view, line, event))\n event.preventDefault();\n });\n }\n this.markers = asArray(config.markers(view));\n if (config.initialSpacer) {\n this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);\n this.dom.appendChild(this.spacer.dom);\n this.spacer.dom.style.cssText += \"visibility: hidden; pointer-events: none\";\n }\n }\n update(update) {\n let prevMarkers = this.markers;\n this.markers = asArray(this.config.markers(update.view));\n if (this.spacer && this.config.updateSpacer) {\n let updated = this.config.updateSpacer(this.spacer.markers[0], update);\n if (updated != this.spacer.markers[0])\n this.spacer.update(update.view, 0, 0, [updated]);\n }\n let vp = update.view.viewport;\n return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||\n (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);\n }\n destroy() {\n for (let elt of this.elements)\n elt.destroy();\n }\n}\nclass GutterElement {\n constructor(view, height, above, markers) {\n this.height = -1;\n this.above = 0;\n this.markers = [];\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutterElement\";\n this.update(view, height, above, markers);\n }\n update(view, height, above, markers) {\n if (this.height != height) {\n this.height = height;\n this.dom.style.height = height / view.scaleY + \"px\";\n }\n if (this.above != above)\n this.dom.style.marginTop = (this.above = above) ? above / view.scaleY + \"px\" : \"\";\n if (!sameMarkers(this.markers, markers))\n this.setMarkers(view, markers);\n }\n setMarkers(view, markers) {\n let cls = \"cm-gutterElement\", domPos = this.dom.firstChild;\n for (let iNew = 0, iOld = 0;;) {\n let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;\n if (marker) {\n let c = marker.elementClass;\n if (c)\n cls += \" \" + c;\n for (let i = iOld; i < this.markers.length; i++)\n if (this.markers[i].compare(marker)) {\n skipTo = i;\n matched = true;\n break;\n }\n }\n else {\n skipTo = this.markers.length;\n }\n while (iOld < skipTo) {\n let next = this.markers[iOld++];\n if (next.toDOM) {\n next.destroy(domPos);\n let after = domPos.nextSibling;\n domPos.remove();\n domPos = after;\n }\n }\n if (!marker)\n break;\n if (marker.toDOM) {\n if (matched)\n domPos = domPos.nextSibling;\n else\n this.dom.insertBefore(marker.toDOM(view), domPos);\n }\n if (matched)\n iOld++;\n }\n this.dom.className = cls;\n this.markers = markers;\n }\n destroy() {\n this.setMarkers(null, []); // First argument not used unless creating markers\n }\n}\nfunction sameMarkers(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!a[i].compare(b[i]))\n return false;\n return true;\n}\n/**\nFacet used to provide markers to the line number gutter.\n*/\nconst lineNumberMarkers = /*@__PURE__*/Facet.define();\nconst lineNumberConfig = /*@__PURE__*/Facet.define({\n combine(values) {\n return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {\n domEventHandlers(a, b) {\n let result = Object.assign({}, a);\n for (let event in b) {\n let exists = result[event], add = b[event];\n result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;\n }\n return result;\n }\n });\n }\n});\nclass NumberMarker extends GutterMarker {\n constructor(number) {\n super();\n this.number = number;\n }\n eq(other) { return this.number == other.number; }\n toDOM() { return document.createTextNode(this.number); }\n}\nfunction formatNumber(view, number) {\n return view.state.facet(lineNumberConfig).formatNumber(number, view.state);\n}\nconst lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({\n class: \"cm-lineNumbers\",\n renderEmptyElements: false,\n markers(view) { return view.state.facet(lineNumberMarkers); },\n lineMarker(view, line, others) {\n if (others.some(m => m.toDOM))\n return null;\n return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));\n },\n widgetMarker: () => null,\n lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),\n initialSpacer(view) {\n return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));\n },\n updateSpacer(spacer, update) {\n let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));\n return max == spacer.number ? spacer : new NumberMarker(max);\n },\n domEventHandlers: state.facet(lineNumberConfig).domEventHandlers\n}));\n/**\nCreate a line number gutter extension.\n*/\nfunction lineNumbers(config = {}) {\n return [\n lineNumberConfig.of(config),\n gutters(),\n lineNumberGutter\n ];\n}\nfunction maxLineNumber(lines) {\n let last = 9;\n while (last < lines)\n last = last * 10 + 9;\n return last;\n}\nconst activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {\n constructor() {\n super(...arguments);\n this.elementClass = \"cm-activeLineGutter\";\n }\n};\nconst activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute([\"selection\"], state => {\n let marks = [], last = -1;\n for (let range of state.selection.ranges) {\n let linePos = state.doc.lineAt(range.head).from;\n if (linePos > last) {\n last = linePos;\n marks.push(activeLineGutterMarker.range(linePos));\n }\n }\n return RangeSet.of(marks);\n});\n/**\nReturns an extension that adds a `cm-activeLineGutter` class to\nall gutter elements on the [active\nline](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).\n*/\nfunction highlightActiveLineGutter() {\n return activeLineGutterHighlighter;\n}\n\nconst WhitespaceDeco = /*@__PURE__*/new Map();\nfunction getWhitespaceDeco(space) {\n let deco = WhitespaceDeco.get(space);\n if (!deco)\n WhitespaceDeco.set(space, deco = Decoration.mark({\n attributes: space === \"\\t\" ? {\n class: \"cm-highlightTab\",\n } : {\n class: \"cm-highlightSpace\",\n \"data-display\": space.replace(/ /g, \"·\")\n }\n }));\n return deco;\n}\nfunction matcher(decorator) {\n return ViewPlugin.define(view => ({\n decorations: decorator.createDeco(view),\n update(u) {\n this.decorations = decorator.updateDeco(u, this.decorations);\n },\n }), {\n decorations: v => v.decorations\n });\n}\nconst whitespaceHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\t| +/g,\n decoration: match => getWhitespaceDeco(match[0]),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that highlights whitespace, adding a\n`cm-highlightSpace` class to stretches of spaces, and a\n`cm-highlightTab` class to individual tab characters. By default,\nthe former are shown as faint dots, and the latter as arrows.\n*/\nfunction highlightWhitespace() {\n return whitespaceHighlighter;\n}\nconst trailingHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\s+$/g,\n decoration: /*@__PURE__*/Decoration.mark({ class: \"cm-trailingSpace\" }),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that adds a `cm-trailingSpace` class to all\ntrailing whitespace.\n*/\nfunction highlightTrailingWhitespace() {\n return trailingHighlighter;\n}\n\n/**\n@internal\n*/\nconst __test = { HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder, moveVisually };\n\nexport { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, __test, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };\n","import { EditorState, Extension } from '@codemirror/state';\nimport { EditorView, lineNumbers } from '@codemirror/view';\n\n/**\n * @class CodeMirror\n */\nexport default class CodeMirror {\n\t/**\n\t * @constructor\n\t * @param {jQuery} $textarea Textarea to add syntax highlighting to.\n\t */\n\tconstructor( $textarea ) {\n\t\tthis.$textarea = $textarea;\n\t\tthis.view = null;\n\t\tthis.state = null;\n\t}\n\n\t/**\n\t * Extensions here should be applicable to all theoretical uses of CodeMirror in MediaWiki.\n\t * Don't assume CodeMirror is used for editing (i.e. \"View source\" of a protected page).\n\t * Subclasses are safe to override this method if needed.\n\t *\n\t * @see https://codemirror.net/docs/ref/#state.Extension\n\t * @return {Extension[]}\n\t */\n\tget defaultExtensions() {\n\t\tconst extensions = [\n\t\t\tthis.contentAttributesExtension\n\t\t];\n\t\tconst namespaces = mw.config.get( 'wgCodeMirrorLineNumberingNamespaces' );\n\n\t\t// Set to [] to disable everywhere, or null to enable everywhere\n\t\tif ( !namespaces || namespaces.includes( mw.config.get( 'wgNamespaceNumber' ) ) ) {\n\t\t\textensions.push( lineNumbers() );\n\t\t}\n\t\treturn extensions;\n\t}\n\n\t/**\n\t * This specifies which attributes get added to the .cm-content element.\n\t * If you need to add more, add another Extension on initialization for the contentAttributes\n\t * Facet in the form of EditorView.contentAttributes.of( {Object} ).\n\t *\n\t * @see https://codemirror.net/docs/ref/#view.EditorView^contentAttributes\n\t * @return {Extension}\n\t */\n\tget contentAttributesExtension() {\n\t\treturn EditorView.contentAttributes.of( {\n\t\t\t// T259347: Use accesskey of the original textbox\n\t\t\taccesskey: this.$textarea.attr( 'accesskey' ),\n\t\t\t// use direction and language of the original textbox\n\t\t\tdir: this.$textarea.attr( 'dir' ),\n\t\t\tlang: this.$textarea.attr( 'lang' )\n\t\t} );\n\t}\n\n\t/**\n\t * Setup CodeMirror and add it to the DOM. This will hide the original textarea.\n\t *\n\t * @param {Extension[]} extensions\n\t */\n\tinitialize( extensions = this.defaultExtensions ) {\n\t\t// Set up the initial EditorState of CodeMirror with contents of the native textarea.\n\t\tthis.state = EditorState.create( {\n\t\t\tdoc: this.$textarea.textSelection( 'getContents' ),\n\t\t\textensions\n\t\t} );\n\n\t\t// Add CodeMirror view to the DOM.\n\t\tthis.view = new EditorView( {\n\t\t\tstate: this.state,\n\t\t\tparent: this.$textarea.parent()[ 0 ]\n\t\t} );\n\n\t\t// Hide native textarea and sync CodeMirror contents upon submission.\n\t\tthis.$textarea.hide();\n\t\tif ( this.$textarea[ 0 ].form ) {\n\t\t\tthis.$textarea[ 0 ].form.addEventListener( 'submit', () => {\n\t\t\t\tthis.$textarea.val( this.view.state.doc.toString() );\n\t\t\t} );\n\t\t}\n\n\t\t// Register $.textSelection() on the .cm-editor element.\n\t\t$( this.view.dom ).textSelection( 'register', this.cmTextSelection );\n\t\t// Also override textSelection() functions for the \"real\" hidden textarea to route to\n\t\t// CodeMirror. We unregister this when switching to normal textarea mode.\n\t\tthis.$textarea.textSelection( 'register', this.cmTextSelection );\n\n\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );\n\t}\n\n\t/**\n\t * Log usage of CodeMirror.\n\t *\n\t * @param {Object} data\n\t */\n\tlogUsage( data ) {\n\t\t/* eslint-disable camelcase */\n\t\tconst event = Object.assign( {\n\t\t\tsession_token: mw.user.sessionId(),\n\t\t\tuser_id: mw.user.getId()\n\t\t}, data );\n\t\tconst editCountBucket = mw.config.get( 'wgUserEditCountBucket' );\n\t\tif ( editCountBucket !== null ) {\n\t\t\tevent.user_edit_count_bucket = editCountBucket;\n\t\t}\n\t\t/* eslint-enable camelcase */\n\t\tmw.track( 'event.CodeMirrorUsage', event );\n\t}\n\n\t/**\n\t * Save CodeMirror enabled preference.\n\t *\n\t * @param {boolean} prefValue True, if CodeMirror should be enabled by default, otherwise false.\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\tif ( !mw.user.isNamed() ) { // Skip it for unnamed users\n\t\t\treturn;\n\t\t}\n\t\tnew mw.Api().saveOption( 'usecodemirror', prefValue ? 1 : 0 );\n\t\tmw.user.options.set( 'usecodemirror', prefValue ? 1 : 0 );\n\t}\n\n\t/**\n\t * jQuery.textSelection overrides for CodeMirror.\n\t *\n\t * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.plugin.textSelection\n\t * @return {Object}\n\t */\n\tget cmTextSelection() {\n\t\tconst $cmDom = $( this.view.dom );\n\t\treturn {\n\t\t\tgetContents: () => this.view.state.doc.toString(),\n\t\t\tsetContents: ( content ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tchanges: {\n\t\t\t\t\t\tfrom: 0,\n\t\t\t\t\t\tto: this.view.state.doc.length,\n\t\t\t\t\t\tinsert: content\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetSelection: () => {\n\t\t\t\treturn this.view.state.sliceDoc(\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t);\n\t\t\t},\n\t\t\tsetSelection: ( options = { start: 0, end: 0 } ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tselection: { anchor: options.start, head: ( options.end || options.start ) }\n\t\t\t\t} );\n\t\t\t\tthis.view.focus();\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\treplaceSelection: ( value ) => {\n\t\t\t\tthis.view.dispatch(\n\t\t\t\t\tthis.view.state.replaceSelection( value )\n\t\t\t\t);\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetCaretPosition: ( options ) => {\n\t\t\t\tif ( !options.startAndEnd ) {\n\t\t\t\t\treturn this.view.state.selection.main.head;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t];\n\t\t\t},\n\t\t\tscrollToCaretPosition: () => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\teffects: EditorView.scrollIntoView( this.view.state.selection.main.head )\n\t\t\t\t} );\n\t\t\t\treturn $cmDom;\n\t\t\t}\n\t\t};\n\t}\n}\n","/**\nThe default maximum length of a `TreeBuffer` node.\n*/\nconst DefaultBufferLength = 1024;\nlet nextPropID = 0;\nclass Range {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\n/**\nEach [node type](#common.NodeType) or [individual tree](#common.Tree)\ncan have metadata associated with it in props. Instances of this\nclass represent prop names.\n*/\nclass NodeProp {\n /**\n Create a new node prop type.\n */\n constructor(config = {}) {\n this.id = nextPropID++;\n this.perNode = !!config.perNode;\n this.deserialize = config.deserialize || (() => {\n throw new Error(\"This node type doesn't define a deserialize function\");\n });\n }\n /**\n This is meant to be used with\n [`NodeSet.extend`](#common.NodeSet.extend) or\n [`LRParser.configure`](#lr.ParserConfig.props) to compute\n prop values for each node type in the set. Takes a [match\n object](#common.NodeType^match) or function that returns undefined\n if the node type doesn't get this prop, and the prop's value if\n it does.\n */\n add(match) {\n if (this.perNode)\n throw new RangeError(\"Can't add per-node props to node types\");\n if (typeof match != \"function\")\n match = NodeType.match(match);\n return (type) => {\n let result = match(type);\n return result === undefined ? null : [this, result];\n };\n }\n}\n/**\nProp that is used to describe matching delimiters. For opening\ndelimiters, this holds an array of node names (written as a\nspace-separated string when declaring this prop in a grammar)\nfor the node types of closing delimiters that match it.\n*/\nNodeProp.closedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nThe inverse of [`closedBy`](#common.NodeProp^closedBy). This is\nattached to closing delimiters, holding an array of node names\nof types of matching opening delimiters.\n*/\nNodeProp.openedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nUsed to assign node types to groups (for example, all node\ntypes that represent an expression could be tagged with an\n`\"Expression\"` group).\n*/\nNodeProp.group = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nThe hash of the [context](#lr.ContextTracker.constructor)\nthat the node was parsed in, if any. Used to limit reuse of\ncontextual nodes.\n*/\nNodeProp.contextHash = new NodeProp({ perNode: true });\n/**\nThe distance beyond the end of the node that the tokenizer\nlooked ahead for any of the tokens inside the node. (The LR\nparser only stores this when it is larger than 25, for\nefficiency reasons.)\n*/\nNodeProp.lookAhead = new NodeProp({ perNode: true });\n/**\nThis per-node prop is used to replace a given node, or part of a\nnode, with another tree. This is useful to include trees from\ndifferent languages in mixed-language parsers.\n*/\nNodeProp.mounted = new NodeProp({ perNode: true });\n/**\nA mounted tree, which can be [stored](#common.NodeProp^mounted) on\na tree node to indicate that parts of its content are\nrepresented by another tree.\n*/\nclass MountedTree {\n constructor(\n /**\n The inner tree.\n */\n tree, \n /**\n If this is null, this tree replaces the entire node (it will\n be included in the regular iteration instead of its host\n node). If not, only the given ranges are considered to be\n covered by this tree. This is used for trees that are mixed in\n a way that isn't strictly hierarchical. Such mounted trees are\n only entered by [`resolveInner`](#common.Tree.resolveInner)\n and [`enter`](#common.SyntaxNode.enter).\n */\n overlay, \n /**\n The parser used to create this subtree.\n */\n parser) {\n this.tree = tree;\n this.overlay = overlay;\n this.parser = parser;\n }\n /**\n @internal\n */\n static get(tree) {\n return tree && tree.props && tree.props[NodeProp.mounted.id];\n }\n}\nconst noProps = Object.create(null);\n/**\nEach node in a syntax tree has a node type associated with it.\n*/\nclass NodeType {\n /**\n @internal\n */\n constructor(\n /**\n The name of the node type. Not necessarily unique, but if the\n grammar was written properly, different node types with the\n same name within a node set should play the same semantic\n role.\n */\n name, \n /**\n @internal\n */\n props, \n /**\n The id of this node in its set. Corresponds to the term ids\n used in the parser.\n */\n id, \n /**\n @internal\n */\n flags = 0) {\n this.name = name;\n this.props = props;\n this.id = id;\n this.flags = flags;\n }\n /**\n Define a node type.\n */\n static define(spec) {\n let props = spec.props && spec.props.length ? Object.create(null) : noProps;\n let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |\n (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);\n let type = new NodeType(spec.name || \"\", props, spec.id, flags);\n if (spec.props)\n for (let src of spec.props) {\n if (!Array.isArray(src))\n src = src(type);\n if (src) {\n if (src[0].perNode)\n throw new RangeError(\"Can't store a per-node prop on a node type\");\n props[src[0].id] = src[1];\n }\n }\n return type;\n }\n /**\n Retrieves a node prop for this type. Will return `undefined` if\n the prop isn't present on this node.\n */\n prop(prop) { return this.props[prop.id]; }\n /**\n True when this is the top node of a grammar.\n */\n get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }\n /**\n True when this node is produced by a skip rule.\n */\n get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }\n /**\n Indicates whether this is an error node.\n */\n get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }\n /**\n When true, this node type doesn't correspond to a user-declared\n named node, for example because it is used to cache repetition.\n */\n get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }\n /**\n Returns true when this node's name or one of its\n [groups](#common.NodeProp^group) matches the given string.\n */\n is(name) {\n if (typeof name == 'string') {\n if (this.name == name)\n return true;\n let group = this.prop(NodeProp.group);\n return group ? group.indexOf(name) > -1 : false;\n }\n return this.id == name;\n }\n /**\n Create a function from node types to arbitrary values by\n specifying an object whose property names are node or\n [group](#common.NodeProp^group) names. Often useful with\n [`NodeProp.add`](#common.NodeProp.add). You can put multiple\n names, separated by spaces, in a single property name to map\n multiple node names to a single value.\n */\n static match(map) {\n let direct = Object.create(null);\n for (let prop in map)\n for (let name of prop.split(\" \"))\n direct[name] = map[prop];\n return (node) => {\n for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {\n let found = direct[i < 0 ? node.name : groups[i]];\n if (found)\n return found;\n }\n };\n }\n}\n/**\nAn empty dummy node type to use when no actual type is available.\n*/\nNodeType.none = new NodeType(\"\", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);\n/**\nA node set holds a collection of node types. It is used to\ncompactly represent trees by storing their type ids, rather than a\nfull pointer to the type object, in a numeric array. Each parser\n[has](#lr.LRParser.nodeSet) a node set, and [tree\nbuffers](#common.TreeBuffer) can only store collections of nodes\nfrom the same set. A set can have a maximum of 2**16 (65536) node\ntypes in it, so that the ids fit into 16-bit typed array slots.\n*/\nclass NodeSet {\n /**\n Create a set with the given types. The `id` property of each\n type should correspond to its position within the array.\n */\n constructor(\n /**\n The node types in this set, by id.\n */\n types) {\n this.types = types;\n for (let i = 0; i < types.length; i++)\n if (types[i].id != i)\n throw new RangeError(\"Node type ids should correspond to array positions when creating a node set\");\n }\n /**\n Create a copy of this set with some node properties added. The\n arguments to this method can be created with\n [`NodeProp.add`](#common.NodeProp.add).\n */\n extend(...props) {\n let newTypes = [];\n for (let type of this.types) {\n let newProps = null;\n for (let source of props) {\n let add = source(type);\n if (add) {\n if (!newProps)\n newProps = Object.assign({}, type.props);\n newProps[add[0].id] = add[1];\n }\n }\n newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);\n }\n return new NodeSet(newTypes);\n }\n}\nconst CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();\n/**\nOptions that control iteration. Can be combined with the `|`\noperator to enable multiple ones.\n*/\nvar IterMode;\n(function (IterMode) {\n /**\n When enabled, iteration will only visit [`Tree`](#common.Tree)\n objects, not nodes packed into\n [`TreeBuffer`](#common.TreeBuffer)s.\n */\n IterMode[IterMode[\"ExcludeBuffers\"] = 1] = \"ExcludeBuffers\";\n /**\n Enable this to make iteration include anonymous nodes (such as\n the nodes that wrap repeated grammar constructs into a balanced\n tree).\n */\n IterMode[IterMode[\"IncludeAnonymous\"] = 2] = \"IncludeAnonymous\";\n /**\n By default, regular [mounted](#common.NodeProp^mounted) nodes\n replace their base node in iteration. Enable this to ignore them\n instead.\n */\n IterMode[IterMode[\"IgnoreMounts\"] = 4] = \"IgnoreMounts\";\n /**\n This option only applies in\n [`enter`](#common.SyntaxNode.enter)-style methods. It tells the\n library to not enter mounted overlays if one covers the given\n position.\n */\n IterMode[IterMode[\"IgnoreOverlays\"] = 8] = \"IgnoreOverlays\";\n})(IterMode || (IterMode = {}));\n/**\nA piece of syntax tree. There are two ways to approach these\ntrees: the way they are actually stored in memory, and the\nconvenient way.\n\nSyntax trees are stored as a tree of `Tree` and `TreeBuffer`\nobjects. By packing detail information into `TreeBuffer` leaf\nnodes, the representation is made a lot more memory-efficient.\n\nHowever, when you want to actually work with tree nodes, this\nrepresentation is very awkward, so most client code will want to\nuse the [`TreeCursor`](#common.TreeCursor) or\n[`SyntaxNode`](#common.SyntaxNode) interface instead, which provides\na view on some part of this data structure, and can be used to\nmove around to adjacent nodes.\n*/\nclass Tree {\n /**\n Construct a new tree. See also [`Tree.build`](#common.Tree^build).\n */\n constructor(\n /**\n The type of the top node.\n */\n type, \n /**\n This node's child nodes.\n */\n children, \n /**\n The positions (offsets relative to the start of this tree) of\n the children.\n */\n positions, \n /**\n The total length of this tree\n */\n length, \n /**\n Per-node [node props](#common.NodeProp) to associate with this node.\n */\n props) {\n this.type = type;\n this.children = children;\n this.positions = positions;\n this.length = length;\n /**\n @internal\n */\n this.props = null;\n if (props && props.length) {\n this.props = Object.create(null);\n for (let [prop, value] of props)\n this.props[typeof prop == \"number\" ? prop : prop.id] = value;\n }\n }\n /**\n @internal\n */\n toString() {\n let mounted = MountedTree.get(this);\n if (mounted && !mounted.overlay)\n return mounted.tree.toString();\n let children = \"\";\n for (let ch of this.children) {\n let str = ch.toString();\n if (str) {\n if (children)\n children += \",\";\n children += str;\n }\n }\n return !this.type.name ? children :\n (/\\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +\n (children.length ? \"(\" + children + \")\" : \"\");\n }\n /**\n Get a [tree cursor](#common.TreeCursor) positioned at the top of\n the tree. Mode can be used to [control](#common.IterMode) which\n nodes the cursor visits.\n */\n cursor(mode = 0) {\n return new TreeCursor(this.topNode, mode);\n }\n /**\n Get a [tree cursor](#common.TreeCursor) pointing into this tree\n at the given position and side (see\n [`moveTo`](#common.TreeCursor.moveTo).\n */\n cursorAt(pos, side = 0, mode = 0) {\n let scope = CachedNode.get(this) || this.topNode;\n let cursor = new TreeCursor(scope);\n cursor.moveTo(pos, side);\n CachedNode.set(this, cursor._tree);\n return cursor;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) object for the top of the\n tree.\n */\n get topNode() {\n return new TreeNode(this, 0, 0, null);\n }\n /**\n Get the [syntax node](#common.SyntaxNode) at the given position.\n If `side` is -1, this will move into nodes that end at the\n position. If 1, it'll move into nodes that start at the\n position. With 0, it'll only enter nodes that cover the position\n from both sides.\n \n Note that this will not enter\n [overlays](#common.MountedTree.overlay), and you often want\n [`resolveInner`](#common.Tree.resolveInner) instead.\n */\n resolve(pos, side = 0) {\n let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);\n CachedNode.set(this, node);\n return node;\n }\n /**\n Like [`resolve`](#common.Tree.resolve), but will enter\n [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node\n pointing into the innermost overlaid tree at the given position\n (with parent links going through all parent structure, including\n the host trees).\n */\n resolveInner(pos, side = 0) {\n let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);\n CachedInnerNode.set(this, node);\n return node;\n }\n /**\n In some situations, it can be useful to iterate through all\n nodes around a position, including those in overlays that don't\n directly cover the position. This method gives you an iterator\n that will produce all nodes, from small to big, around the given\n position.\n */\n resolveStack(pos, side = 0) {\n return stackIterator(this, pos, side);\n }\n /**\n Iterate over the tree and its children, calling `enter` for any\n node that touches the `from`/`to` region (if given) before\n running over such a node's children, and `leave` (if given) when\n leaving the node. When `enter` returns `false`, that node will\n not have its children iterated over (or `leave` called).\n */\n iterate(spec) {\n let { enter, leave, from = 0, to = this.length } = spec;\n let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;\n for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {\n let entered = false;\n if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {\n if (c.firstChild())\n continue;\n entered = true;\n }\n for (;;) {\n if (entered && leave && (anon || !c.type.isAnonymous))\n leave(c);\n if (c.nextSibling())\n break;\n if (!c.parent())\n return;\n entered = true;\n }\n }\n }\n /**\n Get the value of the given [node prop](#common.NodeProp) for this\n node. Works with both per-node and per-type props.\n */\n prop(prop) {\n return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;\n }\n /**\n Returns the node's [per-node props](#common.NodeProp.perNode) in a\n format that can be passed to the [`Tree`](#common.Tree)\n constructor.\n */\n get propValues() {\n let result = [];\n if (this.props)\n for (let id in this.props)\n result.push([+id, this.props[id]]);\n return result;\n }\n /**\n Balance the direct children of this tree, producing a copy of\n which may have children grouped into subtrees with type\n [`NodeType.none`](#common.NodeType^none).\n */\n balance(config = {}) {\n return this.children.length <= 8 /* Balance.BranchFactor */ ? this :\n balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));\n }\n /**\n Build a tree from a postfix-ordered buffer of node information,\n or a cursor over such a buffer.\n */\n static build(data) { return buildTree(data); }\n}\n/**\nThe empty tree\n*/\nTree.empty = new Tree(NodeType.none, [], [], 0);\nclass FlatBufferCursor {\n constructor(buffer, index) {\n this.buffer = buffer;\n this.index = index;\n }\n get id() { return this.buffer[this.index - 4]; }\n get start() { return this.buffer[this.index - 3]; }\n get end() { return this.buffer[this.index - 2]; }\n get size() { return this.buffer[this.index - 1]; }\n get pos() { return this.index; }\n next() { this.index -= 4; }\n fork() { return new FlatBufferCursor(this.buffer, this.index); }\n}\n/**\nTree buffers contain (type, start, end, endIndex) quads for each\nnode. In such a buffer, nodes are stored in prefix order (parents\nbefore children, with the endIndex of the parent indicating which\nchildren belong to it).\n*/\nclass TreeBuffer {\n /**\n Create a tree buffer.\n */\n constructor(\n /**\n The buffer's content.\n */\n buffer, \n /**\n The total length of the group of nodes in the buffer.\n */\n length, \n /**\n The node set used in this buffer.\n */\n set) {\n this.buffer = buffer;\n this.length = length;\n this.set = set;\n }\n /**\n @internal\n */\n get type() { return NodeType.none; }\n /**\n @internal\n */\n toString() {\n let result = [];\n for (let index = 0; index < this.buffer.length;) {\n result.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result.join(\",\");\n }\n /**\n @internal\n */\n childString(index) {\n let id = this.buffer[index], endIndex = this.buffer[index + 3];\n let type = this.set.types[id], result = type.name;\n if (/\\W/.test(result) && !type.isError)\n result = JSON.stringify(result);\n index += 4;\n if (endIndex == index)\n return result;\n let children = [];\n while (index < endIndex) {\n children.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result + \"(\" + children.join(\",\") + \")\";\n }\n /**\n @internal\n */\n findChild(startIndex, endIndex, dir, pos, side) {\n let { buffer } = this, pick = -1;\n for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {\n if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {\n pick = i;\n if (dir > 0)\n break;\n }\n }\n return pick;\n }\n /**\n @internal\n */\n slice(startI, endI, from) {\n let b = this.buffer;\n let copy = new Uint16Array(endI - startI), len = 0;\n for (let i = startI, j = 0; i < endI;) {\n copy[j++] = b[i++];\n copy[j++] = b[i++] - from;\n let to = copy[j++] = b[i++] - from;\n copy[j++] = b[i++] - startI;\n len = Math.max(len, to);\n }\n return new TreeBuffer(copy, len, this.set);\n }\n}\nfunction checkSide(side, pos, from, to) {\n switch (side) {\n case -2 /* Side.Before */: return from < pos;\n case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;\n case 0 /* Side.Around */: return from < pos && to > pos;\n case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;\n case 2 /* Side.After */: return to > pos;\n case 4 /* Side.DontCare */: return true;\n }\n}\nfunction resolveNode(node, pos, side, overlays) {\n var _a;\n // Move up to a node that actually holds the position, if possible\n while (node.from == node.to ||\n (side < 1 ? node.from >= pos : node.from > pos) ||\n (side > -1 ? node.to <= pos : node.to < pos)) {\n let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;\n if (!parent)\n return node;\n node = parent;\n }\n let mode = overlays ? 0 : IterMode.IgnoreOverlays;\n // Must go up out of overlays when those do not overlap with pos\n if (overlays)\n for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {\n if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)\n node = parent;\n }\n for (;;) {\n let inner = node.enter(pos, side, mode);\n if (!inner)\n return node;\n node = inner;\n }\n}\nclass BaseNode {\n cursor(mode = 0) { return new TreeCursor(this, mode); }\n getChild(type, before = null, after = null) {\n let r = getChildren(this, type, before, after);\n return r.length ? r[0] : null;\n }\n getChildren(type, before = null, after = null) {\n return getChildren(this, type, before, after);\n }\n resolve(pos, side = 0) {\n return resolveNode(this, pos, side, false);\n }\n resolveInner(pos, side = 0) {\n return resolveNode(this, pos, side, true);\n }\n matchContext(context) {\n return matchNodeContext(this, context);\n }\n enterUnfinishedNodesBefore(pos) {\n let scan = this.childBefore(pos), node = this;\n while (scan) {\n let last = scan.lastChild;\n if (!last || last.to != scan.to)\n break;\n if (last.type.isError && last.from == last.to) {\n node = scan;\n scan = last.prevSibling;\n }\n else {\n scan = last;\n }\n }\n return node;\n }\n get node() { return this; }\n get next() { return this.parent; }\n}\nclass TreeNode extends BaseNode {\n constructor(_tree, from, \n // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)\n index, _parent) {\n super();\n this._tree = _tree;\n this.from = from;\n this.index = index;\n this._parent = _parent;\n }\n get type() { return this._tree.type; }\n get name() { return this._tree.type.name; }\n get to() { return this.from + this._tree.length; }\n nextChild(i, dir, pos, side, mode = 0) {\n for (let parent = this;;) {\n for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {\n let next = children[i], start = positions[i] + parent.from;\n if (!checkSide(side, pos, start, start + next.length))\n continue;\n if (next instanceof TreeBuffer) {\n if (mode & IterMode.ExcludeBuffers)\n continue;\n let index = next.findChild(0, next.buffer.length, dir, pos - start, side);\n if (index > -1)\n return new BufferNode(new BufferContext(parent, next, i, start), null, index);\n }\n else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {\n let mounted;\n if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)\n return new TreeNode(mounted.tree, start, i, parent);\n let inner = new TreeNode(next, start, i, parent);\n return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner\n : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);\n }\n }\n if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)\n return null;\n if (parent.index >= 0)\n i = parent.index + dir;\n else\n i = dir < 0 ? -1 : parent._parent._tree.children.length;\n parent = parent._parent;\n if (!parent)\n return null;\n }\n }\n get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n let mounted;\n if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {\n let rPos = pos - this.from;\n for (let { from, to } of mounted.overlay) {\n if ((side > 0 ? from <= rPos : from < rPos) &&\n (side < 0 ? to >= rPos : to > rPos))\n return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);\n }\n }\n return this.nextChild(0, 1, pos, side, mode);\n }\n nextSignificantParent() {\n let val = this;\n while (val.type.isAnonymous && val._parent)\n val = val._parent;\n return val;\n }\n get parent() {\n return this._parent ? this._parent.nextSignificantParent() : null;\n }\n get nextSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;\n }\n get prevSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;\n }\n get tree() { return this._tree; }\n toTree() { return this._tree; }\n /**\n @internal\n */\n toString() { return this._tree.toString(); }\n}\nfunction getChildren(node, type, before, after) {\n let cur = node.cursor(), result = [];\n if (!cur.firstChild())\n return result;\n if (before != null)\n while (!cur.type.is(before))\n if (!cur.nextSibling())\n return result;\n for (;;) {\n if (after != null && cur.type.is(after))\n return result;\n if (cur.type.is(type))\n result.push(cur.node);\n if (!cur.nextSibling())\n return after == null ? result : [];\n }\n}\nfunction matchNodeContext(node, context, i = context.length - 1) {\n for (let p = node.parent; i >= 0; p = p.parent) {\n if (!p)\n return false;\n if (!p.type.isAnonymous) {\n if (context[i] && context[i] != p.name)\n return false;\n i--;\n }\n }\n return true;\n}\nclass BufferContext {\n constructor(parent, buffer, index, start) {\n this.parent = parent;\n this.buffer = buffer;\n this.index = index;\n this.start = start;\n }\n}\nclass BufferNode extends BaseNode {\n get name() { return this.type.name; }\n get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }\n get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }\n constructor(context, _parent, index) {\n super();\n this.context = context;\n this._parent = _parent;\n this.index = index;\n this.type = context.buffer.set.types[context.buffer.buffer[index]];\n }\n child(dir, pos, side) {\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n if (mode & IterMode.ExcludeBuffers)\n return null;\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get parent() {\n return this._parent || this.context.parent.nextSignificantParent();\n }\n externalSibling(dir) {\n return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);\n }\n get nextSibling() {\n let { buffer } = this.context;\n let after = buffer.buffer[this.index + 3];\n if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))\n return new BufferNode(this.context, this._parent, after);\n return this.externalSibling(1);\n }\n get prevSibling() {\n let { buffer } = this.context;\n let parentStart = this._parent ? this._parent.index + 4 : 0;\n if (this.index == parentStart)\n return this.externalSibling(-1);\n return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n get tree() { return null; }\n toTree() {\n let children = [], positions = [];\n let { buffer } = this.context;\n let startI = this.index + 4, endI = buffer.buffer[this.index + 3];\n if (endI > startI) {\n let from = buffer.buffer[this.index + 1];\n children.push(buffer.slice(startI, endI, from));\n positions.push(0);\n }\n return new Tree(this.type, children, positions, this.to - this.from);\n }\n /**\n @internal\n */\n toString() { return this.context.buffer.childString(this.index); }\n}\nfunction iterStack(heads) {\n if (!heads.length)\n return null;\n if (heads.length == 1)\n return heads[0];\n let pick = 0, picked = heads[0];\n for (let i = 1; i < heads.length; i++) {\n let node = heads[i];\n if (node.from > picked.from || node.to < picked.to) {\n picked = node;\n pick = i;\n }\n }\n let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;\n let newHeads = heads.slice();\n if (next)\n newHeads[pick] = next;\n else\n newHeads.splice(pick, 1);\n return new StackIterator(newHeads, picked);\n}\nclass StackIterator {\n constructor(heads, node) {\n this.heads = heads;\n this.node = node;\n }\n get next() { return iterStack(this.heads); }\n}\nfunction stackIterator(tree, pos, side) {\n let inner = tree.resolveInner(pos, side), layers = null;\n for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {\n if (scan.index < 0) { // This is an overlay root\n let parent = scan.parent;\n (layers || (layers = [inner])).push(parent.resolve(pos, side));\n scan = parent;\n }\n else {\n let mount = MountedTree.get(scan.tree);\n // Relevant overlay branching off\n if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {\n let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, 0, null);\n (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));\n }\n }\n }\n return layers ? iterStack(layers) : inner;\n}\n/**\nA tree cursor object focuses on a given node in a syntax tree, and\nallows you to move to adjacent nodes.\n*/\nclass TreeCursor {\n /**\n Shorthand for `.type.name`.\n */\n get name() { return this.type.name; }\n /**\n @internal\n */\n constructor(node, \n /**\n @internal\n */\n mode = 0) {\n this.mode = mode;\n /**\n @internal\n */\n this.buffer = null;\n this.stack = [];\n /**\n @internal\n */\n this.index = 0;\n this.bufferNode = null;\n if (node instanceof TreeNode) {\n this.yieldNode(node);\n }\n else {\n this._tree = node.context.parent;\n this.buffer = node.context;\n for (let n = node._parent; n; n = n._parent)\n this.stack.unshift(n.index);\n this.bufferNode = node;\n this.yieldBuf(node.index);\n }\n }\n yieldNode(node) {\n if (!node)\n return false;\n this._tree = node;\n this.type = node.type;\n this.from = node.from;\n this.to = node.to;\n return true;\n }\n yieldBuf(index, type) {\n this.index = index;\n let { start, buffer } = this.buffer;\n this.type = type || buffer.set.types[buffer.buffer[index]];\n this.from = start + buffer.buffer[index + 1];\n this.to = start + buffer.buffer[index + 2];\n return true;\n }\n yield(node) {\n if (!node)\n return false;\n if (node instanceof TreeNode) {\n this.buffer = null;\n return this.yieldNode(node);\n }\n this.buffer = node.context;\n return this.yieldBuf(node.index, node.type);\n }\n /**\n @internal\n */\n toString() {\n return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();\n }\n /**\n @internal\n */\n enterChild(dir, pos, side) {\n if (!this.buffer)\n return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));\n let { buffer } = this.buffer;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);\n if (index < 0)\n return false;\n this.stack.push(this.index);\n return this.yieldBuf(index);\n }\n /**\n Move the cursor to this node's first child. When this returns\n false, the node has no child, and the cursor has not been moved.\n */\n firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to this node's last child.\n */\n lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to the first child that ends after `pos`.\n */\n childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }\n /**\n Move to the last child that starts before `pos`.\n */\n childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }\n /**\n Move the cursor to the child around `pos`. If side is -1 the\n child may end at that position, when 1 it may start there. This\n will also enter [overlaid](#common.MountedTree.overlay)\n [mounted](#common.NodeProp^mounted) trees unless `overlays` is\n set to false.\n */\n enter(pos, side, mode = this.mode) {\n if (!this.buffer)\n return this.yield(this._tree.enter(pos, side, mode));\n return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);\n }\n /**\n Move to the node's parent node, if this isn't the top node.\n */\n parent() {\n if (!this.buffer)\n return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);\n if (this.stack.length)\n return this.yieldBuf(this.stack.pop());\n let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();\n this.buffer = null;\n return this.yieldNode(parent);\n }\n /**\n @internal\n */\n sibling(dir) {\n if (!this.buffer)\n return !this._tree._parent ? false\n : this.yield(this._tree.index < 0 ? null\n : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));\n let { buffer } = this.buffer, d = this.stack.length - 1;\n if (dir < 0) {\n let parentStart = d < 0 ? 0 : this.stack[d] + 4;\n if (this.index != parentStart)\n return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n else {\n let after = buffer.buffer[this.index + 3];\n if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))\n return this.yieldBuf(after);\n }\n return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;\n }\n /**\n Move to this node's next sibling, if any.\n */\n nextSibling() { return this.sibling(1); }\n /**\n Move to this node's previous sibling, if any.\n */\n prevSibling() { return this.sibling(-1); }\n atLastNode(dir) {\n let index, parent, { buffer } = this;\n if (buffer) {\n if (dir > 0) {\n if (this.index < buffer.buffer.buffer.length)\n return false;\n }\n else {\n for (let i = 0; i < this.index; i++)\n if (buffer.buffer.buffer[i + 3] < this.index)\n return false;\n }\n ({ index, parent } = buffer);\n }\n else {\n ({ index, _parent: parent } = this._tree);\n }\n for (; parent; { index, _parent: parent } = parent) {\n if (index > -1)\n for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {\n let child = parent._tree.children[i];\n if ((this.mode & IterMode.IncludeAnonymous) ||\n child instanceof TreeBuffer ||\n !child.type.isAnonymous ||\n hasChild(child))\n return false;\n }\n }\n return true;\n }\n move(dir, enter) {\n if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))\n return true;\n for (;;) {\n if (this.sibling(dir))\n return true;\n if (this.atLastNode(dir) || !this.parent())\n return false;\n }\n }\n /**\n Move to the next node in a\n [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)\n traversal, going from a node to its first child or, if the\n current node is empty or `enter` is false, its next sibling or\n the next sibling of the first parent node that has one.\n */\n next(enter = true) { return this.move(1, enter); }\n /**\n Move to the next node in a last-to-first pre-order traveral. A\n node is followed by its last child or, if it has none, its\n previous sibling or the previous sibling of the first parent\n node that has one.\n */\n prev(enter = true) { return this.move(-1, enter); }\n /**\n Move the cursor to the innermost node that covers `pos`. If\n `side` is -1, it will enter nodes that end at `pos`. If it is 1,\n it will enter nodes that start at `pos`.\n */\n moveTo(pos, side = 0) {\n // Move up to a node that actually holds the position, if possible\n while (this.from == this.to ||\n (side < 1 ? this.from >= pos : this.from > pos) ||\n (side > -1 ? this.to <= pos : this.to < pos))\n if (!this.parent())\n break;\n // Then scan down into child nodes as far as possible\n while (this.enterChild(1, pos, side)) { }\n return this;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) at the cursor's current\n position.\n */\n get node() {\n if (!this.buffer)\n return this._tree;\n let cache = this.bufferNode, result = null, depth = 0;\n if (cache && cache.context == this.buffer) {\n scan: for (let index = this.index, d = this.stack.length; d >= 0;) {\n for (let c = cache; c; c = c._parent)\n if (c.index == index) {\n if (index == this.index)\n return c;\n result = c;\n depth = d + 1;\n break scan;\n }\n index = this.stack[--d];\n }\n }\n for (let i = depth; i < this.stack.length; i++)\n result = new BufferNode(this.buffer, result, this.stack[i]);\n return this.bufferNode = new BufferNode(this.buffer, result, this.index);\n }\n /**\n Get the [tree](#common.Tree) that represents the current node, if\n any. Will return null when the node is in a [tree\n buffer](#common.TreeBuffer).\n */\n get tree() {\n return this.buffer ? null : this._tree._tree;\n }\n /**\n Iterate over the current node and all its descendants, calling\n `enter` when entering a node and `leave`, if given, when leaving\n one. When `enter` returns `false`, any children of that node are\n skipped, and `leave` isn't called for it.\n */\n iterate(enter, leave) {\n for (let depth = 0;;) {\n let mustLeave = false;\n if (this.type.isAnonymous || enter(this) !== false) {\n if (this.firstChild()) {\n depth++;\n continue;\n }\n if (!this.type.isAnonymous)\n mustLeave = true;\n }\n for (;;) {\n if (mustLeave && leave)\n leave(this);\n mustLeave = this.type.isAnonymous;\n if (this.nextSibling())\n break;\n if (!depth)\n return;\n this.parent();\n depth--;\n mustLeave = true;\n }\n }\n }\n /**\n Test whether the current node matches a given context—a sequence\n of direct parent node names. Empty strings in the context array\n are treated as wildcards.\n */\n matchContext(context) {\n if (!this.buffer)\n return matchNodeContext(this.node, context);\n let { buffer } = this.buffer, { types } = buffer.set;\n for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {\n if (d < 0)\n return matchNodeContext(this.node, context, i);\n let type = types[buffer.buffer[this.stack[d]]];\n if (!type.isAnonymous) {\n if (context[i] && context[i] != type.name)\n return false;\n i--;\n }\n }\n return true;\n }\n}\nfunction hasChild(tree) {\n return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));\n}\nfunction buildTree(data) {\n var _a;\n let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;\n let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;\n let types = nodeSet.types;\n let contextHash = 0, lookAhead = 0;\n function takeNode(parentStart, minPos, children, positions, inRepeat) {\n let { id, start, end, size } = cursor;\n let lookAheadAtStart = lookAhead;\n while (size < 0) {\n cursor.next();\n if (size == -1 /* SpecialRecord.Reuse */) {\n let node = reused[id];\n children.push(node);\n positions.push(start - parentStart);\n return;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change\n contextHash = id;\n return;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n return;\n }\n else {\n throw new RangeError(`Unrecognized record size: ${size}`);\n }\n }\n let type = types[id], node, buffer;\n let startPos = start - parentStart;\n if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {\n // Small enough for a buffer, and no reused nodes inside\n let data = new Uint16Array(buffer.size - buffer.skip);\n let endPos = cursor.pos - buffer.size, index = data.length;\n while (cursor.pos > endPos)\n index = copyToBuffer(buffer.start, data, index);\n node = new TreeBuffer(data, end - buffer.start, nodeSet);\n startPos = buffer.start - parentStart;\n }\n else { // Make it a node\n let endPos = cursor.pos - size;\n cursor.next();\n let localChildren = [], localPositions = [];\n let localInRepeat = id >= minRepeatType ? id : -1;\n let lastGroup = 0, lastEnd = end;\n while (cursor.pos > endPos) {\n if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {\n if (cursor.end <= lastEnd - maxBufferLength) {\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);\n lastGroup = localChildren.length;\n lastEnd = cursor.end;\n }\n cursor.next();\n }\n else {\n takeNode(start, endPos, localChildren, localPositions, localInRepeat);\n }\n }\n if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);\n localChildren.reverse();\n localPositions.reverse();\n if (localInRepeat > -1 && lastGroup > 0) {\n let make = makeBalanced(type);\n node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);\n }\n else {\n node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);\n }\n }\n children.push(node);\n positions.push(startPos);\n }\n function makeBalanced(type) {\n return (children, positions, length) => {\n let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;\n if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {\n if (!lastI && last.type == type && last.length == length)\n return last;\n if (lookAheadProp = last.prop(NodeProp.lookAhead))\n lookAhead = positions[lastI] + last.length + lookAheadProp;\n }\n return makeTree(type, children, positions, length, lookAhead);\n };\n }\n function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {\n let localChildren = [], localPositions = [];\n while (children.length > i) {\n localChildren.push(children.pop());\n localPositions.push(positions.pop() + base - from);\n }\n children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));\n positions.push(from - base);\n }\n function makeTree(type, children, positions, length, lookAhead = 0, props) {\n if (contextHash) {\n let pair = [NodeProp.contextHash, contextHash];\n props = props ? [pair].concat(props) : [pair];\n }\n if (lookAhead > 25) {\n let pair = [NodeProp.lookAhead, lookAhead];\n props = props ? [pair].concat(props) : [pair];\n }\n return new Tree(type, children, positions, length, props);\n }\n function findBufferSize(maxSize, inRepeat) {\n // Scan through the buffer to find previous siblings that fit\n // together in a TreeBuffer, and don't contain any reused nodes\n // (which can't be stored in a buffer).\n // If `inRepeat` is > -1, ignore node boundaries of that type for\n // nesting, but make sure the end falls either at the start\n // (`maxSize`) or before such a node.\n let fork = cursor.fork();\n let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;\n let result = { size: 0, start: 0, skip: 0 };\n scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {\n let nodeSize = fork.size;\n // Pretend nested repeat nodes of the same type don't exist\n if (fork.id == inRepeat && nodeSize >= 0) {\n // Except that we store the current state as a valid return\n // value.\n result.size = size;\n result.start = start;\n result.skip = skip;\n skip += 4;\n size += 4;\n fork.next();\n continue;\n }\n let startPos = fork.pos - nodeSize;\n if (nodeSize < 0 || startPos < minPos || fork.start < minStart)\n break;\n let localSkipped = fork.id >= minRepeatType ? 4 : 0;\n let nodeStart = fork.start;\n fork.next();\n while (fork.pos > startPos) {\n if (fork.size < 0) {\n if (fork.size == -3 /* SpecialRecord.ContextChange */)\n localSkipped += 4;\n else\n break scan;\n }\n else if (fork.id >= minRepeatType) {\n localSkipped += 4;\n }\n fork.next();\n }\n start = nodeStart;\n size += nodeSize;\n skip += localSkipped;\n }\n if (inRepeat < 0 || size == maxSize) {\n result.size = size;\n result.start = start;\n result.skip = skip;\n }\n return result.size > 4 ? result : undefined;\n }\n function copyToBuffer(bufferStart, buffer, index) {\n let { id, start, end, size } = cursor;\n cursor.next();\n if (size >= 0 && id < minRepeatType) {\n let startIndex = index;\n if (size > 4) {\n let endPos = cursor.pos - (size - 4);\n while (cursor.pos > endPos)\n index = copyToBuffer(bufferStart, buffer, index);\n }\n buffer[--index] = startIndex;\n buffer[--index] = end - bufferStart;\n buffer[--index] = start - bufferStart;\n buffer[--index] = id;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) {\n contextHash = id;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n }\n return index;\n }\n let children = [], positions = [];\n while (cursor.pos > 0)\n takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);\n let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);\n return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);\n}\nconst nodeSizeCache = new WeakMap;\nfunction nodeSize(balanceType, node) {\n if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)\n return 1;\n let size = nodeSizeCache.get(node);\n if (size == null) {\n size = 1;\n for (let child of node.children) {\n if (child.type != balanceType || !(child instanceof Tree)) {\n size = 1;\n break;\n }\n size += nodeSize(balanceType, child);\n }\n nodeSizeCache.set(node, size);\n }\n return size;\n}\nfunction balanceRange(\n// The type the balanced tree's inner nodes.\nbalanceType, \n// The direct children and their positions\nchildren, positions, \n// The index range in children/positions to use\nfrom, to, \n// The start position of the nodes, relative to their parent.\nstart, \n// Length of the outer node\nlength, \n// Function to build the top node of the balanced tree\nmkTop, \n// Function to build internal nodes for the balanced tree\nmkTree) {\n let total = 0;\n for (let i = from; i < to; i++)\n total += nodeSize(balanceType, children[i]);\n let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);\n let localChildren = [], localPositions = [];\n function divide(children, positions, from, to, offset) {\n for (let i = from; i < to;) {\n let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);\n i++;\n for (; i < to; i++) {\n let nextSize = nodeSize(balanceType, children[i]);\n if (groupSize + nextSize >= maxChild)\n break;\n groupSize += nextSize;\n }\n if (i == groupFrom + 1) {\n if (groupSize > maxChild) {\n let only = children[groupFrom]; // Only trees can have a size > 1\n divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);\n continue;\n }\n localChildren.push(children[groupFrom]);\n }\n else {\n let length = positions[i - 1] + children[i - 1].length - groupStart;\n localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));\n }\n localPositions.push(groupStart + offset - start);\n }\n }\n divide(children, positions, from, to, 0);\n return (mkTop || mkTree)(localChildren, localPositions, length);\n}\n/**\nProvides a way to associate values with pieces of trees. As long\nas that part of the tree is reused, the associated values can be\nretrieved from an updated tree.\n*/\nclass NodeWeakMap {\n constructor() {\n this.map = new WeakMap();\n }\n setBuffer(buffer, index, value) {\n let inner = this.map.get(buffer);\n if (!inner)\n this.map.set(buffer, inner = new Map);\n inner.set(index, value);\n }\n getBuffer(buffer, index) {\n let inner = this.map.get(buffer);\n return inner && inner.get(index);\n }\n /**\n Set the value for this syntax node.\n */\n set(node, value) {\n if (node instanceof BufferNode)\n this.setBuffer(node.context.buffer, node.index, value);\n else if (node instanceof TreeNode)\n this.map.set(node.tree, value);\n }\n /**\n Retrieve value for this syntax node, if it exists in the map.\n */\n get(node) {\n return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)\n : node instanceof TreeNode ? this.map.get(node.tree) : undefined;\n }\n /**\n Set the value for the node that a cursor currently points to.\n */\n cursorSet(cursor, value) {\n if (cursor.buffer)\n this.setBuffer(cursor.buffer.buffer, cursor.index, value);\n else\n this.map.set(cursor.tree, value);\n }\n /**\n Retrieve the value for the node that a cursor currently points\n to.\n */\n cursorGet(cursor) {\n return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);\n }\n}\n\n/**\nTree fragments are used during [incremental\nparsing](#common.Parser.startParse) to track parts of old trees\nthat can be reused in a new parse. An array of fragments is used\nto track regions of an old tree whose nodes might be reused in new\nparses. Use the static\n[`applyChanges`](#common.TreeFragment^applyChanges) method to\nupdate fragments for document changes.\n*/\nclass TreeFragment {\n /**\n Construct a tree fragment. You'll usually want to use\n [`addTree`](#common.TreeFragment^addTree) and\n [`applyChanges`](#common.TreeFragment^applyChanges) instead of\n calling this directly.\n */\n constructor(\n /**\n The start of the unchanged range pointed to by this fragment.\n This refers to an offset in the _updated_ document (as opposed\n to the original tree).\n */\n from, \n /**\n The end of the unchanged range.\n */\n to, \n /**\n The tree that this fragment is based on.\n */\n tree, \n /**\n The offset between the fragment's tree and the document that\n this fragment can be used against. Add this when going from\n document to tree positions, subtract it to go from tree to\n document positions.\n */\n offset, openStart = false, openEnd = false) {\n this.from = from;\n this.to = to;\n this.tree = tree;\n this.offset = offset;\n this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);\n }\n /**\n Whether the start of the fragment represents the start of a\n parse, or the end of a change. (In the second case, it may not\n be safe to reuse some nodes at the start, depending on the\n parsing algorithm.)\n */\n get openStart() { return (this.open & 1 /* Open.Start */) > 0; }\n /**\n Whether the end of the fragment represents the end of a\n full-document parse, or the start of a change.\n */\n get openEnd() { return (this.open & 2 /* Open.End */) > 0; }\n /**\n Create a set of fragments from a freshly parsed tree, or update\n an existing set of fragments by replacing the ones that overlap\n with a tree with content from the new tree. When `partial` is\n true, the parse is treated as incomplete, and the resulting\n fragment has [`openEnd`](#common.TreeFragment.openEnd) set to\n true.\n */\n static addTree(tree, fragments = [], partial = false) {\n let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];\n for (let f of fragments)\n if (f.to > tree.length)\n result.push(f);\n return result;\n }\n /**\n Apply a set of edits to an array of fragments, removing or\n splitting fragments as necessary to remove edited ranges, and\n adjusting offsets for fragments that moved.\n */\n static applyChanges(fragments, changes, minGap = 128) {\n if (!changes.length)\n return fragments;\n let result = [];\n let fI = 1, nextF = fragments.length ? fragments[0] : null;\n for (let cI = 0, pos = 0, off = 0;; cI++) {\n let nextC = cI < changes.length ? changes[cI] : null;\n let nextPos = nextC ? nextC.fromA : 1e9;\n if (nextPos - pos >= minGap)\n while (nextF && nextF.from < nextPos) {\n let cut = nextF;\n if (pos >= cut.from || nextPos <= cut.to || off) {\n let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;\n cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);\n }\n if (cut)\n result.push(cut);\n if (nextF.to > nextPos)\n break;\n nextF = fI < fragments.length ? fragments[fI++] : null;\n }\n if (!nextC)\n break;\n pos = nextC.toA;\n off = nextC.toA - nextC.toB;\n }\n return result;\n }\n}\n/**\nA superclass that parsers should extend.\n*/\nclass Parser {\n /**\n Start a parse, returning a [partial parse](#common.PartialParse)\n object. [`fragments`](#common.TreeFragment) can be passed in to\n make the parse incremental.\n \n By default, the entire input is parsed. You can pass `ranges`,\n which should be a sorted array of non-empty, non-overlapping\n ranges, to parse only those ranges. The tree returned in that\n case will start at `ranges[0].from`.\n */\n startParse(input, fragments, ranges) {\n if (typeof input == \"string\")\n input = new StringInput(input);\n ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map(r => new Range(r.from, r.to)) : [new Range(0, 0)];\n return this.createParse(input, fragments || [], ranges);\n }\n /**\n Run a full parse, returning the resulting tree.\n */\n parse(input, fragments, ranges) {\n let parse = this.startParse(input, fragments, ranges);\n for (;;) {\n let done = parse.advance();\n if (done)\n return done;\n }\n }\n}\nclass StringInput {\n constructor(string) {\n this.string = string;\n }\n get length() { return this.string.length; }\n chunk(from) { return this.string.slice(from); }\n get lineChunks() { return false; }\n read(from, to) { return this.string.slice(from, to); }\n}\n\n/**\nCreate a parse wrapper that, after the inner parse completes,\nscans its tree for mixed language regions with the `nest`\nfunction, runs the resulting [inner parses](#common.NestedParse),\nand then [mounts](#common.NodeProp^mounted) their results onto the\ntree.\n*/\nfunction parseMixed(nest) {\n return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);\n}\nclass InnerParse {\n constructor(parser, parse, overlay, target, ranges) {\n this.parser = parser;\n this.parse = parse;\n this.overlay = overlay;\n this.target = target;\n this.ranges = ranges;\n if (!ranges.length || ranges.some(r => r.from >= r.to))\n throw new RangeError(\"Invalid inner parse ranges given: \" + JSON.stringify(ranges));\n }\n}\nclass ActiveOverlay {\n constructor(parser, predicate, mounts, index, start, target, prev) {\n this.parser = parser;\n this.predicate = predicate;\n this.mounts = mounts;\n this.index = index;\n this.start = start;\n this.target = target;\n this.prev = prev;\n this.depth = 0;\n this.ranges = [];\n }\n}\nconst stoppedInner = new NodeProp({ perNode: true });\nclass MixedParse {\n constructor(base, nest, input, fragments, ranges) {\n this.nest = nest;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.inner = [];\n this.innerDone = 0;\n this.baseTree = null;\n this.stoppedAt = null;\n this.baseParse = base;\n }\n advance() {\n if (this.baseParse) {\n let done = this.baseParse.advance();\n if (!done)\n return null;\n this.baseParse = null;\n this.baseTree = done;\n this.startInner();\n if (this.stoppedAt != null)\n for (let inner of this.inner)\n inner.parse.stopAt(this.stoppedAt);\n }\n if (this.innerDone == this.inner.length) {\n let result = this.baseTree;\n if (this.stoppedAt != null)\n result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));\n return result;\n }\n let inner = this.inner[this.innerDone], done = inner.parse.advance();\n if (done) {\n this.innerDone++;\n // This is a somewhat dodgy but super helpful hack where we\n // patch up nodes created by the inner parse (and thus\n // presumably not aliased anywhere else) to hold the information\n // about the inner parse.\n let props = Object.assign(Object.create(null), inner.target.props);\n props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser);\n inner.target.props = props;\n }\n return null;\n }\n get parsedPos() {\n if (this.baseParse)\n return 0;\n let pos = this.input.length;\n for (let i = this.innerDone; i < this.inner.length; i++) {\n if (this.inner[i].ranges[0].from < pos)\n pos = Math.min(pos, this.inner[i].parse.parsedPos);\n }\n return pos;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n if (this.baseParse)\n this.baseParse.stopAt(pos);\n else\n for (let i = this.innerDone; i < this.inner.length; i++)\n this.inner[i].parse.stopAt(pos);\n }\n startInner() {\n let fragmentCursor = new FragmentCursor(this.fragments);\n let overlay = null;\n let covered = null;\n let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n scan: for (let nest, isCovered; this.stoppedAt == null || cursor.from < this.stoppedAt;) {\n let enter = true, range;\n if (fragmentCursor.hasNode(cursor)) {\n if (overlay) {\n let match = overlay.mounts.find(m => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);\n if (match)\n for (let r of match.mount.overlay) {\n let from = r.from + match.pos, to = r.to + match.pos;\n if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some(r => r.from < to && r.to > from))\n overlay.ranges.push({ from, to });\n }\n }\n enter = false;\n }\n else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) {\n enter = isCovered != 2 /* Cover.Full */;\n }\n else if (!cursor.type.isAnonymous && cursor.from < cursor.to && (nest = this.nest(cursor, this.input))) {\n if (!cursor.tree)\n materialize(cursor);\n let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);\n if (typeof nest.overlay == \"function\") {\n overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, cursor.tree, overlay);\n }\n else {\n let ranges = punchRanges(this.ranges, nest.overlay || [new Range(cursor.from, cursor.to)]);\n if (ranges.length)\n this.inner.push(new InnerParse(nest.parser, nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges), nest.overlay ? nest.overlay.map(r => new Range(r.from - cursor.from, r.to - cursor.from)) : null, cursor.tree, ranges));\n if (!nest.overlay)\n enter = false;\n else if (ranges.length)\n covered = { ranges, depth: 0, prev: covered };\n }\n }\n else if (overlay && (range = overlay.predicate(cursor))) {\n if (range === true)\n range = new Range(cursor.from, cursor.to);\n if (range.from < range.to)\n overlay.ranges.push(range);\n }\n if (enter && cursor.firstChild()) {\n if (overlay)\n overlay.depth++;\n if (covered)\n covered.depth++;\n }\n else {\n for (;;) {\n if (cursor.nextSibling())\n break;\n if (!cursor.parent())\n break scan;\n if (overlay && !--overlay.depth) {\n let ranges = punchRanges(this.ranges, overlay.ranges);\n if (ranges.length)\n this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map(r => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.target, ranges));\n overlay = overlay.prev;\n }\n if (covered && !--covered.depth)\n covered = covered.prev;\n }\n }\n }\n }\n}\nfunction checkCover(covered, from, to) {\n for (let range of covered) {\n if (range.from >= to)\n break;\n if (range.to > from)\n return range.from <= from && range.to >= to ? 2 /* Cover.Full */ : 1 /* Cover.Partial */;\n }\n return 0 /* Cover.None */;\n}\n// Take a piece of buffer and convert it into a stand-alone\n// TreeBuffer.\nfunction sliceBuf(buf, startI, endI, nodes, positions, off) {\n if (startI < endI) {\n let from = buf.buffer[startI + 1];\n nodes.push(buf.slice(startI, endI, from));\n positions.push(from - off);\n }\n}\n// This function takes a node that's in a buffer, and converts it, and\n// its parent buffer nodes, into a Tree. This is again acting on the\n// assumption that the trees and buffers have been constructed by the\n// parse that was ran via the mix parser, and thus aren't shared with\n// any other code, making violations of the immutability safe.\nfunction materialize(cursor) {\n let { node } = cursor, depth = 0;\n // Scan up to the nearest tree\n do {\n cursor.parent();\n depth++;\n } while (!cursor.tree);\n // Find the index of the buffer in that tree\n let i = 0, base = cursor.tree, off = 0;\n for (;; i++) {\n off = base.positions[i] + cursor.from;\n if (off <= node.from && off + base.children[i].length >= node.to)\n break;\n }\n let buf = base.children[i], b = buf.buffer;\n // Split a level in the buffer, putting the nodes before and after\n // the child that contains `node` into new buffers.\n function split(startI, endI, type, innerOffset, length) {\n let i = startI;\n while (b[i + 2] + off <= node.from)\n i = b[i + 3];\n let children = [], positions = [];\n sliceBuf(buf, startI, i, children, positions, innerOffset);\n let from = b[i + 1], to = b[i + 2];\n let isTarget = from + off == node.from && to + off == node.to && b[i] == node.type.id;\n children.push(isTarget ? node.toTree() : split(i + 4, b[i + 3], buf.set.types[b[i]], from, to - from));\n positions.push(from - innerOffset);\n sliceBuf(buf, b[i + 3], endI, children, positions, innerOffset);\n return new Tree(type, children, positions, length);\n }\n base.children[i] = split(0, b.length, NodeType.none, 0, buf.length);\n // Move the cursor back to the target node\n for (let d = 0; d <= depth; d++)\n cursor.childAfter(node.from);\n}\nclass StructureCursor {\n constructor(root, offset) {\n this.offset = offset;\n this.done = false;\n this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n }\n // Move to the first node (in pre-order) that starts at or after `pos`.\n moveTo(pos) {\n let { cursor } = this, p = pos - this.offset;\n while (!this.done && cursor.from < p) {\n if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;\n else if (!cursor.next(false))\n this.done = true;\n }\n }\n hasNode(cursor) {\n this.moveTo(cursor.from);\n if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) {\n for (let tree = this.cursor.tree;;) {\n if (tree == cursor.tree)\n return true;\n if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree)\n tree = tree.children[0];\n else\n break;\n }\n }\n return false;\n }\n}\nclass FragmentCursor {\n constructor(fragments) {\n var _a;\n this.fragments = fragments;\n this.curTo = 0;\n this.fragI = 0;\n if (fragments.length) {\n let first = this.curFrag = fragments[0];\n this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;\n this.inner = new StructureCursor(first.tree, -first.offset);\n }\n else {\n this.curFrag = this.inner = null;\n }\n }\n hasNode(node) {\n while (this.curFrag && node.from >= this.curTo)\n this.nextFrag();\n return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);\n }\n nextFrag() {\n var _a;\n this.fragI++;\n if (this.fragI == this.fragments.length) {\n this.curFrag = this.inner = null;\n }\n else {\n let frag = this.curFrag = this.fragments[this.fragI];\n this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;\n this.inner = new StructureCursor(frag.tree, -frag.offset);\n }\n }\n findMounts(pos, parser) {\n var _a;\n let result = [];\n if (this.inner) {\n this.inner.cursor.moveTo(pos, 1);\n for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {\n let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);\n if (mount && mount.parser == parser) {\n for (let i = this.fragI; i < this.fragments.length; i++) {\n let frag = this.fragments[i];\n if (frag.from >= pos.to)\n break;\n if (frag.tree == this.curFrag.tree)\n result.push({\n frag,\n pos: pos.from - frag.offset,\n mount\n });\n }\n }\n }\n }\n return result;\n }\n}\nfunction punchRanges(outer, ranges) {\n let copy = null, current = ranges;\n for (let i = 1, j = 0; i < outer.length; i++) {\n let gapFrom = outer[i - 1].to, gapTo = outer[i].from;\n for (; j < current.length; j++) {\n let r = current[j];\n if (r.from >= gapTo)\n break;\n if (r.to <= gapFrom)\n continue;\n if (!copy)\n current = copy = ranges.slice();\n if (r.from < gapFrom) {\n copy[j] = new Range(r.from, gapFrom);\n if (r.to > gapTo)\n copy.splice(j + 1, 0, new Range(gapTo, r.to));\n }\n else if (r.to > gapTo) {\n copy[j--] = new Range(gapTo, r.to);\n }\n else {\n copy.splice(j--, 1);\n }\n }\n }\n return current;\n}\nfunction findCoverChanges(a, b, from, to) {\n let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;\n let result = [];\n for (;;) {\n let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;\n let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;\n if (inA != inB) {\n let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);\n if (start < end)\n result.push(new Range(start, end));\n }\n pos = Math.min(nextA, nextB);\n if (pos == 1e9)\n break;\n if (nextA == pos) {\n if (!inA)\n inA = true;\n else {\n inA = false;\n iA++;\n }\n }\n if (nextB == pos) {\n if (!inB)\n inB = true;\n else {\n inB = false;\n iB++;\n }\n }\n }\n return result;\n}\n// Given a number of fragments for the outer tree, and a set of ranges\n// to parse, find fragments for inner trees mounted around those\n// ranges, if any.\nfunction enterFragments(mounts, ranges) {\n let result = [];\n for (let { pos, mount, frag } of mounts) {\n let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;\n let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);\n if (mount.overlay) {\n let overlay = mount.overlay.map(r => new Range(r.from + pos, r.to + pos));\n let changes = findCoverChanges(ranges, overlay, from, to);\n for (let i = 0, pos = from;; i++) {\n let last = i == changes.length, end = last ? to : changes[i].from;\n if (end > pos)\n result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));\n if (last)\n break;\n pos = changes[i].to;\n }\n }\n else {\n result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));\n }\n }\n return result;\n}\n\nexport { DefaultBufferLength, IterMode, MountedTree, NodeProp, NodeSet, NodeType, NodeWeakMap, Parser, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };\n","import { NodeProp } from '@lezer/common';\n\nlet nextTagID = 0;\n/**\nHighlighting tags are markers that denote a highlighting category.\nThey are [associated](#highlight.styleTags) with parts of a syntax\ntree by a language mode, and then mapped to an actual CSS style by\na [highlighter](#highlight.Highlighter).\n\nBecause syntax tree node types and highlight styles have to be\nable to talk the same language, CodeMirror uses a mostly _closed_\n[vocabulary](#highlight.tags) of syntax tags (as opposed to\ntraditional open string-based systems, which make it hard for\nhighlighting themes to cover all the tokens produced by the\nvarious languages).\n\nIt _is_ possible to [define](#highlight.Tag^define) your own\nhighlighting tags for system-internal use (where you control both\nthe language package and the highlighter), but such tags will not\nbe picked up by regular highlighters (though you can derive them\nfrom standard tags to allow highlighters to fall back to those).\n*/\nclass Tag {\n /**\n @internal\n */\n constructor(\n /**\n The set of this tag and all its parent tags, starting with\n this one itself and sorted in order of decreasing specificity.\n */\n set, \n /**\n The base unmodified tag that this one is based on, if it's\n modified @internal\n */\n base, \n /**\n The modifiers applied to this.base @internal\n */\n modified) {\n this.set = set;\n this.base = base;\n this.modified = modified;\n /**\n @internal\n */\n this.id = nextTagID++;\n }\n /**\n Define a new tag. If `parent` is given, the tag is treated as a\n sub-tag of that parent, and\n [highlighters](#highlight.tagHighlighter) that don't mention\n this tag will try to fall back to the parent tag (or grandparent\n tag, etc).\n */\n static define(parent) {\n if (parent === null || parent === void 0 ? void 0 : parent.base)\n throw new Error(\"Can not derive from a modified tag\");\n let tag = new Tag([], null, []);\n tag.set.push(tag);\n if (parent)\n for (let t of parent.set)\n tag.set.push(t);\n return tag;\n }\n /**\n Define a tag _modifier_, which is a function that, given a tag,\n will return a tag that is a subtag of the original. Applying the\n same modifier to a twice tag will return the same value (`m1(t1)\n == m1(t1)`) and applying multiple modifiers will, regardless or\n order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).\n \n When multiple modifiers are applied to a given base tag, each\n smaller set of modifiers is registered as a parent, so that for\n example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,\n `m1(m3(t1)`, and so on.\n */\n static defineModifier() {\n let mod = new Modifier;\n return (tag) => {\n if (tag.modified.indexOf(mod) > -1)\n return tag;\n return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));\n };\n }\n}\nlet nextModifierID = 0;\nclass Modifier {\n constructor() {\n this.instances = [];\n this.id = nextModifierID++;\n }\n static get(base, mods) {\n if (!mods.length)\n return base;\n let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));\n if (exists)\n return exists;\n let set = [], tag = new Tag(set, base, mods);\n for (let m of mods)\n m.instances.push(tag);\n let configs = powerSet(mods);\n for (let parent of base.set)\n if (!parent.modified.length)\n for (let config of configs)\n set.push(Modifier.get(parent, config));\n return tag;\n }\n}\nfunction sameArray(a, b) {\n return a.length == b.length && a.every((x, i) => x == b[i]);\n}\nfunction powerSet(array) {\n let sets = [[]];\n for (let i = 0; i < array.length; i++) {\n for (let j = 0, e = sets.length; j < e; j++) {\n sets.push(sets[j].concat(array[i]));\n }\n }\n return sets.sort((a, b) => b.length - a.length);\n}\n/**\nThis function is used to add a set of tags to a language syntax\nvia [`NodeSet.extend`](#common.NodeSet.extend) or\n[`LRParser.configure`](#lr.LRParser.configure).\n\nThe argument object maps node selectors to [highlighting\ntags](#highlight.Tag) or arrays of tags.\n\nNode selectors may hold one or more (space-separated) node paths.\nSuch a path can be a [node name](#common.NodeType.name), or\nmultiple node names (or `*` wildcards) separated by slash\ncharacters, as in `\"Block/Declaration/VariableName\"`. Such a path\nmatches the final node but only if its direct parent nodes are the\nother nodes mentioned. A `*` in such a path matches any parent,\nbut only a single level—wildcards that match multiple parents\naren't supported, both for efficiency reasons and because Lezer\ntrees make it rather hard to reason about what they would match.)\n\nA path can be ended with `/...` to indicate that the tag assigned\nto the node should also apply to all child nodes, even if they\nmatch their own style (by default, only the innermost style is\nused).\n\nWhen a path ends in `!`, as in `Attribute!`, no further matching\nhappens for the node's child nodes, and the entire node gets the\ngiven style.\n\nIn this notation, node names that contain `/`, `!`, `*`, or `...`\nmust be quoted as JSON strings.\n\nFor example:\n\n```javascript\nparser.withProps(\n styleTags({\n // Style Number and BigNumber nodes\n \"Number BigNumber\": tags.number,\n // Style Escape nodes whose parent is String\n \"String/Escape\": tags.escape,\n // Style anything inside Attributes nodes\n \"Attributes!\": tags.meta,\n // Add a style to all content inside Italic nodes\n \"Italic/...\": tags.emphasis,\n // Style InvalidString nodes as both `string` and `invalid`\n \"InvalidString\": [tags.string, tags.invalid],\n // Style the node named \"/\" as punctuation\n '\"/\"': tags.punctuation\n })\n)\n```\n*/\nfunction styleTags(spec) {\n let byName = Object.create(null);\n for (let prop in spec) {\n let tags = spec[prop];\n if (!Array.isArray(tags))\n tags = [tags];\n for (let part of prop.split(\" \"))\n if (part) {\n let pieces = [], mode = 2 /* Normal */, rest = part;\n for (let pos = 0;;) {\n if (rest == \"...\" && pos > 0 && pos + 3 == part.length) {\n mode = 1 /* Inherit */;\n break;\n }\n let m = /^\"(?:[^\"\\\\]|\\\\.)*?\"|[^\\/!]+/.exec(rest);\n if (!m)\n throw new RangeError(\"Invalid path: \" + part);\n pieces.push(m[0] == \"*\" ? \"\" : m[0][0] == '\"' ? JSON.parse(m[0]) : m[0]);\n pos += m[0].length;\n if (pos == part.length)\n break;\n let next = part[pos++];\n if (pos == part.length && next == \"!\") {\n mode = 0 /* Opaque */;\n break;\n }\n if (next != \"/\")\n throw new RangeError(\"Invalid path: \" + part);\n rest = part.slice(pos);\n }\n let last = pieces.length - 1, inner = pieces[last];\n if (!inner)\n throw new RangeError(\"Invalid path: \" + part);\n let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);\n byName[inner] = rule.sort(byName[inner]);\n }\n }\n return ruleNodeProp.add(byName);\n}\nconst ruleNodeProp = new NodeProp();\nclass Rule {\n constructor(tags, mode, context, next) {\n this.tags = tags;\n this.mode = mode;\n this.context = context;\n this.next = next;\n }\n get opaque() { return this.mode == 0 /* Opaque */; }\n get inherit() { return this.mode == 1 /* Inherit */; }\n sort(other) {\n if (!other || other.depth < this.depth) {\n this.next = other;\n return this;\n }\n other.next = this.sort(other.next);\n return other;\n }\n get depth() { return this.context ? this.context.length : 0; }\n}\nRule.empty = new Rule([], 2 /* Normal */, null);\n/**\nDefine a [highlighter](#highlight.Highlighter) from an array of\ntag/class pairs. Classes associated with more specific tags will\ntake precedence.\n*/\nfunction tagHighlighter(tags, options) {\n let map = Object.create(null);\n for (let style of tags) {\n if (!Array.isArray(style.tag))\n map[style.tag.id] = style.class;\n else\n for (let tag of style.tag)\n map[tag.id] = style.class;\n }\n let { scope, all = null } = options || {};\n return {\n style: (tags) => {\n let cls = all;\n for (let tag of tags) {\n for (let sub of tag.set) {\n let tagClass = map[sub.id];\n if (tagClass) {\n cls = cls ? cls + \" \" + tagClass : tagClass;\n break;\n }\n }\n }\n return cls;\n },\n scope\n };\n}\nfunction highlightTags(highlighters, tags) {\n let result = null;\n for (let highlighter of highlighters) {\n let value = highlighter.style(tags);\n if (value)\n result = result ? result + \" \" + value : value;\n }\n return result;\n}\n/**\nHighlight the given [tree](#common.Tree) with the given\n[highlighter](#highlight.Highlighter).\n*/\nfunction highlightTree(tree, highlighter, \n/**\nAssign styling to a region of the text. Will be called, in order\nof position, for any ranges where more than zero classes apply.\n`classes` is a space separated string of CSS classes.\n*/\nputStyle, \n/**\nThe start of the range to highlight.\n*/\nfrom = 0, \n/**\nThe end of the range.\n*/\nto = tree.length) {\n let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);\n builder.highlightRange(tree.cursor(), from, to, \"\", builder.highlighters);\n builder.flush(to);\n}\nclass HighlightBuilder {\n constructor(at, highlighters, span) {\n this.at = at;\n this.highlighters = highlighters;\n this.span = span;\n this.class = \"\";\n }\n startSpan(at, cls) {\n if (cls != this.class) {\n this.flush(at);\n if (at > this.at)\n this.at = at;\n this.class = cls;\n }\n }\n flush(to) {\n if (to > this.at && this.class)\n this.span(this.at, to, this.class);\n }\n highlightRange(cursor, from, to, inheritedClass, highlighters) {\n let { type, from: start, to: end } = cursor;\n if (start >= to || end <= from)\n return;\n if (type.isTop)\n highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));\n let cls = inheritedClass;\n let rule = getStyleTags(cursor) || Rule.empty;\n let tagCls = highlightTags(highlighters, rule.tags);\n if (tagCls) {\n if (cls)\n cls += \" \";\n cls += tagCls;\n if (rule.mode == 1 /* Inherit */)\n inheritedClass += (inheritedClass ? \" \" : \"\") + tagCls;\n }\n this.startSpan(Math.max(from, start), cls);\n if (rule.opaque)\n return;\n let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);\n if (mounted && mounted.overlay) {\n let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);\n let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));\n let hasChild = cursor.firstChild();\n for (let i = 0, pos = start;; i++) {\n let next = i < mounted.overlay.length ? mounted.overlay[i] : null;\n let nextPos = next ? next.from + start : end;\n let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);\n if (rangeFrom < rangeTo && hasChild) {\n while (cursor.from < rangeTo) {\n this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);\n this.startSpan(Math.min(rangeTo, cursor.to), cls);\n if (cursor.to >= nextPos || !cursor.nextSibling())\n break;\n }\n }\n if (!next || nextPos > to)\n break;\n pos = next.to + start;\n if (pos > from) {\n this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), \"\", innerHighlighters);\n this.startSpan(Math.min(to, pos), cls);\n }\n }\n if (hasChild)\n cursor.parent();\n }\n else if (cursor.firstChild()) {\n if (mounted)\n inheritedClass = \"\";\n do {\n if (cursor.to <= from)\n continue;\n if (cursor.from >= to)\n break;\n this.highlightRange(cursor, from, to, inheritedClass, highlighters);\n this.startSpan(Math.min(to, cursor.to), cls);\n } while (cursor.nextSibling());\n cursor.parent();\n }\n }\n}\n/**\nMatch a syntax node's [highlight rules](#highlight.styleTags). If\nthere's a match, return its set of tags, and whether it is\nopaque (uses a `!`) or applies to all child nodes (`/...`).\n*/\nfunction getStyleTags(node) {\n let rule = node.type.prop(ruleNodeProp);\n while (rule && rule.context && !node.matchContext(rule.context))\n rule = rule.next;\n return rule || null;\n}\nconst t = Tag.define;\nconst comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();\n/**\nThe default set of highlighting [tags](#highlight.Tag).\n\nThis collection is heavily biased towards programming languages,\nand necessarily incomplete. A full ontology of syntactic\nconstructs would fill a stack of books, and be impractical to\nwrite themes for. So try to make do with this set. If all else\nfails, [open an\nissue](https://github.com/codemirror/codemirror.next) to propose a\nnew tag, or [define](#highlight.Tag^define) a local custom tag for\nyour use case.\n\nNote that it is not obligatory to always attach the most specific\ntag possible to an element—if your grammar can't easily\ndistinguish a certain type of element (such as a local variable),\nit is okay to style it as its more general variant (a variable).\n\nFor tags that extend some parent tag, the documentation links to\nthe parent.\n*/\nconst tags = {\n /**\n A comment.\n */\n comment,\n /**\n A line [comment](#highlight.tags.comment).\n */\n lineComment: t(comment),\n /**\n A block [comment](#highlight.tags.comment).\n */\n blockComment: t(comment),\n /**\n A documentation [comment](#highlight.tags.comment).\n */\n docComment: t(comment),\n /**\n Any kind of identifier.\n */\n name,\n /**\n The [name](#highlight.tags.name) of a variable.\n */\n variableName: t(name),\n /**\n A type [name](#highlight.tags.name).\n */\n typeName: typeName,\n /**\n A tag name (subtag of [`typeName`](#highlight.tags.typeName)).\n */\n tagName: t(typeName),\n /**\n A property or field [name](#highlight.tags.name).\n */\n propertyName: propertyName,\n /**\n An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).\n */\n attributeName: t(propertyName),\n /**\n The [name](#highlight.tags.name) of a class.\n */\n className: t(name),\n /**\n A label [name](#highlight.tags.name).\n */\n labelName: t(name),\n /**\n A namespace [name](#highlight.tags.name).\n */\n namespace: t(name),\n /**\n The [name](#highlight.tags.name) of a macro.\n */\n macroName: t(name),\n /**\n A literal value.\n */\n literal,\n /**\n A string [literal](#highlight.tags.literal).\n */\n string,\n /**\n A documentation [string](#highlight.tags.string).\n */\n docString: t(string),\n /**\n A character literal (subtag of [string](#highlight.tags.string)).\n */\n character: t(string),\n /**\n An attribute value (subtag of [string](#highlight.tags.string)).\n */\n attributeValue: t(string),\n /**\n A number [literal](#highlight.tags.literal).\n */\n number,\n /**\n An integer [number](#highlight.tags.number) literal.\n */\n integer: t(number),\n /**\n A floating-point [number](#highlight.tags.number) literal.\n */\n float: t(number),\n /**\n A boolean [literal](#highlight.tags.literal).\n */\n bool: t(literal),\n /**\n Regular expression [literal](#highlight.tags.literal).\n */\n regexp: t(literal),\n /**\n An escape [literal](#highlight.tags.literal), for example a\n backslash escape in a string.\n */\n escape: t(literal),\n /**\n A color [literal](#highlight.tags.literal).\n */\n color: t(literal),\n /**\n A URL [literal](#highlight.tags.literal).\n */\n url: t(literal),\n /**\n A language keyword.\n */\n keyword,\n /**\n The [keyword](#highlight.tags.keyword) for the self or this\n object.\n */\n self: t(keyword),\n /**\n The [keyword](#highlight.tags.keyword) for null.\n */\n null: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) denoting some atomic value.\n */\n atom: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that represents a unit.\n */\n unit: t(keyword),\n /**\n A modifier [keyword](#highlight.tags.keyword).\n */\n modifier: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that acts as an operator.\n */\n operatorKeyword: t(keyword),\n /**\n A control-flow related [keyword](#highlight.tags.keyword).\n */\n controlKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that defines something.\n */\n definitionKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) related to defining or\n interfacing with modules.\n */\n moduleKeyword: t(keyword),\n /**\n An operator.\n */\n operator,\n /**\n An [operator](#highlight.tags.operator) that dereferences something.\n */\n derefOperator: t(operator),\n /**\n Arithmetic-related [operator](#highlight.tags.operator).\n */\n arithmeticOperator: t(operator),\n /**\n Logical [operator](#highlight.tags.operator).\n */\n logicOperator: t(operator),\n /**\n Bit [operator](#highlight.tags.operator).\n */\n bitwiseOperator: t(operator),\n /**\n Comparison [operator](#highlight.tags.operator).\n */\n compareOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that updates its operand.\n */\n updateOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that defines something.\n */\n definitionOperator: t(operator),\n /**\n Type-related [operator](#highlight.tags.operator).\n */\n typeOperator: t(operator),\n /**\n Control-flow [operator](#highlight.tags.operator).\n */\n controlOperator: t(operator),\n /**\n Program or markup punctuation.\n */\n punctuation,\n /**\n [Punctuation](#highlight.tags.punctuation) that separates\n things.\n */\n separator: t(punctuation),\n /**\n Bracket-style [punctuation](#highlight.tags.punctuation).\n */\n bracket,\n /**\n Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`\n tokens).\n */\n angleBracket: t(bracket),\n /**\n Square [brackets](#highlight.tags.bracket) (usually `[` and `]`\n tokens).\n */\n squareBracket: t(bracket),\n /**\n Parentheses (usually `(` and `)` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n paren: t(bracket),\n /**\n Braces (usually `{` and `}` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n brace: t(bracket),\n /**\n Content, for example plain text in XML or markup documents.\n */\n content,\n /**\n [Content](#highlight.tags.content) that represents a heading.\n */\n heading,\n /**\n A level 1 [heading](#highlight.tags.heading).\n */\n heading1: t(heading),\n /**\n A level 2 [heading](#highlight.tags.heading).\n */\n heading2: t(heading),\n /**\n A level 3 [heading](#highlight.tags.heading).\n */\n heading3: t(heading),\n /**\n A level 4 [heading](#highlight.tags.heading).\n */\n heading4: t(heading),\n /**\n A level 5 [heading](#highlight.tags.heading).\n */\n heading5: t(heading),\n /**\n A level 6 [heading](#highlight.tags.heading).\n */\n heading6: t(heading),\n /**\n A prose separator (such as a horizontal rule).\n */\n contentSeparator: t(content),\n /**\n [Content](#highlight.tags.content) that represents a list.\n */\n list: t(content),\n /**\n [Content](#highlight.tags.content) that represents a quote.\n */\n quote: t(content),\n /**\n [Content](#highlight.tags.content) that is emphasized.\n */\n emphasis: t(content),\n /**\n [Content](#highlight.tags.content) that is styled strong.\n */\n strong: t(content),\n /**\n [Content](#highlight.tags.content) that is part of a link.\n */\n link: t(content),\n /**\n [Content](#highlight.tags.content) that is styled as code or\n monospace.\n */\n monospace: t(content),\n /**\n [Content](#highlight.tags.content) that has a strike-through\n style.\n */\n strikethrough: t(content),\n /**\n Inserted text in a change-tracking format.\n */\n inserted: t(),\n /**\n Deleted text.\n */\n deleted: t(),\n /**\n Changed text.\n */\n changed: t(),\n /**\n An invalid or unsyntactic element.\n */\n invalid: t(),\n /**\n Metadata or meta-instruction.\n */\n meta,\n /**\n [Metadata](#highlight.tags.meta) that applies to the entire\n document.\n */\n documentMeta: t(meta),\n /**\n [Metadata](#highlight.tags.meta) that annotates or adds\n attributes to a given syntactic element.\n */\n annotation: t(meta),\n /**\n Processing instruction or preprocessor directive. Subtag of\n [meta](#highlight.tags.meta).\n */\n processingInstruction: t(meta),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that a\n given element is being defined. Expected to be used with the\n various [name](#highlight.tags.name) tags.\n */\n definition: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that\n something is constant. Mostly expected to be used with\n [variable names](#highlight.tags.variableName).\n */\n constant: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) used to indicate that\n a [variable](#highlight.tags.variableName) or [property\n name](#highlight.tags.propertyName) is being called or defined\n as a function.\n */\n function: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that can be applied to\n [names](#highlight.tags.name) to indicate that they belong to\n the language's standard environment.\n */\n standard: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates a given\n [names](#highlight.tags.name) is local to some scope.\n */\n local: Tag.defineModifier(),\n /**\n A generic variant [modifier](#highlight.Tag^defineModifier) that\n can be used to tag language-specific alternative variants of\n some common tag. It is recommended for themes to define special\n forms of at least the [string](#highlight.tags.string) and\n [variable name](#highlight.tags.variableName) tags, since those\n come up a lot.\n */\n special: Tag.defineModifier()\n};\n/**\nThis is a highlighter that adds stable, predictable classes to\ntokens, for styling with external CSS.\n\nThe following tags are mapped to their name prefixed with `\"tok-\"`\n(for example `\"tok-comment\"`):\n\n* [`link`](#highlight.tags.link)\n* [`heading`](#highlight.tags.heading)\n* [`emphasis`](#highlight.tags.emphasis)\n* [`strong`](#highlight.tags.strong)\n* [`keyword`](#highlight.tags.keyword)\n* [`atom`](#highlight.tags.atom)\n* [`bool`](#highlight.tags.bool)\n* [`url`](#highlight.tags.url)\n* [`labelName`](#highlight.tags.labelName)\n* [`inserted`](#highlight.tags.inserted)\n* [`deleted`](#highlight.tags.deleted)\n* [`literal`](#highlight.tags.literal)\n* [`string`](#highlight.tags.string)\n* [`number`](#highlight.tags.number)\n* [`variableName`](#highlight.tags.variableName)\n* [`typeName`](#highlight.tags.typeName)\n* [`namespace`](#highlight.tags.namespace)\n* [`className`](#highlight.tags.className)\n* [`macroName`](#highlight.tags.macroName)\n* [`propertyName`](#highlight.tags.propertyName)\n* [`operator`](#highlight.tags.operator)\n* [`comment`](#highlight.tags.comment)\n* [`meta`](#highlight.tags.meta)\n* [`punctuation`](#highlight.tags.punctuation)\n* [`invalid`](#highlight.tags.invalid)\n\nIn addition, these mappings are provided:\n\n* [`regexp`](#highlight.tags.regexp),\n [`escape`](#highlight.tags.escape), and\n [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)\n are mapped to `\"tok-string2\"`\n* [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName2\"`\n* [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-local\"`\n* [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-definition\"`\n* [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)\n to `\"tok-propertyName tok-definition\"`\n*/\nconst classHighlighter = tagHighlighter([\n { tag: tags.link, class: \"tok-link\" },\n { tag: tags.heading, class: \"tok-heading\" },\n { tag: tags.emphasis, class: \"tok-emphasis\" },\n { tag: tags.strong, class: \"tok-strong\" },\n { tag: tags.keyword, class: \"tok-keyword\" },\n { tag: tags.atom, class: \"tok-atom\" },\n { tag: tags.bool, class: \"tok-bool\" },\n { tag: tags.url, class: \"tok-url\" },\n { tag: tags.labelName, class: \"tok-labelName\" },\n { tag: tags.inserted, class: \"tok-inserted\" },\n { tag: tags.deleted, class: \"tok-deleted\" },\n { tag: tags.literal, class: \"tok-literal\" },\n { tag: tags.string, class: \"tok-string\" },\n { tag: tags.number, class: \"tok-number\" },\n { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: \"tok-string2\" },\n { tag: tags.variableName, class: \"tok-variableName\" },\n { tag: tags.local(tags.variableName), class: \"tok-variableName tok-local\" },\n { tag: tags.definition(tags.variableName), class: \"tok-variableName tok-definition\" },\n { tag: tags.special(tags.variableName), class: \"tok-variableName2\" },\n { tag: tags.definition(tags.propertyName), class: \"tok-propertyName tok-definition\" },\n { tag: tags.typeName, class: \"tok-typeName\" },\n { tag: tags.namespace, class: \"tok-namespace\" },\n { tag: tags.className, class: \"tok-className\" },\n { tag: tags.macroName, class: \"tok-macroName\" },\n { tag: tags.propertyName, class: \"tok-propertyName\" },\n { tag: tags.operator, class: \"tok-operator\" },\n { tag: tags.comment, class: \"tok-comment\" },\n { tag: tags.meta, class: \"tok-meta\" },\n { tag: tags.invalid, class: \"tok-invalid\" },\n { tag: tags.punctuation, class: \"tok-punctuation\" }\n]);\n\nexport { Tag, classHighlighter, getStyleTags, highlightTree, styleTags, tagHighlighter, tags };\n","import { NodeProp, IterMode, Tree, TreeFragment, Parser, NodeType, NodeSet } from '@lezer/common';\nimport { StateEffect, StateField, Facet, EditorState, countColumn, combineConfig, RangeSet, RangeSetBuilder, Prec } from '@codemirror/state';\nimport { ViewPlugin, logException, EditorView, Decoration, WidgetType, gutter, GutterMarker } from '@codemirror/view';\nimport { tags, tagHighlighter, highlightTree, styleTags } from '@lezer/highlight';\nimport { StyleModule } from 'style-mod';\n\nvar _a;\n/**\nNode prop stored in a parser's top syntax node to provide the\nfacet that stores language-specific data for that language.\n*/\nconst languageDataProp = /*@__PURE__*/new NodeProp();\n/**\nHelper function to define a facet (to be added to the top syntax\nnode(s) for a language via\n[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be\nused to associate language data with the language. You\nprobably only need this when subclassing\n[`Language`](https://codemirror.net/6/docs/ref/#language.Language).\n*/\nfunction defineLanguageFacet(baseData) {\n return Facet.define({\n combine: baseData ? values => values.concat(baseData) : undefined\n });\n}\n/**\nSyntax node prop used to register sublanguages. Should be added to\nthe top level node type for the language.\n*/\nconst sublanguageProp = /*@__PURE__*/new NodeProp();\n/**\nA language object manages parsing and per-language\n[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is\nmanaged as a [Lezer](https://lezer.codemirror.net) tree. The class\ncan be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)\nsubclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or\nvia the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass\nfor stream parsers.\n*/\nclass Language {\n /**\n Construct a language object. If you need to invoke this\n directly, first define a data facet with\n [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then\n configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it\n to the language's outer syntax node.\n */\n constructor(\n /**\n The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet\n used for this language.\n */\n data, parser, extraExtensions = [], \n /**\n A language name.\n */\n name = \"\") {\n this.data = data;\n this.name = name;\n // Kludge to define EditorState.tree as a debugging helper,\n // without the EditorState package actually knowing about\n // languages and lezer trees.\n if (!EditorState.prototype.hasOwnProperty(\"tree\"))\n Object.defineProperty(EditorState.prototype, \"tree\", { get() { return syntaxTree(this); } });\n this.parser = parser;\n this.extension = [\n language.of(this),\n EditorState.languageData.of((state, pos, side) => {\n let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);\n if (!data)\n return [];\n let base = state.facet(data), sub = top.type.prop(sublanguageProp);\n if (sub) {\n let innerNode = top.resolve(pos - top.from, side);\n for (let sublang of sub)\n if (sublang.test(innerNode, state)) {\n let data = state.facet(sublang.facet);\n return sublang.type == \"replace\" ? data : data.concat(base);\n }\n }\n return base;\n })\n ].concat(extraExtensions);\n }\n /**\n Query whether this language is active at the given position.\n */\n isActiveAt(state, pos, side = -1) {\n return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;\n }\n /**\n Find the document regions that were parsed using this language.\n The returned regions will _include_ any nested languages rooted\n in this language, when those exist.\n */\n findRegions(state) {\n let lang = state.facet(language);\n if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)\n return [{ from: 0, to: state.doc.length }];\n if (!lang || !lang.allowsNesting)\n return [];\n let result = [];\n let explore = (tree, from) => {\n if (tree.prop(languageDataProp) == this.data) {\n result.push({ from, to: from + tree.length });\n return;\n }\n let mount = tree.prop(NodeProp.mounted);\n if (mount) {\n if (mount.tree.prop(languageDataProp) == this.data) {\n if (mount.overlay)\n for (let r of mount.overlay)\n result.push({ from: r.from + from, to: r.to + from });\n else\n result.push({ from: from, to: from + tree.length });\n return;\n }\n else if (mount.overlay) {\n let size = result.length;\n explore(mount.tree, mount.overlay[0].from + from);\n if (result.length > size)\n return;\n }\n }\n for (let i = 0; i < tree.children.length; i++) {\n let ch = tree.children[i];\n if (ch instanceof Tree)\n explore(ch, tree.positions[i] + from);\n }\n };\n explore(syntaxTree(state), 0);\n return result;\n }\n /**\n Indicates whether this language allows nested languages. The\n default implementation returns true.\n */\n get allowsNesting() { return true; }\n}\n/**\n@internal\n*/\nLanguage.setState = /*@__PURE__*/StateEffect.define();\nfunction topNodeAt(state, pos, side) {\n let topLang = state.facet(language), tree = syntaxTree(state).topNode;\n if (!topLang || topLang.allowsNesting) {\n for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))\n if (node.type.isTop)\n tree = node;\n }\n return tree;\n}\n/**\nA subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer\n[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)\nparsers.\n*/\nclass LRLanguage extends Language {\n constructor(data, parser, name) {\n super(data, parser, [], name);\n this.parser = parser;\n }\n /**\n Define a language from a parser.\n */\n static define(spec) {\n let data = defineLanguageFacet(spec.languageData);\n return new LRLanguage(data, spec.parser.configure({\n props: [languageDataProp.add(type => type.isTop ? data : undefined)]\n }), spec.name);\n }\n /**\n Create a new instance of this language with a reconfigured\n version of its parser and optionally a new name.\n */\n configure(options, name) {\n return new LRLanguage(this.data, this.parser.configure(options), name || this.name);\n }\n get allowsNesting() { return this.parser.hasWrappers(); }\n}\n/**\nGet the syntax tree for a state, which is the current (possibly\nincomplete) parse tree of the active\n[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no\nlanguage available.\n*/\nfunction syntaxTree(state) {\n let field = state.field(Language.state, false);\n return field ? field.tree : Tree.empty;\n}\n/**\nTry to get a parse tree that spans at least up to `upto`. The\nmethod will do at most `timeout` milliseconds of work to parse\nup to that point if the tree isn't already available.\n*/\nfunction ensureSyntaxTree(state, upto, timeout = 50) {\n var _a;\n let parse = (_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context;\n if (!parse)\n return null;\n let oldVieport = parse.viewport;\n parse.updateViewport({ from: 0, to: upto });\n let result = parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;\n parse.updateViewport(oldVieport);\n return result;\n}\n/**\nQueries whether there is a full syntax tree available up to the\ngiven document position. If there isn't, the background parse\nprocess _might_ still be working and update the tree further, but\nthere is no guarantee of that—the parser will [stop\nworking](https://codemirror.net/6/docs/ref/#language.syntaxParserRunning) when it has spent a\ncertain amount of time or has moved beyond the visible viewport.\nAlways returns false if no language has been enabled.\n*/\nfunction syntaxTreeAvailable(state, upto = state.doc.length) {\n var _a;\n return ((_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context.isDone(upto)) || false;\n}\n/**\nMove parsing forward, and update the editor state afterwards to\nreflect the new tree. Will work for at most `timeout`\nmilliseconds. Returns true if the parser managed get to the given\nposition in that time.\n*/\nfunction forceParsing(view, upto = view.viewport.to, timeout = 100) {\n let success = ensureSyntaxTree(view.state, upto, timeout);\n if (success != syntaxTree(view.state))\n view.dispatch({});\n return !!success;\n}\n/**\nTells you whether the language parser is planning to do more\nparsing work (in a `requestIdleCallback` pseudo-thread) or has\nstopped running, either because it parsed the entire document,\nbecause it spent too much time and was cut off, or because there\nis no language parser enabled.\n*/\nfunction syntaxParserRunning(view) {\n var _a;\n return ((_a = view.plugin(parseWorker)) === null || _a === void 0 ? void 0 : _a.isWorking()) || false;\n}\n/**\nLezer-style\n[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)\nobject for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.\n*/\nclass DocInput {\n /**\n Create an input object for the given document.\n */\n constructor(doc) {\n this.doc = doc;\n this.cursorPos = 0;\n this.string = \"\";\n this.cursor = doc.iter();\n }\n get length() { return this.doc.length; }\n syncTo(pos) {\n this.string = this.cursor.next(pos - this.cursorPos).value;\n this.cursorPos = pos + this.string.length;\n return this.cursorPos - this.string.length;\n }\n chunk(pos) {\n this.syncTo(pos);\n return this.string;\n }\n get lineChunks() { return true; }\n read(from, to) {\n let stringStart = this.cursorPos - this.string.length;\n if (from < stringStart || to >= this.cursorPos)\n return this.doc.sliceString(from, to);\n else\n return this.string.slice(from - stringStart, to - stringStart);\n }\n}\nlet currentContext = null;\n/**\nA parse context provided to parsers working on the editor content.\n*/\nclass ParseContext {\n constructor(parser, \n /**\n The current editor state.\n */\n state, \n /**\n Tree fragments that can be reused by incremental re-parses.\n */\n fragments = [], \n /**\n @internal\n */\n tree, \n /**\n @internal\n */\n treeLen, \n /**\n The current editor viewport (or some overapproximation\n thereof). Intended to be used for opportunistically avoiding\n work (in which case\n [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)\n should be called to make sure the parser is restarted when the\n skipped region becomes visible).\n */\n viewport, \n /**\n @internal\n */\n skipped, \n /**\n This is where skipping parsers can register a promise that,\n when resolved, will schedule a new parse. It is cleared when\n the parse worker picks up the promise. @internal\n */\n scheduleOn) {\n this.parser = parser;\n this.state = state;\n this.fragments = fragments;\n this.tree = tree;\n this.treeLen = treeLen;\n this.viewport = viewport;\n this.skipped = skipped;\n this.scheduleOn = scheduleOn;\n this.parse = null;\n /**\n @internal\n */\n this.tempSkipped = [];\n }\n /**\n @internal\n */\n static create(parser, state, viewport) {\n return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);\n }\n startParse() {\n return this.parser.startParse(new DocInput(this.state.doc), this.fragments);\n }\n /**\n @internal\n */\n work(until, upto) {\n if (upto != null && upto >= this.state.doc.length)\n upto = undefined;\n if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {\n this.takeTree();\n return true;\n }\n return this.withContext(() => {\n var _a;\n if (typeof until == \"number\") {\n let endTime = Date.now() + until;\n until = () => Date.now() > endTime;\n }\n if (!this.parse)\n this.parse = this.startParse();\n if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&\n upto < this.state.doc.length)\n this.parse.stopAt(upto);\n for (;;) {\n let done = this.parse.advance();\n if (done) {\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));\n this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;\n this.tree = done;\n this.parse = null;\n if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))\n this.parse = this.startParse();\n else\n return true;\n }\n if (until())\n return false;\n }\n });\n }\n /**\n @internal\n */\n takeTree() {\n let pos, tree;\n if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {\n if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)\n this.parse.stopAt(pos);\n this.withContext(() => { while (!(tree = this.parse.advance())) { } });\n this.treeLen = pos;\n this.tree = tree;\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));\n this.parse = null;\n }\n }\n withContext(f) {\n let prev = currentContext;\n currentContext = this;\n try {\n return f();\n }\n finally {\n currentContext = prev;\n }\n }\n withoutTempSkipped(fragments) {\n for (let r; r = this.tempSkipped.pop();)\n fragments = cutFragments(fragments, r.from, r.to);\n return fragments;\n }\n /**\n @internal\n */\n changes(changes, newState) {\n let { fragments, tree, treeLen, viewport, skipped } = this;\n this.takeTree();\n if (!changes.empty) {\n let ranges = [];\n changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));\n fragments = TreeFragment.applyChanges(fragments, ranges);\n tree = Tree.empty;\n treeLen = 0;\n viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };\n if (this.skipped.length) {\n skipped = [];\n for (let r of this.skipped) {\n let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);\n if (from < to)\n skipped.push({ from, to });\n }\n }\n }\n return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);\n }\n /**\n @internal\n */\n updateViewport(viewport) {\n if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)\n return false;\n this.viewport = viewport;\n let startLen = this.skipped.length;\n for (let i = 0; i < this.skipped.length; i++) {\n let { from, to } = this.skipped[i];\n if (from < viewport.to && to > viewport.from) {\n this.fragments = cutFragments(this.fragments, from, to);\n this.skipped.splice(i--, 1);\n }\n }\n if (this.skipped.length >= startLen)\n return false;\n this.reset();\n return true;\n }\n /**\n @internal\n */\n reset() {\n if (this.parse) {\n this.takeTree();\n this.parse = null;\n }\n }\n /**\n Notify the parse scheduler that the given region was skipped\n because it wasn't in view, and the parse should be restarted\n when it comes into view.\n */\n skipUntilInView(from, to) {\n this.skipped.push({ from, to });\n }\n /**\n Returns a parser intended to be used as placeholder when\n asynchronously loading a nested parser. It'll skip its input and\n mark it as not-really-parsed, so that the next update will parse\n it again.\n \n When `until` is given, a reparse will be scheduled when that\n promise resolves.\n */\n static getSkippingParser(until) {\n return new class extends Parser {\n createParse(input, fragments, ranges) {\n let from = ranges[0].from, to = ranges[ranges.length - 1].to;\n let parser = {\n parsedPos: from,\n advance() {\n let cx = currentContext;\n if (cx) {\n for (let r of ranges)\n cx.tempSkipped.push(r);\n if (until)\n cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;\n }\n this.parsedPos = to;\n return new Tree(NodeType.none, [], [], to - from);\n },\n stoppedAt: null,\n stopAt() { }\n };\n return parser;\n }\n };\n }\n /**\n @internal\n */\n isDone(upto) {\n upto = Math.min(upto, this.state.doc.length);\n let frags = this.fragments;\n return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;\n }\n /**\n Get the context for the current parse, or `null` if no editor\n parse is in progress.\n */\n static get() { return currentContext; }\n}\nfunction cutFragments(fragments, from, to) {\n return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);\n}\nclass LanguageState {\n constructor(\n // A mutable parse state that is used to preserve work done during\n // the lifetime of a state when moving to the next state.\n context) {\n this.context = context;\n this.tree = context.tree;\n }\n apply(tr) {\n if (!tr.docChanged && this.tree == this.context.tree)\n return this;\n let newCx = this.context.changes(tr.changes, tr.state);\n // If the previous parse wasn't done, go forward only up to its\n // end position or the end of the viewport, to avoid slowing down\n // state updates with parse work beyond the viewport.\n let upto = this.context.treeLen == tr.startState.doc.length ? undefined\n : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);\n if (!newCx.work(20 /* Work.Apply */, upto))\n newCx.takeTree();\n return new LanguageState(newCx);\n }\n static init(state) {\n let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);\n let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });\n if (!parseState.work(20 /* Work.Apply */, vpTo))\n parseState.takeTree();\n return new LanguageState(parseState);\n }\n}\nLanguage.state = /*@__PURE__*/StateField.define({\n create: LanguageState.init,\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(Language.setState))\n return e.value;\n if (tr.startState.facet(language) != tr.state.facet(language))\n return LanguageState.init(tr.state);\n return value.apply(tr);\n }\n});\nlet requestIdle = (callback) => {\n let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);\n return () => clearTimeout(timeout);\n};\nif (typeof requestIdleCallback != \"undefined\")\n requestIdle = (callback) => {\n let idle = -1, timeout = setTimeout(() => {\n idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });\n }, 100 /* Work.MinPause */);\n return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);\n };\nconst isInputPending = typeof navigator != \"undefined\" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)\n ? () => navigator.scheduling.isInputPending() : null;\nconst parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {\n constructor(view) {\n this.view = view;\n this.working = null;\n this.workScheduled = 0;\n // End of the current time chunk\n this.chunkEnd = -1;\n // Milliseconds of budget left for this chunk\n this.chunkBudget = -1;\n this.work = this.work.bind(this);\n this.scheduleWork();\n }\n update(update) {\n let cx = this.view.state.field(Language.state).context;\n if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)\n this.scheduleWork();\n if (update.docChanged || update.selectionSet) {\n if (this.view.hasFocus)\n this.chunkBudget += 50 /* Work.ChangeBonus */;\n this.scheduleWork();\n }\n this.checkAsyncSchedule(cx);\n }\n scheduleWork() {\n if (this.working)\n return;\n let { state } = this.view, field = state.field(Language.state);\n if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))\n this.working = requestIdle(this.work);\n }\n work(deadline) {\n this.working = null;\n let now = Date.now();\n if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk\n this.chunkEnd = now + 30000 /* Work.ChunkTime */;\n this.chunkBudget = 3000 /* Work.ChunkBudget */;\n }\n if (this.chunkBudget <= 0)\n return; // No more budget\n let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);\n if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))\n return;\n let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);\n let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;\n let done = field.context.work(() => {\n return isInputPending && isInputPending() || Date.now() > endTime;\n }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));\n this.chunkBudget -= Date.now() - now;\n if (done || this.chunkBudget <= 0) {\n field.context.takeTree();\n this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });\n }\n if (this.chunkBudget > 0 && !(done && !viewportFirst))\n this.scheduleWork();\n this.checkAsyncSchedule(field.context);\n }\n checkAsyncSchedule(cx) {\n if (cx.scheduleOn) {\n this.workScheduled++;\n cx.scheduleOn\n .then(() => this.scheduleWork())\n .catch(err => logException(this.view.state, err))\n .then(() => this.workScheduled--);\n cx.scheduleOn = null;\n }\n }\n destroy() {\n if (this.working)\n this.working();\n }\n isWorking() {\n return !!(this.working || this.workScheduled > 0);\n }\n}, {\n eventHandlers: { focus() { this.scheduleWork(); } }\n});\n/**\nThe facet used to associate a language with an editor state. Used\nby `Language` object's `extension` property (so you don't need to\nmanually wrap your languages in this). Can be used to access the\ncurrent language on a state.\n*/\nconst language = /*@__PURE__*/Facet.define({\n combine(languages) { return languages.length ? languages[0] : null; },\n enables: language => [\n Language.state,\n parseWorker,\n EditorView.contentAttributes.compute([language], state => {\n let lang = state.facet(language);\n return lang && lang.name ? { \"data-language\": lang.name } : {};\n })\n ]\n});\n/**\nThis class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an\noptional set of supporting extensions. Language packages are\nencouraged to export a function that optionally takes a\nconfiguration object and returns a `LanguageSupport` instance, as\nthe main way for client code to use the package.\n*/\nclass LanguageSupport {\n /**\n Create a language support object.\n */\n constructor(\n /**\n The language object.\n */\n language, \n /**\n An optional set of supporting extensions. When nesting a\n language in another language, the outer language is encouraged\n to include the supporting extensions for its inner languages\n in its own set of support extensions.\n */\n support = []) {\n this.language = language;\n this.support = support;\n this.extension = [language, support];\n }\n}\n/**\nLanguage descriptions are used to store metadata about languages\nand to dynamically load them. Their main role is finding the\nappropriate language for a filename or dynamically loading nested\nparsers.\n*/\nclass LanguageDescription {\n constructor(\n /**\n The name of this language.\n */\n name, \n /**\n Alternative names for the mode (lowercased, includes `this.name`).\n */\n alias, \n /**\n File extensions associated with this language.\n */\n extensions, \n /**\n Optional filename pattern that should be associated with this\n language.\n */\n filename, loadFunc, \n /**\n If the language has been loaded, this will hold its value.\n */\n support = undefined) {\n this.name = name;\n this.alias = alias;\n this.extensions = extensions;\n this.filename = filename;\n this.loadFunc = loadFunc;\n this.support = support;\n this.loading = null;\n }\n /**\n Start loading the the language. Will return a promise that\n resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)\n object when the language successfully loads.\n */\n load() {\n return this.loading || (this.loading = this.loadFunc().then(support => this.support = support, err => { this.loading = null; throw err; }));\n }\n /**\n Create a language description.\n */\n static of(spec) {\n let { load, support } = spec;\n if (!load) {\n if (!support)\n throw new RangeError(\"Must pass either 'load' or 'support' to LanguageDescription.of\");\n load = () => Promise.resolve(support);\n }\n return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);\n }\n /**\n Look for a language in the given array of descriptions that\n matches the filename. Will first match\n [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,\n and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),\n and return the first language that matches.\n */\n static matchFilename(descs, filename) {\n for (let d of descs)\n if (d.filename && d.filename.test(filename))\n return d;\n let ext = /\\.([^.]+)$/.exec(filename);\n if (ext)\n for (let d of descs)\n if (d.extensions.indexOf(ext[1]) > -1)\n return d;\n return null;\n }\n /**\n Look for a language whose name or alias matches the the given\n name (case-insensitively). If `fuzzy` is true, and no direct\n matchs is found, this'll also search for a language whose name\n or alias occurs in the string (for names shorter than three\n characters, only when surrounded by non-word characters).\n */\n static matchLanguageName(descs, name, fuzzy = true) {\n name = name.toLowerCase();\n for (let d of descs)\n if (d.alias.some(a => a == name))\n return d;\n if (fuzzy)\n for (let d of descs)\n for (let a of d.alias) {\n let found = name.indexOf(a);\n if (found > -1 && (a.length > 2 || !/\\w/.test(name[found - 1]) && !/\\w/.test(name[found + a.length])))\n return d;\n }\n return null;\n }\n}\n\n/**\nFacet that defines a way to provide a function that computes the\nappropriate indentation depth, as a column number (see\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given\nline. A return value of `null` indicates no indentation can be\ndetermined, and the line should inherit the indentation of the one\nabove it. A return value of `undefined` defers to the next indent\nservice.\n*/\nconst indentService = /*@__PURE__*/Facet.define();\n/**\nFacet for overriding the unit by which indentation happens. Should\nbe a string consisting either entirely of the same whitespace\ncharacter. When not set, this defaults to 2 spaces.\n*/\nconst indentUnit = /*@__PURE__*/Facet.define({\n combine: values => {\n if (!values.length)\n return \" \";\n let unit = values[0];\n if (!unit || /\\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))\n throw new Error(\"Invalid indent unit: \" + JSON.stringify(values[0]));\n return unit;\n }\n});\n/**\nReturn the _column width_ of an indent unit in the state.\nDetermined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)\nfacet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that\ncontains tabs.\n*/\nfunction getIndentUnit(state) {\n let unit = state.facet(indentUnit);\n return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;\n}\n/**\nCreate an indentation string that covers columns 0 to `cols`.\nWill use tabs for as much of the columns as possible when the\n[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains\ntabs.\n*/\nfunction indentString(state, cols) {\n let result = \"\", ts = state.tabSize, ch = state.facet(indentUnit)[0];\n if (ch == \"\\t\") {\n while (cols >= ts) {\n result += \"\\t\";\n cols -= ts;\n }\n ch = \" \";\n }\n for (let i = 0; i < cols; i++)\n result += ch;\n return result;\n}\n/**\nGet the indentation, as a column number, at the given position.\nWill first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)\nthat are registered, and if none of those return an indentation,\nthis will check the syntax tree for the [indent node\nprop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a\nnumber when an indentation could be determined, and null\notherwise.\n*/\nfunction getIndentation(context, pos) {\n if (context instanceof EditorState)\n context = new IndentContext(context);\n for (let service of context.state.facet(indentService)) {\n let result = service(context, pos);\n if (result !== undefined)\n return result;\n }\n let tree = syntaxTree(context.state);\n return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;\n}\n/**\nCreate a change set that auto-indents all lines touched by the\ngiven document range.\n*/\nfunction indentRange(state, from, to) {\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => { var _a; return (_a = updated[start]) !== null && _a !== void 0 ? _a : -1; } });\n let changes = [];\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n pos = line.to + 1;\n let indent = getIndentation(context, line.from);\n if (indent == null)\n continue;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n }\n return state.changes(changes);\n}\n/**\nIndentation contexts are used when calling [indentation\nservices](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities\nuseful in indentation logic, and can selectively override the\nindentation reported for some lines.\n*/\nclass IndentContext {\n /**\n Create an indent context.\n */\n constructor(\n /**\n The editor state.\n */\n state, \n /**\n @internal\n */\n options = {}) {\n this.state = state;\n this.options = options;\n this.unit = getIndentUnit(state);\n }\n /**\n Get a description of the line at the given position, taking\n [simulated line\n breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n into account. If there is such a break at `pos`, the `bias`\n argument determines whether the part of the line line before or\n after the break is used.\n */\n lineAt(pos, bias = 1) {\n let line = this.state.doc.lineAt(pos);\n let { simulateBreak, simulateDoubleBreak } = this.options;\n if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {\n if (simulateDoubleBreak && simulateBreak == pos)\n return { text: \"\", from: pos };\n else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)\n return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };\n else\n return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };\n }\n return line;\n }\n /**\n Get the text directly after `pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n textAfterPos(pos, bias = 1) {\n if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)\n return \"\";\n let { text, from } = this.lineAt(pos, bias);\n return text.slice(pos - from, Math.min(text.length, pos + 100 - from));\n }\n /**\n Find the column for the given position.\n */\n column(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let result = this.countColumn(text, pos - from);\n let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;\n if (override > -1)\n result += override - this.countColumn(text, text.search(/\\S|$/));\n return result;\n }\n /**\n Find the column position (taking tabs into account) of the given\n position in the given string.\n */\n countColumn(line, pos = line.length) {\n return countColumn(line, this.state.tabSize, pos);\n }\n /**\n Find the indentation column of the line at the given point.\n */\n lineIndent(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let override = this.options.overrideIndentation;\n if (override) {\n let overriden = override(from);\n if (overriden > -1)\n return overriden;\n }\n return this.countColumn(text, text.search(/\\S|$/));\n }\n /**\n Returns the [simulated line\n break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n for this context, if any.\n */\n get simulatedBreak() {\n return this.options.simulateBreak || null;\n }\n}\n/**\nA syntax tree node prop used to associate indentation strategies\nwith node types. Such a strategy is a function from an indentation\ncontext to a column number (see also\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null\nindicates that no definitive indentation can be determined.\n*/\nconst indentNodeProp = /*@__PURE__*/new NodeProp();\n// Compute the indentation for a given position from the syntax tree.\nfunction syntaxIndentation(cx, ast, pos) {\n let stack = ast.resolveStack(pos);\n let inner = stack.node.enterUnfinishedNodesBefore(pos);\n if (inner != stack.node) {\n let add = [];\n for (let cur = inner; cur != stack.node; cur = cur.parent)\n add.push(cur);\n for (let i = add.length - 1; i >= 0; i--)\n stack = { node: add[i], next: stack };\n }\n return indentFor(stack, cx, pos);\n}\nfunction indentFor(stack, cx, pos) {\n for (let cur = stack; cur; cur = cur.next) {\n let strategy = indentStrategy(cur.node);\n if (strategy)\n return strategy(TreeIndentContext.create(cx, pos, cur));\n }\n return 0;\n}\nfunction ignoreClosed(cx) {\n return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;\n}\nfunction indentStrategy(tree) {\n let strategy = tree.type.prop(indentNodeProp);\n if (strategy)\n return strategy;\n let first = tree.firstChild, close;\n if (first && (close = first.type.prop(NodeProp.closedBy))) {\n let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;\n return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);\n }\n return tree.parent == null ? topIndent : null;\n}\nfunction topIndent() { return 0; }\n/**\nObjects of this type provide context information and helper\nmethods to indentation functions registered on syntax nodes.\n*/\nclass TreeIndentContext extends IndentContext {\n constructor(base, \n /**\n The position at which indentation is being computed.\n */\n pos, \n /**\n @internal\n */\n context) {\n super(base.state, base.options);\n this.base = base;\n this.pos = pos;\n this.context = context;\n }\n /**\n The syntax tree node to which the indentation strategy\n applies.\n */\n get node() { return this.context.node; }\n /**\n @internal\n */\n static create(base, pos, context) {\n return new TreeIndentContext(base, pos, context);\n }\n /**\n Get the text directly after `this.pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n get textAfter() {\n return this.textAfterPos(this.pos);\n }\n /**\n Get the indentation at the reference line for `this.node`, which\n is the line on which it starts, unless there is a node that is\n _not_ a parent of this node covering the start of that line. If\n so, the line at the start of that node is tried, again skipping\n on if it is covered by another such node.\n */\n get baseIndent() {\n return this.baseIndentFor(this.node);\n }\n /**\n Get the indentation for the reference line of the given node\n (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).\n */\n baseIndentFor(node) {\n let line = this.state.doc.lineAt(node.from);\n // Skip line starts that are covered by a sibling (or cousin, etc)\n for (;;) {\n let atBreak = node.resolve(line.from);\n while (atBreak.parent && atBreak.parent.from == atBreak.from)\n atBreak = atBreak.parent;\n if (isParent(atBreak, node))\n break;\n line = this.state.doc.lineAt(atBreak.from);\n }\n return this.lineIndent(line.from);\n }\n /**\n Continue looking for indentations in the node's parent nodes,\n and return the result of that.\n */\n continue() {\n return indentFor(this.context.next, this.base, this.pos);\n }\n}\nfunction isParent(parent, of) {\n for (let cur = of; cur; cur = cur.parent)\n if (parent == cur)\n return true;\n return false;\n}\n// Check whether a delimited node is aligned (meaning there are\n// non-skipped nodes on the same line as the opening delimiter). And\n// if so, return the opening token.\nfunction bracketedAligned(context) {\n let tree = context.node;\n let openToken = tree.childAfter(tree.from), last = tree.lastChild;\n if (!openToken)\n return null;\n let sim = context.options.simulateBreak;\n let openLine = context.state.doc.lineAt(openToken.from);\n let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);\n for (let pos = openToken.to;;) {\n let next = tree.childAfter(pos);\n if (!next || next == last)\n return null;\n if (!next.type.isSkipped)\n return next.from < lineEnd ? openToken : null;\n pos = next.to;\n }\n}\n/**\nAn indentation strategy for delimited (usually bracketed) nodes.\nWill, by default, indent one unit more than the parent's base\nindent unless the line starts with a closing token. When `align`\nis true and there are non-skipped nodes on the node's opening\nline, the content of the node will be aligned with the end of the\nopening node, like this:\n\n foo(bar,\n baz)\n*/\nfunction delimitedIndent({ closing, align = true, units = 1 }) {\n return (context) => delimitedStrategy(context, align, units, closing);\n}\nfunction delimitedStrategy(context, align, units, closing, closedAt) {\n let after = context.textAfter, space = after.match(/^\\s*/)[0].length;\n let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;\n let aligned = align ? bracketedAligned(context) : null;\n if (aligned)\n return closed ? context.column(aligned.from) : context.column(aligned.to);\n return context.baseIndent + (closed ? 0 : context.unit * units);\n}\n/**\nAn indentation strategy that aligns a node's content to its base\nindentation.\n*/\nconst flatIndent = (context) => context.baseIndent;\n/**\nCreates an indentation strategy that, by default, indents\ncontinued lines one unit more than the node's base indentation.\nYou can provide `except` to prevent indentation of lines that\nmatch a pattern (for example `/^else\\b/` in `if`/`else`\nconstructs), and you can change the amount of units used with the\n`units` option.\n*/\nfunction continuedIndent({ except, units = 1 } = {}) {\n return (context) => {\n let matchExcept = except && except.test(context.textAfter);\n return context.baseIndent + (matchExcept ? 0 : units * context.unit);\n };\n}\nconst DontIndentBeyond = 200;\n/**\nEnables reindentation on input. When a language defines an\n`indentOnInput` field in its [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular\nexpression, the line at the cursor will be reindented whenever new\ntext is typed and the input from the start of the line up to the\ncursor matches that regexp.\n\nTo avoid unneccesary reindents, it is recommended to start the\nregexp with `^` (usually followed by `\\s*`), and end it with `$`.\nFor example, `/^\\s*\\}$/` will reindent when a closing brace is\nadded at the start of a line.\n*/\nfunction indentOnInput() {\n return EditorState.transactionFilter.of(tr => {\n if (!tr.docChanged || !tr.isUserEvent(\"input.type\") && !tr.isUserEvent(\"input.complete\"))\n return tr;\n let rules = tr.startState.languageDataAt(\"indentOnInput\", tr.startState.selection.main.head);\n if (!rules.length)\n return tr;\n let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);\n if (head > line.from + DontIndentBeyond)\n return tr;\n let lineStart = doc.sliceString(line.from, head);\n if (!rules.some(r => r.test(lineStart)))\n return tr;\n let { state } = tr, last = -1, changes = [];\n for (let { head } of state.selection.ranges) {\n let line = state.doc.lineAt(head);\n if (line.from == last)\n continue;\n last = line.from;\n let indent = getIndentation(state, line.from);\n if (indent == null)\n continue;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm)\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n return changes.length ? [tr, { changes, sequential: true }] : tr;\n });\n}\n\n/**\nA facet that registers a code folding service. When called with\nthe extent of a line, such a function should return a foldable\nrange that starts on that line (but continues beyond it), if one\ncan be found.\n*/\nconst foldService = /*@__PURE__*/Facet.define();\n/**\nThis node prop is used to associate folding information with\nsyntax node types. Given a syntax node, it should check whether\nthat tree is foldable and return the range that can be collapsed\nwhen it is.\n*/\nconst foldNodeProp = /*@__PURE__*/new NodeProp();\n/**\n[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but\nthe first and the last child of a syntax node. Useful for nodes\nthat start and end with delimiters.\n*/\nfunction foldInside(node) {\n let first = node.firstChild, last = node.lastChild;\n return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;\n}\nfunction syntaxFolding(state, start, end) {\n let tree = syntaxTree(state);\n if (tree.length < end)\n return null;\n let stack = tree.resolveStack(end, 1);\n let found = null;\n for (let iter = stack; iter; iter = iter.next) {\n let cur = iter.node;\n if (cur.to <= end || cur.from > end)\n continue;\n if (found && cur.from < start)\n break;\n let prop = cur.type.prop(foldNodeProp);\n if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {\n let value = prop(cur, state);\n if (value && value.from <= end && value.from >= start && value.to > end)\n found = value;\n }\n }\n return found;\n}\nfunction isUnfinished(node) {\n let ch = node.lastChild;\n return ch && ch.to == node.to && ch.type.isError;\n}\n/**\nCheck whether the given line is foldable. First asks any fold\nservices registered through\n[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return\na result, tries to query the [fold node\nprop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end\nof the line.\n*/\nfunction foldable(state, lineStart, lineEnd) {\n for (let service of state.facet(foldService)) {\n let result = service(state, lineStart, lineEnd);\n if (result)\n return result;\n }\n return syntaxFolding(state, lineStart, lineEnd);\n}\nfunction mapRange(range, mapping) {\n let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);\n return from >= to ? undefined : { from, to };\n}\n/**\nState effect that can be attached to a transaction to fold the\ngiven range. (You probably only need this in exceptional\ncircumstances—usually you'll just want to let\n[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold\ngutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)\n*/\nconst foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\n/**\nState effect that unfolds the given range (if it was folded).\n*/\nconst unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\nfunction selectedLines(view) {\n let lines = [];\n for (let { head } of view.state.selection.ranges) {\n if (lines.some(l => l.from <= head && l.to >= head))\n continue;\n lines.push(view.lineBlockAt(head));\n }\n return lines;\n}\n/**\nThe state field that stores the folded ranges (as a [decoration\nset](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to\n[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and\n[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold\nstate.\n*/\nconst foldState = /*@__PURE__*/StateField.define({\n create() {\n return Decoration.none;\n },\n update(folded, tr) {\n folded = folded.map(tr.changes);\n for (let e of tr.effects) {\n if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {\n let { preparePlaceholder } = tr.state.facet(foldConfig);\n let widget = !preparePlaceholder ? foldWidget :\n Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });\n folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });\n }\n else if (e.is(unfoldEffect)) {\n folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,\n filterFrom: e.value.from, filterTo: e.value.to });\n }\n }\n // Clear folded ranges that cover the selection head\n if (tr.selection) {\n let onSelection = false, { head } = tr.selection.main;\n folded.between(head, head, (a, b) => { if (a < head && b > head)\n onSelection = true; });\n if (onSelection)\n folded = folded.update({\n filterFrom: head,\n filterTo: head,\n filter: (a, b) => b <= head || a >= head\n });\n }\n return folded;\n },\n provide: f => EditorView.decorations.from(f),\n toJSON(folded, state) {\n let ranges = [];\n folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });\n return ranges;\n },\n fromJSON(value) {\n if (!Array.isArray(value) || value.length % 2)\n throw new RangeError(\"Invalid JSON for fold state\");\n let ranges = [];\n for (let i = 0; i < value.length;) {\n let from = value[i++], to = value[i++];\n if (typeof from != \"number\" || typeof to != \"number\")\n throw new RangeError(\"Invalid JSON for fold state\");\n ranges.push(foldWidget.range(from, to));\n }\n return Decoration.set(ranges, true);\n }\n});\n/**\nGet a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges\nin the given state.\n*/\nfunction foldedRanges(state) {\n return state.field(foldState, false) || RangeSet.empty;\n}\nfunction findFold(state, from, to) {\n var _a;\n let found = null;\n (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {\n if (!found || found.from > from)\n found = { from, to };\n });\n return found;\n}\nfunction foldExists(folded, from, to) {\n let found = false;\n folded.between(from, from, (a, b) => { if (a == from && b == to)\n found = true; });\n return found;\n}\nfunction maybeEnable(state, other) {\n return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));\n}\n/**\nFold the lines that are selected, if possible.\n*/\nconst foldCode = view => {\n for (let line of selectedLines(view)) {\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });\n return true;\n }\n }\n return false;\n};\n/**\nUnfold folded ranges on selected lines.\n*/\nconst unfoldCode = view => {\n if (!view.state.field(foldState, false))\n return false;\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n if (effects.length)\n view.dispatch({ effects });\n return effects.length > 0;\n};\nfunction announceFold(view, range, fold = true) {\n let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;\n return EditorView.announce.of(`${view.state.phrase(fold ? \"Folded lines\" : \"Unfolded lines\")} ${lineFrom} ${view.state.phrase(\"to\")} ${lineTo}.`);\n}\n/**\nFold all top-level foldable ranges. Note that, in most cases,\nfolding information will depend on the [syntax\ntree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work\nreliably when the document hasn't been fully parsed (either\nbecause the editor state was only just initialized, or because the\ndocument is so big that the parser decided not to parse it\nentirely).\n*/\nconst foldAll = view => {\n let { state } = view, effects = [];\n for (let pos = 0; pos < state.doc.length;) {\n let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);\n if (range)\n effects.push(foldEffect.of(range));\n pos = (range ? view.lineBlockAt(range.to) : line).to + 1;\n }\n if (effects.length)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nUnfold all folded code.\n*/\nconst unfoldAll = view => {\n let field = view.state.field(foldState, false);\n if (!field || !field.size)\n return false;\n let effects = [];\n field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });\n view.dispatch({ effects });\n return true;\n};\n// Find the foldable region containing the given line, if one exists\nfunction foldableContainer(view, lineBlock) {\n // Look backwards through line blocks until we find a foldable region that\n // intersects with the line\n for (let line = lineBlock;;) {\n let foldableRegion = foldable(view.state, line.from, line.to);\n if (foldableRegion && foldableRegion.to > lineBlock.from)\n return foldableRegion;\n if (!line.from)\n return null;\n line = view.lineBlockAt(line.from - 1);\n }\n}\n/**\nToggle folding at cursors. Unfolds if there is an existing fold\nstarting in that line, tries to find a foldable range around it\notherwise.\n*/\nconst toggleFold = (view) => {\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n else {\n let foldRange = foldableContainer(view, line);\n if (foldRange)\n effects.push(foldEffect.of(foldRange), announceFold(view, foldRange));\n }\n }\n if (effects.length > 0)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nDefault fold-related key bindings.\n\n - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).\n - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).\n - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).\n - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).\n*/\nconst foldKeymap = [\n { key: \"Ctrl-Shift-[\", mac: \"Cmd-Alt-[\", run: foldCode },\n { key: \"Ctrl-Shift-]\", mac: \"Cmd-Alt-]\", run: unfoldCode },\n { key: \"Ctrl-Alt-[\", run: foldAll },\n { key: \"Ctrl-Alt-]\", run: unfoldAll }\n];\nconst defaultConfig = {\n placeholderDOM: null,\n preparePlaceholder: null,\n placeholderText: \"…\"\n};\nconst foldConfig = /*@__PURE__*/Facet.define({\n combine(values) { return combineConfig(values, defaultConfig); }\n});\n/**\nCreate an extension that configures code folding.\n*/\nfunction codeFolding(config) {\n let result = [foldState, baseTheme$1];\n if (config)\n result.push(foldConfig.of(config));\n return result;\n}\nfunction widgetToDOM(view, prepared) {\n let { state } = view, conf = state.facet(foldConfig);\n let onclick = (event) => {\n let line = view.lineBlockAt(view.posAtDOM(event.target));\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n view.dispatch({ effects: unfoldEffect.of(folded) });\n event.preventDefault();\n };\n if (conf.placeholderDOM)\n return conf.placeholderDOM(view, onclick, prepared);\n let element = document.createElement(\"span\");\n element.textContent = conf.placeholderText;\n element.setAttribute(\"aria-label\", state.phrase(\"folded code\"));\n element.title = state.phrase(\"unfold\");\n element.className = \"cm-foldPlaceholder\";\n element.onclick = onclick;\n return element;\n}\nconst foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {\n toDOM(view) { return widgetToDOM(view, null); }\n } });\nclass PreparedFoldWidget extends WidgetType {\n constructor(value) {\n super();\n this.value = value;\n }\n eq(other) { return this.value == other.value; }\n toDOM(view) { return widgetToDOM(view, this.value); }\n}\nconst foldGutterDefaults = {\n openText: \"⌄\",\n closedText: \"›\",\n markerDOM: null,\n domEventHandlers: {},\n foldingChanged: () => false\n};\nclass FoldMarker extends GutterMarker {\n constructor(config, open) {\n super();\n this.config = config;\n this.open = open;\n }\n eq(other) { return this.config == other.config && this.open == other.open; }\n toDOM(view) {\n if (this.config.markerDOM)\n return this.config.markerDOM(this.open);\n let span = document.createElement(\"span\");\n span.textContent = this.open ? this.config.openText : this.config.closedText;\n span.title = view.state.phrase(this.open ? \"Fold line\" : \"Unfold line\");\n return span;\n }\n}\n/**\nCreate an extension that registers a fold gutter, which shows a\nfold status indicator before foldable lines (which can be clicked\nto fold or unfold the line).\n*/\nfunction foldGutter(config = {}) {\n let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);\n let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);\n let markers = ViewPlugin.fromClass(class {\n constructor(view) {\n this.from = view.viewport.from;\n this.markers = this.buildMarkers(view);\n }\n update(update) {\n if (update.docChanged || update.viewportChanged ||\n update.startState.facet(language) != update.state.facet(language) ||\n update.startState.field(foldState, false) != update.state.field(foldState, false) ||\n syntaxTree(update.startState) != syntaxTree(update.state) ||\n fullConfig.foldingChanged(update))\n this.markers = this.buildMarkers(update.view);\n }\n buildMarkers(view) {\n let builder = new RangeSetBuilder();\n for (let line of view.viewportLineBlocks) {\n let mark = findFold(view.state, line.from, line.to) ? canUnfold\n : foldable(view.state, line.from, line.to) ? canFold : null;\n if (mark)\n builder.add(line.from, line.from, mark);\n }\n return builder.finish();\n }\n });\n let { domEventHandlers } = fullConfig;\n return [\n markers,\n gutter({\n class: \"cm-foldGutter\",\n markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },\n initialSpacer() {\n return new FoldMarker(fullConfig, false);\n },\n domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {\n if (domEventHandlers.click && domEventHandlers.click(view, line, event))\n return true;\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n view.dispatch({ effects: unfoldEffect.of(folded) });\n return true;\n }\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: foldEffect.of(range) });\n return true;\n }\n return false;\n } })\n }),\n codeFolding()\n ];\n}\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-foldPlaceholder\": {\n backgroundColor: \"#eee\",\n border: \"1px solid #ddd\",\n color: \"#888\",\n borderRadius: \".2em\",\n margin: \"0 1px\",\n padding: \"0 1px\",\n cursor: \"pointer\"\n },\n \".cm-foldGutter span\": {\n padding: \"0 1px\",\n cursor: \"pointer\"\n }\n});\n\n/**\nA highlight style associates CSS styles with higlighting\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).\n*/\nclass HighlightStyle {\n constructor(\n /**\n The tag styles used to create this highlight style.\n */\n specs, options) {\n this.specs = specs;\n let modSpec;\n function def(spec) {\n let cls = StyleModule.newName();\n (modSpec || (modSpec = Object.create(null)))[\".\" + cls] = spec;\n return cls;\n }\n const all = typeof options.all == \"string\" ? options.all : options.all ? def(options.all) : undefined;\n const scopeOpt = options.scope;\n this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data\n : scopeOpt ? (type) => type == scopeOpt : undefined;\n this.style = tagHighlighter(specs.map(style => ({\n tag: style.tag,\n class: style.class || def(Object.assign({}, style, { tag: null }))\n })), {\n all,\n }).style;\n this.module = modSpec ? new StyleModule(modSpec) : null;\n this.themeType = options.themeType;\n }\n /**\n Create a highlighter style that associates the given styles to\n the given tags. The specs must be objects that hold a style tag\n or array of tags in their `tag` property, and either a single\n `class` property providing a static CSS class (for highlighter\n that rely on external styling), or a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style\n set of CSS properties (which define the styling for those tags).\n \n The CSS rules created for a highlighter will be emitted in the\n order of the spec's properties. That means that for elements that\n have multiple tags associated with them, styles defined further\n down in the list will have a higher CSS precedence than styles\n defined earlier.\n */\n static define(specs, options) {\n return new HighlightStyle(specs, options || {});\n }\n}\nconst highlighterFacet = /*@__PURE__*/Facet.define();\nconst fallbackHighlighter = /*@__PURE__*/Facet.define({\n combine(values) { return values.length ? [values[0]] : null; }\n});\nfunction getHighlighters(state) {\n let main = state.facet(highlighterFacet);\n return main.length ? main : state.facet(fallbackHighlighter);\n}\n/**\nWrap a highlighter in an editor extension that uses it to apply\nsyntax highlighting to the editor content.\n\nWhen multiple (non-fallback) styles are provided, the styling\napplied is the union of the classes they emit.\n*/\nfunction syntaxHighlighting(highlighter, options) {\n let ext = [treeHighlighter], themeType;\n if (highlighter instanceof HighlightStyle) {\n if (highlighter.module)\n ext.push(EditorView.styleModule.of(highlighter.module));\n themeType = highlighter.themeType;\n }\n if (options === null || options === void 0 ? void 0 : options.fallback)\n ext.push(fallbackHighlighter.of(highlighter));\n else if (themeType)\n ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {\n return state.facet(EditorView.darkTheme) == (themeType == \"dark\") ? [highlighter] : [];\n }));\n else\n ext.push(highlighterFacet.of(highlighter));\n return ext;\n}\n/**\nReturns the CSS classes (if any) that the highlighters active in\nthe state would assign to the given style\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag) and\n(optional) language\n[scope](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define^options.scope).\n*/\nfunction highlightingFor(state, tags, scope) {\n let highlighters = getHighlighters(state);\n let result = null;\n if (highlighters)\n for (let highlighter of highlighters) {\n if (!highlighter.scope || scope && highlighter.scope(scope)) {\n let cls = highlighter.style(tags);\n if (cls)\n result = result ? result + \" \" + cls : cls;\n }\n }\n return result;\n}\nclass TreeHighlighter {\n constructor(view) {\n this.markCache = Object.create(null);\n this.tree = syntaxTree(view.state);\n this.decorations = this.buildDeco(view, getHighlighters(view.state));\n }\n update(update) {\n let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);\n let styleChange = highlighters != getHighlighters(update.startState);\n if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {\n this.decorations = this.decorations.map(update.changes);\n }\n else if (tree != this.tree || update.viewportChanged || styleChange) {\n this.tree = tree;\n this.decorations = this.buildDeco(update.view, highlighters);\n }\n }\n buildDeco(view, highlighters) {\n if (!highlighters || !this.tree.length)\n return Decoration.none;\n let builder = new RangeSetBuilder();\n for (let { from, to } of view.visibleRanges) {\n highlightTree(this.tree, highlighters, (from, to, style) => {\n builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));\n }, from, to);\n }\n return builder.finish();\n }\n}\nconst treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {\n decorations: v => v.decorations\n}));\n/**\nA default highlight style (works well with light themes).\n*/\nconst defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([\n { tag: tags.meta,\n color: \"#404740\" },\n { tag: tags.link,\n textDecoration: \"underline\" },\n { tag: tags.heading,\n textDecoration: \"underline\",\n fontWeight: \"bold\" },\n { tag: tags.emphasis,\n fontStyle: \"italic\" },\n { tag: tags.strong,\n fontWeight: \"bold\" },\n { tag: tags.strikethrough,\n textDecoration: \"line-through\" },\n { tag: tags.keyword,\n color: \"#708\" },\n { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],\n color: \"#219\" },\n { tag: [tags.literal, tags.inserted],\n color: \"#164\" },\n { tag: [tags.string, tags.deleted],\n color: \"#a11\" },\n { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],\n color: \"#e40\" },\n { tag: /*@__PURE__*/tags.definition(tags.variableName),\n color: \"#00f\" },\n { tag: /*@__PURE__*/tags.local(tags.variableName),\n color: \"#30a\" },\n { tag: [tags.typeName, tags.namespace],\n color: \"#085\" },\n { tag: tags.className,\n color: \"#167\" },\n { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],\n color: \"#256\" },\n { tag: /*@__PURE__*/tags.definition(tags.propertyName),\n color: \"#00c\" },\n { tag: tags.comment,\n color: \"#940\" },\n { tag: tags.invalid,\n color: \"#f00\" }\n]);\n\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \"&.cm-focused .cm-matchingBracket\": { backgroundColor: \"#328c8252\" },\n \"&.cm-focused .cm-nonmatchingBracket\": { backgroundColor: \"#bb555544\" }\n});\nconst DefaultScanDist = 10000, DefaultBrackets = \"()[]{}\";\nconst bracketMatchingConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n afterCursor: true,\n brackets: DefaultBrackets,\n maxScanDistance: DefaultScanDist,\n renderMatch: defaultRenderMatch\n });\n }\n});\nconst matchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-matchingBracket\" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-nonmatchingBracket\" });\nfunction defaultRenderMatch(match) {\n let decorations = [];\n let mark = match.matched ? matchingMark : nonmatchingMark;\n decorations.push(mark.range(match.start.from, match.start.to));\n if (match.end)\n decorations.push(mark.range(match.end.from, match.end.to));\n return decorations;\n}\nconst bracketMatchingState = /*@__PURE__*/StateField.define({\n create() { return Decoration.none; },\n update(deco, tr) {\n if (!tr.docChanged && !tr.selection)\n return deco;\n let decorations = [];\n let config = tr.state.facet(bracketMatchingConfig);\n for (let range of tr.state.selection.ranges) {\n if (!range.empty)\n continue;\n let match = matchBrackets(tr.state, range.head, -1, config)\n || (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))\n || (config.afterCursor &&\n (matchBrackets(tr.state, range.head, 1, config) ||\n (range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));\n if (match)\n decorations = decorations.concat(config.renderMatch(match, tr.state));\n }\n return Decoration.set(decorations, true);\n },\n provide: f => EditorView.decorations.from(f)\n});\nconst bracketMatchingUnique = [\n bracketMatchingState,\n baseTheme\n];\n/**\nCreate an extension that enables bracket matching. Whenever the\ncursor is next to a bracket, that bracket and the one it matches\nare highlighted. Or, when no matching bracket is found, another\nhighlighting style is used to indicate this.\n*/\nfunction bracketMatching(config = {}) {\n return [bracketMatchingConfig.of(config), bracketMatchingUnique];\n}\n/**\nWhen larger syntax nodes, such as HTML tags, are marked as\nopening/closing, it can be a bit messy to treat the whole node as\na matchable bracket. This node prop allows you to define, for such\na node, a ‘handle’—the part of the node that is highlighted, and\nthat the cursor must be on to activate highlighting in the first\nplace.\n*/\nconst bracketMatchingHandle = /*@__PURE__*/new NodeProp();\nfunction matchingNodes(node, dir, brackets) {\n let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);\n if (byProp)\n return byProp;\n if (node.name.length == 1) {\n let index = brackets.indexOf(node.name);\n if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))\n return [brackets[index + dir]];\n }\n return null;\n}\nfunction findHandle(node) {\n let hasHandle = node.type.prop(bracketMatchingHandle);\n return hasHandle ? hasHandle(node.node) : node;\n}\n/**\nFind the matching bracket for the token at `pos`, scanning\ndirection `dir`. Only the `brackets` and `maxScanDistance`\nproperties are used from `config`, if given. Returns null if no\nbracket was found at `pos`, or a match result otherwise.\n*/\nfunction matchBrackets(state, pos, dir, config = {}) {\n let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;\n let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);\n for (let cur = node; cur; cur = cur.parent) {\n let matches = matchingNodes(cur.type, dir, brackets);\n if (matches && cur.from < cur.to) {\n let handle = findHandle(cur);\n if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))\n return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);\n }\n }\n return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);\n}\nfunction matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {\n let parent = token.parent, firstToken = { from: handle.from, to: handle.to };\n let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();\n if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))\n do {\n if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {\n if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {\n let endHandle = findHandle(cursor);\n return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };\n }\n else if (matchingNodes(cursor.type, dir, brackets)) {\n depth++;\n }\n else if (matchingNodes(cursor.type, -dir, brackets)) {\n if (depth == 0) {\n let endHandle = findHandle(cursor);\n return {\n start: firstToken,\n end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,\n matched: false\n };\n }\n depth--;\n }\n }\n } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());\n return { start: firstToken, matched: false };\n}\nfunction matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {\n let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);\n let bracket = brackets.indexOf(startCh);\n if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))\n return null;\n let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };\n let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;\n for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {\n let text = iter.value;\n if (dir < 0)\n distance += text.length;\n let basePos = pos + distance * dir;\n for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {\n let found = brackets.indexOf(text[pos]);\n if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)\n continue;\n if ((found % 2 == 0) == (dir > 0)) {\n depth++;\n }\n else if (depth == 1) { // Closing\n return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };\n }\n else {\n depth--;\n }\n }\n if (dir > 0)\n distance += text.length;\n }\n return iter.done ? { start: startToken, matched: false } : null;\n}\n\n// Counts the column offset in a string, taking tabs into account.\n// Used mostly to find indentation.\nfunction countCol(string, end, tabSize, startIndex = 0, startValue = 0) {\n if (end == null) {\n end = string.search(/[^\\s\\u00a0]/);\n if (end == -1)\n end = string.length;\n }\n let n = startValue;\n for (let i = startIndex; i < end; i++) {\n if (string.charCodeAt(i) == 9)\n n += tabSize - (n % tabSize);\n else\n n++;\n }\n return n;\n}\n/**\nEncapsulates a single line of input. Given to stream syntax code,\nwhich uses it to tokenize the content.\n*/\nclass StringStream {\n /**\n Create a stream.\n */\n constructor(\n /**\n The line.\n */\n string, tabSize, \n /**\n The current indent unit size.\n */\n indentUnit, overrideIndent) {\n this.string = string;\n this.tabSize = tabSize;\n this.indentUnit = indentUnit;\n this.overrideIndent = overrideIndent;\n /**\n The current position on the line.\n */\n this.pos = 0;\n /**\n The start position of the current token.\n */\n this.start = 0;\n this.lastColumnPos = 0;\n this.lastColumnValue = 0;\n }\n /**\n True if we are at the end of the line.\n */\n eol() { return this.pos >= this.string.length; }\n /**\n True if we are at the start of the line.\n */\n sol() { return this.pos == 0; }\n /**\n Get the next code unit after the current position, or undefined\n if we're at the end of the line.\n */\n peek() { return this.string.charAt(this.pos) || undefined; }\n /**\n Read the next code unit and advance `this.pos`.\n */\n next() {\n if (this.pos < this.string.length)\n return this.string.charAt(this.pos++);\n }\n /**\n Match the next character against the given string, regular\n expression, or predicate. Consume and return it if it matches.\n */\n eat(match) {\n let ch = this.string.charAt(this.pos);\n let ok;\n if (typeof match == \"string\")\n ok = ch == match;\n else\n ok = ch && (match instanceof RegExp ? match.test(ch) : match(ch));\n if (ok) {\n ++this.pos;\n return ch;\n }\n }\n /**\n Continue matching characters that match the given string,\n regular expression, or predicate function. Return true if any\n characters were consumed.\n */\n eatWhile(match) {\n let start = this.pos;\n while (this.eat(match)) { }\n return this.pos > start;\n }\n /**\n Consume whitespace ahead of `this.pos`. Return true if any was\n found.\n */\n eatSpace() {\n let start = this.pos;\n while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos)))\n ++this.pos;\n return this.pos > start;\n }\n /**\n Move to the end of the line.\n */\n skipToEnd() { this.pos = this.string.length; }\n /**\n Move to directly before the given character, if found on the\n current line.\n */\n skipTo(ch) {\n let found = this.string.indexOf(ch, this.pos);\n if (found > -1) {\n this.pos = found;\n return true;\n }\n }\n /**\n Move back `n` characters.\n */\n backUp(n) { this.pos -= n; }\n /**\n Get the column position at `this.pos`.\n */\n column() {\n if (this.lastColumnPos < this.start) {\n this.lastColumnValue = countCol(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);\n this.lastColumnPos = this.start;\n }\n return this.lastColumnValue;\n }\n /**\n Get the indentation column of the current line.\n */\n indentation() {\n var _a;\n return (_a = this.overrideIndent) !== null && _a !== void 0 ? _a : countCol(this.string, null, this.tabSize);\n }\n /**\n Match the input against the given string or regular expression\n (which should start with a `^`). Return true or the regexp match\n if it matches.\n \n Unless `consume` is set to `false`, this will move `this.pos`\n past the matched text.\n \n When matching a string `caseInsensitive` can be set to true to\n make the match case-insensitive.\n */\n match(pattern, consume, caseInsensitive) {\n if (typeof pattern == \"string\") {\n let cased = (str) => caseInsensitive ? str.toLowerCase() : str;\n let substr = this.string.substr(this.pos, pattern.length);\n if (cased(substr) == cased(pattern)) {\n if (consume !== false)\n this.pos += pattern.length;\n return true;\n }\n else\n return null;\n }\n else {\n let match = this.string.slice(this.pos).match(pattern);\n if (match && match.index > 0)\n return null;\n if (match && consume !== false)\n this.pos += match[0].length;\n return match;\n }\n }\n /**\n Get the current token.\n */\n current() { return this.string.slice(this.start, this.pos); }\n}\n\nfunction fullParser(spec) {\n return {\n name: spec.name || \"\",\n token: spec.token,\n blankLine: spec.blankLine || (() => { }),\n startState: spec.startState || (() => true),\n copyState: spec.copyState || defaultCopyState,\n indent: spec.indent || (() => null),\n languageData: spec.languageData || {},\n tokenTable: spec.tokenTable || noTokens\n };\n}\nfunction defaultCopyState(state) {\n if (typeof state != \"object\")\n return state;\n let newState = {};\n for (let prop in state) {\n let val = state[prop];\n newState[prop] = (val instanceof Array ? val.slice() : val);\n }\n return newState;\n}\nconst IndentedFrom = /*@__PURE__*/new WeakMap();\n/**\nA [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a CodeMirror\n5-style [streaming parser](https://codemirror.net/6/docs/ref/#language.StreamParser).\n*/\nclass StreamLanguage extends Language {\n constructor(parser) {\n let data = defineLanguageFacet(parser.languageData);\n let p = fullParser(parser), self;\n let impl = new class extends Parser {\n createParse(input, fragments, ranges) {\n return new Parse(self, input, fragments, ranges);\n }\n };\n super(data, impl, [indentService.of((cx, pos) => this.getIndent(cx, pos))], parser.name);\n this.topNode = docID(data);\n self = this;\n this.streamParser = p;\n this.stateAfter = new NodeProp({ perNode: true });\n this.tokenTable = parser.tokenTable ? new TokenTable(p.tokenTable) : defaultTokenTable;\n }\n /**\n Define a stream language.\n */\n static define(spec) { return new StreamLanguage(spec); }\n getIndent(cx, pos) {\n let tree = syntaxTree(cx.state), at = tree.resolve(pos);\n while (at && at.type != this.topNode)\n at = at.parent;\n if (!at)\n return null;\n let from = undefined;\n let { overrideIndentation } = cx.options;\n if (overrideIndentation) {\n from = IndentedFrom.get(cx.state);\n if (from != null && from < pos - 1e4)\n from = undefined;\n }\n let start = findState(this, tree, 0, at.from, from !== null && from !== void 0 ? from : pos), statePos, state;\n if (start) {\n state = start.state;\n statePos = start.pos + 1;\n }\n else {\n state = this.streamParser.startState(cx.unit);\n statePos = 0;\n }\n if (pos - statePos > 10000 /* C.MaxIndentScanDist */)\n return null;\n while (statePos < pos) {\n let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);\n if (line.length) {\n let indentation = overrideIndentation ? overrideIndentation(line.from) : -1;\n let stream = new StringStream(line.text, cx.state.tabSize, cx.unit, indentation < 0 ? undefined : indentation);\n while (stream.pos < end - line.from)\n readToken(this.streamParser.token, stream, state);\n }\n else {\n this.streamParser.blankLine(state, cx.unit);\n }\n if (end == pos)\n break;\n statePos = line.to + 1;\n }\n let line = cx.lineAt(pos);\n if (overrideIndentation && from == null)\n IndentedFrom.set(cx.state, line.from);\n return this.streamParser.indent(state, /^\\s*(.*)/.exec(line.text)[1], cx);\n }\n get allowsNesting() { return false; }\n}\nfunction findState(lang, tree, off, startPos, before) {\n let state = off >= startPos && off + tree.length <= before && tree.prop(lang.stateAfter);\n if (state)\n return { state: lang.streamParser.copyState(state), pos: off + tree.length };\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let child = tree.children[i], pos = off + tree.positions[i];\n let found = child instanceof Tree && pos < before && findState(lang, child, pos, startPos, before);\n if (found)\n return found;\n }\n return null;\n}\nfunction cutTree(lang, tree, from, to, inside) {\n if (inside && from <= 0 && to >= tree.length)\n return tree;\n if (!inside && tree.type == lang.topNode)\n inside = true;\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let pos = tree.positions[i], child = tree.children[i], inner;\n if (pos < to && child instanceof Tree) {\n if (!(inner = cutTree(lang, child, from - pos, to - pos, inside)))\n break;\n return !inside ? inner\n : new Tree(tree.type, tree.children.slice(0, i).concat(inner), tree.positions.slice(0, i + 1), pos + inner.length);\n }\n }\n return null;\n}\nfunction findStartInFragments(lang, fragments, startPos, editorState) {\n for (let f of fragments) {\n let from = f.from + (f.openStart ? 25 : 0), to = f.to - (f.openEnd ? 25 : 0);\n let found = from <= startPos && to > startPos && findState(lang, f.tree, 0 - f.offset, startPos, to), tree;\n if (found && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))\n return { state: found.state, tree };\n }\n return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: Tree.empty };\n}\nclass Parse {\n constructor(lang, input, fragments, ranges) {\n this.lang = lang;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.stoppedAt = null;\n this.chunks = [];\n this.chunkPos = [];\n this.chunk = [];\n this.chunkReused = undefined;\n this.rangeIndex = 0;\n this.to = ranges[ranges.length - 1].to;\n let context = ParseContext.get(), from = ranges[0].from;\n let { state, tree } = findStartInFragments(lang, fragments, from, context === null || context === void 0 ? void 0 : context.state);\n this.state = state;\n this.parsedPos = this.chunkStart = from + tree.length;\n for (let i = 0; i < tree.children.length; i++) {\n this.chunks.push(tree.children[i]);\n this.chunkPos.push(tree.positions[i]);\n }\n if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */) {\n this.state = this.lang.streamParser.startState(getIndentUnit(context.state));\n context.skipUntilInView(this.parsedPos, context.viewport.from);\n this.parsedPos = context.viewport.from;\n }\n this.moveRangeIndex();\n }\n advance() {\n let context = ParseContext.get();\n let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);\n let end = Math.min(parseEnd, this.chunkStart + 2048 /* C.ChunkSize */);\n if (context)\n end = Math.min(end, context.viewport.to);\n while (this.parsedPos < end)\n this.parseLine(context);\n if (this.chunkStart < this.parsedPos)\n this.finishChunk();\n if (this.parsedPos >= parseEnd)\n return this.finish();\n if (context && this.parsedPos >= context.viewport.to) {\n context.skipUntilInView(this.parsedPos, parseEnd);\n return this.finish();\n }\n return null;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n }\n lineAfter(pos) {\n let chunk = this.input.chunk(pos);\n if (!this.input.lineChunks) {\n let eol = chunk.indexOf(\"\\n\");\n if (eol > -1)\n chunk = chunk.slice(0, eol);\n }\n else if (chunk == \"\\n\") {\n chunk = \"\";\n }\n return pos + chunk.length <= this.to ? chunk : chunk.slice(0, this.to - pos);\n }\n nextLine() {\n let from = this.parsedPos, line = this.lineAfter(from), end = from + line.length;\n for (let index = this.rangeIndex;;) {\n let rangeEnd = this.ranges[index].to;\n if (rangeEnd >= end)\n break;\n line = line.slice(0, rangeEnd - (end - line.length));\n index++;\n if (index == this.ranges.length)\n break;\n let rangeStart = this.ranges[index].from;\n let after = this.lineAfter(rangeStart);\n line += after;\n end = rangeStart + after.length;\n }\n return { line, end };\n }\n skipGapsTo(pos, offset, side) {\n for (;;) {\n let end = this.ranges[this.rangeIndex].to, offPos = pos + offset;\n if (side > 0 ? end > offPos : end >= offPos)\n break;\n let start = this.ranges[++this.rangeIndex].from;\n offset += start - end;\n }\n return offset;\n }\n moveRangeIndex() {\n while (this.ranges[this.rangeIndex].to < this.parsedPos)\n this.rangeIndex++;\n }\n emitToken(id, from, to, size, offset) {\n if (this.ranges.length > 1) {\n offset = this.skipGapsTo(from, offset, 1);\n from += offset;\n let len0 = this.chunk.length;\n offset = this.skipGapsTo(to, offset, -1);\n to += offset;\n size += this.chunk.length - len0;\n }\n this.chunk.push(id, from, to, size);\n return offset;\n }\n parseLine(context) {\n let { line, end } = this.nextLine(), offset = 0, { streamParser } = this.lang;\n let stream = new StringStream(line, context ? context.state.tabSize : 4, context ? getIndentUnit(context.state) : 2);\n if (stream.eol()) {\n streamParser.blankLine(this.state, stream.indentUnit);\n }\n else {\n while (!stream.eol()) {\n let token = readToken(streamParser.token, stream, this.state);\n if (token)\n offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, 4, offset);\n if (stream.start > 10000 /* C.MaxLineLength */)\n break;\n }\n }\n this.parsedPos = end;\n this.moveRangeIndex();\n if (this.parsedPos < this.to)\n this.parsedPos++;\n }\n finishChunk() {\n let tree = Tree.build({\n buffer: this.chunk,\n start: this.chunkStart,\n length: this.parsedPos - this.chunkStart,\n nodeSet,\n topID: 0,\n maxBufferLength: 2048 /* C.ChunkSize */,\n reused: this.chunkReused\n });\n tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);\n this.chunks.push(tree);\n this.chunkPos.push(this.chunkStart - this.ranges[0].from);\n this.chunk = [];\n this.chunkReused = undefined;\n this.chunkStart = this.parsedPos;\n }\n finish() {\n return new Tree(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();\n }\n}\nfunction readToken(token, stream, state) {\n stream.start = stream.pos;\n for (let i = 0; i < 10; i++) {\n let result = token(stream, state);\n if (stream.pos > stream.start)\n return result;\n }\n throw new Error(\"Stream parser failed to advance stream.\");\n}\nconst noTokens = /*@__PURE__*/Object.create(null);\nconst typeArray = [NodeType.none];\nconst nodeSet = /*@__PURE__*/new NodeSet(typeArray);\nconst warned = [];\n// Cache of node types by name and tags\nconst byTag = /*@__PURE__*/Object.create(null);\nconst defaultTable = /*@__PURE__*/Object.create(null);\nfor (let [legacyName, name] of [\n [\"variable\", \"variableName\"],\n [\"variable-2\", \"variableName.special\"],\n [\"string-2\", \"string.special\"],\n [\"def\", \"variableName.definition\"],\n [\"tag\", \"tagName\"],\n [\"attribute\", \"attributeName\"],\n [\"type\", \"typeName\"],\n [\"builtin\", \"variableName.standard\"],\n [\"qualifier\", \"modifier\"],\n [\"error\", \"invalid\"],\n [\"header\", \"heading\"],\n [\"property\", \"propertyName\"]\n])\n defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);\nclass TokenTable {\n constructor(extra) {\n this.extra = extra;\n this.table = Object.assign(Object.create(null), defaultTable);\n }\n resolve(tag) {\n return !tag ? 0 : this.table[tag] || (this.table[tag] = createTokenType(this.extra, tag));\n }\n}\nconst defaultTokenTable = /*@__PURE__*/new TokenTable(noTokens);\nfunction warnForPart(part, msg) {\n if (warned.indexOf(part) > -1)\n return;\n warned.push(part);\n console.warn(msg);\n}\nfunction createTokenType(extra, tagStr) {\n let tags$1 = [];\n for (let name of tagStr.split(\" \")) {\n let found = [];\n for (let part of name.split(\".\")) {\n let value = (extra[part] || tags[part]);\n if (!value) {\n warnForPart(part, `Unknown highlighting tag ${part}`);\n }\n else if (typeof value == \"function\") {\n if (!found.length)\n warnForPart(part, `Modifier ${part} used at start of tag`);\n else\n found = found.map(value);\n }\n else {\n if (found.length)\n warnForPart(part, `Tag ${part} used as modifier`);\n else\n found = Array.isArray(value) ? value : [value];\n }\n }\n for (let tag of found)\n tags$1.push(tag);\n }\n if (!tags$1.length)\n return 0;\n let name = tagStr.replace(/ /g, \"_\"), key = name + \" \" + tags$1.map(t => t.id);\n let known = byTag[key];\n if (known)\n return known.id;\n let type = byTag[key] = NodeType.define({\n id: typeArray.length,\n name,\n props: [styleTags({ [name]: tags$1 })]\n });\n typeArray.push(type);\n return type.id;\n}\nfunction docID(data) {\n let type = NodeType.define({ id: typeArray.length, name: \"Document\", props: [languageDataProp.add(() => data)], top: true });\n typeArray.push(type);\n return type;\n}\n\nexport { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, StreamLanguage, StringStream, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };\n","import { Annotation, Facet, combineConfig, StateField, EditorSelection, Transaction, ChangeSet, ChangeDesc, StateEffect, Text, findClusterBreak, countColumn, CharCategory } from '@codemirror/state';\nimport { EditorView, Direction } from '@codemirror/view';\nimport { IndentContext, getIndentation, indentString, matchBrackets, syntaxTree, getIndentUnit, indentUnit } from '@codemirror/language';\nimport { NodeProp } from '@lezer/common';\n\n/**\nComment or uncomment the current selection. Will use line comments\nif available, otherwise falling back to block comments.\n*/\nconst toggleComment = target => {\n let { state } = target, line = state.doc.lineAt(state.selection.main.from), config = getConfig(target.state, line.from);\n return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;\n};\nfunction command(f, option) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let tr = f(option, state);\n if (!tr)\n return false;\n dispatch(state.update(tr));\n return true;\n };\n}\n/**\nComment or uncomment the current selection using line comments.\nThe line comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using line comments.\n*/\nconst lineComment = /*@__PURE__*/command(changeLineComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using line comments.\n*/\nconst lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the current selection using block comments.\nThe block comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using block comments.\n*/\nconst blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using block comments.\n*/\nconst blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the lines around the current selection using\nblock comments.\n*/\nconst toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);\nfunction getConfig(state, pos) {\n let data = state.languageDataAt(\"commentTokens\", pos);\n return data.length ? data[0] : {};\n}\nconst SearchMargin = 50;\n/**\nDetermines if the given range is block-commented in the given\nstate.\n*/\nfunction findBlockComment(state, { open, close }, from, to) {\n let textBefore = state.sliceDoc(from - SearchMargin, from);\n let textAfter = state.sliceDoc(to, to + SearchMargin);\n let spaceBefore = /\\s*$/.exec(textBefore)[0].length, spaceAfter = /^\\s*/.exec(textAfter)[0].length;\n let beforeOff = textBefore.length - spaceBefore;\n if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&\n textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {\n return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },\n close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };\n }\n let startText, endText;\n if (to - from <= 2 * SearchMargin) {\n startText = endText = state.sliceDoc(from, to);\n }\n else {\n startText = state.sliceDoc(from, from + SearchMargin);\n endText = state.sliceDoc(to - SearchMargin, to);\n }\n let startSpace = /^\\s*/.exec(startText)[0].length, endSpace = /\\s*$/.exec(endText)[0].length;\n let endOff = endText.length - endSpace - close.length;\n if (startText.slice(startSpace, startSpace + open.length) == open &&\n endText.slice(endOff, endOff + close.length) == close) {\n return { open: { pos: from + startSpace + open.length,\n margin: /\\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },\n close: { pos: to - endSpace - close.length,\n margin: /\\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };\n }\n return null;\n}\nfunction selectedLineRanges(state) {\n let ranges = [];\n for (let r of state.selection.ranges) {\n let fromLine = state.doc.lineAt(r.from);\n let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last].to > fromLine.from)\n ranges[last].to = toLine.to;\n else\n ranges.push({ from: fromLine.from + /^\\s*/.exec(fromLine.text)[0].length, to: toLine.to });\n }\n return ranges;\n}\n// Performs toggle, comment and uncomment of block comments in\n// languages that support them.\nfunction changeBlockComment(option, state, ranges = state.selection.ranges) {\n let tokens = ranges.map(r => getConfig(state, r.from).block);\n if (!tokens.every(c => c))\n return null;\n let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));\n if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {\n return { changes: state.changes(ranges.map((range, i) => {\n if (comments[i])\n return [];\n return [{ from: range.from, insert: tokens[i].open + \" \" }, { from: range.to, insert: \" \" + tokens[i].close }];\n })) };\n }\n else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {\n let changes = [];\n for (let i = 0, comment; i < comments.length; i++)\n if (comment = comments[i]) {\n let token = tokens[i], { open, close } = comment;\n changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });\n }\n return { changes };\n }\n return null;\n}\n// Performs toggle, comment and uncomment of line comments.\nfunction changeLineComment(option, state, ranges = state.selection.ranges) {\n let lines = [];\n let prevLine = -1;\n for (let { from, to } of ranges) {\n let startI = lines.length, minIndent = 1e9;\n let token = getConfig(state, from).line;\n if (!token)\n continue;\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n if (line.from > prevLine && (from == to || to > line.from)) {\n prevLine = line.from;\n let indent = /^\\s*/.exec(line.text)[0].length;\n let empty = indent == line.length;\n let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;\n if (indent < line.text.length && indent < minIndent)\n minIndent = indent;\n lines.push({ line, comment, token, indent, empty, single: false });\n }\n pos = line.to + 1;\n }\n if (minIndent < 1e9)\n for (let i = startI; i < lines.length; i++)\n if (lines[i].indent < lines[i].line.text.length)\n lines[i].indent = minIndent;\n if (lines.length == startI + 1)\n lines[startI].single = true;\n }\n if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {\n let changes = [];\n for (let { line, token, indent, empty, single } of lines)\n if (single || !empty)\n changes.push({ from: line.from + indent, insert: token + \" \" });\n let changeSet = state.changes(changes);\n return { changes: changeSet, selection: state.selection.map(changeSet, 1) };\n }\n else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {\n let changes = [];\n for (let { line, comment, token } of lines)\n if (comment >= 0) {\n let from = line.from + comment, to = from + token.length;\n if (line.text[to - line.from] == \" \")\n to++;\n changes.push({ from, to });\n }\n return { changes };\n }\n return null;\n}\n\nconst fromHistory = /*@__PURE__*/Annotation.define();\n/**\nTransaction annotation that will prevent that transaction from\nbeing combined with other transactions in the undo history. Given\n`\"before\"`, it'll prevent merging with previous transactions. With\n`\"after\"`, subsequent transactions won't be combined with this\none. With `\"full\"`, the transaction is isolated on both sides.\n*/\nconst isolateHistory = /*@__PURE__*/Annotation.define();\n/**\nThis facet provides a way to register functions that, given a\ntransaction, provide a set of effects that the history should\nstore when inverting the transaction. This can be used to\nintegrate some kinds of effects in the history, so that they can\nbe undone (and redone again).\n*/\nconst invertedEffects = /*@__PURE__*/Facet.define();\nconst historyConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n minDepth: 100,\n newGroupDelay: 500,\n joinToEvent: (_t, isAdjacent) => isAdjacent,\n }, {\n minDepth: Math.max,\n newGroupDelay: Math.min,\n joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)\n });\n }\n});\nfunction changeEnd(changes) {\n let end = 0;\n changes.iterChangedRanges((_, to) => end = to);\n return end;\n}\nconst historyField_ = /*@__PURE__*/StateField.define({\n create() {\n return HistoryState.empty;\n },\n update(state, tr) {\n let config = tr.state.facet(historyConfig);\n let fromHist = tr.annotation(fromHistory);\n if (fromHist) {\n let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;\n let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;\n let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;\n if (item)\n other = updateBranch(other, other.length, config.minDepth, item);\n else\n other = addSelection(other, tr.startState.selection);\n return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);\n }\n let isolate = tr.annotation(isolateHistory);\n if (isolate == \"full\" || isolate == \"before\")\n state = state.isolate();\n if (tr.annotation(Transaction.addToHistory) === false)\n return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;\n let event = HistEvent.fromTransaction(tr);\n let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);\n if (event)\n state = state.addChanges(event, time, userEvent, config, tr);\n else if (tr.selection)\n state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);\n if (isolate == \"full\" || isolate == \"after\")\n state = state.isolate();\n return state;\n },\n toJSON(value) {\n return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };\n },\n fromJSON(json) {\n return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));\n }\n});\n/**\nCreate a history extension with the given configuration.\n*/\nfunction history(config = {}) {\n return [\n historyField_,\n historyConfig.of(config),\n EditorView.domEventHandlers({\n beforeinput(e, view) {\n let command = e.inputType == \"historyUndo\" ? undo : e.inputType == \"historyRedo\" ? redo : null;\n if (!command)\n return false;\n e.preventDefault();\n return command(view);\n }\n })\n ];\n}\n/**\nThe state field used to store the history data. Should probably\nonly be used when you want to\n[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or\n[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way\nthat preserves history.\n*/\nconst historyField = historyField_;\nfunction cmd(side, selection) {\n return function ({ state, dispatch }) {\n if (!selection && state.readOnly)\n return false;\n let historyState = state.field(historyField_, false);\n if (!historyState)\n return false;\n let tr = historyState.pop(side, state, selection);\n if (!tr)\n return false;\n dispatch(tr);\n return true;\n };\n}\n/**\nUndo a single group of history events. Returns false if no group\nwas available.\n*/\nconst undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);\n/**\nRedo a group of history events. Returns false if no group was\navailable.\n*/\nconst redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);\n/**\nUndo a change or selection change.\n*/\nconst undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);\n/**\nRedo a change or selection change.\n*/\nconst redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);\nfunction depth(side) {\n return function (state) {\n let histState = state.field(historyField_, false);\n if (!histState)\n return 0;\n let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;\n return branch.length - (branch.length && !branch[0].changes ? 1 : 0);\n };\n}\n/**\nThe amount of undoable change events available in a given state.\n*/\nconst undoDepth = /*@__PURE__*/depth(0 /* BranchName.Done */);\n/**\nThe amount of redoable change events available in a given state.\n*/\nconst redoDepth = /*@__PURE__*/depth(1 /* BranchName.Undone */);\n// History events store groups of changes or effects that need to be\n// undone/redone together.\nclass HistEvent {\n constructor(\n // The changes in this event. Normal events hold at least one\n // change or effect. But it may be necessary to store selection\n // events before the first change, in which case a special type of\n // instance is created which doesn't hold any changes, with\n // changes == startSelection == undefined\n changes, \n // The effects associated with this event\n effects, \n // Accumulated mapping (from addToHistory==false) that should be\n // applied to events below this one.\n mapped, \n // The selection before this event\n startSelection, \n // Stores selection changes after this event, to be used for\n // selection undo/redo.\n selectionsAfter) {\n this.changes = changes;\n this.effects = effects;\n this.mapped = mapped;\n this.startSelection = startSelection;\n this.selectionsAfter = selectionsAfter;\n }\n setSelAfter(after) {\n return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);\n }\n toJSON() {\n var _a, _b, _c;\n return {\n changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),\n mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),\n startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),\n selectionsAfter: this.selectionsAfter.map(s => s.toJSON())\n };\n }\n static fromJSON(json) {\n return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON));\n }\n // This does not check `addToHistory` and such, it assumes the\n // transaction needs to be converted to an item. Returns null when\n // there are no changes or effects in the transaction.\n static fromTransaction(tr, selection) {\n let effects = none;\n for (let invert of tr.startState.facet(invertedEffects)) {\n let result = invert(tr);\n if (result.length)\n effects = effects.concat(result);\n }\n if (!effects.length && tr.changes.empty)\n return null;\n return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none);\n }\n static selection(selections) {\n return new HistEvent(undefined, none, undefined, undefined, selections);\n }\n}\nfunction updateBranch(branch, to, maxLen, newEvent) {\n let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;\n let newBranch = branch.slice(start, to);\n newBranch.push(newEvent);\n return newBranch;\n}\nfunction isAdjacent(a, b) {\n let ranges = [], isAdjacent = false;\n a.iterChangedRanges((f, t) => ranges.push(f, t));\n b.iterChangedRanges((_f, _t, f, t) => {\n for (let i = 0; i < ranges.length;) {\n let from = ranges[i++], to = ranges[i++];\n if (t >= from && f <= to)\n isAdjacent = true;\n }\n });\n return isAdjacent;\n}\nfunction eqSelectionShape(a, b) {\n return a.ranges.length == b.ranges.length &&\n a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;\n}\nfunction conc(a, b) {\n return !a.length ? b : !b.length ? a : a.concat(b);\n}\nconst none = [];\nconst MaxSelectionsPerEvent = 200;\nfunction addSelection(branch, selection) {\n if (!branch.length) {\n return [HistEvent.selection([selection])];\n }\n else {\n let lastEvent = branch[branch.length - 1];\n let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));\n if (sels.length && sels[sels.length - 1].eq(selection))\n return branch;\n sels.push(selection);\n return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));\n }\n}\n// Assumes the top item has one or more selectionAfter values\nfunction popSelection(branch) {\n let last = branch[branch.length - 1];\n let newBranch = branch.slice();\n newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));\n return newBranch;\n}\n// Add a mapping to the top event in the given branch. If this maps\n// away all the changes and effects in that item, drop it and\n// propagate the mapping to the next item.\nfunction addMappingToBranch(branch, mapping) {\n if (!branch.length)\n return branch;\n let length = branch.length, selections = none;\n while (length) {\n let event = mapEvent(branch[length - 1], mapping, selections);\n if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping\n let result = branch.slice(0, length);\n result[length - 1] = event;\n return result;\n }\n else { // Drop this event, since there's no changes or effects left\n mapping = event.mapped;\n length--;\n selections = event.selectionsAfter;\n }\n }\n return selections.length ? [HistEvent.selection(selections)] : none;\n}\nfunction mapEvent(event, mapping, extraSelections) {\n let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections);\n // Change-less events don't store mappings (they are always the last event in a branch)\n if (!event.changes)\n return HistEvent.selection(selections);\n let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);\n let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;\n return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);\n}\nconst joinableUserEvent = /^(input\\.type|delete)($|\\.)/;\nclass HistoryState {\n constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {\n this.done = done;\n this.undone = undone;\n this.prevTime = prevTime;\n this.prevUserEvent = prevUserEvent;\n }\n isolate() {\n return this.prevTime ? new HistoryState(this.done, this.undone) : this;\n }\n addChanges(event, time, userEvent, config, tr) {\n let done = this.done, lastEvent = done[done.length - 1];\n if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&\n (!userEvent || joinableUserEvent.test(userEvent)) &&\n ((!lastEvent.selectionsAfter.length &&\n time - this.prevTime < config.newGroupDelay &&\n config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) ||\n // For compose (but not compose.start) events, always join with previous event\n userEvent == \"input.type.compose\")) {\n done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));\n }\n else {\n done = updateBranch(done, done.length, config.minDepth, event);\n }\n return new HistoryState(done, none, time, userEvent);\n }\n addSelection(selection, time, userEvent, newGroupDelay) {\n let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none;\n if (last.length > 0 &&\n time - this.prevTime < newGroupDelay &&\n userEvent == this.prevUserEvent && userEvent && /^select($|\\.)/.test(userEvent) &&\n eqSelectionShape(last[last.length - 1], selection))\n return this;\n return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);\n }\n addMapping(mapping) {\n return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);\n }\n pop(side, state, selection) {\n let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;\n if (branch.length == 0)\n return null;\n let event = branch[branch.length - 1];\n if (selection && event.selectionsAfter.length) {\n return state.update({\n selection: event.selectionsAfter[event.selectionsAfter.length - 1],\n annotations: fromHistory.of({ side, rest: popSelection(branch) }),\n userEvent: side == 0 /* BranchName.Done */ ? \"select.undo\" : \"select.redo\",\n scrollIntoView: true\n });\n }\n else if (!event.changes) {\n return null;\n }\n else {\n let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1);\n if (event.mapped)\n rest = addMappingToBranch(rest, event.mapped);\n return state.update({\n changes: event.changes,\n selection: event.startSelection,\n effects: event.effects,\n annotations: fromHistory.of({ side, rest }),\n filter: false,\n userEvent: side == 0 /* BranchName.Done */ ? \"undo\" : \"redo\",\n scrollIntoView: true\n });\n }\n }\n}\nHistoryState.empty = /*@__PURE__*/new HistoryState(none, none);\n/**\nDefault key bindings for the undo history.\n\n- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).\n- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).\n- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).\n- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).\n*/\nconst historyKeymap = [\n { key: \"Mod-z\", run: undo, preventDefault: true },\n { key: \"Mod-y\", mac: \"Mod-Shift-z\", run: redo, preventDefault: true },\n { linux: \"Ctrl-Shift-z\", run: redo, preventDefault: true },\n { key: \"Mod-u\", run: undoSelection, preventDefault: true },\n { key: \"Alt-u\", mac: \"Mod-Shift-u\", run: redoSelection, preventDefault: true }\n];\n\nfunction updateSel(sel, by) {\n return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);\n}\nfunction setSel(state, selection) {\n return state.update({ selection, scrollIntoView: true, userEvent: \"select\" });\n}\nfunction moveSel({ state, dispatch }, how) {\n let selection = updateSel(state.selection, how);\n if (selection.eq(state.selection))\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\nfunction rangeEnd(range, forward) {\n return EditorSelection.cursor(forward ? range.to : range.from);\n}\nfunction cursorByChar(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));\n}\nfunction ltrAtCursor(view) {\n return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;\n}\n/**\nMove the selection one character to the left (which is backward in\nleft-to-right text, forward in right-to-left text).\n*/\nconst cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));\n/**\nMove the selection one character to the right.\n*/\nconst cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));\n/**\nMove the selection one character forward.\n*/\nconst cursorCharForward = view => cursorByChar(view, true);\n/**\nMove the selection one character backward.\n*/\nconst cursorCharBackward = view => cursorByChar(view, false);\nfunction cursorByGroup(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection to the left across one group of word or\nnon-word (but also non-space) characters.\n*/\nconst cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection one group to the right.\n*/\nconst cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));\n/**\nMove the selection one group forward.\n*/\nconst cursorGroupForward = view => cursorByGroup(view, true);\n/**\nMove the selection one group backward.\n*/\nconst cursorGroupBackward = view => cursorByGroup(view, false);\nconst segmenter = typeof Intl != \"undefined\" && Intl.Segmenter ?\n /*@__PURE__*/new (Intl.Segmenter)(undefined, { granularity: \"word\" }) : null;\nfunction moveBySubword(view, range, forward) {\n let categorize = view.state.charCategorizer(range.from);\n let cat = CharCategory.Space, pos = range.from, steps = 0;\n let done = false, sawUpper = false, sawLower = false;\n let step = (next) => {\n if (done)\n return false;\n pos += forward ? next.length : -next.length;\n let nextCat = categorize(next), ahead;\n if (nextCat == CharCategory.Word && next.charCodeAt(0) < 128 && /[\\W_]/.test(next))\n nextCat = -1; // Treat word punctuation specially\n if (cat == CharCategory.Space)\n cat = nextCat;\n if (cat != nextCat)\n return false;\n if (cat == CharCategory.Word) {\n if (next.toLowerCase() == next) {\n if (!forward && sawUpper)\n return false;\n sawLower = true;\n }\n else if (sawLower) {\n if (forward)\n return false;\n done = true;\n }\n else {\n if (sawUpper && forward && categorize(ahead = view.state.sliceDoc(pos, pos + 1)) == CharCategory.Word &&\n ahead.toLowerCase() == ahead)\n return false;\n sawUpper = true;\n }\n }\n steps++;\n return true;\n };\n let end = view.moveByChar(range, forward, start => {\n step(start);\n return step;\n });\n if (segmenter && cat == CharCategory.Word && end.from == range.from + steps * (forward ? 1 : -1)) {\n let from = Math.min(range.head, end.head), to = Math.max(range.head, end.head);\n let skipped = view.state.sliceDoc(from, to);\n if (skipped.length > 1 && /[\\u4E00-\\uffff]/.test(skipped)) {\n let segments = Array.from(segmenter.segment(skipped));\n if (segments.length > 1) {\n if (forward)\n return EditorSelection.cursor(range.head + segments[1].index, -1);\n return EditorSelection.cursor(end.head + segments[segments.length - 1].index, 1);\n }\n }\n }\n return end;\n}\nfunction cursorBySubword(view, forward) {\n return moveSel(view, range => range.empty ? moveBySubword(view, range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection one group or camel-case subword forward.\n*/\nconst cursorSubwordForward = view => cursorBySubword(view, true);\n/**\nMove the selection one group or camel-case subword backward.\n*/\nconst cursorSubwordBackward = view => cursorBySubword(view, false);\nfunction interestingNode(state, node, bracketProp) {\n if (node.type.prop(bracketProp))\n return true;\n let len = node.to - node.from;\n return len && (len > 2 || /[^\\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;\n}\nfunction moveBySyntax(state, start, forward) {\n let pos = syntaxTree(state).resolveInner(start.head);\n let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;\n // Scan forward through child nodes to see if there's an interesting\n // node ahead.\n for (let at = start.head;;) {\n let next = forward ? pos.childAfter(at) : pos.childBefore(at);\n if (!next)\n break;\n if (interestingNode(state, next, bracketProp))\n pos = next;\n else\n at = forward ? next.to : next.from;\n }\n let bracket = pos.type.prop(bracketProp), match, newPos;\n if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)\n newPos = forward ? match.end.to : match.end.from;\n else\n newPos = forward ? pos.to : pos.from;\n return EditorSelection.cursor(newPos, forward ? -1 : 1);\n}\n/**\nMove the cursor over the next syntactic element to the left.\n*/\nconst cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the cursor over the next syntactic element to the right.\n*/\nconst cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction cursorByLine(view, forward) {\n return moveSel(view, range => {\n if (!range.empty)\n return rangeEnd(range, forward);\n let moved = view.moveVertically(range, forward);\n return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);\n });\n}\n/**\nMove the selection one line up.\n*/\nconst cursorLineUp = view => cursorByLine(view, false);\n/**\nMove the selection one line down.\n*/\nconst cursorLineDown = view => cursorByLine(view, true);\nfunction pageInfo(view) {\n let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2;\n let marginTop = 0, marginBottom = 0, height;\n if (selfScroll) {\n for (let source of view.state.facet(EditorView.scrollMargins)) {\n let margins = source(view);\n if (margins === null || margins === void 0 ? void 0 : margins.top)\n marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop);\n if (margins === null || margins === void 0 ? void 0 : margins.bottom)\n marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom);\n }\n height = view.scrollDOM.clientHeight - marginTop - marginBottom;\n }\n else {\n height = (view.dom.ownerDocument.defaultView || window).innerHeight;\n }\n return { marginTop, marginBottom, selfScroll,\n height: Math.max(view.defaultLineHeight, height - 5) };\n}\nfunction cursorByPage(view, forward) {\n let page = pageInfo(view);\n let { state } = view, selection = updateSel(state.selection, range => {\n return range.empty ? view.moveVertically(range, forward, page.height)\n : rangeEnd(range, forward);\n });\n if (selection.eq(state.selection))\n return false;\n let effect;\n if (page.selfScroll) {\n let startPos = view.coordsAtPos(state.selection.main.head);\n let scrollRect = view.scrollDOM.getBoundingClientRect();\n let scrollTop = scrollRect.top + page.marginTop, scrollBottom = scrollRect.bottom - page.marginBottom;\n if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom)\n effect = EditorView.scrollIntoView(selection.main.head, { y: \"start\", yMargin: startPos.top - scrollTop });\n }\n view.dispatch(setSel(state, selection), { effects: effect });\n return true;\n}\n/**\nMove the selection one page up.\n*/\nconst cursorPageUp = view => cursorByPage(view, false);\n/**\nMove the selection one page down.\n*/\nconst cursorPageDown = view => cursorByPage(view, true);\nfunction moveByLineBoundary(view, start, forward) {\n let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);\n if (moved.head == start.head && moved.head != (forward ? line.to : line.from))\n moved = view.moveToLineBoundary(start, forward, false);\n if (!forward && moved.head == line.from && line.length) {\n let space = /^\\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;\n if (space && start.head != line.from + space)\n moved = EditorSelection.cursor(line.from + space);\n }\n return moved;\n}\n/**\nMove the selection to the next line wrap point, or to the end of\nthe line if there isn't one left on this line.\n*/\nconst cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection to previous line wrap point, or failing that to\nthe start of the line. If the line is indented, and the cursor\nisn't already at the end of the indentation, this will move to the\nend of the indentation instead of the start of the line.\n*/\nconst cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection one line wrap point to the left.\n*/\nconst cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection one line wrap point to the right.\n*/\nconst cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection to the start of the line.\n*/\nconst cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));\n/**\nMove the selection to the end of the line.\n*/\nconst cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));\nfunction toMatchingBracket(state, dispatch, extend) {\n let found = false, selection = updateSel(state.selection, range => {\n let matching = matchBrackets(state, range.head, -1)\n || matchBrackets(state, range.head, 1)\n || (range.head > 0 && matchBrackets(state, range.head - 1, 1))\n || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));\n if (!matching || !matching.end)\n return range;\n found = true;\n let head = matching.start.from == range.head ? matching.end.to : matching.end.from;\n return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);\n });\n if (!found)\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\n/**\nMove the selection to the bracket matching the one it is currently\non, if any.\n*/\nconst cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false);\n/**\nExtend the selection to the bracket matching the one the selection\nhead is currently on, if any.\n*/\nconst selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, true);\nfunction extendSel(view, how) {\n let selection = updateSel(view.state.selection, range => {\n let head = how(range);\n return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);\n });\n if (selection.eq(view.state.selection))\n return false;\n view.dispatch(setSel(view.state, selection));\n return true;\n}\nfunction selectByChar(view, forward) {\n return extendSel(view, range => view.moveByChar(range, forward));\n}\n/**\nMove the selection head one character to the left, while leaving\nthe anchor in place.\n*/\nconst selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));\n/**\nMove the selection head one character to the right.\n*/\nconst selectCharRight = view => selectByChar(view, ltrAtCursor(view));\n/**\nMove the selection head one character forward.\n*/\nconst selectCharForward = view => selectByChar(view, true);\n/**\nMove the selection head one character backward.\n*/\nconst selectCharBackward = view => selectByChar(view, false);\nfunction selectByGroup(view, forward) {\n return extendSel(view, range => view.moveByGroup(range, forward));\n}\n/**\nMove the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to\nthe left.\n*/\nconst selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection head one group to the right.\n*/\nconst selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));\n/**\nMove the selection head one group forward.\n*/\nconst selectGroupForward = view => selectByGroup(view, true);\n/**\nMove the selection head one group backward.\n*/\nconst selectGroupBackward = view => selectByGroup(view, false);\nfunction selectBySubword(view, forward) {\n return extendSel(view, range => moveBySubword(view, range, forward));\n}\n/**\nMove the selection head one group or camel-case subword forward.\n*/\nconst selectSubwordForward = view => selectBySubword(view, true);\n/**\nMove the selection head one group or subword backward.\n*/\nconst selectSubwordBackward = view => selectBySubword(view, false);\n/**\nMove the selection head over the next syntactic element to the left.\n*/\nconst selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the selection head over the next syntactic element to the right.\n*/\nconst selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction selectByLine(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward));\n}\n/**\nMove the selection head one line up.\n*/\nconst selectLineUp = view => selectByLine(view, false);\n/**\nMove the selection head one line down.\n*/\nconst selectLineDown = view => selectByLine(view, true);\nfunction selectByPage(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height));\n}\n/**\nMove the selection head one page up.\n*/\nconst selectPageUp = view => selectByPage(view, false);\n/**\nMove the selection head one page down.\n*/\nconst selectPageDown = view => selectByPage(view, true);\n/**\nMove the selection head to the next line boundary.\n*/\nconst selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection head to the previous line boundary.\n*/\nconst selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection head one line boundary to the left.\n*/\nconst selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection head one line boundary to the right.\n*/\nconst selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection head to the start of the line.\n*/\nconst selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));\n/**\nMove the selection head to the end of the line.\n*/\nconst selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));\n/**\nMove the selection to the start of the document.\n*/\nconst cursorDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: 0 }));\n return true;\n};\n/**\nMove the selection to the end of the document.\n*/\nconst cursorDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.doc.length }));\n return true;\n};\n/**\nMove the selection head to the start of the document.\n*/\nconst selectDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));\n return true;\n};\n/**\nMove the selection head to the end of the document.\n*/\nconst selectDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));\n return true;\n};\n/**\nSelect the entire document.\n*/\nconst selectAll = ({ state, dispatch }) => {\n dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: \"select\" }));\n return true;\n};\n/**\nExpand the selection to cover entire lines.\n*/\nconst selectLine = ({ state, dispatch }) => {\n let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));\n dispatch(state.update({ selection: EditorSelection.create(ranges), userEvent: \"select\" }));\n return true;\n};\n/**\nSelect the next syntactic construct that is larger than the\nselection. Note that this will only work insofar as the language\n[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full\nsyntax tree.\n*/\nconst selectParentSyntax = ({ state, dispatch }) => {\n let selection = updateSel(state.selection, range => {\n var _a;\n let context = syntaxTree(state).resolveInner(range.head, 1);\n while (!((context.from < range.from && context.to >= range.to) ||\n (context.to > range.to && context.from <= range.from) ||\n !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))\n context = context.parent;\n return EditorSelection.range(context.to, context.from);\n });\n dispatch(setSel(state, selection));\n return true;\n};\n/**\nSimplify the current selection. When multiple ranges are selected,\nreduce it to its main range. Otherwise, if the selection is\nnon-empty, convert it to a cursor selection.\n*/\nconst simplifySelection = ({ state, dispatch }) => {\n let cur = state.selection, selection = null;\n if (cur.ranges.length > 1)\n selection = EditorSelection.create([cur.main]);\n else if (!cur.main.empty)\n selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);\n if (!selection)\n return false;\n dispatch(setSel(state, selection));\n return true;\n};\nfunction deleteBy(target, by) {\n if (target.state.readOnly)\n return false;\n let event = \"delete.selection\", { state } = target;\n let changes = state.changeByRange(range => {\n let { from, to } = range;\n if (from == to) {\n let towards = by(from);\n if (towards < from) {\n event = \"delete.backward\";\n towards = skipAtomic(target, towards, false);\n }\n else if (towards > from) {\n event = \"delete.forward\";\n towards = skipAtomic(target, towards, true);\n }\n from = Math.min(from, towards);\n to = Math.max(to, towards);\n }\n else {\n from = skipAtomic(target, from, false);\n to = skipAtomic(target, to, true);\n }\n return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from) };\n });\n if (changes.changes.empty)\n return false;\n target.dispatch(state.update(changes, {\n scrollIntoView: true,\n userEvent: event,\n effects: event == \"delete.selection\" ? EditorView.announce.of(state.phrase(\"Selection deleted\")) : undefined\n }));\n return true;\n}\nfunction skipAtomic(target, pos, forward) {\n if (target instanceof EditorView)\n for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target)))\n ranges.between(pos, pos, (from, to) => {\n if (from < pos && to > pos)\n pos = forward ? to : from;\n });\n return pos;\n}\nconst deleteByChar = (target, forward) => deleteBy(target, pos => {\n let { state } = target, line = state.doc.lineAt(pos), before, targetPos;\n if (!forward && pos > line.from && pos < line.from + 200 &&\n !/[^ \\t]/.test(before = line.text.slice(0, pos - line.from))) {\n if (before[before.length - 1] == \"\\t\")\n return pos - 1;\n let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);\n for (let i = 0; i < drop && before[before.length - 1 - i] == \" \"; i++)\n pos--;\n targetPos = pos;\n }\n else {\n targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;\n if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))\n targetPos += forward ? 1 : -1;\n }\n return targetPos;\n});\n/**\nDelete the selection, or, for cursor selections, the character\nbefore the cursor.\n*/\nconst deleteCharBackward = view => deleteByChar(view, false);\n/**\nDelete the selection or the character after the cursor.\n*/\nconst deleteCharForward = view => deleteByChar(view, true);\nconst deleteByGroup = (target, forward) => deleteBy(target, start => {\n let pos = start, { state } = target, line = state.doc.lineAt(pos);\n let categorize = state.charCategorizer(pos);\n for (let cat = null;;) {\n if (pos == (forward ? line.to : line.from)) {\n if (pos == start && line.number != (forward ? state.doc.lines : 1))\n pos += forward ? 1 : -1;\n break;\n }\n let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;\n let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);\n let nextCat = categorize(nextChar);\n if (cat != null && nextCat != cat)\n break;\n if (nextChar != \" \" || pos != start)\n cat = nextCat;\n pos = next;\n }\n return pos;\n});\n/**\nDelete the selection or backward until the end of the next\n[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of\nwhitespace when they consist of a single space.\n*/\nconst deleteGroupBackward = target => deleteByGroup(target, false);\n/**\nDelete the selection or forward until the end of the next group.\n*/\nconst deleteGroupForward = target => deleteByGroup(target, true);\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe end of the line. If the cursor is directly at the end of the\nline, delete the line break after it.\n*/\nconst deleteToLineEnd = view => deleteBy(view, pos => {\n let lineEnd = view.lineBlockAt(pos).to;\n return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);\n});\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe start of the line. If the cursor is directly at the start of the\nline, delete the line break before it.\n*/\nconst deleteToLineStart = view => deleteBy(view, pos => {\n let lineStart = view.lineBlockAt(pos).from;\n return pos > lineStart ? lineStart : Math.max(0, pos - 1);\n});\n/**\nDelete all whitespace directly before a line end from the\ndocument.\n*/\nconst deleteTrailingWhitespace = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let pos = 0, prev = \"\", iter = state.doc.iter();;) {\n iter.next();\n if (iter.lineBreak || iter.done) {\n let trailing = prev.search(/\\s+$/);\n if (trailing > -1)\n changes.push({ from: pos - (prev.length - trailing), to: pos });\n if (iter.done)\n break;\n prev = \"\";\n }\n else {\n prev = iter.value;\n }\n pos += iter.value.length;\n }\n if (!changes.length)\n return false;\n dispatch(state.update({ changes, userEvent: \"delete\" }));\n return true;\n};\n/**\nReplace each selection range with a line break, leaving the cursor\non the line before the break.\n*/\nconst splitLine = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n return { changes: { from: range.from, to: range.to, insert: Text.of([\"\", \"\"]) },\n range: EditorSelection.cursor(range.from) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nFlip the characters before and after the cursor(s).\n*/\nconst transposeChars = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n if (!range.empty || range.from == 0 || range.from == state.doc.length)\n return { range };\n let pos = range.from, line = state.doc.lineAt(pos);\n let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;\n let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;\n return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },\n range: EditorSelection.cursor(to) };\n });\n if (changes.changes.empty)\n return false;\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"move.character\" }));\n return true;\n};\nfunction selectedLineBlocks(state) {\n let blocks = [], upto = -1;\n for (let range of state.selection.ranges) {\n let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);\n if (!range.empty && range.to == endLine.from)\n endLine = state.doc.lineAt(range.to - 1);\n if (upto >= startLine.number) {\n let prev = blocks[blocks.length - 1];\n prev.to = endLine.to;\n prev.ranges.push(range);\n }\n else {\n blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });\n }\n upto = endLine.number + 1;\n }\n return blocks;\n}\nfunction moveLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [], ranges = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward ? block.to == state.doc.length : block.from == 0)\n continue;\n let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);\n let size = nextLine.length + 1;\n if (forward) {\n changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));\n }\n else {\n changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(r.anchor - size, r.head - size));\n }\n }\n if (!changes.length)\n return false;\n dispatch(state.update({\n changes,\n scrollIntoView: true,\n selection: EditorSelection.create(ranges, state.selection.mainIndex),\n userEvent: \"move.line\"\n }));\n return true;\n}\n/**\nMove the selected lines up one line.\n*/\nconst moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);\n/**\nMove the selected lines down one line.\n*/\nconst moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);\nfunction copyLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward)\n changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });\n else\n changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });\n }\n dispatch(state.update({ changes, scrollIntoView: true, userEvent: \"input.copyline\" }));\n return true;\n}\n/**\nCreate a copy of the selected lines. Keep the selection in the top copy.\n*/\nconst copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);\n/**\nCreate a copy of the selected lines. Keep the selection in the bottom copy.\n*/\nconst copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);\n/**\nDelete selected lines.\n*/\nconst deleteLine = view => {\n if (view.state.readOnly)\n return false;\n let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {\n if (from > 0)\n from--;\n else if (to < state.doc.length)\n to++;\n return { from, to };\n }));\n let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);\n view.dispatch({ changes, selection, scrollIntoView: true, userEvent: \"delete.line\" });\n return true;\n};\n/**\nReplace the selection with a newline.\n*/\nconst insertNewline = ({ state, dispatch }) => {\n dispatch(state.update(state.replaceSelection(state.lineBreak), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\nfunction isBetweenBrackets(state, pos) {\n if (/\\(\\)|\\[\\]|\\{\\}/.test(state.sliceDoc(pos - 1, pos + 1)))\n return { from: pos, to: pos };\n let context = syntaxTree(state).resolveInner(pos);\n let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;\n if (before && after && before.to <= pos && after.from >= pos &&\n (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 &&\n state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from &&\n !/\\S/.test(state.sliceDoc(before.to, after.from)))\n return { from: before.to, to: after.from };\n return null;\n}\n/**\nReplace the selection with a newline and indent the newly created\nline(s). If the current line consists only of whitespace, this\nwill also delete that whitespace. When the cursor is between\nmatching brackets, an additional newline will be inserted after\nthe cursor.\n*/\nconst insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);\n/**\nCreate a blank, indented line below the current line.\n*/\nconst insertBlankLine = /*@__PURE__*/newlineAndIndent(true);\nfunction newlineAndIndent(atEof) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n let { from, to } = range, line = state.doc.lineAt(from);\n let explode = !atEof && from == to && isBetweenBrackets(state, from);\n if (atEof)\n from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;\n let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });\n let indent = getIndentation(cx, from);\n if (indent == null)\n indent = countColumn(/^\\s*/.exec(state.doc.lineAt(from).text)[0], state.tabSize);\n while (to < line.to && /\\s/.test(line.text[to - line.from]))\n to++;\n if (explode)\n ({ from, to } = explode);\n else if (from > line.from && from < line.from + 100 && !/\\S/.test(line.text.slice(0, from)))\n from = line.from;\n let insert = [\"\", indentString(state, indent)];\n if (explode)\n insert.push(indentString(state, cx.lineIndent(line.from, -1)));\n return { changes: { from, to, insert: Text.of(insert) },\n range: EditorSelection.cursor(from + 1 + insert[1].length) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n };\n}\nfunction changeBySelectedLine(state, f) {\n let atLine = -1;\n return state.changeByRange(range => {\n let changes = [];\n for (let pos = range.from; pos <= range.to;) {\n let line = state.doc.lineAt(pos);\n if (line.number > atLine && (range.empty || range.to > line.from)) {\n f(line, changes, range);\n atLine = line.number;\n }\n pos = line.to + 1;\n }\n let changeSet = state.changes(changes);\n return { changes,\n range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };\n });\n}\n/**\nAuto-indent the selected lines. This uses the [indentation service\nfacet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent\ninformation.\n*/\nconst indentSelection = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => {\n let found = updated[start];\n return found == null ? -1 : found;\n } });\n let changes = changeBySelectedLine(state, (line, changes, range) => {\n let indent = getIndentation(context, line.from);\n if (indent == null)\n return;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm || range.from < line.from + cur.length) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n });\n if (!changes.changes.empty)\n dispatch(state.update(changes, { userEvent: \"indent\" }));\n return true;\n};\n/**\nAdd a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected\nlines.\n*/\nconst indentMore = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n changes.push({ from: line.from, insert: state.facet(indentUnit) });\n }), { userEvent: \"input.indent\" }));\n return true;\n};\n/**\nRemove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all\nselected lines.\n*/\nconst indentLess = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n let space = /^\\s*/.exec(line.text)[0];\n if (!space)\n return;\n let col = countColumn(space, state.tabSize), keep = 0;\n let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));\n while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))\n keep++;\n changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });\n }), { userEvent: \"delete.dedent\" }));\n return true;\n};\n/**\nInsert a tab character at the cursor or, if something is selected,\nuse [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire\nselection.\n*/\nconst insertTab = ({ state, dispatch }) => {\n if (state.selection.ranges.some(r => !r.empty))\n return indentMore({ state, dispatch });\n dispatch(state.update(state.replaceSelection(\"\\t\"), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nArray of key bindings containing the Emacs-style bindings that are\navailable on macOS by default.\n\n - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)\n - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)\n - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)\n - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)\n - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)\n*/\nconst emacsStyleKeymap = [\n { key: \"Ctrl-b\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Ctrl-f\", run: cursorCharRight, shift: selectCharRight },\n { key: \"Ctrl-p\", run: cursorLineUp, shift: selectLineUp },\n { key: \"Ctrl-n\", run: cursorLineDown, shift: selectLineDown },\n { key: \"Ctrl-a\", run: cursorLineStart, shift: selectLineStart },\n { key: \"Ctrl-e\", run: cursorLineEnd, shift: selectLineEnd },\n { key: \"Ctrl-d\", run: deleteCharForward },\n { key: \"Ctrl-h\", run: deleteCharBackward },\n { key: \"Ctrl-k\", run: deleteToLineEnd },\n { key: \"Ctrl-Alt-h\", run: deleteGroupBackward },\n { key: \"Ctrl-o\", run: splitLine },\n { key: \"Ctrl-t\", run: transposeChars },\n { key: \"Ctrl-v\", run: cursorPageDown },\n];\n/**\nAn array of key bindings closely sticking to platform-standard or\nwidely used bindings. (This includes the bindings from\n[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`\nproperty changed to `mac`.)\n\n - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)\n - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)\n - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)\n - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)\n - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)\n - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)\n - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)\n - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)\n - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)\n - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)\n - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)\n - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).\n - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).\n*/\nconst standardKeymap = /*@__PURE__*/[\n { key: \"ArrowLeft\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Mod-ArrowLeft\", mac: \"Alt-ArrowLeft\", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true },\n { mac: \"Cmd-ArrowLeft\", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true },\n { key: \"ArrowRight\", run: cursorCharRight, shift: selectCharRight, preventDefault: true },\n { key: \"Mod-ArrowRight\", mac: \"Alt-ArrowRight\", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true },\n { mac: \"Cmd-ArrowRight\", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true },\n { key: \"ArrowUp\", run: cursorLineUp, shift: selectLineUp, preventDefault: true },\n { mac: \"Cmd-ArrowUp\", run: cursorDocStart, shift: selectDocStart },\n { mac: \"Ctrl-ArrowUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"ArrowDown\", run: cursorLineDown, shift: selectLineDown, preventDefault: true },\n { mac: \"Cmd-ArrowDown\", run: cursorDocEnd, shift: selectDocEnd },\n { mac: \"Ctrl-ArrowDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"PageUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"PageDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"Home\", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },\n { key: \"Mod-Home\", run: cursorDocStart, shift: selectDocStart },\n { key: \"End\", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },\n { key: \"Mod-End\", run: cursorDocEnd, shift: selectDocEnd },\n { key: \"Enter\", run: insertNewlineAndIndent },\n { key: \"Mod-a\", run: selectAll },\n { key: \"Backspace\", run: deleteCharBackward, shift: deleteCharBackward },\n { key: \"Delete\", run: deleteCharForward },\n { key: \"Mod-Backspace\", mac: \"Alt-Backspace\", run: deleteGroupBackward },\n { key: \"Mod-Delete\", mac: \"Alt-Delete\", run: deleteGroupForward },\n { mac: \"Mod-Backspace\", run: deleteToLineStart },\n { mac: \"Mod-Delete\", run: deleteToLineEnd }\n].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));\n/**\nThe default keymap. Includes all bindings from\n[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:\n\n- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)\n- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)\n- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)\n- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)\n- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)\n- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)\n- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)\n- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)\n- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)\n- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)\n- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)\n- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)\n- Ctrl-Alt-\\\\ (Cmd-Alt-\\\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)\n- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)\n- Shift-Ctrl-\\\\ (Shift-Cmd-\\\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)\n- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).\n- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).\n*/\nconst defaultKeymap = /*@__PURE__*/[\n { key: \"Alt-ArrowLeft\", mac: \"Ctrl-ArrowLeft\", run: cursorSyntaxLeft, shift: selectSyntaxLeft },\n { key: \"Alt-ArrowRight\", mac: \"Ctrl-ArrowRight\", run: cursorSyntaxRight, shift: selectSyntaxRight },\n { key: \"Alt-ArrowUp\", run: moveLineUp },\n { key: \"Shift-Alt-ArrowUp\", run: copyLineUp },\n { key: \"Alt-ArrowDown\", run: moveLineDown },\n { key: \"Shift-Alt-ArrowDown\", run: copyLineDown },\n { key: \"Escape\", run: simplifySelection },\n { key: \"Mod-Enter\", run: insertBlankLine },\n { key: \"Alt-l\", mac: \"Ctrl-l\", run: selectLine },\n { key: \"Mod-i\", run: selectParentSyntax, preventDefault: true },\n { key: \"Mod-[\", run: indentLess },\n { key: \"Mod-]\", run: indentMore },\n { key: \"Mod-Alt-\\\\\", run: indentSelection },\n { key: \"Shift-Mod-k\", run: deleteLine },\n { key: \"Shift-Mod-\\\\\", run: cursorMatchingBracket },\n { key: \"Mod-/\", run: toggleComment },\n { key: \"Alt-A\", run: toggleBlockComment }\n].concat(standardKeymap);\n/**\nA binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and\nShift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).\nPlease see the [Tab example](../../examples/tab/) before using\nthis.\n*/\nconst indentWithTab = { key: \"Tab\", run: indentMore, shift: indentLess };\n\nexport { blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };\n","export default function crelt() {\n var elt = arguments[0]\n if (typeof elt == \"string\") elt = document.createElement(elt)\n var i = 1, next = arguments[1]\n if (next && typeof next == \"object\" && next.nodeType == null && !Array.isArray(next)) {\n for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {\n var value = next[name]\n if (typeof value == \"string\") elt.setAttribute(name, value)\n else if (value != null) elt[name] = value\n }\n i++\n }\n for (; i < arguments.length; i++) add(elt, arguments[i])\n return elt\n}\n\nfunction add(elt, child) {\n if (typeof child == \"string\") {\n elt.appendChild(document.createTextNode(child))\n } else if (child == null) {\n } else if (child.nodeType != null) {\n elt.appendChild(child)\n } else if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) add(elt, child[i])\n } else {\n throw new RangeError(\"Unsupported child node: \" + child)\n }\n}\n","import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view';\nimport { codePointAt, fromCodePoint, codePointSize, StateEffect, StateField, EditorSelection, Facet, combineConfig, CharCategory, RangeSetBuilder, Prec, EditorState, findClusterBreak } from '@codemirror/state';\nimport elt from 'crelt';\n\nconst basicNormalize = typeof String.prototype.normalize == \"function\"\n ? x => x.normalize(\"NFKD\") : x => x;\n/**\nA search cursor provides an iterator over text matches in a\ndocument.\n*/\nclass SearchCursor {\n /**\n Create a text cursor. The query is the search string, `from` to\n `to` provides the region to search.\n \n When `normalize` is given, it will be called, on both the query\n string and the content it is matched against, before comparing.\n You can, for example, create a case-insensitive search by\n passing `s => s.toLowerCase()`.\n \n Text is always normalized with\n [`.normalize(\"NFKD\")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)\n (when supported).\n */\n constructor(text, query, from = 0, to = text.length, normalize, test) {\n this.test = test;\n /**\n The current match (only holds a meaningful value after\n [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when\n `done` is false).\n */\n this.value = { from: 0, to: 0 };\n /**\n Whether the end of the iterated region has been reached.\n */\n this.done = false;\n this.matches = [];\n this.buffer = \"\";\n this.bufferPos = 0;\n this.iter = text.iterRange(from, to);\n this.bufferStart = from;\n this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;\n this.query = this.normalize(query);\n }\n peek() {\n if (this.bufferPos == this.buffer.length) {\n this.bufferStart += this.buffer.length;\n this.iter.next();\n if (this.iter.done)\n return -1;\n this.bufferPos = 0;\n this.buffer = this.iter.value;\n }\n return codePointAt(this.buffer, this.bufferPos);\n }\n /**\n Look for the next match. Updates the iterator's\n [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and\n [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called\n at least once before using the cursor.\n */\n next() {\n while (this.matches.length)\n this.matches.pop();\n return this.nextOverlapping();\n }\n /**\n The `next` method will ignore matches that partially overlap a\n previous match. This method behaves like `next`, but includes\n such matches.\n */\n nextOverlapping() {\n for (;;) {\n let next = this.peek();\n if (next < 0) {\n this.done = true;\n return this;\n }\n let str = fromCodePoint(next), start = this.bufferStart + this.bufferPos;\n this.bufferPos += codePointSize(next);\n let norm = this.normalize(str);\n for (let i = 0, pos = start;; i++) {\n let code = norm.charCodeAt(i);\n let match = this.match(code, pos);\n if (i == norm.length - 1) {\n if (match) {\n this.value = match;\n return this;\n }\n break;\n }\n if (pos == start && i < str.length && str.charCodeAt(i) == code)\n pos++;\n }\n }\n }\n match(code, pos) {\n let match = null;\n for (let i = 0; i < this.matches.length; i += 2) {\n let index = this.matches[i], keep = false;\n if (this.query.charCodeAt(index) == code) {\n if (index == this.query.length - 1) {\n match = { from: this.matches[i + 1], to: pos + 1 };\n }\n else {\n this.matches[i]++;\n keep = true;\n }\n }\n if (!keep) {\n this.matches.splice(i, 2);\n i -= 2;\n }\n }\n if (this.query.charCodeAt(0) == code) {\n if (this.query.length == 1)\n match = { from: pos, to: pos + 1 };\n else\n this.matches.push(1, pos);\n }\n if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferStart))\n match = null;\n return match;\n }\n}\nif (typeof Symbol != \"undefined\")\n SearchCursor.prototype[Symbol.iterator] = function () { return this; };\n\nconst empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec(\"\") };\nconst baseFlags = \"gm\" + (/x/.unicode == null ? \"\" : \"u\");\n/**\nThis class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)\nbut searches for a regular expression pattern instead of a plain\nstring.\n*/\nclass RegExpCursor {\n /**\n Create a cursor that will search the given range in the given\n document. `query` should be the raw pattern (as you'd pass it to\n `new RegExp`).\n */\n constructor(text, query, options, from = 0, to = text.length) {\n this.text = text;\n this.to = to;\n this.curLine = \"\";\n /**\n Set to `true` when the cursor has reached the end of the search\n range.\n */\n this.done = false;\n /**\n Will contain an object with the extent of the match and the\n match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)\n sucessfully finds a match.\n */\n this.value = empty;\n if (/\\\\[sWDnr]|\\n|\\r|\\[\\^/.test(query))\n return new MultilineRegExpCursor(text, query, options, from, to);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.iter = text.iter();\n let startLine = text.lineAt(from);\n this.curLineStart = startLine.from;\n this.matchPos = toCharEnd(text, from);\n this.getLine(this.curLineStart);\n }\n getLine(skip) {\n this.iter.next(skip);\n if (this.iter.lineBreak) {\n this.curLine = \"\";\n }\n else {\n this.curLine = this.iter.value;\n if (this.curLineStart + this.curLine.length > this.to)\n this.curLine = this.curLine.slice(0, this.to - this.curLineStart);\n this.iter.next();\n }\n }\n nextLine() {\n this.curLineStart = this.curLineStart + this.curLine.length + 1;\n if (this.curLineStart > this.to)\n this.curLine = \"\";\n else\n this.getLine(0);\n }\n /**\n Move to the next match, if there is one.\n */\n next() {\n for (let off = this.matchPos - this.curLineStart;;) {\n this.re.lastIndex = off;\n let match = this.matchPos <= this.to && this.re.exec(this.curLine);\n if (match) {\n let from = this.curLineStart + match.index, to = from + match[0].length;\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n if (from == this.curLineStart + this.curLine.length)\n this.nextLine();\n if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n return this;\n }\n off = this.matchPos - this.curLineStart;\n }\n else if (this.curLineStart + this.curLine.length < this.to) {\n this.nextLine();\n off = 0;\n }\n else {\n this.done = true;\n return this;\n }\n }\n }\n}\nconst flattened = /*@__PURE__*/new WeakMap();\n// Reusable (partially) flattened document strings\nclass FlattenedDoc {\n constructor(from, text) {\n this.from = from;\n this.text = text;\n }\n get to() { return this.from + this.text.length; }\n static get(doc, from, to) {\n let cached = flattened.get(doc);\n if (!cached || cached.from >= to || cached.to <= from) {\n let flat = new FlattenedDoc(from, doc.sliceString(from, to));\n flattened.set(doc, flat);\n return flat;\n }\n if (cached.from == from && cached.to == to)\n return cached;\n let { text, from: cachedFrom } = cached;\n if (cachedFrom > from) {\n text = doc.sliceString(from, cachedFrom) + text;\n cachedFrom = from;\n }\n if (cached.to < to)\n text += doc.sliceString(cached.to, to);\n flattened.set(doc, new FlattenedDoc(cachedFrom, text));\n return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));\n }\n}\nclass MultilineRegExpCursor {\n constructor(text, query, options, from, to) {\n this.text = text;\n this.to = to;\n this.done = false;\n this.value = empty;\n this.matchPos = toCharEnd(text, from);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));\n }\n chunkEnd(pos) {\n return pos >= this.to ? this.to : this.text.lineAt(pos).to;\n }\n next() {\n for (;;) {\n let off = this.re.lastIndex = this.matchPos - this.flat.from;\n let match = this.re.exec(this.flat.text);\n // Skip empty matches directly after the last match\n if (match && !match[0] && match.index == off) {\n this.re.lastIndex = off + 1;\n match = this.re.exec(this.flat.text);\n }\n if (match) {\n let from = this.flat.from + match.index, to = from + match[0].length;\n // If a match goes almost to the end of a noncomplete chunk, try\n // again, since it'll likely be able to match more\n if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) &&\n (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n return this;\n }\n }\n if (this.flat.to == this.to) {\n this.done = true;\n return this;\n }\n // Grow the flattened doc\n this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));\n }\n }\n}\nif (typeof Symbol != \"undefined\") {\n RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =\n function () { return this; };\n}\nfunction validRegExp(source) {\n try {\n new RegExp(source, baseFlags);\n return true;\n }\n catch (_a) {\n return false;\n }\n}\nfunction toCharEnd(text, pos) {\n if (pos >= text.length)\n return pos;\n let line = text.lineAt(pos), next;\n while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 0xDC00 && next < 0xE000)\n pos++;\n return pos;\n}\n\nfunction createLineDialog(view) {\n let line = String(view.state.doc.lineAt(view.state.selection.main.head).number);\n let input = elt(\"input\", { class: \"cm-textfield\", name: \"line\", value: line });\n let dom = elt(\"form\", {\n class: \"cm-gotoLine\",\n onkeydown: (event) => {\n if (event.keyCode == 27) { // Escape\n event.preventDefault();\n view.dispatch({ effects: dialogEffect.of(false) });\n view.focus();\n }\n else if (event.keyCode == 13) { // Enter\n event.preventDefault();\n go();\n }\n },\n onsubmit: (event) => {\n event.preventDefault();\n go();\n }\n }, elt(\"label\", view.state.phrase(\"Go to line\"), \": \", input), \" \", elt(\"button\", { class: \"cm-button\", type: \"submit\" }, view.state.phrase(\"go\")));\n function go() {\n let match = /^([+-])?(\\d+)?(:\\d+)?(%)?$/.exec(input.value);\n if (!match)\n return;\n let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);\n let [, sign, ln, cl, percent] = match;\n let col = cl ? +cl.slice(1) : 0;\n let line = ln ? +ln : startLine.number;\n if (ln && percent) {\n let pc = line / 100;\n if (sign)\n pc = pc * (sign == \"-\" ? -1 : 1) + (startLine.number / state.doc.lines);\n line = Math.round(state.doc.lines * pc);\n }\n else if (ln && sign) {\n line = line * (sign == \"-\" ? -1 : 1) + startLine.number;\n }\n let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));\n let selection = EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length)));\n view.dispatch({\n effects: [dialogEffect.of(false), EditorView.scrollIntoView(selection.from, { y: 'center' })],\n selection,\n });\n view.focus();\n }\n return { dom };\n}\nconst dialogEffect = /*@__PURE__*/StateEffect.define();\nconst dialogField = /*@__PURE__*/StateField.define({\n create() { return true; },\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(dialogEffect))\n value = e.value;\n return value;\n },\n provide: f => showPanel.from(f, val => val ? createLineDialog : null)\n});\n/**\nCommand that shows a dialog asking the user for a line number, and\nwhen a valid position is provided, moves the cursor to that line.\n\nSupports line numbers, relative line offsets prefixed with `+` or\n`-`, document percentages suffixed with `%`, and an optional\ncolumn position by adding `:` and a second number after the line\nnumber.\n*/\nconst gotoLine = view => {\n let panel = getPanel(view, createLineDialog);\n if (!panel) {\n let effects = [dialogEffect.of(true)];\n if (view.state.field(dialogField, false) == null)\n effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1]));\n view.dispatch({ effects });\n panel = getPanel(view, createLineDialog);\n }\n if (panel)\n panel.dom.querySelector(\"input\").select();\n return true;\n};\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-gotoLine\": {\n padding: \"2px 6px 4px\",\n \"& label\": { fontSize: \"80%\" }\n }\n});\n\nconst defaultHighlightOptions = {\n highlightWordAroundCursor: false,\n minSelectionLength: 1,\n maxMatches: 100,\n wholeWords: false\n};\nconst highlightConfig = /*@__PURE__*/Facet.define({\n combine(options) {\n return combineConfig(options, defaultHighlightOptions, {\n highlightWordAroundCursor: (a, b) => a || b,\n minSelectionLength: Math.min,\n maxMatches: Math.min\n });\n }\n});\n/**\nThis extension highlights text that matches the selection. It uses\nthe `\"cm-selectionMatch\"` class for the highlighting. When\n`highlightWordAroundCursor` is enabled, the word at the cursor\nitself will be highlighted with `\"cm-selectionMatch-main\"`.\n*/\nfunction highlightSelectionMatches(options) {\n let ext = [defaultTheme, matchHighlighter];\n if (options)\n ext.push(highlightConfig.of(options));\n return ext;\n}\nconst matchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch\" });\nconst mainMatchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch cm-selectionMatch-main\" });\n// Whether the characters directly outside the given positions are non-word characters\nfunction insideWordBoundaries(check, state, from, to) {\n return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) &&\n (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);\n}\n// Whether the characters directly at the given positions are word characters\nfunction insideWord(check, state, from, to) {\n return check(state.sliceDoc(from, from + 1)) == CharCategory.Word\n && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;\n}\nconst matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.selectionSet || update.docChanged || update.viewportChanged)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let conf = view.state.facet(highlightConfig);\n let { state } = view, sel = state.selection;\n if (sel.ranges.length > 1)\n return Decoration.none;\n let range = sel.main, query, check = null;\n if (range.empty) {\n if (!conf.highlightWordAroundCursor)\n return Decoration.none;\n let word = state.wordAt(range.head);\n if (!word)\n return Decoration.none;\n check = state.charCategorizer(range.head);\n query = state.sliceDoc(word.from, word.to);\n }\n else {\n let len = range.to - range.from;\n if (len < conf.minSelectionLength || len > 200)\n return Decoration.none;\n if (conf.wholeWords) {\n query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?\n check = state.charCategorizer(range.head);\n if (!(insideWordBoundaries(check, state, range.from, range.to)\n && insideWord(check, state, range.from, range.to)))\n return Decoration.none;\n }\n else {\n query = state.sliceDoc(range.from, range.to).trim();\n if (!query)\n return Decoration.none;\n }\n }\n let deco = [];\n for (let part of view.visibleRanges) {\n let cursor = new SearchCursor(state.doc, query, part.from, part.to);\n while (!cursor.next().done) {\n let { from, to } = cursor.value;\n if (!check || insideWordBoundaries(check, state, from, to)) {\n if (range.empty && from <= range.from && to >= range.to)\n deco.push(mainMatchDeco.range(from, to));\n else if (from >= range.to || to <= range.from)\n deco.push(matchDeco.range(from, to));\n if (deco.length > conf.maxMatches)\n return Decoration.none;\n }\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\nconst defaultTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-selectionMatch\": { backgroundColor: \"#99ff7780\" },\n \".cm-searchMatch .cm-selectionMatch\": { backgroundColor: \"transparent\" }\n});\n// Select the words around the cursors.\nconst selectWord = ({ state, dispatch }) => {\n let { selection } = state;\n let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);\n if (newSel.eq(selection))\n return false;\n dispatch(state.update({ selection: newSel }));\n return true;\n};\n// Find next occurrence of query relative to last cursor. Wrap around\n// the document if there are no more matches.\nfunction findNextOccurrence(state, query) {\n let { main, ranges } = state.selection;\n let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;\n for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {\n cursor.next();\n if (cursor.done) {\n if (cycled)\n return null;\n cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));\n cycled = true;\n }\n else {\n if (cycled && ranges.some(r => r.from == cursor.value.from))\n continue;\n if (fullWord) {\n let word = state.wordAt(cursor.value.from);\n if (!word || word.from != cursor.value.from || word.to != cursor.value.to)\n continue;\n }\n return cursor.value;\n }\n }\n}\n/**\nSelect next occurrence of the current selection. Expand selection\nto the surrounding word when the selection is empty.\n*/\nconst selectNextOccurrence = ({ state, dispatch }) => {\n let { ranges } = state.selection;\n if (ranges.some(sel => sel.from === sel.to))\n return selectWord({ state, dispatch });\n let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);\n if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))\n return false;\n let range = findNextOccurrence(state, searchedText);\n if (!range)\n return false;\n dispatch(state.update({\n selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),\n effects: EditorView.scrollIntoView(range.to)\n }));\n return true;\n};\n\nconst searchConfigFacet = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n top: false,\n caseSensitive: false,\n literal: false,\n regexp: false,\n wholeWord: false,\n createPanel: view => new SearchPanel(view),\n scrollToMatch: range => EditorView.scrollIntoView(range)\n });\n }\n});\n/**\nAdd search state to the editor configuration, and optionally\nconfigure the search extension.\n([`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) will automatically\nenable this if it isn't already on).\n*/\nfunction search(config) {\n return config ? [searchConfigFacet.of(config), searchExtensions] : searchExtensions;\n}\n/**\nA search query. Part of the editor's search state.\n*/\nclass SearchQuery {\n /**\n Create a query object.\n */\n constructor(config) {\n this.search = config.search;\n this.caseSensitive = !!config.caseSensitive;\n this.literal = !!config.literal;\n this.regexp = !!config.regexp;\n this.replace = config.replace || \"\";\n this.valid = !!this.search && (!this.regexp || validRegExp(this.search));\n this.unquoted = this.unquote(this.search);\n this.wholeWord = !!config.wholeWord;\n }\n /**\n @internal\n */\n unquote(text) {\n return this.literal ? text :\n text.replace(/\\\\([nrt\\\\])/g, (_, ch) => ch == \"n\" ? \"\\n\" : ch == \"r\" ? \"\\r\" : ch == \"t\" ? \"\\t\" : \"\\\\\");\n }\n /**\n Compare this query to another query.\n */\n eq(other) {\n return this.search == other.search && this.replace == other.replace &&\n this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&\n this.wholeWord == other.wholeWord;\n }\n /**\n @internal\n */\n create() {\n return this.regexp ? new RegExpQuery(this) : new StringQuery(this);\n }\n /**\n Get a search cursor for this query, searching through the given\n range in the given state.\n */\n getCursor(state, from = 0, to) {\n let st = state.doc ? state : EditorState.create({ doc: state });\n if (to == null)\n to = st.doc.length;\n return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);\n }\n}\nclass QueryType {\n constructor(spec) {\n this.spec = spec;\n }\n}\nfunction stringCursor(spec, state, from, to) {\n return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);\n}\nfunction stringWordTest(doc, categorizer) {\n return (from, to, buf, bufPos) => {\n if (bufPos > from || bufPos + buf.length < to) {\n bufPos = Math.max(0, from - 2);\n buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));\n }\n return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word ||\n categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) &&\n (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word ||\n categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);\n };\n}\nclass StringQuery extends QueryType {\n constructor(spec) {\n super(spec);\n }\n nextMatch(state, curFrom, curTo) {\n let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();\n if (cursor.done)\n cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();\n return cursor.done ? null : cursor.value;\n }\n // Searching in reverse is, rather than implementing an inverted search\n // cursor, done by scanning chunk after chunk forward.\n prevMatchInRange(state, from, to) {\n for (let pos = to;;) {\n let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);\n let cursor = stringCursor(this.spec, state, start, pos), range = null;\n while (!cursor.nextOverlapping().done)\n range = cursor.value;\n if (range)\n return range;\n if (start == from)\n return null;\n pos -= 10000 /* FindPrev.ChunkSize */;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(_result) { return this.spec.unquote(this.spec.replace); }\n matchAll(state, limit) {\n let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\nfunction regexpCursor(spec, state, from, to) {\n return new RegExpCursor(state.doc, spec.search, {\n ignoreCase: !spec.caseSensitive,\n test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined\n }, from, to);\n}\nfunction charBefore(str, index) {\n return str.slice(findClusterBreak(str, index, false), index);\n}\nfunction charAfter(str, index) {\n return str.slice(index, findClusterBreak(str, index));\n}\nfunction regexpWordTest(categorizer) {\n return (_from, _to, match) => !match[0].length ||\n (categorizer(charBefore(match.input, match.index)) != CharCategory.Word ||\n categorizer(charAfter(match.input, match.index)) != CharCategory.Word) &&\n (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word ||\n categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);\n}\nclass RegExpQuery extends QueryType {\n nextMatch(state, curFrom, curTo) {\n let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();\n if (cursor.done)\n cursor = regexpCursor(this.spec, state, 0, curFrom).next();\n return cursor.done ? null : cursor.value;\n }\n prevMatchInRange(state, from, to) {\n for (let size = 1;; size++) {\n let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);\n let cursor = regexpCursor(this.spec, state, start, to), range = null;\n while (!cursor.next().done)\n range = cursor.value;\n if (range && (start == from || range.from > start + 10))\n return range;\n if (start == from)\n return null;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(result) {\n return this.spec.unquote(this.spec.replace.replace(/\\$([$&\\d+])/g, (m, i) => i == \"$\" ? \"$\"\n : i == \"&\" ? result.match[0]\n : i != \"0\" && +i < result.match.length ? result.match[i]\n : m));\n }\n matchAll(state, limit) {\n let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\n/**\nA state effect that updates the current search query. Note that\nthis only has an effect if the search state has been initialized\n(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or\nby running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least\nonce).\n*/\nconst setSearchQuery = /*@__PURE__*/StateEffect.define();\nconst togglePanel = /*@__PURE__*/StateEffect.define();\nconst searchState = /*@__PURE__*/StateField.define({\n create(state) {\n return new SearchState(defaultQuery(state).create(), null);\n },\n update(value, tr) {\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery))\n value = new SearchState(effect.value.create(), value.panel);\n else if (effect.is(togglePanel))\n value = new SearchState(value.query, effect.value ? createSearchPanel : null);\n }\n return value;\n },\n provide: f => showPanel.from(f, val => val.panel)\n});\n/**\nGet the current search query from an editor state.\n*/\nfunction getSearchQuery(state) {\n let curState = state.field(searchState, false);\n return curState ? curState.query.spec : defaultQuery(state);\n}\n/**\nQuery whether the search panel is open in the given editor state.\n*/\nfunction searchPanelOpen(state) {\n var _a;\n return ((_a = state.field(searchState, false)) === null || _a === void 0 ? void 0 : _a.panel) != null;\n}\nclass SearchState {\n constructor(query, panel) {\n this.query = query;\n this.panel = panel;\n }\n}\nconst matchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch\" }), selectedMatchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch cm-searchMatch-selected\" });\nconst searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = this.highlight(view.state.field(searchState));\n }\n update(update) {\n let state = update.state.field(searchState);\n if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)\n this.decorations = this.highlight(state);\n }\n highlight({ query, panel }) {\n if (!panel || !query.spec.valid)\n return Decoration.none;\n let { view } = this;\n let builder = new RangeSetBuilder();\n for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {\n let { from, to } = ranges[i];\n while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */)\n to = ranges[++i].to;\n query.highlight(view.state, from, to, (from, to) => {\n let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);\n builder.add(from, to, selected ? selectedMatchMark : matchMark);\n });\n }\n return builder.finish();\n }\n}, {\n decorations: v => v.decorations\n});\nfunction searchCommand(f) {\n return view => {\n let state = view.state.field(searchState, false);\n return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);\n };\n}\n/**\nOpen the search panel if it isn't already open, and move the\nselection to the first match after the current main selection.\nWill wrap around to the start of the document when it reaches the\nend.\n*/\nconst findNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { to } = view.state.selection.main;\n let next = query.nextMatch(view.state, to, to);\n if (!next)\n return false;\n let selection = EditorSelection.single(next.from, next.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, next), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nMove the selection to the previous instance of the search query,\nbefore the current main selection. Will wrap past the start\nof the document to start searching at the end again.\n*/\nconst findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from } = state.selection.main;\n let prev = query.prevMatch(state, from, from);\n if (!prev)\n return false;\n let selection = EditorSelection.single(prev.from, prev.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, prev), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nSelect all instances of the search query.\n*/\nconst selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {\n let ranges = query.matchAll(view.state, 1000);\n if (!ranges || !ranges.length)\n return false;\n view.dispatch({\n selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),\n userEvent: \"select.search.matches\"\n });\n return true;\n});\n/**\nSelect all instances of the currently selected text.\n*/\nconst selectSelectionMatches = ({ state, dispatch }) => {\n let sel = state.selection;\n if (sel.ranges.length > 1 || sel.main.empty)\n return false;\n let { from, to } = sel.main;\n let ranges = [], main = 0;\n for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {\n if (ranges.length > 1000)\n return false;\n if (cur.value.from == from)\n main = ranges.length;\n ranges.push(EditorSelection.range(cur.value.from, cur.value.to));\n }\n dispatch(state.update({\n selection: EditorSelection.create(ranges, main),\n userEvent: \"select.search.matches\"\n }));\n return true;\n};\n/**\nReplace the current match of the search query.\n*/\nconst replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from, to } = state.selection.main;\n if (state.readOnly)\n return false;\n let next = query.nextMatch(state, from, from);\n if (!next)\n return false;\n let changes = [], selection, replacement;\n let effects = [];\n if (next.from == from && next.to == to) {\n replacement = state.toText(query.getReplacement(next));\n changes.push({ from: next.from, to: next.to, insert: replacement });\n next = query.nextMatch(state, next.from, next.to);\n effects.push(EditorView.announce.of(state.phrase(\"replaced match on line $\", state.doc.lineAt(from).number) + \".\"));\n }\n if (next) {\n let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;\n selection = EditorSelection.single(next.from - off, next.to - off);\n effects.push(announceMatch(view, next));\n effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));\n }\n view.dispatch({\n changes, selection, effects,\n userEvent: \"input.replace\"\n });\n return true;\n});\n/**\nReplace all instances of the search query with the given\nreplacement.\n*/\nconst replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {\n if (view.state.readOnly)\n return false;\n let changes = query.matchAll(view.state, 1e9).map(match => {\n let { from, to } = match;\n return { from, to, insert: query.getReplacement(match) };\n });\n if (!changes.length)\n return false;\n let announceText = view.state.phrase(\"replaced $ matches\", changes.length) + \".\";\n view.dispatch({\n changes,\n effects: EditorView.announce.of(announceText),\n userEvent: \"input.replace.all\"\n });\n return true;\n});\nfunction createSearchPanel(view) {\n return view.state.facet(searchConfigFacet).createPanel(view);\n}\nfunction defaultQuery(state, fallback) {\n var _a, _b, _c, _d, _e;\n let sel = state.selection.main;\n let selText = sel.empty || sel.to > sel.from + 100 ? \"\" : state.sliceDoc(sel.from, sel.to);\n if (fallback && !selText)\n return fallback;\n let config = state.facet(searchConfigFacet);\n return new SearchQuery({\n search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\\n/g, \"\\\\n\"),\n caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,\n literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,\n regexp: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.regexp) !== null && _d !== void 0 ? _d : config.regexp,\n wholeWord: (_e = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _e !== void 0 ? _e : config.wholeWord\n });\n}\nfunction getSearchInput(view) {\n let panel = getPanel(view, createSearchPanel);\n return panel && panel.dom.querySelector(\"[main-field]\");\n}\nfunction selectSearchInput(view) {\n let input = getSearchInput(view);\n if (input && input == view.root.activeElement)\n input.select();\n}\n/**\nMake sure the search panel is open and focused.\n*/\nconst openSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (state && state.panel) {\n let searchInput = getSearchInput(view);\n if (searchInput && searchInput != view.root.activeElement) {\n let query = defaultQuery(view.state, state.query.spec);\n if (query.valid)\n view.dispatch({ effects: setSearchQuery.of(query) });\n searchInput.focus();\n searchInput.select();\n }\n }\n else {\n view.dispatch({ effects: [\n togglePanel.of(true),\n state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)\n ] });\n }\n return true;\n};\n/**\nClose the search panel.\n*/\nconst closeSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (!state || !state.panel)\n return false;\n let panel = getPanel(view, createSearchPanel);\n if (panel && panel.dom.contains(view.root.activeElement))\n view.focus();\n view.dispatch({ effects: togglePanel.of(false) });\n return true;\n};\n/**\nDefault search-related key bindings.\n\n - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)\n - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)\n - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)\n - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)\n - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)\n*/\nconst searchKeymap = [\n { key: \"Mod-f\", run: openSearchPanel, scope: \"editor search-panel\" },\n { key: \"F3\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Mod-g\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Escape\", run: closeSearchPanel, scope: \"editor search-panel\" },\n { key: \"Mod-Shift-l\", run: selectSelectionMatches },\n { key: \"Alt-g\", run: gotoLine },\n { key: \"Mod-d\", run: selectNextOccurrence, preventDefault: true },\n];\nclass SearchPanel {\n constructor(view) {\n this.view = view;\n let query = this.query = view.state.field(searchState).query.spec;\n this.commit = this.commit.bind(this);\n this.searchField = elt(\"input\", {\n value: query.search,\n placeholder: phrase(view, \"Find\"),\n \"aria-label\": phrase(view, \"Find\"),\n class: \"cm-textfield\",\n name: \"search\",\n form: \"\",\n \"main-field\": \"true\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.replaceField = elt(\"input\", {\n value: query.replace,\n placeholder: phrase(view, \"Replace\"),\n \"aria-label\": phrase(view, \"Replace\"),\n class: \"cm-textfield\",\n name: \"replace\",\n form: \"\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.caseField = elt(\"input\", {\n type: \"checkbox\",\n name: \"case\",\n form: \"\",\n checked: query.caseSensitive,\n onchange: this.commit\n });\n this.reField = elt(\"input\", {\n type: \"checkbox\",\n name: \"re\",\n form: \"\",\n checked: query.regexp,\n onchange: this.commit\n });\n this.wordField = elt(\"input\", {\n type: \"checkbox\",\n name: \"word\",\n form: \"\",\n checked: query.wholeWord,\n onchange: this.commit\n });\n function button(name, onclick, content) {\n return elt(\"button\", { class: \"cm-button\", name, onclick, type: \"button\" }, content);\n }\n this.dom = elt(\"div\", { onkeydown: (e) => this.keydown(e), class: \"cm-search\" }, [\n this.searchField,\n button(\"next\", () => findNext(view), [phrase(view, \"next\")]),\n button(\"prev\", () => findPrevious(view), [phrase(view, \"previous\")]),\n button(\"select\", () => selectMatches(view), [phrase(view, \"all\")]),\n elt(\"label\", null, [this.caseField, phrase(view, \"match case\")]),\n elt(\"label\", null, [this.reField, phrase(view, \"regexp\")]),\n elt(\"label\", null, [this.wordField, phrase(view, \"by word\")]),\n ...view.state.readOnly ? [] : [\n elt(\"br\"),\n this.replaceField,\n button(\"replace\", () => replaceNext(view), [phrase(view, \"replace\")]),\n button(\"replaceAll\", () => replaceAll(view), [phrase(view, \"replace all\")])\n ],\n elt(\"button\", {\n name: \"close\",\n onclick: () => closeSearchPanel(view),\n \"aria-label\": phrase(view, \"close\"),\n type: \"button\"\n }, [\"×\"])\n ]);\n }\n commit() {\n let query = new SearchQuery({\n search: this.searchField.value,\n caseSensitive: this.caseField.checked,\n regexp: this.reField.checked,\n wholeWord: this.wordField.checked,\n replace: this.replaceField.value,\n });\n if (!query.eq(this.query)) {\n this.query = query;\n this.view.dispatch({ effects: setSearchQuery.of(query) });\n }\n }\n keydown(e) {\n if (runScopeHandlers(this.view, e, \"search-panel\")) {\n e.preventDefault();\n }\n else if (e.keyCode == 13 && e.target == this.searchField) {\n e.preventDefault();\n (e.shiftKey ? findPrevious : findNext)(this.view);\n }\n else if (e.keyCode == 13 && e.target == this.replaceField) {\n e.preventDefault();\n replaceNext(this.view);\n }\n }\n update(update) {\n for (let tr of update.transactions)\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery) && !effect.value.eq(this.query))\n this.setQuery(effect.value);\n }\n }\n setQuery(query) {\n this.query = query;\n this.searchField.value = query.search;\n this.replaceField.value = query.replace;\n this.caseField.checked = query.caseSensitive;\n this.reField.checked = query.regexp;\n this.wordField.checked = query.wholeWord;\n }\n mount() {\n this.searchField.select();\n }\n get pos() { return 80; }\n get top() { return this.view.state.facet(searchConfigFacet).top; }\n}\nfunction phrase(view, phrase) { return view.state.phrase(phrase); }\nconst AnnounceMargin = 30;\nconst Break = /[\\s\\.,:;?!]/;\nfunction announceMatch(view, { from, to }) {\n let line = view.state.doc.lineAt(from), lineEnd = view.state.doc.lineAt(to).to;\n let start = Math.max(line.from, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);\n let text = view.state.sliceDoc(start, end);\n if (start != line.from) {\n for (let i = 0; i < AnnounceMargin; i++)\n if (!Break.test(text[i + 1]) && Break.test(text[i])) {\n text = text.slice(i);\n break;\n }\n }\n if (end != lineEnd) {\n for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)\n if (!Break.test(text[i - 1]) && Break.test(text[i])) {\n text = text.slice(0, i);\n break;\n }\n }\n return EditorView.announce.of(`${view.state.phrase(\"current match\")}. ${text} ${view.state.phrase(\"on line\")} ${line.number}.`);\n}\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-search\": {\n padding: \"2px 6px 4px\",\n position: \"relative\",\n \"& [name=close]\": {\n position: \"absolute\",\n top: \"0\",\n right: \"4px\",\n backgroundColor: \"inherit\",\n border: \"none\",\n font: \"inherit\",\n padding: 0,\n margin: 0\n },\n \"& input, & button, & label\": {\n margin: \".2em .6em .2em 0\"\n },\n \"& input[type=checkbox]\": {\n marginRight: \".2em\"\n },\n \"& label\": {\n fontSize: \"80%\",\n whiteSpace: \"pre\"\n }\n },\n \"&light .cm-searchMatch\": { backgroundColor: \"#ffff0054\" },\n \"&dark .cm-searchMatch\": { backgroundColor: \"#00ffff8a\" },\n \"&light .cm-searchMatch-selected\": { backgroundColor: \"#ff6a0054\" },\n \"&dark .cm-searchMatch-selected\": { backgroundColor: \"#ff00ff8a\" }\n});\nconst searchExtensions = [\n searchState,\n /*@__PURE__*/Prec.low(searchHighlighter),\n baseTheme\n];\n\nexport { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };\n","import CodeMirror from './codemirror';\nimport { EditorSelection } from '@codemirror/state';\nimport { EditorView, keymap } from '@codemirror/view';\nimport { defaultKeymap, history, historyKeymap } from '@codemirror/commands';\nimport { searchKeymap } from '@codemirror/search';\nimport { bracketMatching } from '@codemirror/language';\n\n/**\n * @class CodeMirrorWikiEditor\n */\nexport default class CodeMirrorWikiEditor extends CodeMirror {\n\tconstructor( $textarea ) {\n\t\tsuper( $textarea );\n\t\tthis.realtimePreviewHandler = null;\n\t\tthis.useCodeMirror = mw.user.options.get( 'usecodemirror' ) > 0;\n\t\tthis.editRecoveryHandler = null;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\tthis.useCodeMirror = prefValue; // Save state for function updateToolbarButton()\n\t\tsuper.setCodeMirrorPreference( prefValue );\n\t}\n\n\t/**\n\t * Replaces the default textarea with CodeMirror\n\t */\n\tenableCodeMirror() {\n\t\t// If CodeMirror is already loaded, abort.\n\t\tif ( this.view ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectionStart = this.$textarea.prop( 'selectionStart' ),\n\t\t\tselectionEnd = this.$textarea.prop( 'selectionEnd' ),\n\t\t\tscrollTop = this.$textarea.scrollTop(),\n\t\t\thasFocus = this.$textarea.is( ':focus' );\n\n\t\t/*\n\t\t * Default configuration, which we may conditionally add to later.\n\t\t * @see https://codemirror.net/docs/ref/#state.Extension\n\t\t */\n\t\tconst extensions = [\n\t\t\t...this.defaultExtensions,\n\t\t\tbracketMatching(),\n\t\t\thistory(),\n\t\t\t// See also the default attributes at contentAttributesExtension() in the parent class.\n\t\t\tEditorView.contentAttributes.of( {\n\t\t\t\tspellcheck: 'true'\n\t\t\t} ),\n\t\t\tEditorView.domEventHandlers( {\n\t\t\t\tblur: () => this.$textarea.triggerHandler( 'blur' ),\n\t\t\t\tfocus: () => this.$textarea.triggerHandler( 'focus' )\n\t\t\t} ),\n\t\t\tEditorView.updateListener.of( ( update ) => {\n\t\t\t\tif ( update.docChanged && typeof this.editRecoveryHandler === 'function' ) {\n\t\t\t\t\tthis.editRecoveryHandler();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\tEditorView.lineWrapping,\n\t\t\tkeymap.of( [\n\t\t\t\t...defaultKeymap,\n\t\t\t\t...searchKeymap,\n\t\t\t\t...historyKeymap\n\t\t\t] )\n\t\t];\n\n\t\tmw.hook( 'editRecovery.loadEnd' ).add( ( data ) => {\n\t\t\tthis.editRecoveryHandler = data.fieldChangeHandler;\n\t\t} );\n\n\t\tthis.initialize( extensions );\n\n\t\t// Sync scroll position, selections, and focus state.\n\t\tthis.view.scrollDOM.scrollTop = scrollTop;\n\t\tthis.view.dispatch( {\n\t\t\tselection: EditorSelection.create( [\n\t\t\t\tEditorSelection.range( selectionStart, selectionEnd )\n\t\t\t] ),\n\t\t\tscrollIntoView: true\n\t\t} );\n\t\tif ( hasFocus ) {\n\t\t\tthis.view.focus();\n\t\t}\n\n\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );\n\t}\n\n\t/**\n\t * Adds the CodeMirror button to WikiEditor\n\t */\n\taddCodeMirrorToWikiEditor() {\n\t\tconst context = this.$textarea.data( 'wikiEditor-context' );\n\t\tconst toolbar = context && context.modules && context.modules.toolbar;\n\n\t\t// Guard against something having removed WikiEditor (T271457)\n\t\tif ( !toolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.$textarea.wikiEditor(\n\t\t\t'addToToolbar',\n\t\t\t{\n\t\t\t\tsection: 'main',\n\t\t\t\tgroups: {\n\t\t\t\t\tcodemirror: {\n\t\t\t\t\t\ttools: {\n\t\t\t\t\t\t\tCodeMirror: {\n\t\t\t\t\t\t\t\tlabel: mw.msg( 'codemirror-toggle-label' ),\n\t\t\t\t\t\t\t\ttype: 'toggle',\n\t\t\t\t\t\t\t\toouiIcon: 'highlight',\n\t\t\t\t\t\t\t\taction: {\n\t\t\t\t\t\t\t\t\ttype: 'callback',\n\t\t\t\t\t\t\t\t\texecute: () => this.switchCodeMirror()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst $codeMirrorButton = toolbar.$toolbar.find( '.tool[rel=CodeMirror]' );\n\t\t$codeMirrorButton\n\t\t\t.attr( 'id', 'mw-editbutton-codemirror' );\n\n\t\tif ( this.useCodeMirror ) {\n\t\t\tthis.enableCodeMirror();\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: false,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n\n\t/**\n\t * Updates CodeMirror button on the toolbar according to the current state (on/off)\n\t */\n\tupdateToolbarButton() {\n\t\t// eslint-disable-next-line no-jquery/no-global-selector\n\t\tconst $button = $( '#mw-editbutton-codemirror' );\n\t\t$button.toggleClass( 'mw-editbutton-codemirror-active', this.useCodeMirror );\n\n\t\t// WikiEditor2010 OOUI ToggleButtonWidget\n\t\tif ( $button.data( 'setActive' ) ) {\n\t\t\t$button.data( 'setActive' )( this.useCodeMirror );\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables CodeMirror\n\t */\n\tswitchCodeMirror() {\n\t\tif ( this.view ) {\n\t\t\tthis.setCodeMirrorPreference( false );\n\t\t\tconst scrollTop = this.view.scrollDOM.scrollTop;\n\t\t\tconst hasFocus = this.view.hasFocus;\n\t\t\tconst { from, to } = this.view.state.selection.ranges[ 0 ];\n\t\t\t$( this.view.dom ).textSelection( 'unregister' );\n\t\t\tthis.$textarea.textSelection( 'unregister' );\n\t\t\tthis.$textarea.val( this.view.state.doc.toString() );\n\t\t\tthis.view.destroy();\n\t\t\tthis.view = null;\n\t\t\tthis.$textarea.show();\n\t\t\tif ( hasFocus ) {\n\t\t\t\tthis.$textarea.trigger( 'focus' );\n\t\t\t}\n\t\t\tthis.$textarea.prop( 'selectionStart', Math.min( from, to ) )\n\t\t\t\t.prop( 'selectionEnd', Math.max( to, from ) );\n\t\t\tthis.$textarea.scrollTop( scrollTop );\n\t\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( false, this.$textarea );\n\t\t} else {\n\t\t\tthis.enableCodeMirror();\n\t\t\tthis.setCodeMirrorPreference( true );\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: true,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n}\n","import CodeMirrorWikiEditor from './codemirror.wikieditor';\n\nif ( mw.loader.getState( 'ext.wikiEditor' ) ) {\n\tmw.hook( 'wikiEditor.toolbarReady' ).add( ( $textarea ) => {\n\t\tconst cmWE = new CodeMirrorWikiEditor( $textarea );\n\t\tcmWE.addCodeMirrorToWikiEditor();\n\t} );\n}\n"],"names":["Text","lineAt","pos","this","length","RangeError","lineInner","line","n","lines","replace","from","to","text","parts","decompose","TextNode","append","other","slice","eq","start","scanIdentical","end","a","RawTextCursor","b","skip","next","lineBreak","done","value","iter","dir","iterRange","PartialTextCursor","iterLines","inner","Math","max","LineCursor","toString","sliceString","toJSON","flatten","constructor","of","TextLeaf","split","empty","textLength","super","children","target","isLine","offset","i","string","Line","open","sliceText","min","prev","pop","joined","appendText","push","mid","newLen","lineSep","result","part","len","child","endLine","childOpen","updated","totalLines","copy","iA","iB","eA","eB","chA","chB","reduce","l","ch","flat","chunk","maxChunk","minChunk","chunked","currentLines","currentLen","currentChunk","add","last","node","flush","concat","first","nodes","offsets","nextInner","top","offsetValue","size","cursor","limit","afterBreak","Symbol","prototype","iterator","number","extend","map","s","parseInt","isExtendingChar","code","isRegionalIndicator","ZWJ","findClusterBreak","str","forward","includeExtending","nextClusterBreak","prevClusterBreak","surrogateLow","charCodeAt","surrogateHigh","codePointSize","countBefore","found","code0","code1","fromCodePoint","String","fromCharCode","DefaultSplit","MapMode","ChangeDesc","sections","newLength","ins","iterGaps","f","posA","posB","iterChangedRanges","individual","iterChanges","invertedDesc","composeDesc","composeSets","mapDesc","before","mapSet","mapPos","assoc","mode","Simple","endA","TrackDel","TrackBefore","TrackAfter","touchesRange","fromJSON","json","Array","isArray","some","create","ChangeSet","inserted","apply","doc","fromA","toA","fromB","_toB","invert","index","compose","desc","filter","ranges","resultSections","resultInserted","filteredSections","SectionIter","addSection","off","addInsert","changes","filtered","total","force","set","process","spec","sub","insert","insText","insLen","e","createSet","forceJoin","values","endB","setA","setB","mkSet","piece","Error","left","len2","sectionLen","insB","textBit","forward2","undefined","SelectionRange","flags","anchor","head","bidiLevel","level","goalColumn","change","range","abs","mainIndex","r","main","asSingle","addRange","replaceRange","which","single","normalized","sort","indexOf","splice","checkSelection","selection","docLength","nextID","combine","compareInput","compare","isStatic","enables","id","default","extensions","define","config","sameArray","static","FacetProvider","compute","deps","get","computeN","field","x","state","every","dependencies","facet","type","dynamicSlot","addresses","_a","getter","idx","multi","depDoc","depSel","depAddrs","dep","update","tr","docChanged","ensureAll","newVal","compareArray","reconfigure","oldState","oldAddr","address","oldVal","getAddr","addrs","changed","addr","ensureAddr","dynamicFacetSlot","providers","providerAddrs","p","providerTypes","dynamic","val","depChanged","oldProviders","facets","oldValue","initField","createF","updateF","compareF","provides","provide","init","find","slot","extension","prec","ext","PrecExtension","highest","high","low","lowest","Compartment","CompartmentInstance","content","compartment","compartments","Configuration","base","dynamicSlots","staticValues","statusTemplate","staticFacet","resolve","fields","Object","newCompartments","Map","seen","known","delete","has","oldFacets","status","computeSlot","languageData","allowMultipleSelections","v","lineSeparator","changeFilter","transactionFilter","transactionExtender","readOnly","Annotation","AnnotationType","StateEffectType","mapping","mapped","is","mapEffects","effects","effect","appendConfig","Transaction","startState","annotations","scrollIntoView","_doc","_state","time","Date","now","newDoc","newSelection","applyTransaction","annotation","ann","reconfigured","isUserEvent","event","userEvent","joinRanges","mergeTransaction","sequential","mapForA","mapForB","resolveTransactionInner","docSize","sel","asArray","resolveTransaction","specs","seq","extenders","keys","extendTransaction","back","filters","filterTransaction","addToHistory","remote","none","CharCategory","nonASCIISingleCaseWordChar","wordChar","RegExp","_","require","startValues","conf","forEach","key","replaceSelection","toText","changeByRange","result1","newChanges","newMapped","j","mapBy","sliceDoc","prop","fieldInit","hasOwnProperty","call","configuration","tabSize","phrase","phrases","m","languageDataAt","name","side","provider","charCategorizer","at","wordChars","join","char","test","Space","toUpperCase","toLowerCase","hasWordChar","Word","Other","wordAt","cat","combineConfig","configs","defaults","current","kA","kB","k","RangeValue","Range","startSide","endSide","point","mapMode","cmpRange","Chunk","maxPoint","findIndex","startAt","arr","lo","hi","diff","between","newPos","newFrom","newTo","curFrom","curTo","chunkPos","nextLayer","chunkEnd","isEmpty","updateSpec","filterFrom","filterTo","cur","LayerCursor","goto","spill","builder","addInner","rangeIndex","chunkIndex","addChunk","nextChunk","finishInner","chunks","touch","HeapCursor","sets","oldSets","newSets","textDiff","comparator","minPointSize","sharedChunks","findSharedChunks","sideA","SpanCursor","sideB","sameValues","active","spans","openRanges","openStart","activeForPoint","openCount","pointFrom","pointRank","openEnd","span","build","lazySort","finish","finishChunk","newArrays","chunkStart","setMaxPoint","lastFrom","lastTo","inA","shared","Set","layer","minPoint","rank","gotoInner","setRangeIndex","heap","heapBubble","childIndex","activeTo","activeRank","minActive","removeActive","remove","findMinIndex","addActive","trackOpen","wasPoint","nextVal","reverse","startA","startB","dPos","clipEnd","comparePoint","compareRange","array","foundPos","COUNT","for","SET","floor","random","globalThis","window","StyleModule","options","rules","splitSelector","selector","render","selectors","isKeyframes","local","isAt","exec","keyframes","getRules","newName","mount","root","modules","nonce","setNonce","StyleSet","adoptedSet","ownerDocument","win","defaultView","adoptedStyleSheets","CSSStyleSheet","adopted","sheet","styleTag","createElement","setAttribute","insertBefore","firstChild","mod","insertRule","textContent","getAttribute","shift","mac","navigator","platform","ie","userAgent","getSelection","nodeType","contains","dom","parentNode","hasSelection","anchorNode","clientRectsFor","textRange","nodeValue","getClientRects","isEquivalentPosition","targetNode","targetOff","scanFor","domIndex","previousSibling","maxOffset","nodeName","parent","childNodes","contentEditable","flattenRect","rect","right","bottom","windowRect","innerWidth","innerHeight","DOMSelectionState","anchorOffset","focusNode","focusOffset","domSel","setRange","scratchRange","preventScrollSupported","focusPreventScroll","setActive","focus","stack","scrollTop","scrollLeft","preventScroll","elt","document","createRange","setEnd","setStart","dispatchKey","keyCode","cancelable","down","KeyboardEvent","synthetic","dispatchEvent","up","defaultPrevented","clearAttributes","attributes","removeAttributeNode","isScrolledToBottom","scrollHeight","clientHeight","DOMPos","precise","after","noChildren","ContentView","overrideDOMText","posAtStart","posBefore","posAtEnd","view","breakAfter","posAfter","sync","track","nextSibling","contentView","canReuseDOM","reuseDOM","written","rm$1","_dom","localPosFromDOM","bias","lastChild","domBoundsAround","fromI","fromStart","toI","toEnd","prevEnd","startDOM","endDOM","markDirty","andParent","markParentsDirty","childList","setParent","setDOM","cmView","rootView","replaceChildren","destroy","ignoreMutation","_rec","ignoreEvent","_event","childCursor","ChildCursor","childPos","findPos","isEditable","isWidget","isHidden","merge","source","hasStart","become","getSide","removeChild","fromOff","toOff","breakAtStart","breakAtEnd","mergeChildrenInto","dLen","nav","vendor","documentElement","style","ie_edge","ie_upto10","ie_11up","gecko","chrome","webkit","safari","ios","maxTouchPoints","browser","windows","linux","ie_version","documentMode","gecko_version","chrome_version","android","webkit_version","TextView","createDOM","textDOM","createTextNode","domAtPos","_from","_to","coordsAt","rects","width","textCoords","MarkView","mark","setAttrs","class","className","attrs","tagName","_hasStart","detachFrom","inlineDOMAtPos","coordsInChildren","WidgetView","widget","prevWidget","updateDOM","toDOM","custom","fromBack","WidgetBufferView","getBoundingClientRect","joinInlineInto","beforePos","afterPos","scan","fallbackRect","combineAttrs","noAttrs","attrsEq","ignore","keysA","keysB","updateAttrs","cssText","removeAttribute","getAttrs","attr","WidgetType","estimatedHeight","lineBreaks","BlockType","Decoration","heightRelevant","MarkDecoration","block","inlineOrder","PointDecoration","isBlockGap","getInclusive","LineDecoration","hasHeight","_b","isReplace","WidgetRange","WidgetBefore","WidgetAfter","inclusiveStart","inclusiveEnd","inclusive","margin","LineView","arguments","prevAttrs","transferDOM","setDeco","addLineDeco","deco","cls","classList","hack","cmIgnore","appendChild","measureTextSize","textHeight","totalWidth","height","lineHeight","charWidth","heightOracle","viewState","dist","_other","docView","BlockWidgetView","_takeDeco","ContentBuilder","disallowBlockEffectsFor","curLine","pendingBuffer","bufferMarks","atCursorPos","textOff","posCovered","getLine","flushBuffer","wrapMarks","addBlockWidget","buildText","take","NullWidget","cursorBefore","cursorAfter","decorations","dynamicDecorationMap","tag","clickAddsSelectionRange","dragMovesSelection$1","mouseSelectionStyle","exceptionSink","updateListener","inputHandler","focusChangeEffect","perLineTextDirection","nativeSelectionHidden","ScrollTarget","y","yMargin","xMargin","t","logException","exception","context","handler","onerror","console","error","editable","nextPluginID","viewPlugin","domEventHandlers","buildExtensions","eventHandlers","plugin","pluginInst","fromClass","PluginInstance","mustUpdate","deactivate","editorAttributes","contentAttributes","atomicRanges","bidiIsolatedRanges","getIsolatedRanges","isolates","Function","iso","bidiIsolate","direction","scrollMargins","getScrollMargins","styleModule","ChangedRange","toB","addToSet","me","extendWithRanges","dI","rI","ViewUpdate","transactions","changedRanges","viewportChanged","heightChanged","geometryChanged","focusChanged","selectionSet","Direction","LTR","RTL","dec","LowTypes","ArabicTypes","Brackets","BracketStack","BidiRE","BidiSpan","order","maybe","isolatesEq","types","emitSpans","baseLevel","ourType","iCh","iI","sameDir","isNum","recurse","localLevel","iScan","run","upto","jI","computeSectionOrder","outerType","rFrom","rTo","prevType","prevStrong","computeCharTypes","oppositeType","sI","br","sJ","embed","processBracketPairs","beforeL","fromJ","processNeutrals","trivialOrder","movedOver","moveVisually","startIndex","spanI","indexForward","nextIndex","nextSpan","DocView","domChanged","hasComposition","markedForComposition","minWidth","minWidthFrom","minWidthTo","impreciseAnchor","impreciseHead","forceSelection","lastUpdate","contentDOM","updateDeco","updateInner","readCompositionAt","inputState","composing","newSel","composition","touched","touchesComposition","headPos","findCompositionNode","textNode","inv","marks","parentView","findCompositionRange","clear","decoDiff","comp","DecorationComparator$1","findChangedDeco","oldLength","mustMeasureContent","updateChildren","observer","contentHeight","scaleY","flexBasis","selectionRange","cView","gaps","viewport","BlockGapWidget","updateGaps","compLine","compositionView","fixCompositionDOM","fix","c","updateSelection","mustRead","fromPointer","readSelectionRange","activeElt","activeElement","focused","selectionNotFocus","moveToLine","dummy","inside","assignedSlot","inUneditable","blur","rawSel","nextTo","nearbyTextNode","collapse","caretBidiLevel","removeAllRanges","setSelectionRange","enforceCursorAssoc","modify","lineStart","newRange","posFromDOM","nearest","domView","coordsForChar","childOff","measureVisibleLineHeights","contentWidth","clientWidth","isWider","scrollDOM","widest","ltr","textDirection","childRect","textDirectionAt","getComputedStyle","measure","position","computeBlockGapDeco","vs","viewports","lineBlockAt","allDeco","d","lineGapDeco","margins","targetRect","stop","bounding","body","scaleX","scrollWidth","offsetWidth","offsetHeight","moveX","moveY","rectHeight","boundingHeight","scrollBy","movedX","movedY","host","scrollRectIntoView","startNode","startOffset","getdx","getdy","yOverlap","upTop","upBot","domPosAtCoords","closest","closestRect","closestX","closestY","above","below","aboveRect","belowRect","closestOverlap","dx","dy","domPosInText","clipX","closestOffset","closestDY","generalSide","posAtCoords","coords","docTop","paddingTop","docHeight","yOffset","halfLine","bounced","elementAtHeight","posAtCoordsImprecise","elementFromPoint","element","caretPositionFromPoint","offsetNode","caretRangeFromPoint","startContainer","isSuspiciousSafariCaretResult","isSuspiciousChromeCaretResult","contentRect","into","round","defaultCharacterWidth","lineWrapping","defaultLineHeight","lineLength","col","strict","moveByChar","by","bidiSpans","check","skipAtomicRanges","atoms","moved","skipAtoms","oldPos","InputState","setSelectionOrigin","origin","lastSelectionOrigin","lastSelectionTime","lastKeyCode","lastKeyTime","lastTouchTime","lastFocusTime","lastScrollTop","lastScrollLeft","chromeScrollHack","pendingIOSKey","lastEscPress","lastContextMenu","scrollHandlers","registeredEvents","customHandlers","compositionFirstChange","compositionEndedAt","compositionPendingKey","compositionPendingChange","mouseSelection","handleEvent","ignoreDuringComposition","keydown","mustFlushObserver","forceFlush","runCustomHandlers","preventDefault","handlers","addEventListener","eventBelongsToEditor","handlerOptions","clientY","mousedown","button","minHeight","setTimeout","drop","pointerEvents","clearTimeout","passive","notifiedFocused","hasFocus","appliedFirefoxHack","firefoxCopyCutHack","ensureHandlers","plugins","runScrollHandlers","scroll","modifierCodes","delayAndroidKey","pending","altKey","metaKey","PendingKeys","ctrlKey","EmacsyPendingKeys","shiftKey","flushIOSKey","startMouseSelection","inputType","dragScrollSpeed","MouseSelection","startEvent","mustSelect","scrollSpeed","scrolling","lastEvent","scrollParent","scrollableParent","move","bind","multiple","addsSelectionRange","dragging","rangeCount","getRangeAt","clientX","isInPrimarySelection","getClickType","select","buttons","sx","sy","setScrollSpeed","removeEventListener","setInterval","clearInterval","dispatch","bubbles","brokenClipboardAPI","doPaste","input","byLine","lastLinewiseCopy","lastLine","rangeForClick","categorize","linePos","groupAt","visual","touchstart","touchmove","makeStyle","queryPos","startSel","removed","startRange","removeRangeAround","basicMouseSelection","mustFocus","insideY","findPositionSide","BadMouseDetail","lastMouseDown","lastMouseDownCount","lastMouseDownTime","detail","lastTime","dropText","direct","dropPos","del","dragMovesSelection","dragstart","dataTransfer","setData","effectAllowed","files","read","finishFile","reader","FileReader","onload","readAsText","getData","paste","data","clipboardData","capturePaste","cut","linewise","copiedRange","clearData","selectionEnd","selectionStart","captureCopy","isFocusChange","focusChangeTransaction","getEffect","updateForFocusChange","clearSelectionRange","compositionstart","compositionupdate","compositionend","pendingRecords","flushSoon","Promise","then","contextmenu","beforeinput","startViewHeight","visualViewport","wrappingWhiteSpace","HeightOracle","heightSamples","heightForGap","ceil","heightForLine","setDoc","mustRefreshForWrapping","whiteSpace","mustRefreshForHeights","lineHeights","newHeight","h","refresh","knownHeights","MeasuredHeights","heights","more","BlockInfo","_content","widgetLineBreaks","QueryType","Epsilon","HeightMap","outdated","setHeight","oracle","decomposeLeft","decomposeRight","applyChanges","oldDoc","ByPosNoHeight","NodeBuilder","updateHeight","HeightMapText","break","brk","HeightMapBranch","HeightMapBlock","blockAt","_height","_oracle","_value","_type","forEachLine","_force","measured","collapsed","widgetHeight","breaks","HeightMapGap","heightMetrics","perLine","firstLine","perChar","totalPerLine","guess","lineTop","ByHeight","linesAbove","unshift","singleHeight","rightTop","rightOffset","subQuery","ByPos","rightStart","balanced","mergeGaps","rebalance","around","lineEnd","covering","writtenTo","isCovered","addBlock","enterLine","blankContent","gap","ensureLine","DecorationComparator","visiblePixelRange","overflow","parentRect","offsetParent","fullPixelRange","LineGap","same","gA","gB","draw","wrapping","LineGapWidget","vertical","display","ViewState","pixelViewport","inView","paddingBottom","contentDOMWidth","contentDOMHeight","editorHeight","editorWidth","scrolledToBottom","scrollAnchorPos","scrollAnchorHeight","scaler","IdScaler","scrollTarget","printing","defaultTextDirection","visibleRanges","mustEnforceCursorAssoc","guessWrapping","stateDeco","heightMap","getViewport","updateViewportLines","updateForViewport","lineGaps","ensureLineGaps","computeVisibleRanges","Viewport","BigScaler","viewportLines","scale","scaleBlock","prevDeco","contentChanges","heightChanges","heightRelevantDecoChanges","prevHeight","scrollAnchor","scrollAnchorAt","mapViewport","viewportIsAppropriate","updateLines","updateLineGaps","mapLineGaps","domRect","measureContent","dTop","dBottom","vp","viewportChange","visibleTop","fromDOM","visibleBottom","marginTop","topPos","viewHeight","mayMeasure","halfMargin","doubleMargin","addGap","structure","avoid","moveToLineBoundary","gapSize","lineStructure","viewFrom","viewTo","bot","marginHeight","targetFrac","findFraction","spaceFrac","findPosition","marginWidth","fraction","lineBlockAtHeight","ratio","counted","vpHeight","domBase","domTop","domBottom","obj","bTop","bBottom","theme","strs","darkTheme","baseThemeID","baseLightID","baseDarkID","lightDarkIDs","buildTheme","scopes","baseTheme$1","boxSizing","outline","flexDirection","alignItems","fontFamily","overflowX","zIndex","flexGrow","flexShrink","wordWrap","padding","WebkitUserModify","whiteSpace_fallback","wordBreak","overflowWrap","caretColor","contain","background","animation","opacity","borderLeft","marginLeft","borderLeftColor","backgroundColor","color","insetInlineStart","borderRight","textAlign","borderBottom","borderTop","verticalAlign","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","fontSize","borderRadius","border","LineBreakPlaceholder","DOMReader","points","readRange","findPointBefore","oldLen","readNode","nextView","isBlockElement","readTextNode","re","nextBreak","breakSize","fromView","findPointInside","maxLen","DOMPoint","DOMChange","typeOver","bounds","iHead","iAnchor","selPoints","selectionPoints","selectionFromPoints","applyDOMChange","domChange","lastKey","preferredPos","preferredSide","minLen","findDiff","defaultTr","defaultInsert","mainSel","compositionRange","replaced","rangeChanges","selOff","applyDefaultInsert","observeOptions","characterData","subtree","characterDataOldValue","useCharData","DOMObserver","selectionChanged","delayedFlush","resizeTimeout","queue","delayedAndroidKey","flushingAndroidKey","lastChange","scrollTargets","intersection","resizeScroll","resizeContent","intersecting","gapIntersection","parentCheck","MutationObserver","mutations","mut","removedNodes","onCharData","prevValue","onSelectionChange","onResize","onPrint","onScroll","ResizeObserver","observe","requestMeasure","addWindowListeners","IntersectionObserver","entries","listenForScroll","intersectionRatio","onScrollChanged","createEvent","threshold","g","disconnect","wasChanged","shadowRoot","deepActiveElement","stopImmediatePropagation","getTargetRanges","execCommand","endContainer","endOffset","curAnchor","safariSelectionRangeHack","atElementStart","processRecords","clearDelayedAndroidKey","requestAnimationFrame","cancelAnimationFrame","takeRecords","records","record","readMutation","readChange","readSelection","handled","rec","childBefore","findChild","childAfter","setWindow","removeWindowListeners","_c","_d","curView","compositionStarted","_root","pluginMap","editorAttrs","contentAttrs","bidiCache","destroyed","updateState","measureScheduled","measureRequests","tabIndex","announceDOM","dispatchTransactions","trs","getRoot","mountStyles","redrawn","attrsChanged","focusFlag","dispatchFocus","pendingKey","setState","CachedOrder","updatePlugins","styleModules","showAnnouncements","listener","newState","hadFocus","prevSpecs","newPlugins","sDOM","warn","measuring","BadMeasure","write","themeClasses","attrsFromFacet","spellcheck","autocorrect","autocapitalize","translate","contenteditable","role","changedContent","changedEditor","announce","cspNonce","readMeasured","request","documentTop","documentPadding","viewportLineBlocks","moveByGroup","initial","nextCat","byGroup","includeWrap","coordsAtPos","editorRect","moveVertically","distance","startPos","startY","goal","startCoords","resolvedGoal","extra","curY","posAtDOM","MaxBidiLine","entry","fresh","computeOrder","setRoot","prefix","dark","baseTheme","findFromDOM","querySelector","cache","lastDir","sources","currentPlatform","modifiers","keymap","runHandlers","getKeymap","Keymaps","WeakMap","bindings","bound","isPrefix","checkPrefix","scope","command","stopPropagation","scopeObj","alt","ctrl","meta","normalizeKeyName","ourObj","storedPrefix","PrefixTimeout","full","binding","_any","any","buildKeymap","keyName","isChar","prevented","baseName","shiftName","ran","runFor","cmd","panelConfig","topContainer","bottomContainer","getPanel","panel","panelPlugin","panels","showPanel","PanelGroup","container","syncClasses","scrollMargin","classes","syncDOM","curDOM","rm","elementClass","gutterLineClass","activeGutters","unfixGutters","gutters","gutterView","fixed","prevViewport","SingleGutterView","gutter","syncGutters","updateGutters","vpA","vpB","vpOverlap","detach","lineClasses","classSet","contexts","UpdateContext","advanceCursor","cx","collect","markers","addElement","elements","newElt","GutterElement","extraMarkers","localMarkers","forLine","lineMarker","renderEmptyElements","marker","widgetMarker","spacer","initialSpacer","prevMarkers","updateSpacer","lineMarkerChange","sameMarkers","setMarkers","domPos","iNew","iOld","skipTo","matched","lineNumberMarkers","lineNumberConfig","formatNumber","assign","exists","NumberMarker","lineNumberGutter","others","maxLineNumber","CodeMirror","$textarea","_classCallCheck","contentAttributesExtension","namespaces","mw","includes","lineNumbers","EditorView","accesskey","lang","_this","defaultExtensions","EditorState","textSelection","hide","form","$","cmTextSelection","hook","fire","session_token","user","sessionId","user_id","getId","editCountBucket","user_edit_count_bucket","prefValue","isNamed","Api","saveOption","_this2","$cmDom","getContents","setContents","setSelection","getCaretPosition","startAndEnd","scrollToCaretPosition","DefaultBufferLength","nextPropID","perNode","deserialize","match","closedBy","openedBy","group","contextHash","lookAhead","mounted","MountedTree","tree","overlay","parser","props","noProps","skipped","src","isTop","isSkipped","isError","isAnonymous","groups","CachedNode","CachedInnerNode","IterMode","positions","JSON","stringify","TreeCursor","topNode","cursorAt","moveTo","_tree","TreeNode","resolveNode","resolveInner","resolveStack","layers","iterStack","stackIterator","iterate","enter","leave","anon","IncludeAnonymous","entered","propValues","balance","balanceRange","makeTree","buffer","nodeSet","maxBufferLength","reused","minRepeatType","FlatBufferCursor","takeNode","parentStart","minPos","inRepeat","lookAheadAtStart","maxSize","fork","minStart","nodeSize","localSkipped","nodeStart","findBufferSize","Uint16Array","endPos","copyToBuffer","TreeBuffer","localChildren","localPositions","localInRepeat","lastGroup","lastEnd","makeRepeatLeaf","make","lookAheadProp","lastI","makeBalanced","pair","bufferStart","topID","buildTree","childString","endIndex","pick","checkSide","startI","endI","overlays","IgnoreOverlays","BaseNode","getChild","getChildren","matchContext","matchNodeContext","enterUnfinishedNodesBefore","prevSibling","_parent","nextChild","ExcludeBuffers","BufferNode","BufferContext","hasChild","IgnoreMounts","rPos","nextSignificantParent","toTree","externalSibling","heads","picked","newHeads","StackIterator","bufferNode","yieldNode","yieldBuf","yield","enterChild","sibling","atLastNode","depth","mustLeave","nodeSizeCache","balanceType","mkTop","mkTree","maxChild","divide","groupFrom","groupStart","groupSize","nextSize","only","TreeFragment","addTree","fragments","partial","minGap","fI","nextF","cI","nextC","nextPos","fFrom","fTo","startParse","StringInput","createParse","parse","advance","lineChunks","nextTagID","Tag","modified","defineModifier","Modifier","nextModifierID","instances","mods","powerSet","styleTags","byName","tags","pieces","rest","rule","Rule","ruleNodeProp","opaque","inherit","tagHighlighter","all","tagClass","comment","typeName","propertyName","literal","heading","keyword","operator","punctuation","bracket","lineComment","blockComment","docComment","variableName","attributeName","labelName","namespace","macroName","docString","character","attributeValue","integer","float","bool","regexp","escape","url","self","null","atom","unit","modifier","operatorKeyword","controlKeyword","definitionKeyword","moduleKeyword","derefOperator","arithmeticOperator","logicOperator","bitwiseOperator","compareOperator","updateOperator","definitionOperator","typeOperator","controlOperator","separator","angleBracket","squareBracket","paren","brace","heading1","heading2","heading3","heading4","heading5","heading6","contentSeparator","list","quote","emphasis","strong","link","monospace","strikethrough","deleted","invalid","documentMeta","processingInstruction","definition","constant","function","standard","special","languageDataProp","sublanguageProp","Language","extraExtensions","defineProperty","syntaxTree","language","topNodeAt","innerNode","sublang","isActiveAt","findRegions","allowsNesting","explore","topLang","DocInput","cursorPos","syncTo","stringStart","currentContext","ParseContext","treeLen","scheduleOn","tempSkipped","work","until","isDone","takeTree","withContext","endTime","stoppedAt","stopAt","withoutTempSkipped","parsedPos","cutFragments","updateViewport","startLen","reset","skipUntilInView","getSkippingParser","frags","LanguageState","newCx","vpTo","parseState","requestIdle","callback","timeout","requestIdleCallback","idle","cancelIdleCallback","isInputPending","scheduling","parseWorker","working","workScheduled","chunkBudget","scheduleWork","checkAsyncSchedule","deadline","timeRemaining","viewportFirst","catch","err","isWorking","languages","indentService","indentUnit","getIndentUnit","indentString","cols","ts","getIndentation","IndentContext","service","ast","indentFor","syntaxIndentation","simulateBreak","simulateDoubleBreak","textAfterPos","column","countColumn","override","overrideIndentation","search","lineIndent","overriden","simulatedBreak","indentNodeProp","strategy","indentStrategy","TreeIndentContext","close","closed","align","units","closing","closedAt","textAfter","space","aligned","openToken","sim","openLine","bracketedAligned","baseIndent","delimitedStrategy","ignoreClosed","topIndent","baseIndentFor","atBreak","isParent","DefaultScanDist","DefaultBrackets","bracketMatchingConfig","afterCursor","brackets","maxScanDistance","renderMatch","defaultRenderMatch","matchingMark","nonmatchingMark","bracketMatchingState","matchBrackets","bracketMatchingUnique","bracketMatching","bracketMatchingHandle","matchingNodes","byProp","findHandle","hasHandle","matches","handle","matchMarkedBrackets","tokenType","startCh","startToken","basePos","matchPlainBrackets","_pos","token","matching","firstToken","endHandle","noTokens","typeArray","warned","byTag","defaultTable","legacyName","createTokenType","warnForPart","msg","tagStr","tags$1","option","toggleLineComment","changeLineComment","toggleBlockComment","changeBlockComment","toggleBlockCommentByLine","o","fromLine","toLine","selectedLineRanges","getConfig","SearchMargin","tokens","comments","startText","endText","textBefore","spaceBefore","spaceAfter","beforeOff","startSpace","endSpace","endOff","charAt","findBlockComment","prevLine","minIndent","indent","changeSet","fromHistory","isolateHistory","invertedEffects","historyConfig","minDepth","newGroupDelay","joinToEvent","_t","isAdjacent","adj","historyField_","HistoryState","fromHist","changeEnd","item","HistEvent","fromTransaction","undone","updateBranch","addSelection","isolate","addMapping","addChanges","undo","redo","historyState","undoSelection","redoSelection","startSelection","selectionsAfter","setSelAfter","selections","branch","newEvent","newBranch","conc","MaxSelectionsPerEvent","sels","popSelection","addMappingToBranch","mapEvent","extraSelections","mappedChanges","fullMapping","joinableUserEvent","prevTime","prevUserEvent","_f","historyKeymap","updateSel","setSel","moveSel","how","rangeEnd","cursorByChar","ltrAtCursor","cursorCharLeft","cursorCharRight","cursorByGroup","interestingNode","bracketProp","moveBySyntax","cursorByLine","Intl","Segmenter","cursorLineUp","cursorLineDown","pageInfo","selfScroll","marginBottom","cursorByPage","page","scrollRect","scrollBottom","cursorPageUp","cursorPageDown","moveByLineBoundary","extendSel","selectByChar","selectCharLeft","selectCharRight","selectByGroup","selectByLine","selectLineUp","selectLineDown","selectByPage","selectPageUp","selectPageDown","cursorDocStart","cursorDocEnd","selectDocStart","selectDocEnd","deleteBy","towards","skipAtomic","deleteByChar","targetPos","deleteCharBackward","deleteCharForward","deleteByGroup","nextChar","deleteGroupBackward","deleteToLineEnd","selectedLineBlocks","blocks","startLine","moveLine","nextLine","copyLine","insertNewlineAndIndent","newlineAndIndent","atEof","explode","isBetweenBrackets","changeBySelectedLine","atLine","defaultKeymap","keep","norm","toMatchingBracket","crelt","basicNormalize","normalize","SearchCursor","query","bufferPos","peek","nextOverlapping","baseFlags","unicode","RegExpCursor","MultilineRegExpCursor","ignoreCase","curLineStart","matchPos","toCharEnd","lastIndex","flattened","FlattenedDoc","cached","cachedFrom","createLineDialog","go","sign","ln","cl","percent","pc","docLine","dialogEffect","onkeydown","onsubmit","dialogField","searchConfigFacet","caseSensitive","wholeWord","createPanel","SearchPanel","scrollToMatch","SearchQuery","valid","validRegExp","unquoted","unquote","RegExpQuery","StringQuery","getCursor","st","regexpCursor","stringCursor","categorizer","buf","bufPos","charBefore","charAfter","stringWordTest","nextMatch","prevMatchInRange","prevMatch","getReplacement","_result","matchAll","highlight","setSearchQuery","togglePanel","searchState","SearchState","defaultQuery","createSearchPanel","matchMark","selectedMatchMark","searchHighlighter","selected","searchCommand","openSearchPanel","findNext","announceMatch","selectSearchInput","findPrevious","selectMatches","replaceNext","replacement","replaceAll","announceText","fallback","_e","selText","getSearchInput","searchInput","searchExtensions","closeSearchPanel","searchKeymap","selectWord","searchedText","word","fullWord","cycled","findNextOccurrence","onclick","commit","searchField","placeholder","onchange","onkeyup","replaceField","caseField","checked","reField","wordField","setQuery","AnnounceMargin","Break","font","marginRight","CodeMirrorWikiEditor","_CodeMirror","_inherits","_super","realtimePreviewHandler","useCodeMirror","editRecoveryHandler","_get","_getPrototypeOf","_toConsumableArray","history","triggerHandler","fieldChangeHandler","initialize","EditorSelection","_this3","toolbar","wikiEditor","section","codemirror","tools","label","oouiIcon","action","execute","switchCodeMirror","$toolbar","enableCodeMirror","updateToolbarButton","logUsage","editor","enabled","toggled","edit_start_ts_ms","$button","toggleClass","setCodeMirrorPreference","_this$view$state$sele","show","trigger","loader","getState","addCodeMirrorToWikiEditor"],"sourceRoot":""} |