@drjoshcsimmons/scl 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/components/ui/accordion/accordion.d.ts +8 -0
  4. package/dist/components/ui/accordion/accordion.d.ts.map +1 -0
  5. package/dist/components/ui/accordion/index.d.ts +2 -0
  6. package/dist/components/ui/accordion/index.d.ts.map +1 -0
  7. package/dist/components/ui/alert/alert.d.ts +9 -0
  8. package/dist/components/ui/alert/alert.d.ts.map +1 -0
  9. package/dist/components/ui/alert/index.d.ts +2 -0
  10. package/dist/components/ui/alert/index.d.ts.map +1 -0
  11. package/dist/components/ui/alert-dialog/alert-dialog.d.ts +21 -0
  12. package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -0
  13. package/dist/components/ui/alert-dialog/index.d.ts +2 -0
  14. package/dist/components/ui/alert-dialog/index.d.ts.map +1 -0
  15. package/dist/components/ui/avatar/avatar.d.ts +7 -0
  16. package/dist/components/ui/avatar/avatar.d.ts.map +1 -0
  17. package/dist/components/ui/avatar/index.d.ts +2 -0
  18. package/dist/components/ui/avatar/index.d.ts.map +1 -0
  19. package/dist/components/ui/badge/badge.d.ts +10 -0
  20. package/dist/components/ui/badge/badge.d.ts.map +1 -0
  21. package/dist/components/ui/badge/index.d.ts +2 -0
  22. package/dist/components/ui/badge/index.d.ts.map +1 -0
  23. package/dist/components/ui/button/button.d.ts +12 -0
  24. package/dist/components/ui/button/button.d.ts.map +1 -0
  25. package/dist/components/ui/button/index.d.ts +2 -0
  26. package/dist/components/ui/button/index.d.ts.map +1 -0
  27. package/dist/components/ui/card/card.d.ts +9 -0
  28. package/dist/components/ui/card/card.d.ts.map +1 -0
  29. package/dist/components/ui/card/index.d.ts +2 -0
  30. package/dist/components/ui/card/index.d.ts.map +1 -0
  31. package/dist/components/ui/checkbox/checkbox.d.ts +5 -0
  32. package/dist/components/ui/checkbox/checkbox.d.ts.map +1 -0
  33. package/dist/components/ui/checkbox/index.d.ts +2 -0
  34. package/dist/components/ui/checkbox/index.d.ts.map +1 -0
  35. package/dist/components/ui/collapsible/collapsible.d.ts +6 -0
  36. package/dist/components/ui/collapsible/collapsible.d.ts.map +1 -0
  37. package/dist/components/ui/collapsible/index.d.ts +2 -0
  38. package/dist/components/ui/collapsible/index.d.ts.map +1 -0
  39. package/dist/components/ui/dialog/dialog.d.ts +20 -0
  40. package/dist/components/ui/dialog/dialog.d.ts.map +1 -0
  41. package/dist/components/ui/dialog/index.d.ts +2 -0
  42. package/dist/components/ui/dialog/index.d.ts.map +1 -0
  43. package/dist/components/ui/dithered-image/dithered-image.d.ts +17 -0
  44. package/dist/components/ui/dithered-image/dithered-image.d.ts.map +1 -0
  45. package/dist/components/ui/dithered-image/index.d.ts +3 -0
  46. package/dist/components/ui/dithered-image/index.d.ts.map +1 -0
  47. package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts +28 -0
  48. package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts.map +1 -0
  49. package/dist/components/ui/dropdown-menu/index.d.ts +2 -0
  50. package/dist/components/ui/dropdown-menu/index.d.ts.map +1 -0
  51. package/dist/components/ui/input/index.d.ts +2 -0
  52. package/dist/components/ui/input/index.d.ts.map +1 -0
  53. package/dist/components/ui/input/input.d.ts +5 -0
  54. package/dist/components/ui/input/input.d.ts.map +1 -0
  55. package/dist/components/ui/label/index.d.ts +2 -0
  56. package/dist/components/ui/label/index.d.ts.map +1 -0
  57. package/dist/components/ui/label/label.d.ts +6 -0
  58. package/dist/components/ui/label/label.d.ts.map +1 -0
  59. package/dist/components/ui/popover/index.d.ts +2 -0
  60. package/dist/components/ui/popover/index.d.ts.map +1 -0
  61. package/dist/components/ui/popover/popover.d.ts +8 -0
  62. package/dist/components/ui/popover/popover.d.ts.map +1 -0
  63. package/dist/components/ui/progress/index.d.ts +2 -0
  64. package/dist/components/ui/progress/index.d.ts.map +1 -0
  65. package/dist/components/ui/progress/progress.d.ts +19 -0
  66. package/dist/components/ui/progress/progress.d.ts.map +1 -0
  67. package/dist/components/ui/radio-group/index.d.ts +2 -0
  68. package/dist/components/ui/radio-group/index.d.ts.map +1 -0
  69. package/dist/components/ui/radio-group/radio-group.d.ts +6 -0
  70. package/dist/components/ui/radio-group/radio-group.d.ts.map +1 -0
  71. package/dist/components/ui/scroll-area/index.d.ts +2 -0
  72. package/dist/components/ui/scroll-area/index.d.ts.map +1 -0
  73. package/dist/components/ui/scroll-area/scroll-area.d.ts +6 -0
  74. package/dist/components/ui/scroll-area/scroll-area.d.ts.map +1 -0
  75. package/dist/components/ui/select/index.d.ts +2 -0
  76. package/dist/components/ui/select/index.d.ts.map +1 -0
  77. package/dist/components/ui/select/select.d.ts +14 -0
  78. package/dist/components/ui/select/select.d.ts.map +1 -0
  79. package/dist/components/ui/separator/index.d.ts +2 -0
  80. package/dist/components/ui/separator/index.d.ts.map +1 -0
  81. package/dist/components/ui/separator/separator.d.ts +5 -0
  82. package/dist/components/ui/separator/separator.d.ts.map +1 -0
  83. package/dist/components/ui/sheet/index.d.ts +2 -0
  84. package/dist/components/ui/sheet/index.d.ts.map +1 -0
  85. package/dist/components/ui/sheet/sheet.d.ts +26 -0
  86. package/dist/components/ui/sheet/sheet.d.ts.map +1 -0
  87. package/dist/components/ui/skeleton/index.d.ts +2 -0
  88. package/dist/components/ui/skeleton/index.d.ts.map +1 -0
  89. package/dist/components/ui/skeleton/skeleton.d.ts +3 -0
  90. package/dist/components/ui/skeleton/skeleton.d.ts.map +1 -0
  91. package/dist/components/ui/slider/index.d.ts +2 -0
  92. package/dist/components/ui/slider/index.d.ts.map +1 -0
  93. package/dist/components/ui/slider/slider.d.ts +5 -0
  94. package/dist/components/ui/slider/slider.d.ts.map +1 -0
  95. package/dist/components/ui/statusline/index.d.ts +2 -0
  96. package/dist/components/ui/statusline/index.d.ts.map +1 -0
  97. package/dist/components/ui/statusline/statusline.d.ts +40 -0
  98. package/dist/components/ui/statusline/statusline.d.ts.map +1 -0
  99. package/dist/components/ui/switch/index.d.ts +2 -0
  100. package/dist/components/ui/switch/index.d.ts.map +1 -0
  101. package/dist/components/ui/switch/switch.d.ts +5 -0
  102. package/dist/components/ui/switch/switch.d.ts.map +1 -0
  103. package/dist/components/ui/table/index.d.ts +2 -0
  104. package/dist/components/ui/table/index.d.ts.map +1 -0
  105. package/dist/components/ui/table/table.d.ts +11 -0
  106. package/dist/components/ui/table/table.d.ts.map +1 -0
  107. package/dist/components/ui/tabs/index.d.ts +2 -0
  108. package/dist/components/ui/tabs/index.d.ts.map +1 -0
  109. package/dist/components/ui/tabs/tabs.d.ts +8 -0
  110. package/dist/components/ui/tabs/tabs.d.ts.map +1 -0
  111. package/dist/components/ui/terminal-textarea/index.d.ts +2 -0
  112. package/dist/components/ui/terminal-textarea/index.d.ts.map +1 -0
  113. package/dist/components/ui/terminal-textarea/terminal-textarea.d.ts +27 -0
  114. package/dist/components/ui/terminal-textarea/terminal-textarea.d.ts.map +1 -0
  115. package/dist/components/ui/textarea/index.d.ts +2 -0
  116. package/dist/components/ui/textarea/index.d.ts.map +1 -0
  117. package/dist/components/ui/textarea/textarea.d.ts +5 -0
  118. package/dist/components/ui/textarea/textarea.d.ts.map +1 -0
  119. package/dist/components/ui/toggle/index.d.ts +2 -0
  120. package/dist/components/ui/toggle/index.d.ts.map +1 -0
  121. package/dist/components/ui/toggle/toggle.d.ts +13 -0
  122. package/dist/components/ui/toggle/toggle.d.ts.map +1 -0
  123. package/dist/components/ui/tooltip/index.d.ts +2 -0
  124. package/dist/components/ui/tooltip/index.d.ts.map +1 -0
  125. package/dist/components/ui/tooltip/tooltip.d.ts +11 -0
  126. package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -0
  127. package/dist/index.d.ts +34 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +165 -0
  130. package/dist/index10.js +61 -0
  131. package/dist/index100.js +32 -0
  132. package/dist/index101.js +17 -0
  133. package/dist/index102.js +137 -0
  134. package/dist/index103.js +52 -0
  135. package/dist/index104.js +11 -0
  136. package/dist/index105.js +6 -0
  137. package/dist/index106.js +183 -0
  138. package/dist/index107.js +652 -0
  139. package/dist/index108.js +109 -0
  140. package/dist/index109.js +93 -0
  141. package/dist/index11.js +27 -0
  142. package/dist/index110.js +69 -0
  143. package/dist/index111.js +161 -0
  144. package/dist/index112.js +399 -0
  145. package/dist/index113.js +1682 -0
  146. package/dist/index114.js +280 -0
  147. package/dist/index115.js +134 -0
  148. package/dist/index116.js +34 -0
  149. package/dist/index117.js +1613 -0
  150. package/dist/index118.js +300 -0
  151. package/dist/index119.js +637 -0
  152. package/dist/index12.js +7 -0
  153. package/dist/index120.js +146 -0
  154. package/dist/index121.js +23 -0
  155. package/dist/index122.js +11 -0
  156. package/dist/index123.js +40 -0
  157. package/dist/index124.js +20 -0
  158. package/dist/index125.js +8 -0
  159. package/dist/index126.js +14 -0
  160. package/dist/index127.js +208 -0
  161. package/dist/index128.js +24 -0
  162. package/dist/index129.js +402 -0
  163. package/dist/index13.js +100 -0
  164. package/dist/index130.js +1308 -0
  165. package/dist/index131.js +620 -0
  166. package/dist/index132.js +4 -0
  167. package/dist/index133.js +55 -0
  168. package/dist/index134.js +67 -0
  169. package/dist/index135.js +27 -0
  170. package/dist/index136.js +31 -0
  171. package/dist/index137.js +7 -0
  172. package/dist/index138.js +4 -0
  173. package/dist/index139.js +4 -0
  174. package/dist/index14.js +226 -0
  175. package/dist/index140.js +7 -0
  176. package/dist/index141.js +5 -0
  177. package/dist/index142.js +26 -0
  178. package/dist/index143.js +115 -0
  179. package/dist/index144.js +18 -0
  180. package/dist/index145.js +527 -0
  181. package/dist/index146.js +130 -0
  182. package/dist/index147.js +136 -0
  183. package/dist/index148.js +67 -0
  184. package/dist/index149.js +71 -0
  185. package/dist/index15.js +146 -0
  186. package/dist/index150.js +11 -0
  187. package/dist/index151.js +16 -0
  188. package/dist/index152.js +68 -0
  189. package/dist/index153.js +6 -0
  190. package/dist/index154.js +25 -0
  191. package/dist/index155.js +25 -0
  192. package/dist/index156.js +15 -0
  193. package/dist/index157.js +30 -0
  194. package/dist/index158.js +7 -0
  195. package/dist/index16.js +21 -0
  196. package/dist/index17.js +19 -0
  197. package/dist/index18.js +24 -0
  198. package/dist/index19.js +58 -0
  199. package/dist/index2.js +8 -0
  200. package/dist/index20.js +31 -0
  201. package/dist/index21.js +38 -0
  202. package/dist/index22.js +123 -0
  203. package/dist/index23.js +24 -0
  204. package/dist/index24.js +72 -0
  205. package/dist/index25.js +17 -0
  206. package/dist/index26.js +34 -0
  207. package/dist/index27.js +81 -0
  208. package/dist/index28.js +27 -0
  209. package/dist/index29.js +90 -0
  210. package/dist/index3.js +22 -0
  211. package/dist/index30.js +46 -0
  212. package/dist/index31.js +234 -0
  213. package/dist/index32.js +20 -0
  214. package/dist/index33.js +37 -0
  215. package/dist/index34.js +25 -0
  216. package/dist/index35.js +105 -0
  217. package/dist/index36.js +68 -0
  218. package/dist/index37.js +51 -0
  219. package/dist/index38.js +102 -0
  220. package/dist/index39.js +13 -0
  221. package/dist/index4.js +46 -0
  222. package/dist/index40.js +17 -0
  223. package/dist/index41.js +2265 -0
  224. package/dist/index42.js +35 -0
  225. package/dist/index43.js +20 -0
  226. package/dist/index44.js +239 -0
  227. package/dist/index45.js +13 -0
  228. package/dist/index46.js +75 -0
  229. package/dist/index47.js +251 -0
  230. package/dist/index48.js +11 -0
  231. package/dist/index49.js +338 -0
  232. package/dist/index5.js +51 -0
  233. package/dist/index50.js +62 -0
  234. package/dist/index51.js +243 -0
  235. package/dist/index52.js +862 -0
  236. package/dist/index53.js +11 -0
  237. package/dist/index54.js +120 -0
  238. package/dist/index55.js +227 -0
  239. package/dist/index56.js +13 -0
  240. package/dist/index57.js +13 -0
  241. package/dist/index58.js +238 -0
  242. package/dist/index59.js +262 -0
  243. package/dist/index6.js +51 -0
  244. package/dist/index60.js +14 -0
  245. package/dist/index61.js +24 -0
  246. package/dist/index62.js +532 -0
  247. package/dist/index63.js +6157 -0
  248. package/dist/index64.js +2635 -0
  249. package/dist/index65.js +300 -0
  250. package/dist/index66.js +674 -0
  251. package/dist/index67.js +832 -0
  252. package/dist/index68.js +27 -0
  253. package/dist/index69.js +330 -0
  254. package/dist/index7.js +42 -0
  255. package/dist/index70.js +4901 -0
  256. package/dist/index71.js +831 -0
  257. package/dist/index72.js +1260 -0
  258. package/dist/index73.js +536 -0
  259. package/dist/index74.js +127 -0
  260. package/dist/index75.js +163 -0
  261. package/dist/index76.js +33 -0
  262. package/dist/index77.js +437 -0
  263. package/dist/index78.js +132 -0
  264. package/dist/index79.js +83 -0
  265. package/dist/index8.js +31 -0
  266. package/dist/index80.js +70 -0
  267. package/dist/index81.js +48 -0
  268. package/dist/index82.js +29 -0
  269. package/dist/index83.js +9 -0
  270. package/dist/index84.js +54 -0
  271. package/dist/index85.js +36 -0
  272. package/dist/index86.js +13 -0
  273. package/dist/index87.js +10 -0
  274. package/dist/index88.js +32 -0
  275. package/dist/index89.js +57 -0
  276. package/dist/index9.js +54 -0
  277. package/dist/index90.js +13 -0
  278. package/dist/index91.js +6 -0
  279. package/dist/index92.js +15 -0
  280. package/dist/index93.js +8 -0
  281. package/dist/index94.js +27 -0
  282. package/dist/index95.js +71 -0
  283. package/dist/index96.js +127 -0
  284. package/dist/index97.js +221 -0
  285. package/dist/index98.js +16 -0
  286. package/dist/index99.js +56 -0
  287. package/dist/lib/utils.d.ts +14 -0
  288. package/dist/lib/utils.d.ts.map +1 -0
  289. package/dist/tokens/animations.d.ts +174 -0
  290. package/dist/tokens/animations.d.ts.map +1 -0
  291. package/dist/tokens/colors.d.ts +92 -0
  292. package/dist/tokens/colors.d.ts.map +1 -0
  293. package/dist/tokens/index.d.ts +403 -0
  294. package/dist/tokens/index.d.ts.map +1 -0
  295. package/dist/tokens/shadows.d.ts +15 -0
  296. package/dist/tokens/shadows.d.ts.map +1 -0
  297. package/dist/tokens/spacing.d.ts +55 -0
  298. package/dist/tokens/spacing.d.ts.map +1 -0
  299. package/dist/tokens/typography.d.ts +80 -0
  300. package/dist/tokens/typography.d.ts.map +1 -0
  301. package/package.json +128 -0
@@ -0,0 +1,4901 @@
1
+ import { Prec as cn, StateField as hn, StateEffect as dn, RangeSetBuilder as pn, EditorSelection as Ce, MapMode as rr } from "./index64.js";
2
+ import { foldCode as vn, matchBrackets as Gt, indentUnit as Yt, ensureSyntaxTree as nr, StringStream as gn } from "./index72.js";
3
+ import { EditorView as Ye, ViewPlugin as yn, showPanel as ir, Decoration as ht, getDrawSelectionConfig as mn, Direction as Cn, runScopeHandlers as He } from "./index63.js";
4
+ import { setSearchQuery as dt, SearchQuery as kn, RegExpCursor as wn } from "./index118.js";
5
+ import { indentMore as Sn, indentLess as xn, cursorLineBoundaryBackward as Mn, cursorLineBoundaryForward as Ln, cursorCharBackward as bn, indentSelection as Tn, insertNewlineAndIndent as An, cursorCharLeft as On, undo as En, redo as Rn } from "./index71.js";
6
+ function In(f) {
7
+ var o = f.Pos;
8
+ function c(e, t, r) {
9
+ if (t.line === r.line && t.ch >= r.ch - 1) {
10
+ var n = e.getLine(t.line), i = n.charCodeAt(t.ch);
11
+ 55296 <= i && i <= 55551 && (r.ch += 1);
12
+ }
13
+ return { start: t, end: r };
14
+ }
15
+ var p = [
16
+ // Key to key mapping. This goes first to make it possible to override
17
+ // existing mappings.
18
+ { keys: "<Left>", type: "keyToKey", toKeys: "h" },
19
+ { keys: "<Right>", type: "keyToKey", toKeys: "l" },
20
+ { keys: "<Up>", type: "keyToKey", toKeys: "k" },
21
+ { keys: "<Down>", type: "keyToKey", toKeys: "j" },
22
+ { keys: "g<Up>", type: "keyToKey", toKeys: "gk" },
23
+ { keys: "g<Down>", type: "keyToKey", toKeys: "gj" },
24
+ { keys: "<Space>", type: "keyToKey", toKeys: "l" },
25
+ { keys: "<BS>", type: "keyToKey", toKeys: "h" },
26
+ { keys: "<Del>", type: "keyToKey", toKeys: "x" },
27
+ { keys: "<C-Space>", type: "keyToKey", toKeys: "W" },
28
+ { keys: "<C-BS>", type: "keyToKey", toKeys: "B" },
29
+ { keys: "<S-Space>", type: "keyToKey", toKeys: "w" },
30
+ { keys: "<S-BS>", type: "keyToKey", toKeys: "b" },
31
+ { keys: "<C-n>", type: "keyToKey", toKeys: "j" },
32
+ { keys: "<C-p>", type: "keyToKey", toKeys: "k" },
33
+ { keys: "<C-[>", type: "keyToKey", toKeys: "<Esc>" },
34
+ { keys: "<C-c>", type: "keyToKey", toKeys: "<Esc>" },
35
+ { keys: "<C-[>", type: "keyToKey", toKeys: "<Esc>", context: "insert" },
36
+ { keys: "<C-c>", type: "keyToKey", toKeys: "<Esc>", context: "insert" },
37
+ { keys: "<C-Esc>", type: "keyToKey", toKeys: "<Esc>" },
38
+ // ipad keyboard sends C-Esc instead of C-[
39
+ { keys: "<C-Esc>", type: "keyToKey", toKeys: "<Esc>", context: "insert" },
40
+ { keys: "s", type: "keyToKey", toKeys: "cl", context: "normal" },
41
+ { keys: "s", type: "keyToKey", toKeys: "c", context: "visual" },
42
+ { keys: "S", type: "keyToKey", toKeys: "cc", context: "normal" },
43
+ { keys: "S", type: "keyToKey", toKeys: "VdO", context: "visual" },
44
+ { keys: "<Home>", type: "keyToKey", toKeys: "0" },
45
+ { keys: "<End>", type: "keyToKey", toKeys: "$" },
46
+ { keys: "<PageUp>", type: "keyToKey", toKeys: "<C-b>" },
47
+ { keys: "<PageDown>", type: "keyToKey", toKeys: "<C-f>" },
48
+ { keys: "<CR>", type: "keyToKey", toKeys: "j^", context: "normal" },
49
+ { keys: "<Ins>", type: "keyToKey", toKeys: "i", context: "normal" },
50
+ { keys: "<Ins>", type: "action", action: "toggleOverwrite", context: "insert" },
51
+ // Motions
52
+ { keys: "H", type: "motion", motion: "moveToTopLine", motionArgs: { linewise: !0, toJumplist: !0 } },
53
+ { keys: "M", type: "motion", motion: "moveToMiddleLine", motionArgs: { linewise: !0, toJumplist: !0 } },
54
+ { keys: "L", type: "motion", motion: "moveToBottomLine", motionArgs: { linewise: !0, toJumplist: !0 } },
55
+ { keys: "h", type: "motion", motion: "moveByCharacters", motionArgs: { forward: !1 } },
56
+ { keys: "l", type: "motion", motion: "moveByCharacters", motionArgs: { forward: !0 } },
57
+ { keys: "j", type: "motion", motion: "moveByLines", motionArgs: { forward: !0, linewise: !0 } },
58
+ { keys: "k", type: "motion", motion: "moveByLines", motionArgs: { forward: !1, linewise: !0 } },
59
+ { keys: "gj", type: "motion", motion: "moveByDisplayLines", motionArgs: { forward: !0 } },
60
+ { keys: "gk", type: "motion", motion: "moveByDisplayLines", motionArgs: { forward: !1 } },
61
+ { keys: "w", type: "motion", motion: "moveByWords", motionArgs: { forward: !0, wordEnd: !1 } },
62
+ { keys: "W", type: "motion", motion: "moveByWords", motionArgs: { forward: !0, wordEnd: !1, bigWord: !0 } },
63
+ { keys: "e", type: "motion", motion: "moveByWords", motionArgs: { forward: !0, wordEnd: !0, inclusive: !0 } },
64
+ { keys: "E", type: "motion", motion: "moveByWords", motionArgs: { forward: !0, wordEnd: !0, bigWord: !0, inclusive: !0 } },
65
+ { keys: "b", type: "motion", motion: "moveByWords", motionArgs: { forward: !1, wordEnd: !1 } },
66
+ { keys: "B", type: "motion", motion: "moveByWords", motionArgs: { forward: !1, wordEnd: !1, bigWord: !0 } },
67
+ { keys: "ge", type: "motion", motion: "moveByWords", motionArgs: { forward: !1, wordEnd: !0, inclusive: !0 } },
68
+ { keys: "gE", type: "motion", motion: "moveByWords", motionArgs: { forward: !1, wordEnd: !0, bigWord: !0, inclusive: !0 } },
69
+ { keys: "{", type: "motion", motion: "moveByParagraph", motionArgs: { forward: !1, toJumplist: !0 } },
70
+ { keys: "}", type: "motion", motion: "moveByParagraph", motionArgs: { forward: !0, toJumplist: !0 } },
71
+ { keys: "(", type: "motion", motion: "moveBySentence", motionArgs: { forward: !1 } },
72
+ { keys: ")", type: "motion", motion: "moveBySentence", motionArgs: { forward: !0 } },
73
+ { keys: "<C-f>", type: "motion", motion: "moveByPage", motionArgs: { forward: !0 } },
74
+ { keys: "<C-b>", type: "motion", motion: "moveByPage", motionArgs: { forward: !1 } },
75
+ { keys: "<C-d>", type: "motion", motion: "moveByScroll", motionArgs: { forward: !0, explicitRepeat: !0 } },
76
+ { keys: "<C-u>", type: "motion", motion: "moveByScroll", motionArgs: { forward: !1, explicitRepeat: !0 } },
77
+ { keys: "gg", type: "motion", motion: "moveToLineOrEdgeOfDocument", motionArgs: { forward: !1, explicitRepeat: !0, linewise: !0, toJumplist: !0 } },
78
+ { keys: "G", type: "motion", motion: "moveToLineOrEdgeOfDocument", motionArgs: { forward: !0, explicitRepeat: !0, linewise: !0, toJumplist: !0 } },
79
+ { keys: "g$", type: "motion", motion: "moveToEndOfDisplayLine" },
80
+ { keys: "g^", type: "motion", motion: "moveToStartOfDisplayLine" },
81
+ { keys: "g0", type: "motion", motion: "moveToStartOfDisplayLine" },
82
+ { keys: "0", type: "motion", motion: "moveToStartOfLine" },
83
+ { keys: "^", type: "motion", motion: "moveToFirstNonWhiteSpaceCharacter" },
84
+ { keys: "+", type: "motion", motion: "moveByLines", motionArgs: { forward: !0, toFirstChar: !0 } },
85
+ { keys: "-", type: "motion", motion: "moveByLines", motionArgs: { forward: !1, toFirstChar: !0 } },
86
+ { keys: "_", type: "motion", motion: "moveByLines", motionArgs: { forward: !0, toFirstChar: !0, repeatOffset: -1 } },
87
+ { keys: "$", type: "motion", motion: "moveToEol", motionArgs: { inclusive: !0 } },
88
+ { keys: "%", type: "motion", motion: "moveToMatchedSymbol", motionArgs: { inclusive: !0, toJumplist: !0 } },
89
+ { keys: "f<character>", type: "motion", motion: "moveToCharacter", motionArgs: { forward: !0, inclusive: !0 } },
90
+ { keys: "F<character>", type: "motion", motion: "moveToCharacter", motionArgs: { forward: !1 } },
91
+ { keys: "t<character>", type: "motion", motion: "moveTillCharacter", motionArgs: { forward: !0, inclusive: !0 } },
92
+ { keys: "T<character>", type: "motion", motion: "moveTillCharacter", motionArgs: { forward: !1 } },
93
+ { keys: ";", type: "motion", motion: "repeatLastCharacterSearch", motionArgs: { forward: !0 } },
94
+ { keys: ",", type: "motion", motion: "repeatLastCharacterSearch", motionArgs: { forward: !1 } },
95
+ { keys: "'<register>", type: "motion", motion: "goToMark", motionArgs: { toJumplist: !0, linewise: !0 } },
96
+ { keys: "`<register>", type: "motion", motion: "goToMark", motionArgs: { toJumplist: !0 } },
97
+ { keys: "]`", type: "motion", motion: "jumpToMark", motionArgs: { forward: !0 } },
98
+ { keys: "[`", type: "motion", motion: "jumpToMark", motionArgs: { forward: !1 } },
99
+ { keys: "]'", type: "motion", motion: "jumpToMark", motionArgs: { forward: !0, linewise: !0 } },
100
+ { keys: "['", type: "motion", motion: "jumpToMark", motionArgs: { forward: !1, linewise: !0 } },
101
+ // the next two aren't motions but must come before more general motion declarations
102
+ { keys: "]p", type: "action", action: "paste", isEdit: !0, actionArgs: { after: !0, isEdit: !0, matchIndent: !0 } },
103
+ { keys: "[p", type: "action", action: "paste", isEdit: !0, actionArgs: { after: !1, isEdit: !0, matchIndent: !0 } },
104
+ { keys: "]<character>", type: "motion", motion: "moveToSymbol", motionArgs: { forward: !0, toJumplist: !0 } },
105
+ { keys: "[<character>", type: "motion", motion: "moveToSymbol", motionArgs: { forward: !1, toJumplist: !0 } },
106
+ { keys: "|", type: "motion", motion: "moveToColumn" },
107
+ { keys: "o", type: "motion", motion: "moveToOtherHighlightedEnd", context: "visual" },
108
+ { keys: "O", type: "motion", motion: "moveToOtherHighlightedEnd", motionArgs: { sameLine: !0 }, context: "visual" },
109
+ // Operators
110
+ { keys: "d", type: "operator", operator: "delete" },
111
+ { keys: "y", type: "operator", operator: "yank" },
112
+ { keys: "c", type: "operator", operator: "change" },
113
+ { keys: "=", type: "operator", operator: "indentAuto" },
114
+ { keys: ">", type: "operator", operator: "indent", operatorArgs: { indentRight: !0 } },
115
+ { keys: "<", type: "operator", operator: "indent", operatorArgs: { indentRight: !1 } },
116
+ { keys: "g~", type: "operator", operator: "changeCase" },
117
+ { keys: "gu", type: "operator", operator: "changeCase", operatorArgs: { toLower: !0 }, isEdit: !0 },
118
+ { keys: "gU", type: "operator", operator: "changeCase", operatorArgs: { toLower: !1 }, isEdit: !0 },
119
+ { keys: "n", type: "motion", motion: "findNext", motionArgs: { forward: !0, toJumplist: !0 } },
120
+ { keys: "N", type: "motion", motion: "findNext", motionArgs: { forward: !1, toJumplist: !0 } },
121
+ { keys: "gn", type: "motion", motion: "findAndSelectNextInclusive", motionArgs: { forward: !0 } },
122
+ { keys: "gN", type: "motion", motion: "findAndSelectNextInclusive", motionArgs: { forward: !1 } },
123
+ { keys: "gq", type: "operator", operator: "hardWrap" },
124
+ { keys: "gw", type: "operator", operator: "hardWrap", operatorArgs: { keepCursor: !0 } },
125
+ { keys: "g?", type: "operator", operator: "rot13" },
126
+ // Operator-Motion dual commands
127
+ { keys: "x", type: "operatorMotion", operator: "delete", motion: "moveByCharacters", motionArgs: { forward: !0 }, operatorMotionArgs: { visualLine: !1 } },
128
+ { keys: "X", type: "operatorMotion", operator: "delete", motion: "moveByCharacters", motionArgs: { forward: !1 }, operatorMotionArgs: { visualLine: !0 } },
129
+ { keys: "D", type: "operatorMotion", operator: "delete", motion: "moveToEol", motionArgs: { inclusive: !0 }, context: "normal" },
130
+ { keys: "D", type: "operator", operator: "delete", operatorArgs: { linewise: !0 }, context: "visual" },
131
+ { keys: "Y", type: "operatorMotion", operator: "yank", motion: "expandToLine", motionArgs: { linewise: !0 }, context: "normal" },
132
+ { keys: "Y", type: "operator", operator: "yank", operatorArgs: { linewise: !0 }, context: "visual" },
133
+ { keys: "C", type: "operatorMotion", operator: "change", motion: "moveToEol", motionArgs: { inclusive: !0 }, context: "normal" },
134
+ { keys: "C", type: "operator", operator: "change", operatorArgs: { linewise: !0 }, context: "visual" },
135
+ { keys: "~", type: "operatorMotion", operator: "changeCase", motion: "moveByCharacters", motionArgs: { forward: !0 }, operatorArgs: { shouldMoveCursor: !0 }, context: "normal" },
136
+ { keys: "~", type: "operator", operator: "changeCase", context: "visual" },
137
+ { keys: "<C-u>", type: "operatorMotion", operator: "delete", motion: "moveToStartOfLine", context: "insert" },
138
+ { keys: "<C-w>", type: "operatorMotion", operator: "delete", motion: "moveByWords", motionArgs: { forward: !1, wordEnd: !1 }, context: "insert" },
139
+ //ignore C-w in normal mode
140
+ { keys: "<C-w>", type: "idle", context: "normal" },
141
+ // Actions
142
+ { keys: "<C-i>", type: "action", action: "jumpListWalk", actionArgs: { forward: !0 } },
143
+ { keys: "<C-o>", type: "action", action: "jumpListWalk", actionArgs: { forward: !1 } },
144
+ { keys: "<C-e>", type: "action", action: "scroll", actionArgs: { forward: !0, linewise: !0 } },
145
+ { keys: "<C-y>", type: "action", action: "scroll", actionArgs: { forward: !1, linewise: !0 } },
146
+ { keys: "a", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "charAfter" }, context: "normal" },
147
+ { keys: "A", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "eol" }, context: "normal" },
148
+ { keys: "A", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "endOfSelectedArea" }, context: "visual" },
149
+ { keys: "i", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "inplace" }, context: "normal" },
150
+ { keys: "gi", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "lastEdit" }, context: "normal" },
151
+ { keys: "I", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "firstNonBlank" }, context: "normal" },
152
+ { keys: "gI", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "bol" }, context: "normal" },
153
+ { keys: "I", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { insertAt: "startOfSelectedArea" }, context: "visual" },
154
+ { keys: "o", type: "action", action: "newLineAndEnterInsertMode", isEdit: !0, interlaceInsertRepeat: !0, actionArgs: { after: !0 }, context: "normal" },
155
+ { keys: "O", type: "action", action: "newLineAndEnterInsertMode", isEdit: !0, interlaceInsertRepeat: !0, actionArgs: { after: !1 }, context: "normal" },
156
+ { keys: "v", type: "action", action: "toggleVisualMode" },
157
+ { keys: "V", type: "action", action: "toggleVisualMode", actionArgs: { linewise: !0 } },
158
+ { keys: "<C-v>", type: "action", action: "toggleVisualMode", actionArgs: { blockwise: !0 } },
159
+ { keys: "<C-q>", type: "action", action: "toggleVisualMode", actionArgs: { blockwise: !0 } },
160
+ { keys: "gv", type: "action", action: "reselectLastSelection" },
161
+ { keys: "J", type: "action", action: "joinLines", isEdit: !0 },
162
+ { keys: "gJ", type: "action", action: "joinLines", actionArgs: { keepSpaces: !0 }, isEdit: !0 },
163
+ { keys: "p", type: "action", action: "paste", isEdit: !0, actionArgs: { after: !0, isEdit: !0 } },
164
+ { keys: "P", type: "action", action: "paste", isEdit: !0, actionArgs: { after: !1, isEdit: !0 } },
165
+ { keys: "r<character>", type: "action", action: "replace", isEdit: !0 },
166
+ { keys: "@<register>", type: "action", action: "replayMacro" },
167
+ { keys: "q<register>", type: "action", action: "enterMacroRecordMode" },
168
+ // Handle Replace-mode as a special case of insert mode.
169
+ { keys: "R", type: "action", action: "enterInsertMode", isEdit: !0, actionArgs: { replace: !0 }, context: "normal" },
170
+ { keys: "R", type: "operator", operator: "change", operatorArgs: { linewise: !0, fullLine: !0 }, context: "visual", exitVisualBlock: !0 },
171
+ { keys: "u", type: "action", action: "undo", context: "normal" },
172
+ { keys: "u", type: "operator", operator: "changeCase", operatorArgs: { toLower: !0 }, context: "visual", isEdit: !0 },
173
+ { keys: "U", type: "operator", operator: "changeCase", operatorArgs: { toLower: !1 }, context: "visual", isEdit: !0 },
174
+ { keys: "<C-r>", type: "action", action: "redo" },
175
+ { keys: "m<register>", type: "action", action: "setMark" },
176
+ { keys: '"<register>', type: "action", action: "setRegister" },
177
+ { keys: "<C-r><register>", type: "action", action: "insertRegister", context: "insert", isEdit: !0 },
178
+ { keys: "<C-o>", type: "action", action: "oneNormalCommand", context: "insert" },
179
+ { keys: "zz", type: "action", action: "scrollToCursor", actionArgs: { position: "center" } },
180
+ { keys: "z.", type: "action", action: "scrollToCursor", actionArgs: { position: "center" }, motion: "moveToFirstNonWhiteSpaceCharacter" },
181
+ { keys: "zt", type: "action", action: "scrollToCursor", actionArgs: { position: "top" } },
182
+ { keys: "z<CR>", type: "action", action: "scrollToCursor", actionArgs: { position: "top" }, motion: "moveToFirstNonWhiteSpaceCharacter" },
183
+ { keys: "zb", type: "action", action: "scrollToCursor", actionArgs: { position: "bottom" } },
184
+ { keys: "z-", type: "action", action: "scrollToCursor", actionArgs: { position: "bottom" }, motion: "moveToFirstNonWhiteSpaceCharacter" },
185
+ { keys: ".", type: "action", action: "repeatLastEdit" },
186
+ { keys: "<C-a>", type: "action", action: "incrementNumberToken", isEdit: !0, actionArgs: { increase: !0, backtrack: !1 } },
187
+ { keys: "<C-x>", type: "action", action: "incrementNumberToken", isEdit: !0, actionArgs: { increase: !1, backtrack: !1 } },
188
+ { keys: "<C-t>", type: "action", action: "indent", actionArgs: { indentRight: !0 }, context: "insert" },
189
+ { keys: "<C-d>", type: "action", action: "indent", actionArgs: { indentRight: !1 }, context: "insert" },
190
+ // Text object motions
191
+ { keys: "a<register>", type: "motion", motion: "textObjectManipulation" },
192
+ { keys: "i<register>", type: "motion", motion: "textObjectManipulation", motionArgs: { textObjectInner: !0 } },
193
+ // Search
194
+ { keys: "/", type: "search", searchArgs: { forward: !0, querySrc: "prompt", toJumplist: !0 } },
195
+ { keys: "?", type: "search", searchArgs: { forward: !1, querySrc: "prompt", toJumplist: !0 } },
196
+ { keys: "*", type: "search", searchArgs: { forward: !0, querySrc: "wordUnderCursor", wholeWordOnly: !0, toJumplist: !0 } },
197
+ { keys: "#", type: "search", searchArgs: { forward: !1, querySrc: "wordUnderCursor", wholeWordOnly: !0, toJumplist: !0 } },
198
+ { keys: "g*", type: "search", searchArgs: { forward: !0, querySrc: "wordUnderCursor", toJumplist: !0 } },
199
+ { keys: "g#", type: "search", searchArgs: { forward: !1, querySrc: "wordUnderCursor", toJumplist: !0 } },
200
+ // Ex command
201
+ { keys: ":", type: "ex" }
202
+ ], y = /* @__PURE__ */ Object.create(null), k = p.length, L = [
203
+ { name: "colorscheme", shortName: "colo" },
204
+ { name: "map" },
205
+ { name: "imap", shortName: "im" },
206
+ { name: "nmap", shortName: "nm" },
207
+ { name: "vmap", shortName: "vm" },
208
+ { name: "omap", shortName: "om" },
209
+ { name: "noremap", shortName: "no" },
210
+ { name: "nnoremap", shortName: "nn" },
211
+ { name: "vnoremap", shortName: "vn" },
212
+ { name: "inoremap", shortName: "ino" },
213
+ { name: "onoremap", shortName: "ono" },
214
+ { name: "unmap" },
215
+ { name: "mapclear", shortName: "mapc" },
216
+ { name: "nmapclear", shortName: "nmapc" },
217
+ { name: "vmapclear", shortName: "vmapc" },
218
+ { name: "imapclear", shortName: "imapc" },
219
+ { name: "omapclear", shortName: "omapc" },
220
+ { name: "write", shortName: "w" },
221
+ { name: "undo", shortName: "u" },
222
+ { name: "redo", shortName: "red" },
223
+ { name: "set", shortName: "se" },
224
+ { name: "setlocal", shortName: "setl" },
225
+ { name: "setglobal", shortName: "setg" },
226
+ { name: "sort", shortName: "sor" },
227
+ { name: "substitute", shortName: "s", possiblyAsync: !0 },
228
+ { name: "startinsert", shortName: "start" },
229
+ { name: "nohlsearch", shortName: "noh" },
230
+ { name: "yank", shortName: "y" },
231
+ { name: "delmarks", shortName: "delm" },
232
+ { name: "marks", excludeFromCommandHistory: !0 },
233
+ { name: "registers", shortName: "reg", excludeFromCommandHistory: !0 },
234
+ { name: "vglobal", shortName: "v" },
235
+ { name: "delete", shortName: "d" },
236
+ { name: "join", shortName: "j" },
237
+ { name: "normal", shortName: "norm" },
238
+ { name: "global", shortName: "g" }
239
+ ], x = Ct("");
240
+ function b(e) {
241
+ e.setOption("disableInput", !0), e.setOption("showCursorWhenSelecting", !1), f.signal(e, "vim-mode-change", { mode: "normal" }), e.on("cursorActivity", Ut), Ne(e), f.on(e.getInputField(), "paste", D(e));
242
+ }
243
+ function F(e) {
244
+ e.setOption("disableInput", !1), e.off("cursorActivity", Ut), f.off(e.getInputField(), "paste", D(e)), e.state.vim = null, Ue && clearTimeout(Ue);
245
+ }
246
+ function D(e) {
247
+ var t = e.state.vim;
248
+ return t.onPasteFn || (t.onPasteFn = function() {
249
+ t.insertMode || (e.setCursor(G(e.getCursor(), 0, 1)), De.enterInsertMode(e, {}, t));
250
+ }), t.onPasteFn;
251
+ }
252
+ var H = /[\d]/, j = [f.isWordChar, function(e) {
253
+ return e && !f.isWordChar(e) && !/\s/.test(e);
254
+ }], B = [function(e) {
255
+ return /\S/.test(e);
256
+ }], _ = ["<", ">"], Q = ["-", '"', ".", ":", "_", "/", "+"], W = /^\w$/, z = /^[A-Z]$/;
257
+ try {
258
+ z = new RegExp("^[\\p{Lu}]$", "u");
259
+ } catch {
260
+ }
261
+ function ie(e, t) {
262
+ return t >= e.firstLine() && t <= e.lastLine();
263
+ }
264
+ function ae(e) {
265
+ return /^[a-z]$/.test(e);
266
+ }
267
+ function ce(e) {
268
+ return "()[]{}".indexOf(e) != -1;
269
+ }
270
+ function oe(e) {
271
+ return H.test(e);
272
+ }
273
+ function ge(e) {
274
+ return z.test(e);
275
+ }
276
+ function Z(e) {
277
+ return /^\s*$/.test(e);
278
+ }
279
+ function Ie(e) {
280
+ return ".?!".indexOf(e) != -1;
281
+ }
282
+ function Ze(e, t) {
283
+ for (var r = 0; r < t.length; r++)
284
+ if (t[r] == e)
285
+ return !0;
286
+ return !1;
287
+ }
288
+ var Le = {};
289
+ function Be(e, t, r, n, i) {
290
+ if (t === void 0 && !i)
291
+ throw Error("defaultValue is required unless callback is provided");
292
+ if (r || (r = "string"), Le[e] = {
293
+ type: r,
294
+ defaultValue: t,
295
+ callback: i
296
+ }, n)
297
+ for (var a = 0; a < n.length; a++)
298
+ Le[n[a]] = Le[e];
299
+ t && Je(e, t);
300
+ }
301
+ function Je(e, t, r, n) {
302
+ var i = Le[e];
303
+ n = n || {};
304
+ var a = n.scope;
305
+ if (!i)
306
+ return new Error("Unknown option: " + e);
307
+ if (i.type == "boolean") {
308
+ if (t && t !== !0)
309
+ return new Error("Invalid argument: " + e + "=" + t);
310
+ t !== !1 && (t = !0);
311
+ }
312
+ i.callback ? (a !== "local" && i.callback(t, void 0), a !== "global" && r && i.callback(t, r)) : (a !== "local" && (i.value = i.type == "boolean" ? !!t : t), a !== "global" && r && (r.state.vim.options[e] = { value: t }));
313
+ }
314
+ function le(e, t, r) {
315
+ var n = Le[e];
316
+ r = r || {};
317
+ var i = r.scope;
318
+ if (!n)
319
+ return new Error("Unknown option: " + e);
320
+ if (n.callback) {
321
+ let a = t && n.callback(void 0, t);
322
+ return i !== "global" && a !== void 0 ? a : i !== "local" ? n.callback() : void 0;
323
+ } else
324
+ return (i !== "global" && t && t.state.vim.options[e] || i !== "local" && n || {}).value;
325
+ }
326
+ Be("filetype", void 0, "string", ["ft"], function(e, t) {
327
+ if (t !== void 0)
328
+ if (e === void 0) {
329
+ let r = t.getOption("mode");
330
+ return r == "null" ? "" : r;
331
+ } else {
332
+ let r = e == "" ? "null" : e;
333
+ t.setOption("mode", r);
334
+ }
335
+ }), Be("textwidth", 80, "number", ["tw"], function(e, t) {
336
+ if (t !== void 0)
337
+ if (e === void 0) {
338
+ var r = t.getOption("textwidth");
339
+ return r;
340
+ } else {
341
+ var n = Math.round(e);
342
+ n > 1 && t.setOption("textwidth", n);
343
+ }
344
+ });
345
+ var dr = function() {
346
+ var e = 100, t = -1, r = 0, n = 0, i = (
347
+ /**@type {(Marker|undefined)[]} */
348
+ new Array(e)
349
+ );
350
+ function a(u, d, h) {
351
+ var g = t % e, C = i[g];
352
+ function m(w) {
353
+ var S = ++t % e, A = i[S];
354
+ A && A.clear(), i[S] = u.setBookmark(w);
355
+ }
356
+ if (C) {
357
+ var v = C.find();
358
+ v && !he(v, d) && m(d);
359
+ } else
360
+ m(d);
361
+ m(h), r = t, n = t - e + 1, n < 0 && (n = 0);
362
+ }
363
+ function s(u, d) {
364
+ t += d, t > r ? t = r : t < n && (t = n);
365
+ var h = i[(e + t) % e];
366
+ if (h && !h.find()) {
367
+ var g = d > 0 ? 1 : -1, C, m = u.getCursor();
368
+ do
369
+ if (t += g, h = i[(e + t) % e], h && (C = h.find()) && !he(m, C))
370
+ break;
371
+ while (t < r && t > n);
372
+ }
373
+ return h;
374
+ }
375
+ function l(u, d) {
376
+ var h = t, g = s(u, d);
377
+ return t = h, g && g.find();
378
+ }
379
+ return {
380
+ /**@type{Pos|undefined} */
381
+ cachedCursor: void 0,
382
+ //used for # and * jumps
383
+ add: a,
384
+ find: l,
385
+ move: s
386
+ };
387
+ }, gt = function(e) {
388
+ return e ? {
389
+ changes: e.changes,
390
+ expectCursorActivityForChange: e.expectCursorActivityForChange
391
+ } : {
392
+ // Change list
393
+ changes: [],
394
+ // Set to true on change, false on cursorActivity.
395
+ expectCursorActivityForChange: !1
396
+ };
397
+ };
398
+ class pr {
399
+ constructor() {
400
+ this.latestRegister = void 0, this.isPlaying = !1, this.isRecording = !1, this.replaySearchQueries = [], this.onRecordingDone = void 0, this.lastInsertModeChanges = gt();
401
+ }
402
+ exitMacroRecordMode() {
403
+ var t = T.macroModeState;
404
+ t.onRecordingDone && t.onRecordingDone(), t.onRecordingDone = void 0, t.isRecording = !1;
405
+ }
406
+ /**
407
+ * @arg {CodeMirror} cm
408
+ * @arg {string} registerName
409
+ */
410
+ enterMacroRecordMode(t, r) {
411
+ var n = T.registerController.getRegister(r);
412
+ if (n) {
413
+ if (n.clear(), this.latestRegister = r, t.openDialog) {
414
+ var i = me("span", { class: "cm-vim-message" }, "recording @" + r);
415
+ this.onRecordingDone = t.openDialog(i, function() {
416
+ }, { bottom: !0 });
417
+ }
418
+ this.isRecording = !0;
419
+ }
420
+ }
421
+ }
422
+ function Ne(e) {
423
+ return e.state.vim || (e.state.vim = {
424
+ inputState: new kt(),
425
+ // Vim's input state that triggered the last edit, used to repeat
426
+ // motions and operators with '.'.
427
+ lastEditInputState: void 0,
428
+ // Vim's action command before the last edit, used to repeat actions
429
+ // with '.' and insert mode repeat.
430
+ lastEditActionCommand: void 0,
431
+ // When using jk for navigation, if you move from a longer line to a
432
+ // shorter line, the cursor may clip to the end of the shorter line.
433
+ // If j is pressed again and cursor goes to the next line, the
434
+ // cursor should go back to its horizontal position on the longer
435
+ // line if it can. This is to keep track of the horizontal position.
436
+ lastHPos: -1,
437
+ // Doing the same with screen-position for gj/gk
438
+ lastHSPos: -1,
439
+ // The last motion command run. Cleared if a non-motion command gets
440
+ // executed in between.
441
+ lastMotion: null,
442
+ marks: {},
443
+ insertMode: !1,
444
+ insertModeReturn: !1,
445
+ // Repeat count for changes made in insert mode, triggered by key
446
+ // sequences like 3,i. Only exists when insertMode is true.
447
+ insertModeRepeat: void 0,
448
+ visualMode: !1,
449
+ // If we are in visual line mode. No effect if visualMode is false.
450
+ visualLine: !1,
451
+ visualBlock: !1,
452
+ lastSelection: (
453
+ /**@type{vimState["lastSelection"]}*/
454
+ /**@type{unknown}*/
455
+ null
456
+ ),
457
+ lastPastedText: void 0,
458
+ sel: { anchor: new o(0, 0), head: new o(0, 0) },
459
+ // Buffer-local/window-local values of vim options.
460
+ options: {},
461
+ // Whether the next character should be interpreted literally
462
+ // Necassary for correct implementation of f<character>, r<character> etc.
463
+ // in terms of langmaps.
464
+ expectLiteralNext: !1,
465
+ status: ""
466
+ }), e.state.vim;
467
+ }
468
+ var T;
469
+ function yt() {
470
+ T = {
471
+ // The current search query.
472
+ searchQuery: null,
473
+ // Whether we are searching backwards.
474
+ searchIsReversed: !1,
475
+ // Replace part of the last substituted pattern
476
+ lastSubstituteReplacePart: void 0,
477
+ jumpList: dr(),
478
+ macroModeState: new pr(),
479
+ // Recording latest f, t, F or T motion command.
480
+ lastCharacterSearch: { increment: 0, forward: !0, selectedCharacter: "" },
481
+ registerController: new Cr({}),
482
+ // search history buffer
483
+ searchHistoryController: new wt(),
484
+ // ex Command history buffer
485
+ exCommandHistoryController: new wt()
486
+ };
487
+ for (var e in Le) {
488
+ var t = Le[e];
489
+ t.value = t.defaultValue;
490
+ }
491
+ }
492
+ class et {
493
+ /**
494
+ * Wrapper for special keys pressed in insert mode
495
+ * @arg {string} keyName
496
+ * @arg {KeyboardEvent} e
497
+ * @returns
498
+ */
499
+ constructor(t, r) {
500
+ this.keyName = t, this.key = r.key, this.ctrlKey = r.ctrlKey, this.altKey = r.altKey, this.metaKey = r.metaKey, this.shiftKey = r.shiftKey;
501
+ }
502
+ }
503
+ var Ve, ue = {
504
+ enterVimMode: b,
505
+ leaveVimMode: F,
506
+ buildKeyMap: function() {
507
+ },
508
+ // Testing hook, though it might be useful to expose the register
509
+ // controller anyway.
510
+ getRegisterController: function() {
511
+ return T.registerController;
512
+ },
513
+ // Testing hook.
514
+ resetVimGlobalState_: yt,
515
+ // Testing hook.
516
+ getVimGlobalState_: function() {
517
+ return T;
518
+ },
519
+ // Testing hook.
520
+ maybeInitVimState_: Ne,
521
+ suppressErrorLogging: !1,
522
+ InsertModeKey: et,
523
+ /**@type {(lhs: string, rhs: string, ctx: string) => void} */
524
+ map: function(e, t, r) {
525
+ se.map(e, t, r);
526
+ },
527
+ /**@type {(lhs: string, ctx: string) => any} */
528
+ unmap: function(e, t) {
529
+ return se.unmap(e, t);
530
+ },
531
+ // Non-recursive map function.
532
+ // NOTE: This will not create mappings to key maps that aren't present
533
+ // in the default key map. See TODO at bottom of function.
534
+ /**@type {(lhs: string, rhs: string, ctx: string) => void} */
535
+ noremap: function(e, t, r) {
536
+ se.map(e, t, r, !0);
537
+ },
538
+ // Remove all user-defined mappings for the provided context.
539
+ /**@arg {string} [ctx]} */
540
+ mapclear: function(e) {
541
+ var t = p.length, r = k, n = p.slice(0, t - r);
542
+ if (p = p.slice(t - r), e)
543
+ for (var i = n.length - 1; i >= 0; i--) {
544
+ var a = n[i];
545
+ if (e !== a.context)
546
+ if (a.context)
547
+ this._mapCommand(a);
548
+ else {
549
+ var s = ["normal", "insert", "visual"];
550
+ for (var l in s)
551
+ if (s[l] !== e) {
552
+ var u = Object.assign({}, a);
553
+ u.context = s[l], this._mapCommand(u);
554
+ }
555
+ }
556
+ }
557
+ },
558
+ langmap: mt,
559
+ vimKeyFromEvent: We,
560
+ // TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
561
+ // them, or somehow make them work with the existing CodeMirror setOption/getOption API.
562
+ setOption: Je,
563
+ getOption: le,
564
+ defineOption: Be,
565
+ /**@type {(name: string, prefix: string|undefined, func: ExFn) => void} */
566
+ defineEx: function(e, t, r) {
567
+ if (!t)
568
+ t = e;
569
+ else if (e.indexOf(t) !== 0)
570
+ throw new Error('(Vim.defineEx) "' + t + '" is not a prefix of "' + e + '", command not registered');
571
+ Wt[e] = r, se.commandMap_[t] = { name: e, shortName: t, type: "api" };
572
+ },
573
+ /**@type {(cm: CodeMirror, key: string, origin: string) => undefined | boolean} */
574
+ handleKey: function(e, t, r) {
575
+ var n = this.findKey(e, t, r);
576
+ if (typeof n == "function")
577
+ return n();
578
+ },
579
+ multiSelectHandleKey: un,
580
+ /**
581
+ * This is the outermost function called by CodeMirror, after keys have
582
+ * been mapped to their Vim equivalents.
583
+ *
584
+ * Finds a command based on the key (and cached keys if there is a
585
+ * multi-key sequence). Returns `undefined` if no key is matched, a noop
586
+ * function if a partial match is found (multi-key), and a function to
587
+ * execute the bound command if a a key is matched. The function always
588
+ * returns true.
589
+ */
590
+ /**@type {(cm_: CodeMirror, key: string, origin?: string| undefined) => (() => boolean|undefined) | undefined} */
591
+ findKey: function(e, t, r) {
592
+ var n = Ne(e), i = (
593
+ /**@type {CodeMirrorV}*/
594
+ e
595
+ );
596
+ function a() {
597
+ var h = T.macroModeState;
598
+ if (h.isRecording) {
599
+ if (t == "q")
600
+ return h.exitMacroRecordMode(), Y(i), !0;
601
+ r != "mapping" && on(h, t);
602
+ }
603
+ }
604
+ function s() {
605
+ if (t == "<Esc>") {
606
+ if (n.visualMode)
607
+ Se(i);
608
+ else if (n.insertMode)
609
+ Ae(i);
610
+ else
611
+ return;
612
+ return Y(i), !0;
613
+ }
614
+ }
615
+ function l() {
616
+ if (s())
617
+ return !0;
618
+ n.inputState.keyBuffer.push(t);
619
+ var h = n.inputState.keyBuffer.join(""), g = t.length == 1, C = Oe.matchCommand(h, p, n.inputState, "insert"), m = n.inputState.changeQueue;
620
+ if (C.type == "none")
621
+ return Y(i), !1;
622
+ if (C.type == "partial") {
623
+ if (C.expectLiteralNext && (n.expectLiteralNext = !0), Ve && window.clearTimeout(Ve), Ve = g && window.setTimeout(
624
+ function() {
625
+ n.insertMode && n.inputState.keyBuffer.length && Y(i);
626
+ },
627
+ le("insertModeEscKeysTimeout")
628
+ ), g) {
629
+ var v = i.listSelections();
630
+ (!m || m.removed.length != v.length) && (m = n.inputState.changeQueue = new yr()), m.inserted += t;
631
+ for (var w = 0; w < v.length; w++) {
632
+ var S = ne(v[w].anchor, v[w].head), A = Te(v[w].anchor, v[w].head), M = i.getRange(S, i.state.overwrite ? G(A, 0, 1) : A);
633
+ m.removed[w] = (m.removed[w] || "") + M;
634
+ }
635
+ }
636
+ return !g;
637
+ } else C.type == "full" && (n.inputState.keyBuffer.length = 0);
638
+ if (n.expectLiteralNext = !1, Ve && window.clearTimeout(Ve), C.command && m) {
639
+ for (var v = i.listSelections(), w = 0; w < v.length; w++) {
640
+ var E = v[w].head;
641
+ i.replaceRange(
642
+ m.removed[w] || "",
643
+ G(E, 0, -m.inserted.length),
644
+ E,
645
+ "+input"
646
+ );
647
+ }
648
+ T.macroModeState.lastInsertModeChanges.changes.pop();
649
+ }
650
+ return C.command || Y(i), C.command;
651
+ }
652
+ function u() {
653
+ if (a() || s())
654
+ return !0;
655
+ n.inputState.keyBuffer.push(t);
656
+ var h = n.inputState.keyBuffer.join("");
657
+ if (/^[1-9]\d*$/.test(h))
658
+ return !0;
659
+ var g = /^(\d*)(.*)$/.exec(h);
660
+ if (!g)
661
+ return Y(i), !1;
662
+ var C = n.visualMode ? "visual" : "normal", m = g[2] || g[1];
663
+ n.inputState.operatorShortcut && n.inputState.operatorShortcut.slice(-1) == m && (m = n.inputState.operatorShortcut);
664
+ var v = Oe.matchCommand(m, p, n.inputState, C);
665
+ return v.type == "none" ? (Y(i), !1) : v.type == "partial" ? (v.expectLiteralNext && (n.expectLiteralNext = !0), !0) : v.type == "clear" ? (Y(i), !0) : (n.expectLiteralNext = !1, n.inputState.keyBuffer.length = 0, g = /^(\d*)(.*)$/.exec(h), g && g[1] && g[1] != "0" && n.inputState.pushRepeatDigit(g[1]), v.command);
666
+ }
667
+ var d = n.insertMode ? l() : u();
668
+ if (d === !1)
669
+ return !n.insertMode && (t.length === 1 || f.isMac && /<A-.>/.test(t)) ? function() {
670
+ return !0;
671
+ } : void 0;
672
+ if (d === !0)
673
+ return function() {
674
+ return !0;
675
+ };
676
+ if (d)
677
+ return function() {
678
+ return i.operation(function() {
679
+ i.curOp.isVimOp = !0;
680
+ try {
681
+ if (typeof d != "object") return;
682
+ d.type == "keyToKey" ? $e(i, d.toKeys, d) : Oe.processCommand(i, n, d);
683
+ } catch (h) {
684
+ throw i.state.vim = void 0, Ne(i), ue.suppressErrorLogging || console.log(h), h;
685
+ }
686
+ return !0;
687
+ });
688
+ };
689
+ },
690
+ /**@type {(cm: CodeMirrorV, input: string)=>void} */
691
+ handleEx: function(e, t) {
692
+ se.processCommand(e, t);
693
+ },
694
+ defineMotion: kr,
695
+ defineAction: Sr,
696
+ defineOperator: wr,
697
+ mapCommand: nn,
698
+ _mapCommand: ut,
699
+ defineRegister: mr,
700
+ exitVisualMode: Se,
701
+ exitInsertMode: Ae
702
+ }, Pe = [], ze = !1, X;
703
+ function vr(e) {
704
+ if (!X) throw new Error("No prompt to send key to");
705
+ if (e[0] == "<") {
706
+ var t = e.toLowerCase().slice(1, -1), r = t.split("-");
707
+ if (t = r.pop() || "", t == "lt") e = "<";
708
+ else if (t == "space") e = " ";
709
+ else if (t == "cr") e = `
710
+ `;
711
+ else if (Ke[t]) {
712
+ var n = X.value || "", i = {
713
+ key: Ke[t],
714
+ target: {
715
+ value: n,
716
+ selectionEnd: n.length,
717
+ selectionStart: n.length
718
+ }
719
+ };
720
+ X.onKeyDown && X.onKeyDown(i, X.value, s), X && X.onKeyUp && X.onKeyUp(i, X.value, s);
721
+ return;
722
+ }
723
+ }
724
+ if (e == `
725
+ `) {
726
+ var a = X;
727
+ X = null, a.onClose && a.onClose(a.value);
728
+ } else
729
+ X.value = (X.value || "") + e;
730
+ function s(l) {
731
+ X && (typeof l == "string" ? X.value = l : X = null);
732
+ }
733
+ }
734
+ function $e(e, t, r) {
735
+ var n = ze;
736
+ if (r) {
737
+ if (Pe.indexOf(r) != -1) return;
738
+ Pe.push(r), ze = r.noremap != !1;
739
+ }
740
+ try {
741
+ for (var i = Ne(e), a = /<(?:[CSMA]-)*\w+>|./gi, s; s = a.exec(t); ) {
742
+ var l = s[0], u = i.insertMode;
743
+ if (X) {
744
+ vr(l);
745
+ continue;
746
+ }
747
+ var d = ue.handleKey(e, l, "mapping");
748
+ if (!d && u && i.insertMode) {
749
+ if (l[0] == "<") {
750
+ var h = l.toLowerCase().slice(1, -1), g = h.split("-");
751
+ if (h = g.pop() || "", h == "lt") l = "<";
752
+ else if (h == "space") l = " ";
753
+ else if (h == "cr") l = `
754
+ `;
755
+ else if (Ke.hasOwnProperty(h)) {
756
+ l = Ke[h], qt(e, l);
757
+ continue;
758
+ } else
759
+ l = l[0], a.lastIndex = s.index + 1;
760
+ }
761
+ e.replaceSelection(l);
762
+ }
763
+ }
764
+ } finally {
765
+ if (Pe.pop(), ze = Pe.length ? n : !1, !Pe.length && X) {
766
+ var C = X;
767
+ X = null, Xe(e, C);
768
+ }
769
+ }
770
+ }
771
+ var tt = {
772
+ Return: "CR",
773
+ Backspace: "BS",
774
+ Delete: "Del",
775
+ Escape: "Esc",
776
+ Insert: "Ins",
777
+ ArrowLeft: "Left",
778
+ ArrowRight: "Right",
779
+ ArrowUp: "Up",
780
+ ArrowDown: "Down",
781
+ Enter: "CR",
782
+ " ": "Space"
783
+ }, gr = {
784
+ Shift: 1,
785
+ Alt: 1,
786
+ Command: 1,
787
+ Control: 1,
788
+ CapsLock: 1,
789
+ AltGraph: 1,
790
+ Dead: 1,
791
+ Unidentified: 1
792
+ }, Ke = {};
793
+ "Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(tt)).forEach(function(e) {
794
+ Ke[(tt[e] || "").toLowerCase()] = Ke[e.toLowerCase()] = e;
795
+ });
796
+ function We(e, t) {
797
+ var a;
798
+ var r = e.key;
799
+ if (!gr[r]) {
800
+ r.length > 1 && r[0] == "n" && (r = r.replace("Numpad", "")), r = tt[r] || r;
801
+ var n = "";
802
+ if (e.ctrlKey && (n += "C-"), e.altKey && (n += "A-"), e.metaKey && (n += "M-"), f.isMac && n == "A-" && r.length == 1 && (n = n.slice(2)), (n || r.length > 1) && e.shiftKey && (n += "S-"), t && !t.expectLiteralNext && r.length == 1) {
803
+ if (x.keymap && r in x.keymap)
804
+ (x.remapCtrl != !1 || !n) && (r = x.keymap[r]);
805
+ else if (r.charCodeAt(0) > 128 && !y[r]) {
806
+ var i = ((a = e.code) == null ? void 0 : a.slice(-1)) || "";
807
+ e.shiftKey || (i = i.toLowerCase()), i && (r = i, !n && e.altKey && (n = "A-"));
808
+ }
809
+ }
810
+ return n += r, n.length > 1 && (n = "<" + n + ">"), n;
811
+ }
812
+ }
813
+ function mt(e, t) {
814
+ x.string !== e && (x = Ct(e)), x.remapCtrl = t;
815
+ }
816
+ function Ct(e) {
817
+ let t = {};
818
+ if (!e) return { keymap: t, string: "" };
819
+ function r(n) {
820
+ return n.split(/\\?(.)/).filter(Boolean);
821
+ }
822
+ return e.split(/((?:[^\\,]|\\.)+),/).map((n) => {
823
+ if (!n) return;
824
+ const i = n.split(/((?:[^\\;]|\\.)+);/);
825
+ if (i.length == 3) {
826
+ const a = r(i[1]), s = r(i[2]);
827
+ if (a.length !== s.length) return;
828
+ for (let l = 0; l < a.length; ++l) t[a[l]] = s[l];
829
+ } else if (i.length == 1) {
830
+ const a = r(n);
831
+ if (a.length % 2 !== 0) return;
832
+ for (let s = 0; s < a.length; s += 2) t[a[s]] = a[s + 1];
833
+ }
834
+ }), { keymap: t, string: e };
835
+ }
836
+ Be("langmap", void 0, "string", ["lmap"], function(e, t) {
837
+ if (e === void 0)
838
+ return x.string;
839
+ mt(e);
840
+ });
841
+ class kt {
842
+ constructor() {
843
+ this.prefixRepeat = [], this.motionRepeat = [], this.operator = null, this.operatorArgs = null, this.motion = null, this.motionArgs = null, this.keyBuffer = [], this.registerName = void 0, this.changeQueue = null;
844
+ }
845
+ /** @param {string} n */
846
+ pushRepeatDigit(t) {
847
+ this.operator ? this.motionRepeat = this.motionRepeat.concat(t) : this.prefixRepeat = this.prefixRepeat.concat(t);
848
+ }
849
+ getRepeat() {
850
+ var t = 0;
851
+ return (this.prefixRepeat.length > 0 || this.motionRepeat.length > 0) && (t = 1, this.prefixRepeat.length > 0 && (t *= parseInt(this.prefixRepeat.join(""), 10)), this.motionRepeat.length > 0 && (t *= parseInt(this.motionRepeat.join(""), 10))), t;
852
+ }
853
+ }
854
+ function Y(e, t) {
855
+ e.state.vim.inputState = new kt(), e.state.vim.expectLiteralNext = !1, f.signal(e, "vim-command-done", t);
856
+ }
857
+ function yr() {
858
+ this.removed = [], this.inserted = "";
859
+ }
860
+ class ke {
861
+ /** @arg {string} [text] @arg {boolean} [linewise] @arg {boolean } [blockwise] */
862
+ constructor(t, r, n) {
863
+ this.clear(), this.keyBuffer = [t || ""], this.insertModeChanges = [], this.searchQueries = [], this.linewise = !!r, this.blockwise = !!n;
864
+ }
865
+ /** @arg {string} [text] @arg {boolean} [linewise] @arg {boolean } [blockwise] */
866
+ setText(t, r, n) {
867
+ this.keyBuffer = [t || ""], this.linewise = !!r, this.blockwise = !!n;
868
+ }
869
+ /** @arg {string} text @arg {boolean} [linewise] */
870
+ pushText(t, r) {
871
+ r && (this.linewise || this.keyBuffer.push(`
872
+ `), this.linewise = !0), this.keyBuffer.push(t);
873
+ }
874
+ /** @arg {InsertModeChanges} changes */
875
+ pushInsertModeChanges(t) {
876
+ this.insertModeChanges.push(gt(t));
877
+ }
878
+ /** @arg {string} query */
879
+ pushSearchQuery(t) {
880
+ this.searchQueries.push(t);
881
+ }
882
+ clear() {
883
+ this.keyBuffer = [], this.insertModeChanges = [], this.searchQueries = [], this.linewise = !1;
884
+ }
885
+ toString() {
886
+ return this.keyBuffer.join("");
887
+ }
888
+ }
889
+ function mr(e, t) {
890
+ var r = T.registerController.registers;
891
+ if (!e || e.length != 1)
892
+ throw Error("Register name must be 1 character");
893
+ if (r[e])
894
+ throw Error("Register already defined " + e);
895
+ r[e] = t, Q.push(e);
896
+ }
897
+ class Cr {
898
+ /** @arg {Object<string, Register>} registers */
899
+ constructor(t) {
900
+ this.registers = t, this.unnamedRegister = t['"'] = new ke(), t["."] = new ke(), t[":"] = new ke(), t["/"] = new ke(), t["+"] = new ke();
901
+ }
902
+ /**
903
+ * @param {string | null | undefined} registerName
904
+ * @param {string} operator
905
+ * @param {string} text
906
+ * @param {boolean} [linewise]
907
+ * @param {boolean} [blockwise]
908
+ */
909
+ pushText(t, r, n, i, a) {
910
+ if (t !== "_") {
911
+ i && n.charAt(n.length - 1) !== `
912
+ ` && (n += `
913
+ `);
914
+ var s = this.isValidRegister(t) ? this.getRegister(t) : null;
915
+ if (!s || !t) {
916
+ switch (r) {
917
+ case "yank":
918
+ this.registers[0] = new ke(n, i, a);
919
+ break;
920
+ case "delete":
921
+ case "change":
922
+ n.indexOf(`
923
+ `) == -1 ? this.registers["-"] = new ke(n, i) : (this.shiftNumericRegisters_(), this.registers[1] = new ke(n, i));
924
+ break;
925
+ }
926
+ this.unnamedRegister.setText(n, i, a);
927
+ return;
928
+ }
929
+ var l = ge(t);
930
+ l ? s.pushText(n, i) : s.setText(n, i, a), t === "+" && navigator.clipboard.writeText(n), this.unnamedRegister.setText(s.toString(), i);
931
+ }
932
+ }
933
+ /**
934
+ * Gets the register named @name. If one of @name doesn't already exist,
935
+ * create it. If @name is invalid, return the unnamedRegister.
936
+ * @arg {string} [name]
937
+ */
938
+ getRegister(t) {
939
+ return this.isValidRegister(t) ? (t = t.toLowerCase(), this.registers[t] || (this.registers[t] = new ke()), this.registers[t]) : this.unnamedRegister;
940
+ }
941
+ /**@type {{(name: any): name is string}} */
942
+ isValidRegister(t) {
943
+ return t && (Ze(t, Q) || W.test(t));
944
+ }
945
+ shiftNumericRegisters_() {
946
+ for (var t = 9; t >= 2; t--)
947
+ this.registers[t] = this.getRegister("" + (t - 1));
948
+ }
949
+ }
950
+ class wt {
951
+ constructor() {
952
+ this.historyBuffer = [], this.iterator = 0, this.initialPrefix = null;
953
+ }
954
+ /**
955
+ * the input argument here acts a user entered prefix for a small time
956
+ * until we start autocompletion in which case it is the autocompleted.
957
+ * @arg {string} input
958
+ * @arg {boolean} up
959
+ */
960
+ nextMatch(t, r) {
961
+ var n = this.historyBuffer, i = r ? -1 : 1;
962
+ this.initialPrefix === null && (this.initialPrefix = t);
963
+ for (var a = this.iterator + i; r ? a >= 0 : a < n.length; a += i)
964
+ for (var s = n[a], l = 0; l <= s.length; l++)
965
+ if (this.initialPrefix == s.substring(0, l))
966
+ return this.iterator = a, s;
967
+ if (a >= n.length)
968
+ return this.iterator = n.length, this.initialPrefix;
969
+ if (a < 0) return t;
970
+ }
971
+ /** @arg {string} input */
972
+ pushInput(t) {
973
+ var r = this.historyBuffer.indexOf(t);
974
+ r > -1 && this.historyBuffer.splice(r, 1), t.length && this.historyBuffer.push(t);
975
+ }
976
+ reset() {
977
+ this.initialPrefix = null, this.iterator = this.historyBuffer.length;
978
+ }
979
+ }
980
+ var Oe = {
981
+ /**
982
+ * @param {string} keys
983
+ * @param {vimKey[]} keyMap
984
+ * @param {InputStateInterface} inputState
985
+ * @param {string} context
986
+ */
987
+ matchCommand: function(e, t, r, n) {
988
+ var i = xr(e, t, n, r), a = i.full[0];
989
+ if (!a)
990
+ return i.partial.length ? {
991
+ type: "partial",
992
+ expectLiteralNext: i.partial.length == 1 && i.partial[0].keys.slice(-11) == "<character>"
993
+ // langmap literal logic
994
+ } : { type: "none" };
995
+ if (a.keys.slice(-11) == "<character>" || a.keys.slice(-10) == "<register>") {
996
+ var s = Lr(e);
997
+ if (!s || s.length > 1) return { type: "clear" };
998
+ r.selectedCharacter = s;
999
+ }
1000
+ return { type: "full", command: a };
1001
+ },
1002
+ /**
1003
+ * @arg {CodeMirrorV} cm
1004
+ * @arg {vimState} vim
1005
+ * @arg {vimKey} command
1006
+ */
1007
+ processCommand: function(e, t, r) {
1008
+ switch (t.inputState.repeatOverride = r.repeatOverride, r.type) {
1009
+ case "motion":
1010
+ this.processMotion(e, t, r);
1011
+ break;
1012
+ case "operator":
1013
+ this.processOperator(e, t, r);
1014
+ break;
1015
+ case "operatorMotion":
1016
+ this.processOperatorMotion(e, t, r);
1017
+ break;
1018
+ case "action":
1019
+ this.processAction(e, t, r);
1020
+ break;
1021
+ case "search":
1022
+ this.processSearch(e, t, r);
1023
+ break;
1024
+ case "ex":
1025
+ case "keyToEx":
1026
+ this.processEx(e, t, r);
1027
+ break;
1028
+ }
1029
+ },
1030
+ /**
1031
+ * @arg {CodeMirrorV} cm
1032
+ * @arg {vimState} vim
1033
+ * @arg {import("./types").motionCommand|import("./types").operatorMotionCommand} command
1034
+ */
1035
+ processMotion: function(e, t, r) {
1036
+ t.inputState.motion = r.motion, t.inputState.motionArgs = /**@type {MotionArgs}*/
1037
+ qe(r.motionArgs), this.evalInput(e, t);
1038
+ },
1039
+ /**
1040
+ * @arg {CodeMirrorV} cm
1041
+ * @arg {vimState} vim
1042
+ * @arg {import("./types").operatorCommand|import("./types").operatorMotionCommand} command
1043
+ */
1044
+ processOperator: function(e, t, r) {
1045
+ var n = t.inputState;
1046
+ if (n.operator)
1047
+ if (n.operator == r.operator) {
1048
+ n.motion = "expandToLine", n.motionArgs = { linewise: !0, repeat: 1 }, this.evalInput(e, t);
1049
+ return;
1050
+ } else
1051
+ Y(e);
1052
+ n.operator = r.operator, n.operatorArgs = qe(r.operatorArgs), r.keys.length > 1 && (n.operatorShortcut = r.keys), r.exitVisualBlock && (t.visualBlock = !1, _e(e)), t.visualMode && this.evalInput(e, t);
1053
+ },
1054
+ /**
1055
+ * @arg {CodeMirrorV} cm
1056
+ * @arg {vimState} vim
1057
+ * @arg {import("./types").operatorMotionCommand} command
1058
+ */
1059
+ processOperatorMotion: function(e, t, r) {
1060
+ var n = t.visualMode, i = qe(r.operatorMotionArgs);
1061
+ i && n && i.visualLine && (t.visualLine = !0), this.processOperator(e, t, r), n || this.processMotion(e, t, r);
1062
+ },
1063
+ /**
1064
+ * @arg {CodeMirrorV} cm
1065
+ * @arg {vimState} vim
1066
+ * @arg {import("./types").actionCommand} command
1067
+ */
1068
+ processAction: function(e, t, r) {
1069
+ var n = t.inputState, i = n.getRepeat(), a = !!i, s = (
1070
+ /**@type {ActionArgs}*/
1071
+ qe(r.actionArgs) || { repeat: 1 }
1072
+ );
1073
+ n.selectedCharacter && (s.selectedCharacter = n.selectedCharacter), r.operator && this.processOperator(e, t, r), r.motion && this.processMotion(e, t, r), (r.motion || r.operator) && this.evalInput(e, t), s.repeat = i || 1, s.repeatIsExplicit = a, s.registerName = n.registerName, Y(e), t.lastMotion = null, r.isEdit && this.recordLastEdit(t, n, r), De[r.action](e, s, t);
1074
+ },
1075
+ /** @arg {CodeMirrorV} cm @arg {vimState} vim @arg {import("./types").searchCommand} command*/
1076
+ processSearch: function(e, t, r) {
1077
+ if (!e.getSearchCursor)
1078
+ return;
1079
+ var n = r.searchArgs.forward, i = r.searchArgs.wholeWordOnly;
1080
+ ye(e).setReversed(!n);
1081
+ var a = n ? "/" : "?", s = ye(e).getQuery(), l = e.getScrollInfo(), u = "";
1082
+ function d(M, E, N) {
1083
+ T.searchHistoryController.pushInput(M), T.searchHistoryController.reset();
1084
+ try {
1085
+ je(e, M, E, N);
1086
+ } catch {
1087
+ K(e, "Invalid regex: " + M), Y(e);
1088
+ return;
1089
+ }
1090
+ Oe.processMotion(e, t, {
1091
+ keys: "",
1092
+ type: "motion",
1093
+ motion: "findNext",
1094
+ motionArgs: { forward: !0, toJumplist: r.searchArgs.toJumplist }
1095
+ });
1096
+ }
1097
+ function h(M) {
1098
+ e.scrollTo(l.left, l.top), d(
1099
+ M,
1100
+ !0,
1101
+ !0
1102
+ /** smartCase */
1103
+ );
1104
+ var E = T.macroModeState;
1105
+ E.isRecording && ln(E, M);
1106
+ }
1107
+ function g() {
1108
+ return le("pcre") ? "(JavaScript regexp: set pcre)" : "(Vim regexp: set nopcre)";
1109
+ }
1110
+ function C(M, E, N) {
1111
+ var R = We(M), U, J;
1112
+ R == "<Up>" || R == "<Down>" ? (U = R == "<Up>", J = M.target ? M.target.selectionEnd : 0, E = T.searchHistoryController.nextMatch(E, U) || "", N(E), J && M.target && (M.target.selectionEnd = M.target.selectionStart = Math.min(J, M.target.value.length))) : R && R != "<Left>" && R != "<Right>" && T.searchHistoryController.reset(), u = E, m();
1113
+ }
1114
+ function m() {
1115
+ var M;
1116
+ try {
1117
+ M = je(
1118
+ e,
1119
+ u,
1120
+ !0,
1121
+ !0
1122
+ /** smartCase */
1123
+ );
1124
+ } catch {
1125
+ }
1126
+ M ? e.scrollIntoView(Vt(e, !n, M), 30) : (Fe(e), e.scrollTo(l.left, l.top));
1127
+ }
1128
+ function v(M, E, N) {
1129
+ var R = We(M);
1130
+ R == "<Esc>" || R == "<C-c>" || R == "<C-[>" || R == "<BS>" && E == "" ? (T.searchHistoryController.pushInput(E), T.searchHistoryController.reset(), je(e, (s == null ? void 0 : s.source) || ""), Fe(e), e.scrollTo(l.left, l.top), f.e_stop(M), Y(e), N(), e.focus()) : R == "<Up>" || R == "<Down>" ? f.e_stop(M) : R == "<C-u>" && (f.e_stop(M), N(""));
1131
+ }
1132
+ switch (r.searchArgs.querySrc) {
1133
+ case "prompt":
1134
+ var w = T.macroModeState;
1135
+ if (w.isPlaying) {
1136
+ let E = w.replaySearchQueries.shift();
1137
+ d(
1138
+ E || "",
1139
+ !0,
1140
+ !1
1141
+ /** smartCase */
1142
+ );
1143
+ } else
1144
+ Xe(e, {
1145
+ onClose: h,
1146
+ prefix: a,
1147
+ desc: me(
1148
+ "span",
1149
+ {
1150
+ $cursor: "pointer",
1151
+ onmousedown: function(E) {
1152
+ E.preventDefault(), Je("pcre", !le("pcre")), this.textContent = g(), m();
1153
+ }
1154
+ },
1155
+ g()
1156
+ ),
1157
+ onKeyUp: C,
1158
+ onKeyDown: v
1159
+ });
1160
+ break;
1161
+ case "wordUnderCursor":
1162
+ var S = at(e, { noSymbol: !0 }), A = !0;
1163
+ if (S || (S = at(e, { noSymbol: !1 }), A = !1), !S) {
1164
+ K(e, "No word under cursor"), Y(e);
1165
+ return;
1166
+ }
1167
+ let M = e.getLine(S.start.line).substring(
1168
+ S.start.ch,
1169
+ S.end.ch
1170
+ );
1171
+ A && i ? M = "\\b" + M + "\\b" : M = br(M), T.jumpList.cachedCursor = e.getCursor(), e.setCursor(S.start), d(
1172
+ M,
1173
+ !0,
1174
+ !1
1175
+ /** smartCase */
1176
+ );
1177
+ break;
1178
+ }
1179
+ },
1180
+ /**
1181
+ * @arg {CodeMirrorV} cm
1182
+ * @arg {vimState} vim
1183
+ * @arg {import("./types").exCommand | import("./types").keyToExCommand} command
1184
+ */
1185
+ processEx: function(e, t, r) {
1186
+ function n(l) {
1187
+ T.exCommandHistoryController.pushInput(l), T.exCommandHistoryController.reset(), se.processCommand(e, l), e.state.vim && Y(e), Fe(e);
1188
+ }
1189
+ function i(l, u, d) {
1190
+ var h = We(l), g, C;
1191
+ (h == "<Esc>" || h == "<C-c>" || h == "<C-[>" || h == "<BS>" && u == "") && (T.exCommandHistoryController.pushInput(u), T.exCommandHistoryController.reset(), f.e_stop(l), Y(e), Fe(e), d(), e.focus()), h == "<Up>" || h == "<Down>" ? (f.e_stop(l), g = h == "<Up>", C = l.target ? l.target.selectionEnd : 0, u = T.exCommandHistoryController.nextMatch(u, g) || "", d(u), C && l.target && (l.target.selectionEnd = l.target.selectionStart = Math.min(C, l.target.value.length))) : h == "<C-u>" ? (f.e_stop(l), d("")) : h && h != "<Left>" && h != "<Right>" && T.exCommandHistoryController.reset();
1192
+ }
1193
+ function a(l, u) {
1194
+ var d = new f.StringStream(u), h = (
1195
+ /**@type{import("./types").exCommandArgs}*/
1196
+ {}
1197
+ );
1198
+ try {
1199
+ if (se.parseInput_(e, d, h), h.commandName != "s") {
1200
+ Fe(e);
1201
+ return;
1202
+ }
1203
+ var g = se.matchCommand_(h.commandName);
1204
+ if (!g || (se.parseCommandArgs_(d, h, g), !h.argString)) return;
1205
+ var C = Ht(h.argString.slice(1), !0, !0);
1206
+ C && st(e, C);
1207
+ } catch {
1208
+ }
1209
+ }
1210
+ if (r.type == "keyToEx")
1211
+ se.processCommand(e, r.exArgs.input);
1212
+ else {
1213
+ var s = {
1214
+ onClose: n,
1215
+ onKeyDown: i,
1216
+ onKeyUp: a,
1217
+ prefix: ":"
1218
+ };
1219
+ t.visualMode && (s.value = "'<,'>", s.selectValueOnOpen = !1), Xe(e, s);
1220
+ }
1221
+ },
1222
+ /**@arg {CodeMirrorV} cm @arg {vimState} vim */
1223
+ evalInput: function(e, t) {
1224
+ var r = t.inputState, n = r.motion, i = r.motionArgs || { repeat: 1 }, a = r.operator, s = r.operatorArgs || {}, l = r.registerName, u = t.sel, d = V(t.visualMode ? re(e, u.head) : e.getCursor("head")), h = V(t.visualMode ? re(e, u.anchor) : e.getCursor("anchor")), g = V(d), C = V(h), m, v, w;
1225
+ if (a && this.recordLastEdit(t, r), r.repeatOverride !== void 0 ? w = r.repeatOverride : w = r.getRepeat(), w > 0 && i.explicitRepeat ? i.repeatIsExplicit = !0 : (i.noRepeat || !i.explicitRepeat && w === 0) && (w = 1, i.repeatIsExplicit = !1), r.selectedCharacter && (i.selectedCharacter = s.selectedCharacter = r.selectedCharacter), i.repeat = w, Y(e), n) {
1226
+ var S = we[n](e, d, i, t, r);
1227
+ if (t.lastMotion = we[n], !S)
1228
+ return;
1229
+ if (i.toJumplist) {
1230
+ var A = T.jumpList, M = A.cachedCursor;
1231
+ M ? (At(e, M, S), delete A.cachedCursor) : At(e, d, S);
1232
+ }
1233
+ S instanceof Array ? (v = S[0], m = S[1]) : m = S, m || (m = V(d)), t.visualMode ? (t.visualBlock && m.ch === 1 / 0 || (m = re(e, m, g)), v && (v = re(e, v)), v = v || C, u.anchor = v, u.head = m, _e(e), be(
1234
+ e,
1235
+ t,
1236
+ "<",
1237
+ q(v, m) ? v : m
1238
+ ), be(
1239
+ e,
1240
+ t,
1241
+ ">",
1242
+ q(v, m) ? m : v
1243
+ )) : a || (m = re(e, m, g), e.setCursor(m.line, m.ch));
1244
+ }
1245
+ if (a) {
1246
+ if (s.lastSel) {
1247
+ v = C;
1248
+ var E = s.lastSel, N = Math.abs(E.head.line - E.anchor.line), R = Math.abs(E.head.ch - E.anchor.ch);
1249
+ E.visualLine ? m = new o(C.line + N, C.ch) : E.visualBlock ? m = new o(C.line + N, C.ch + R) : E.head.line == E.anchor.line ? m = new o(C.line, C.ch + R) : m = new o(C.line + N, C.ch), t.visualMode = !0, t.visualLine = E.visualLine, t.visualBlock = E.visualBlock, u = t.sel = {
1250
+ anchor: v,
1251
+ head: m
1252
+ }, _e(e);
1253
+ } else t.visualMode && (s.lastSel = {
1254
+ anchor: V(u.anchor),
1255
+ head: V(u.head),
1256
+ visualBlock: t.visualBlock,
1257
+ visualLine: t.visualLine
1258
+ });
1259
+ var U, J, P, O, $;
1260
+ if (t.visualMode) {
1261
+ U = ne(u.head, u.anchor), J = Te(u.head, u.anchor), P = t.visualLine || s.linewise, O = t.visualBlock ? "block" : P ? "line" : "char";
1262
+ var de = c(e, U, J);
1263
+ if ($ = it(e, {
1264
+ anchor: de.start,
1265
+ head: de.end
1266
+ }, O), P) {
1267
+ var ee = $.ranges;
1268
+ if (O == "block")
1269
+ for (var pe = 0; pe < ee.length; pe++)
1270
+ ee[pe].head.ch = te(e, ee[pe].head.line);
1271
+ else O == "line" && (ee[0].head = new o(ee[0].head.line + 1, 0));
1272
+ }
1273
+ } else {
1274
+ if (U = V(v || C), J = V(m || g), q(J, U)) {
1275
+ var Ee = U;
1276
+ U = J, J = Ee;
1277
+ }
1278
+ P = i.linewise || s.linewise, P ? Br(e, U, J) : i.forward && Ir(e, U, J), O = "char";
1279
+ var fn = !i.inclusive || P, de = c(e, U, J);
1280
+ $ = it(e, {
1281
+ anchor: de.start,
1282
+ head: de.end
1283
+ }, O, fn);
1284
+ }
1285
+ e.setSelections($.ranges, $.primary), t.lastMotion = null, s.repeat = w, s.registerName = l, s.linewise = P;
1286
+ var ct = rt[a](
1287
+ e,
1288
+ s,
1289
+ $.ranges,
1290
+ C,
1291
+ m
1292
+ );
1293
+ t.visualMode && Se(e, ct != null), ct && e.setCursor(ct);
1294
+ }
1295
+ },
1296
+ /**@arg {vimState} vim @arg {InputStateInterface} inputState, @arg {import("./types").actionCommand} [actionCommand] */
1297
+ recordLastEdit: function(e, t, r) {
1298
+ var n = T.macroModeState;
1299
+ n.isPlaying || (e.lastEditInputState = t, e.lastEditActionCommand = r, n.lastInsertModeChanges.changes = [], n.lastInsertModeChanges.expectCursorActivityForChange = !1, n.lastInsertModeChanges.visualBlock = e.visualBlock ? e.sel.head.line - e.sel.anchor.line : 0);
1300
+ }
1301
+ }, we = {
1302
+ moveToTopLine: function(e, t, r) {
1303
+ var n = lt(e).top + r.repeat - 1;
1304
+ return new o(n, xe(e.getLine(n)));
1305
+ },
1306
+ moveToMiddleLine: function(e) {
1307
+ var t = lt(e), r = Math.floor((t.top + t.bottom) * 0.5);
1308
+ return new o(r, xe(e.getLine(r)));
1309
+ },
1310
+ moveToBottomLine: function(e, t, r) {
1311
+ var n = lt(e).bottom - r.repeat + 1;
1312
+ return new o(n, xe(e.getLine(n)));
1313
+ },
1314
+ expandToLine: function(e, t, r) {
1315
+ var n = t;
1316
+ return new o(n.line + r.repeat - 1, 1 / 0);
1317
+ },
1318
+ findNext: function(e, t, r) {
1319
+ var n = ye(e), i = n.getQuery();
1320
+ if (i) {
1321
+ var a = !r.forward;
1322
+ a = n.isReversed() ? !a : a, st(e, i);
1323
+ var s = Vt(e, a, i, r.repeat);
1324
+ return s || K(e, "No match found " + i + (le("pcre") ? " (set nopcre to use Vim regexps)" : "")), s;
1325
+ }
1326
+ },
1327
+ /**
1328
+ * Find and select the next occurrence of the search query. If the cursor is currently
1329
+ * within a match, then find and select the current match. Otherwise, find the next occurrence in the
1330
+ * appropriate direction.
1331
+ *
1332
+ * This differs from `findNext` in the following ways:
1333
+ *
1334
+ * 1. Instead of only returning the "from", this returns a "from", "to" range.
1335
+ * 2. If the cursor is currently inside a search match, this selects the current match
1336
+ * instead of the next match.
1337
+ * 3. If there is no associated operator, this will turn on visual mode.
1338
+ */
1339
+ findAndSelectNextInclusive: function(e, t, r, n, i) {
1340
+ var a = ye(e), s = a.getQuery();
1341
+ if (s) {
1342
+ var l = !r.forward;
1343
+ l = a.isReversed() ? !l : l;
1344
+ var u = Gr(e, l, s, r.repeat, n);
1345
+ if (u) {
1346
+ if (i.operator)
1347
+ return u;
1348
+ var d = u[0], h = new o(u[1].line, u[1].ch - 1);
1349
+ if (n.visualMode) {
1350
+ (n.visualLine || n.visualBlock) && (n.visualLine = !1, n.visualBlock = !1, f.signal(e, "vim-mode-change", { mode: "visual", subMode: "" }));
1351
+ var g = n.sel.anchor;
1352
+ if (g)
1353
+ return a.isReversed() ? r.forward ? [g, d] : [g, h] : r.forward ? [g, h] : [g, d];
1354
+ } else
1355
+ n.visualMode = !0, n.visualLine = !1, n.visualBlock = !1, f.signal(e, "vim-mode-change", { mode: "visual", subMode: "" });
1356
+ return l ? [h, d] : [d, h];
1357
+ }
1358
+ }
1359
+ },
1360
+ goToMark: function(e, t, r, n) {
1361
+ var i = Ge(e, n, r.selectedCharacter || "");
1362
+ return i ? r.linewise ? { line: i.line, ch: xe(e.getLine(i.line)) } : i : null;
1363
+ },
1364
+ moveToOtherHighlightedEnd: function(e, t, r, n) {
1365
+ var i = n.sel;
1366
+ return n.visualBlock && r.sameLine ? [
1367
+ re(e, new o(i.anchor.line, i.head.ch)),
1368
+ re(e, new o(i.head.line, i.anchor.ch))
1369
+ ] : [i.head, i.anchor];
1370
+ },
1371
+ jumpToMark: function(e, t, r, n) {
1372
+ for (var i = t, a = 0; a < r.repeat; a++) {
1373
+ var s = i;
1374
+ for (var l in n.marks)
1375
+ if (ae(l)) {
1376
+ var u = n.marks[l].find(), d = r.forward ? (
1377
+ // @ts-ignore
1378
+ q(u, s)
1379
+ ) : q(s, u);
1380
+ if (!d && !(r.linewise && u.line == s.line)) {
1381
+ var h = he(s, i), g = r.forward ? (
1382
+ // @ts-ignore
1383
+ Mt(s, u, i)
1384
+ ) : (
1385
+ // @ts-ignore
1386
+ Mt(i, u, s)
1387
+ );
1388
+ (h || g) && (i = u);
1389
+ }
1390
+ }
1391
+ }
1392
+ return r.linewise && (i = new o(i.line, xe(e.getLine(i.line)))), i;
1393
+ },
1394
+ moveByCharacters: function(e, t, r) {
1395
+ var n = t, i = r.repeat, a = r.forward ? n.ch + i : n.ch - i;
1396
+ return new o(n.line, a);
1397
+ },
1398
+ moveByLines: function(e, t, r, n) {
1399
+ var i = t, a = i.ch;
1400
+ switch (n.lastMotion) {
1401
+ case this.moveByLines:
1402
+ case this.moveByDisplayLines:
1403
+ case this.moveByScroll:
1404
+ case this.moveToColumn:
1405
+ case this.moveToEol:
1406
+ a = n.lastHPos;
1407
+ break;
1408
+ default:
1409
+ n.lastHPos = a;
1410
+ }
1411
+ var s = r.repeat + (r.repeatOffset || 0), l = r.forward ? i.line + s : i.line - s, u = e.firstLine(), d = e.lastLine(), h = e.findPosV(i, r.forward ? s : -s, "line", n.lastHSPos), g = r.forward ? h.line > l : h.line < l;
1412
+ return g && (l = h.line, a = h.ch), l < u && i.line == u ? this.moveToStartOfLine(e, t, r, n) : l > d && i.line == d ? It(e, t, r, n, !0) : (r.toFirstChar && (a = xe(e.getLine(l)), n.lastHPos = a), n.lastHSPos = e.charCoords(new o(l, a), "div").left, new o(l, a));
1413
+ },
1414
+ moveByDisplayLines: function(e, t, r, n) {
1415
+ var i = t;
1416
+ switch (n.lastMotion) {
1417
+ case this.moveByDisplayLines:
1418
+ case this.moveByScroll:
1419
+ case this.moveByLines:
1420
+ case this.moveToColumn:
1421
+ case this.moveToEol:
1422
+ break;
1423
+ default:
1424
+ n.lastHSPos = e.charCoords(i, "div").left;
1425
+ }
1426
+ var a = r.repeat, s = e.findPosV(i, r.forward ? a : -a, "line", n.lastHSPos);
1427
+ if (s.hitSide)
1428
+ if (r.forward) {
1429
+ var l = e.charCoords(s, "div"), u = { top: l.top + 8, left: n.lastHSPos };
1430
+ s = e.coordsChar(u, "div");
1431
+ } else {
1432
+ var d = e.charCoords(new o(e.firstLine(), 0), "div");
1433
+ d.left = n.lastHSPos, s = e.coordsChar(d, "div");
1434
+ }
1435
+ return n.lastHPos = s.ch, s;
1436
+ },
1437
+ moveByPage: function(e, t, r) {
1438
+ var n = t, i = r.repeat;
1439
+ return e.findPosV(n, r.forward ? i : -i, "page");
1440
+ },
1441
+ moveByParagraph: function(e, t, r) {
1442
+ var n = r.forward ? 1 : -1;
1443
+ return Bt(e, t, r.repeat, n).start;
1444
+ },
1445
+ moveBySentence: function(e, t, r) {
1446
+ var n = r.forward ? 1 : -1;
1447
+ return Hr(e, t, r.repeat, n);
1448
+ },
1449
+ moveByScroll: function(e, t, r, n) {
1450
+ var i = e.getScrollInfo(), a = null, s = r.repeat;
1451
+ s || (s = i.clientHeight / (2 * e.defaultTextHeight()));
1452
+ var l = e.charCoords(t, "local");
1453
+ if (r.repeat = s, a = we.moveByDisplayLines(e, t, r, n), !a)
1454
+ return null;
1455
+ var u = e.charCoords(a, "local");
1456
+ return e.scrollTo(null, i.top + u.top - l.top), a;
1457
+ },
1458
+ moveByWords: function(e, t, r) {
1459
+ return Dr(
1460
+ e,
1461
+ t,
1462
+ r.repeat,
1463
+ !!r.forward,
1464
+ !!r.wordEnd,
1465
+ !!r.bigWord
1466
+ );
1467
+ },
1468
+ moveTillCharacter: function(e, t, r) {
1469
+ var n = r.repeat, i = ot(
1470
+ e,
1471
+ n,
1472
+ r.forward,
1473
+ r.selectedCharacter,
1474
+ t
1475
+ ), a = r.forward ? -1 : 1;
1476
+ return Ot(a, r), i ? (i.ch += a, i) : null;
1477
+ },
1478
+ moveToCharacter: function(e, t, r) {
1479
+ var n = r.repeat;
1480
+ return Ot(0, r), ot(
1481
+ e,
1482
+ n,
1483
+ r.forward,
1484
+ r.selectedCharacter,
1485
+ t
1486
+ ) || t;
1487
+ },
1488
+ moveToSymbol: function(e, t, r) {
1489
+ var n = r.repeat;
1490
+ return r.selectedCharacter && Kr(
1491
+ e,
1492
+ n,
1493
+ r.forward,
1494
+ r.selectedCharacter
1495
+ ) || t;
1496
+ },
1497
+ moveToColumn: function(e, t, r, n) {
1498
+ var i = r.repeat;
1499
+ return n.lastHPos = i - 1, n.lastHSPos = e.charCoords(t, "div").left, _r(e, i);
1500
+ },
1501
+ moveToEol: function(e, t, r, n) {
1502
+ return It(e, t, r, n, !1);
1503
+ },
1504
+ moveToFirstNonWhiteSpaceCharacter: function(e, t) {
1505
+ var r = t;
1506
+ return new o(
1507
+ r.line,
1508
+ xe(e.getLine(r.line))
1509
+ );
1510
+ },
1511
+ moveToMatchedSymbol: function(e, t) {
1512
+ for (var r = t, n = r.line, i = r.ch, a = e.getLine(n), s; i < a.length; i++)
1513
+ if (s = a.charAt(i), s && ce(s)) {
1514
+ var l = e.getTokenTypeAt(new o(n, i + 1));
1515
+ if (l !== "string" && l !== "comment")
1516
+ break;
1517
+ }
1518
+ if (i < a.length) {
1519
+ var u = s === "<" || s === ">" ? /[(){}[\]<>]/ : /[(){}[\]]/, d = e.findMatchingBracket(new o(n, i), { bracketRegex: u });
1520
+ return d.to;
1521
+ } else
1522
+ return r;
1523
+ },
1524
+ moveToStartOfLine: function(e, t) {
1525
+ return new o(t.line, 0);
1526
+ },
1527
+ moveToLineOrEdgeOfDocument: function(e, t, r) {
1528
+ var n = r.forward ? e.lastLine() : e.firstLine();
1529
+ return r.repeatIsExplicit && (n = r.repeat - e.getOption("firstLineNumber")), new o(
1530
+ n,
1531
+ xe(e.getLine(n))
1532
+ );
1533
+ },
1534
+ moveToStartOfDisplayLine: function(e) {
1535
+ return e.execCommand("goLineLeft"), e.getCursor();
1536
+ },
1537
+ moveToEndOfDisplayLine: function(e) {
1538
+ e.execCommand("goLineRight");
1539
+ var t = e.getCursor();
1540
+ return t.sticky == "before" && t.ch--, t;
1541
+ },
1542
+ textObjectManipulation: function(e, t, r, n) {
1543
+ var i = {
1544
+ "(": ")",
1545
+ ")": "(",
1546
+ "{": "}",
1547
+ "}": "{",
1548
+ "[": "]",
1549
+ "]": "[",
1550
+ "<": ">",
1551
+ ">": "<"
1552
+ }, a = { "'": !0, '"': !0, "`": !0 }, s = r.selectedCharacter || "";
1553
+ s == "b" ? s = "(" : s == "B" && (s = "{");
1554
+ var l = !r.textObjectInner, u, d;
1555
+ if (i[s]) {
1556
+ if (d = !0, u = Pt(e, t, s, l), !u) {
1557
+ var h = e.getSearchCursor(new RegExp("\\" + s, "g"), t);
1558
+ h.find() && (u = Pt(e, h.from(), s, l));
1559
+ }
1560
+ } else if (a[s])
1561
+ d = !0, u = Vr(e, t, s, l);
1562
+ else if (s === "W" || s === "w")
1563
+ for (var g = r.repeat || 1; g-- > 0; ) {
1564
+ var C = at(e, {
1565
+ inclusive: l,
1566
+ innerWord: !l,
1567
+ bigWord: s === "W",
1568
+ noSymbol: s === "W",
1569
+ multiline: !0
1570
+ }, u && u.end);
1571
+ C && (u || (u = C), u.end = C.end);
1572
+ }
1573
+ else if (s === "p")
1574
+ if (u = Bt(e, t, r.repeat, 0, l), r.linewise = !0, n.visualMode)
1575
+ n.visualLine || (n.visualLine = !0);
1576
+ else {
1577
+ var m = n.inputState.operatorArgs;
1578
+ m && (m.linewise = !0), u.end.line--;
1579
+ }
1580
+ else if (s === "t")
1581
+ u = Nr(e, t, l);
1582
+ else if (s === "s") {
1583
+ var v = e.getLine(t.line);
1584
+ t.ch > 0 && Ie(v[t.ch]) && (t.ch -= 1);
1585
+ var w = Nt(e, t, r.repeat, 1, l), S = Nt(e, t, r.repeat, -1, l);
1586
+ Z(e.getLine(S.line)[S.ch]) && Z(e.getLine(w.line)[w.ch - 1]) && (S = { line: S.line, ch: S.ch + 1 }), u = { start: S, end: w };
1587
+ }
1588
+ return u ? e.state.vim.visualMode ? Er(e, u.start, u.end, d) : [u.start, u.end] : null;
1589
+ },
1590
+ repeatLastCharacterSearch: function(e, t, r) {
1591
+ var n = T.lastCharacterSearch, i = r.repeat, a = r.forward === n.forward, s = (n.increment ? 1 : 0) * (a ? -1 : 1);
1592
+ e.moveH(-s, "char"), r.inclusive = !!a;
1593
+ var l = ot(e, i, a, n.selectedCharacter);
1594
+ return l ? (l.ch += s, l) : (e.moveH(s, "char"), t);
1595
+ }
1596
+ };
1597
+ function kr(e, t) {
1598
+ we[e] = t;
1599
+ }
1600
+ function St(e, t) {
1601
+ for (var r = [], n = 0; n < t; n++)
1602
+ r.push(e);
1603
+ return r;
1604
+ }
1605
+ var rt = {
1606
+ change: function(e, t, r) {
1607
+ var n, i, a = e.state.vim, s = r[0].anchor, l = r[0].head;
1608
+ if (a.visualMode)
1609
+ if (t.fullLine)
1610
+ l.ch = Number.MAX_VALUE, l.line--, e.setSelection(s, l), i = e.getSelection(), e.replaceSelection(""), n = s;
1611
+ else {
1612
+ i = e.getSelection();
1613
+ var h = St("", r.length);
1614
+ e.replaceSelections(h), n = ne(r[0].head, r[0].anchor);
1615
+ }
1616
+ else {
1617
+ i = e.getRange(s, l);
1618
+ var u = a.lastEditInputState;
1619
+ if ((u == null ? void 0 : u.motion) == "moveByWords" && !Z(i)) {
1620
+ var d = /\s+$/.exec(i);
1621
+ d && u.motionArgs && u.motionArgs.forward && (l = G(l, 0, -d[0].length), i = i.slice(0, -d[0].length));
1622
+ }
1623
+ t.linewise && (s = new o(s.line, xe(e.getLine(s.line))), l.line > s.line && (l = new o(l.line - 1, Number.MAX_VALUE))), e.replaceRange("", s, l), n = s;
1624
+ }
1625
+ T.registerController.pushText(
1626
+ t.registerName,
1627
+ "change",
1628
+ i,
1629
+ t.linewise,
1630
+ r.length > 1
1631
+ ), De.enterInsertMode(e, { head: n }, e.state.vim);
1632
+ },
1633
+ delete: function(e, t, r) {
1634
+ var n, i, a = e.state.vim;
1635
+ if (a.visualBlock) {
1636
+ i = e.getSelection();
1637
+ var u = St("", r.length);
1638
+ e.replaceSelections(u), n = ne(r[0].head, r[0].anchor);
1639
+ } else {
1640
+ var s = r[0].anchor, l = r[0].head;
1641
+ t.linewise && l.line != e.firstLine() && s.line == e.lastLine() && s.line == l.line - 1 && (s.line == e.firstLine() ? s.ch = 0 : s = new o(s.line - 1, te(e, s.line - 1))), i = e.getRange(s, l), e.replaceRange("", s, l), n = s, t.linewise && (n = we.moveToFirstNonWhiteSpaceCharacter(e, s));
1642
+ }
1643
+ return T.registerController.pushText(
1644
+ t.registerName,
1645
+ "delete",
1646
+ i,
1647
+ t.linewise,
1648
+ a.visualBlock
1649
+ ), re(e, n);
1650
+ },
1651
+ indent: function(e, t, r) {
1652
+ var n = e.state.vim, i = n.visualMode && t.repeat || 1;
1653
+ if (n.visualBlock) {
1654
+ for (var a = e.getOption("tabSize"), s = e.getOption("indentWithTabs") ? " " : " ".repeat(a), l, u = r.length - 1; u >= 0; u--)
1655
+ if (l = ne(r[u].anchor, r[u].head), t.indentRight)
1656
+ e.replaceRange(s.repeat(i), l, l);
1657
+ else {
1658
+ for (var d = e.getLine(l.line), h = 0, g = 0; g < i; g++) {
1659
+ var C = d[l.ch + h];
1660
+ if (C == " ")
1661
+ h++;
1662
+ else if (C == " ") {
1663
+ h++;
1664
+ for (var m = 1; m < s.length && (C = d[l.ch + h], C === " "); m++)
1665
+ h++;
1666
+ } else
1667
+ break;
1668
+ }
1669
+ e.replaceRange("", l, G(l, 0, h));
1670
+ }
1671
+ return l;
1672
+ } else if (e.indentMore)
1673
+ for (var g = 0; g < i; g++)
1674
+ t.indentRight ? e.indentMore() : e.indentLess();
1675
+ else {
1676
+ var v = r[0].anchor.line, w = n.visualBlock ? r[r.length - 1].anchor.line : r[0].head.line;
1677
+ t.linewise && w--;
1678
+ for (var u = v; u <= w; u++)
1679
+ for (var g = 0; g < i; g++)
1680
+ e.indentLine(u, t.indentRight);
1681
+ }
1682
+ return we.moveToFirstNonWhiteSpaceCharacter(e, r[0].anchor);
1683
+ },
1684
+ indentAuto: function(e, t, r) {
1685
+ return e.execCommand("indentAuto"), we.moveToFirstNonWhiteSpaceCharacter(e, r[0].anchor);
1686
+ },
1687
+ hardWrap: function(e, t, r, n) {
1688
+ if (e.hardWrap) {
1689
+ var i = r[0].anchor.line, a = r[0].head.line;
1690
+ t.linewise && a--;
1691
+ var s = e.hardWrap({ from: i, to: a });
1692
+ return s > i && t.linewise && s--, t.keepCursor ? n : new o(s, 0);
1693
+ }
1694
+ },
1695
+ changeCase: function(e, t, r, n, i) {
1696
+ for (var a = e.getSelections(), s = [], l = t.toLower, u = 0; u < a.length; u++) {
1697
+ var d = a[u], h = "";
1698
+ if (l === !0)
1699
+ h = d.toLowerCase();
1700
+ else if (l === !1)
1701
+ h = d.toUpperCase();
1702
+ else
1703
+ for (var g = 0; g < d.length; g++) {
1704
+ var C = d.charAt(g);
1705
+ h += ge(C) ? C.toLowerCase() : C.toUpperCase();
1706
+ }
1707
+ s.push(h);
1708
+ }
1709
+ return e.replaceSelections(s), t.shouldMoveCursor ? i : !e.state.vim.visualMode && t.linewise && r[0].anchor.line + 1 == r[0].head.line ? we.moveToFirstNonWhiteSpaceCharacter(e, n) : t.linewise ? n : ne(r[0].anchor, r[0].head);
1710
+ },
1711
+ yank: function(e, t, r, n) {
1712
+ var i = e.state.vim, a = e.getSelection(), s = i.visualMode ? ne(i.sel.anchor, i.sel.head, r[0].head, r[0].anchor) : n;
1713
+ return T.registerController.pushText(
1714
+ t.registerName,
1715
+ "yank",
1716
+ a,
1717
+ t.linewise,
1718
+ i.visualBlock
1719
+ ), s;
1720
+ },
1721
+ rot13: function(e, t, r, n, i) {
1722
+ for (var a = e.getSelections(), s = [], l = 0; l < a.length; l++) {
1723
+ const u = a[l].split("").map((d) => {
1724
+ const h = d.charCodeAt(0);
1725
+ return h >= 65 && h <= 90 ? String.fromCharCode(65 + (h - 65 + 13) % 26) : h >= 97 && h <= 122 ? String.fromCharCode(97 + (h - 97 + 13) % 26) : d;
1726
+ }).join("");
1727
+ s.push(u);
1728
+ }
1729
+ return e.replaceSelections(s), t.shouldMoveCursor ? i : !e.state.vim.visualMode && t.linewise && r[0].anchor.line + 1 == r[0].head.line ? we.moveToFirstNonWhiteSpaceCharacter(e, n) : t.linewise ? n : ne(r[0].anchor, r[0].head);
1730
+ }
1731
+ };
1732
+ function wr(e, t) {
1733
+ rt[e] = t;
1734
+ }
1735
+ var De = {
1736
+ jumpListWalk: function(e, t, r) {
1737
+ if (!r.visualMode) {
1738
+ var n = t.repeat || 1, i = t.forward, a = T.jumpList, s = a.move(e, i ? n : -n), l = s ? s.find() : void 0;
1739
+ l = l || e.getCursor(), e.setCursor(l);
1740
+ }
1741
+ },
1742
+ scroll: function(e, t, r) {
1743
+ if (!r.visualMode) {
1744
+ var n = t.repeat || 1, i = e.defaultTextHeight(), a = e.getScrollInfo().top, s = i * n, l = t.forward ? a + s : a - s, u = V(e.getCursor()), d = e.charCoords(u, "local");
1745
+ if (t.forward)
1746
+ l > d.top ? (u.line += (l - d.top) / i, u.line = Math.ceil(u.line), e.setCursor(u), d = e.charCoords(u, "local"), e.scrollTo(null, d.top)) : e.scrollTo(null, l);
1747
+ else {
1748
+ var h = l + e.getScrollInfo().clientHeight;
1749
+ h < d.bottom ? (u.line -= (d.bottom - h) / i, u.line = Math.floor(u.line), e.setCursor(u), d = e.charCoords(u, "local"), e.scrollTo(
1750
+ null,
1751
+ d.bottom - e.getScrollInfo().clientHeight
1752
+ )) : e.scrollTo(null, l);
1753
+ }
1754
+ }
1755
+ },
1756
+ scrollToCursor: function(e, t) {
1757
+ var r = e.getCursor().line, n = e.charCoords(new o(r, 0), "local"), i = e.getScrollInfo().clientHeight, a = n.top;
1758
+ switch (t.position) {
1759
+ case "center":
1760
+ a = n.bottom - i / 2;
1761
+ break;
1762
+ case "bottom":
1763
+ var s = new o(r, e.getLine(r).length - 1), l = e.charCoords(s, "local"), u = l.bottom - a;
1764
+ a = a - i + u;
1765
+ break;
1766
+ }
1767
+ e.scrollTo(null, a);
1768
+ },
1769
+ replayMacro: function(e, t, r) {
1770
+ var n = t.selectedCharacter || "", i = t.repeat || 1, a = T.macroModeState;
1771
+ for (n == "@" ? n = a.latestRegister || "" : a.latestRegister = n; i--; )
1772
+ an(e, r, a, n);
1773
+ },
1774
+ enterMacroRecordMode: function(e, t) {
1775
+ var r = T.macroModeState, n = t.selectedCharacter;
1776
+ T.registerController.isValidRegister(n) && r.enterMacroRecordMode(e, n);
1777
+ },
1778
+ toggleOverwrite: function(e) {
1779
+ e.state.overwrite ? (e.toggleOverwrite(!1), e.setOption("keyMap", "vim-insert"), f.signal(e, "vim-mode-change", { mode: "insert" })) : (e.toggleOverwrite(!0), e.setOption("keyMap", "vim-replace"), f.signal(e, "vim-mode-change", { mode: "replace" }));
1780
+ },
1781
+ enterInsertMode: function(e, t, r) {
1782
+ if (!e.getOption("readOnly")) {
1783
+ r.insertMode = !0, r.insertModeRepeat = t && t.repeat || 1;
1784
+ var n = t ? t.insertAt : null, i = r.sel, a = t.head || e.getCursor("head"), s = e.listSelections().length;
1785
+ if (n == "eol")
1786
+ a = new o(a.line, te(e, a.line));
1787
+ else if (n == "bol")
1788
+ a = new o(a.line, 0);
1789
+ else if (n == "charAfter") {
1790
+ var l = c(e, a, G(a, 0, 1));
1791
+ a = l.end;
1792
+ } else if (n == "firstNonBlank") {
1793
+ var l = c(e, a, we.moveToFirstNonWhiteSpaceCharacter(e, a));
1794
+ a = l.end;
1795
+ } else if (n == "startOfSelectedArea") {
1796
+ if (!r.visualMode)
1797
+ return;
1798
+ r.visualBlock ? (a = new o(
1799
+ Math.min(i.head.line, i.anchor.line),
1800
+ Math.min(i.head.ch, i.anchor.ch)
1801
+ ), s = Math.abs(i.head.line - i.anchor.line) + 1) : i.head.line < i.anchor.line ? a = i.head : a = new o(i.anchor.line, 0);
1802
+ } else if (n == "endOfSelectedArea") {
1803
+ if (!r.visualMode)
1804
+ return;
1805
+ r.visualBlock ? (a = new o(
1806
+ Math.min(i.head.line, i.anchor.line),
1807
+ Math.max(i.head.ch, i.anchor.ch) + 1
1808
+ ), s = Math.abs(i.head.line - i.anchor.line) + 1) : i.head.line >= i.anchor.line ? a = G(i.head, 0, 1) : a = new o(i.anchor.line, 0);
1809
+ } else if (n == "inplace") {
1810
+ if (r.visualMode)
1811
+ return;
1812
+ } else n == "lastEdit" && (a = $t(e) || a);
1813
+ e.setOption("disableInput", !1), t && t.replace ? (e.toggleOverwrite(!0), e.setOption("keyMap", "vim-replace"), f.signal(e, "vim-mode-change", { mode: "replace" })) : (e.toggleOverwrite(!1), e.setOption("keyMap", "vim-insert"), f.signal(e, "vim-mode-change", { mode: "insert" })), T.macroModeState.isPlaying || (e.on("change", jt), r.insertEnd && r.insertEnd.clear(), r.insertEnd = e.setBookmark(a, { insertLeft: !0 }), f.on(e.getInputField(), "keydown", Jt)), r.visualMode && Se(e), bt(e, a, s);
1814
+ }
1815
+ },
1816
+ toggleVisualMode: function(e, t, r) {
1817
+ var n = t.repeat, i = e.getCursor(), a;
1818
+ if (r.visualMode)
1819
+ r.visualLine != !!t.linewise || r.visualBlock != !!t.blockwise ? (r.visualLine = !!t.linewise, r.visualBlock = !!t.blockwise, f.signal(e, "vim-mode-change", { mode: "visual", subMode: r.visualLine ? "linewise" : r.visualBlock ? "blockwise" : "" }), _e(e)) : Se(e);
1820
+ else {
1821
+ r.visualMode = !0, r.visualLine = !!t.linewise, r.visualBlock = !!t.blockwise, a = re(
1822
+ e,
1823
+ new o(i.line, i.ch + n - 1)
1824
+ );
1825
+ var s = c(e, i, a);
1826
+ r.sel = {
1827
+ anchor: s.start,
1828
+ head: s.end
1829
+ }, f.signal(e, "vim-mode-change", { mode: "visual", subMode: r.visualLine ? "linewise" : r.visualBlock ? "blockwise" : "" }), _e(e), be(e, r, "<", ne(i, a)), be(e, r, ">", Te(i, a));
1830
+ }
1831
+ },
1832
+ reselectLastSelection: function(e, t, r) {
1833
+ var n = r.lastSelection;
1834
+ if (r.visualMode && Tt(e, r), n) {
1835
+ var i = n.anchorMark.find(), a = n.headMark.find();
1836
+ if (!i || !a)
1837
+ return;
1838
+ r.sel = {
1839
+ anchor: i,
1840
+ head: a
1841
+ }, r.visualMode = !0, r.visualLine = n.visualLine, r.visualBlock = n.visualBlock, _e(e), be(e, r, "<", ne(i, a)), be(e, r, ">", Te(i, a)), f.signal(e, "vim-mode-change", {
1842
+ mode: "visual",
1843
+ subMode: r.visualLine ? "linewise" : r.visualBlock ? "blockwise" : ""
1844
+ });
1845
+ }
1846
+ },
1847
+ joinLines: function(e, t, r) {
1848
+ var n, i;
1849
+ if (r.visualMode) {
1850
+ if (n = e.getCursor("anchor"), i = e.getCursor("head"), q(i, n)) {
1851
+ var a = i;
1852
+ i = n, n = a;
1853
+ }
1854
+ i.ch = te(e, i.line) - 1;
1855
+ } else {
1856
+ var s = Math.max(t.repeat, 2);
1857
+ n = e.getCursor(), i = re(e, new o(
1858
+ n.line + s - 1,
1859
+ 1 / 0
1860
+ ));
1861
+ }
1862
+ for (var l = 0, u = n.line; u < i.line; u++) {
1863
+ l = te(e, n.line);
1864
+ var d = "", h = 0;
1865
+ if (!t.keepSpaces) {
1866
+ var g = e.getLine(n.line + 1);
1867
+ h = g.search(/\S/), h == -1 ? h = g.length : d = " ";
1868
+ }
1869
+ e.replaceRange(
1870
+ d,
1871
+ new o(n.line, l),
1872
+ new o(n.line + 1, h)
1873
+ );
1874
+ }
1875
+ var C = re(e, new o(n.line, l));
1876
+ r.visualMode && Se(e, !1), e.setCursor(C);
1877
+ },
1878
+ newLineAndEnterInsertMode: function(e, t, r) {
1879
+ r.insertMode = !0;
1880
+ var n = V(e.getCursor());
1881
+ if (n.line === e.firstLine() && !t.after)
1882
+ e.replaceRange(`
1883
+ `, new o(e.firstLine(), 0)), e.setCursor(e.firstLine(), 0);
1884
+ else {
1885
+ n.line = t.after ? n.line : n.line - 1, n.ch = te(e, n.line), e.setCursor(n);
1886
+ var i = f.commands.newlineAndIndentContinueComment || f.commands.newlineAndIndent;
1887
+ i(e);
1888
+ }
1889
+ this.enterInsertMode(e, { repeat: t.repeat }, r);
1890
+ },
1891
+ paste: function(e, t, r) {
1892
+ var n = T.registerController.getRegister(
1893
+ t.registerName
1894
+ );
1895
+ if (t.registerName === "+")
1896
+ navigator.clipboard.readText().then((a) => {
1897
+ this.continuePaste(e, t, r, a, n);
1898
+ });
1899
+ else {
1900
+ var i = n.toString();
1901
+ this.continuePaste(e, t, r, i, n);
1902
+ }
1903
+ },
1904
+ continuePaste: function(e, t, r, n, i) {
1905
+ var a = V(e.getCursor());
1906
+ if (n) {
1907
+ if (t.matchIndent) {
1908
+ var s = e.getOption("tabSize"), l = function(ee) {
1909
+ var pe = ee.split(" ").length - 1, Ee = ee.split(" ").length - 1;
1910
+ return pe * s + Ee * 1;
1911
+ }, u = e.getLine(e.getCursor().line), d = l(u.match(/^\s*/)[0]), h = n.replace(/\n$/, ""), g = n !== h, C = l(n.match(/^\s*/)[0]), n = h.replace(/^\s*/gm, function(ee) {
1912
+ var pe = d + (l(ee) - C);
1913
+ if (pe < 0)
1914
+ return "";
1915
+ if (e.getOption("indentWithTabs")) {
1916
+ var Ee = Math.floor(pe / s);
1917
+ return Array(Ee + 1).join(" ");
1918
+ } else
1919
+ return Array(pe + 1).join(" ");
1920
+ });
1921
+ n += g ? `
1922
+ ` : "";
1923
+ }
1924
+ t.repeat > 1 && (n = Array(t.repeat + 1).join(n));
1925
+ var m = i.linewise, v = i.blockwise, w = v ? n.split(`
1926
+ `) : void 0;
1927
+ if (w) {
1928
+ m && w.pop();
1929
+ for (var S = 0; S < w.length; S++)
1930
+ w[S] = w[S] == "" ? " " : w[S];
1931
+ a.ch += t.after ? 1 : 0, a.ch = Math.min(te(e, a.line), a.ch);
1932
+ } else m ? r.visualMode ? n = r.visualLine ? n.slice(0, -1) : `
1933
+ ` + n.slice(0, n.length - 1) + `
1934
+ ` : t.after ? (n = `
1935
+ ` + n.slice(0, n.length - 1), a.ch = te(e, a.line)) : a.ch = 0 : a.ch += t.after ? 1 : 0;
1936
+ var A;
1937
+ if (r.visualMode) {
1938
+ r.lastPastedText = n;
1939
+ var M, E = Or(e), N = E[0], R = E[1], U = e.getSelection(), J = e.listSelections(), P = new Array(J.length).join("1").split("1");
1940
+ r.lastSelection && (M = r.lastSelection.headMark.find()), T.registerController.unnamedRegister.setText(U), v ? (e.replaceSelections(P), R = new o(N.line + n.length - 1, N.ch), e.setCursor(N), Lt(e, R), e.replaceSelections(n), A = N) : r.visualBlock ? (e.replaceSelections(P), e.setCursor(N), e.replaceRange(n, N, N), A = N) : (e.replaceRange(n, N, R), A = e.posFromIndex(e.indexFromPos(N) + n.length - 1)), M && (r.lastSelection.headMark = e.setBookmark(M)), m && (A.ch = 0);
1941
+ } else if (v && w) {
1942
+ e.setCursor(a);
1943
+ for (var S = 0; S < w.length; S++) {
1944
+ var O = a.line + S;
1945
+ O > e.lastLine() && e.replaceRange(`
1946
+ `, new o(O, 0));
1947
+ var $ = te(e, O);
1948
+ $ < a.ch && Tr(e, O, a.ch);
1949
+ }
1950
+ e.setCursor(a), Lt(e, new o(a.line + w.length - 1, a.ch)), e.replaceSelections(w), A = a;
1951
+ } else if (e.replaceRange(n, a), m) {
1952
+ var O = t.after ? a.line + 1 : a.line;
1953
+ A = new o(O, xe(e.getLine(O)));
1954
+ } else
1955
+ A = V(a), /\n/.test(n) || (A.ch += n.length - (t.after ? 1 : 0));
1956
+ r.visualMode && Se(e, !1), e.setCursor(A);
1957
+ }
1958
+ },
1959
+ undo: function(e, t) {
1960
+ e.operation(function() {
1961
+ xt(e, f.commands.undo, t.repeat)(), e.setCursor(re(e, e.getCursor("start")));
1962
+ });
1963
+ },
1964
+ redo: function(e, t) {
1965
+ xt(e, f.commands.redo, t.repeat)();
1966
+ },
1967
+ setRegister: function(e, t, r) {
1968
+ r.inputState.registerName = t.selectedCharacter;
1969
+ },
1970
+ insertRegister: function(e, t, r) {
1971
+ var n = t.selectedCharacter, i = T.registerController.getRegister(n), a = i && i.toString();
1972
+ a && e.replaceSelection(a);
1973
+ },
1974
+ oneNormalCommand: function(e, t, r) {
1975
+ Ae(e, !0), r.insertModeReturn = !0, f.on(e, "vim-command-done", function n() {
1976
+ r.visualMode || (r.insertModeReturn && (r.insertModeReturn = !1, r.insertMode || De.enterInsertMode(e, {}, r)), f.off(e, "vim-command-done", n));
1977
+ });
1978
+ },
1979
+ setMark: function(e, t, r) {
1980
+ var n = t.selectedCharacter;
1981
+ n && be(e, r, n, e.getCursor());
1982
+ },
1983
+ replace: function(e, t, r) {
1984
+ var n = t.selectedCharacter || "", i = e.getCursor(), a, s, l = e.listSelections();
1985
+ if (r.visualMode)
1986
+ i = e.getCursor("start"), s = e.getCursor("end");
1987
+ else {
1988
+ var u = e.getLine(i.line);
1989
+ a = i.ch + t.repeat, a > u.length && (a = u.length), s = new o(i.line, a);
1990
+ }
1991
+ var d = c(e, i, s);
1992
+ if (i = d.start, s = d.end, n == `
1993
+ `)
1994
+ r.visualMode || e.replaceRange("", i, s), (f.commands.newlineAndIndentContinueComment || f.commands.newlineAndIndent)(e);
1995
+ else {
1996
+ var h = e.getRange(i, s);
1997
+ if (h = h.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, n), h = h.replace(/[^\n]/g, n), r.visualBlock) {
1998
+ var g = new Array(e.getOption("tabSize") + 1).join(" ");
1999
+ h = e.getSelection(), h = h.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, n);
2000
+ var C = h.replace(/\t/g, g).replace(/[^\n]/g, n).split(`
2001
+ `);
2002
+ e.replaceSelections(C);
2003
+ } else
2004
+ e.replaceRange(h, i, s);
2005
+ r.visualMode ? (i = q(l[0].anchor, l[0].head) ? l[0].anchor : l[0].head, e.setCursor(i), Se(e, !1)) : e.setCursor(G(s, 0, -1));
2006
+ }
2007
+ },
2008
+ incrementNumberToken: function(e, t) {
2009
+ for (var r = e.getCursor(), n = e.getLine(r.line), i = /(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi, a, s, l, u; (a = i.exec(n)) !== null && (s = a.index, l = s + a[0].length, !(r.ch < l)); )
2010
+ ;
2011
+ if (!(!t.backtrack && l <= r.ch)) {
2012
+ if (a) {
2013
+ var d = a[2] || a[4], h = a[3] || a[5], g = t.increase ? 1 : -1, C = { "0b": 2, 0: 8, "": 10, "0x": 16 }[d.toLowerCase()], m = parseInt(a[1] + h, C) + g * t.repeat;
2014
+ u = m.toString(C);
2015
+ var v = d ? new Array(h.length - u.length + 1 + a[1].length).join("0") : "";
2016
+ u.charAt(0) === "-" ? u = "-" + d + v + u.substr(1) : u = d + v + u;
2017
+ var w = new o(r.line, s), S = new o(r.line, l);
2018
+ e.replaceRange(u, w, S);
2019
+ } else
2020
+ return;
2021
+ e.setCursor(new o(r.line, s + u.length - 1));
2022
+ }
2023
+ },
2024
+ repeatLastEdit: function(e, t, r) {
2025
+ var n = r.lastEditInputState;
2026
+ if (n) {
2027
+ var i = t.repeat;
2028
+ i && t.repeatIsExplicit ? n.repeatOverride = i : i = n.repeatOverride || i, zt(
2029
+ e,
2030
+ r,
2031
+ i,
2032
+ !1
2033
+ /** repeatForInsert */
2034
+ );
2035
+ }
2036
+ },
2037
+ indent: function(e, t) {
2038
+ e.indentLine(e.getCursor().line, t.indentRight);
2039
+ },
2040
+ exitInsertMode: function(e, t) {
2041
+ Ae(e);
2042
+ }
2043
+ };
2044
+ function Sr(e, t) {
2045
+ De[e] = t;
2046
+ }
2047
+ function re(e, t, r) {
2048
+ var n = e.state.vim, i = n.insertMode || n.visualMode, a = Math.min(Math.max(e.firstLine(), t.line), e.lastLine()), s = e.getLine(a), l = s.length - 1 + +!!i, u = Math.min(Math.max(0, t.ch), l), d = s.charCodeAt(u);
2049
+ if (56320 <= d && d <= 57343) {
2050
+ var h = 1;
2051
+ r && r.line == a && r.ch > u && (h = -1), u += h, u > l && (u -= 2);
2052
+ }
2053
+ return new o(a, u);
2054
+ }
2055
+ function qe(e) {
2056
+ var t = (
2057
+ /**@type{typeof args}*/
2058
+ {}
2059
+ );
2060
+ for (var r in e)
2061
+ Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
2062
+ return (
2063
+ /**@type{typeof args}*/
2064
+ t
2065
+ );
2066
+ }
2067
+ function G(e, t, r) {
2068
+ return typeof t == "object" && (r = t.ch, t = t.line), new o(e.line + t, e.ch + r);
2069
+ }
2070
+ function xr(e, t, r, n) {
2071
+ n.operator && (r = "operatorPending");
2072
+ for (var i, a = [], s = [], l = ze ? t.length - k : 0, u = l; u < t.length; u++) {
2073
+ var d = t[u];
2074
+ r == "insert" && d.context != "insert" || d.context && d.context != r || n.operator && d.type == "action" || !(i = Mr(e, d.keys)) || (i == "partial" && a.push(d), i == "full" && s.push(d));
2075
+ }
2076
+ return {
2077
+ partial: a,
2078
+ full: s
2079
+ };
2080
+ }
2081
+ function Mr(e, t) {
2082
+ const r = t.slice(-11) == "<character>", n = t.slice(-10) == "<register>";
2083
+ if (r || n) {
2084
+ var i = t.length - (r ? 11 : 10), a = e.slice(0, i), s = t.slice(0, i);
2085
+ return a == s && e.length > i ? "full" : s.indexOf(a) == 0 ? "partial" : !1;
2086
+ } else
2087
+ return e == t ? "full" : t.indexOf(e) == 0 ? "partial" : !1;
2088
+ }
2089
+ function Lr(e) {
2090
+ var t = /^.*(<[^>]+>)$/.exec(e), r = t ? t[1] : e.slice(-1);
2091
+ if (r.length > 1)
2092
+ switch (r) {
2093
+ case "<CR>":
2094
+ case "<S-CR>":
2095
+ r = `
2096
+ `;
2097
+ break;
2098
+ case "<Space>":
2099
+ case "<S-Space>":
2100
+ r = " ";
2101
+ break;
2102
+ default:
2103
+ r = "";
2104
+ break;
2105
+ }
2106
+ return r;
2107
+ }
2108
+ function xt(e, t, r) {
2109
+ return function() {
2110
+ for (var n = 0; n < r; n++)
2111
+ t(e);
2112
+ };
2113
+ }
2114
+ function V(e) {
2115
+ return new o(e.line, e.ch);
2116
+ }
2117
+ function he(e, t) {
2118
+ return e.ch == t.ch && e.line == t.line;
2119
+ }
2120
+ function q(e, t) {
2121
+ return e.line < t.line || e.line == t.line && e.ch < t.ch;
2122
+ }
2123
+ function ne(e, t) {
2124
+ return arguments.length > 2 && (t = ne.apply(void 0, Array.prototype.slice.call(arguments, 1))), q(e, t) ? e : t;
2125
+ }
2126
+ function Te(e, t) {
2127
+ return arguments.length > 2 && (t = Te.apply(void 0, Array.prototype.slice.call(arguments, 1))), q(e, t) ? t : e;
2128
+ }
2129
+ function Mt(e, t, r) {
2130
+ var n = q(e, t), i = q(t, r);
2131
+ return n && i;
2132
+ }
2133
+ function te(e, t) {
2134
+ return e.getLine(t).length;
2135
+ }
2136
+ function nt(e) {
2137
+ return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "");
2138
+ }
2139
+ function br(e) {
2140
+ return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g, "\\$1");
2141
+ }
2142
+ function Tr(e, t, r) {
2143
+ var n = te(e, t), i = new Array(r - n + 1).join(" ");
2144
+ e.setCursor(new o(t, n)), e.replaceRange(i, e.getCursor());
2145
+ }
2146
+ function Lt(e, t) {
2147
+ var r = [], n = e.listSelections(), i = V(e.clipPos(t)), a = !he(t, i), s = e.getCursor("head"), l = Ar(n, s), u = he(n[l].head, n[l].anchor), d = n.length - 1, h = d - l > l ? d : 0, g = n[h].anchor, C = Math.min(g.line, i.line), m = Math.max(g.line, i.line), v = g.ch, w = i.ch, S = n[h].head.ch - v, A = w - v;
2148
+ S > 0 && A <= 0 ? (v++, a || w--) : S < 0 && A >= 0 ? (v--, u || w++) : S < 0 && A == -1 && (v--, w++);
2149
+ for (var M = C; M <= m; M++) {
2150
+ var E = { anchor: new o(M, v), head: new o(M, w) };
2151
+ r.push(E);
2152
+ }
2153
+ return e.setSelections(r), t.ch = w, g.ch = v, g;
2154
+ }
2155
+ function bt(e, t, r) {
2156
+ for (var n = [], i = 0; i < r; i++) {
2157
+ var a = G(t, i, 0);
2158
+ n.push({ anchor: a, head: a });
2159
+ }
2160
+ e.setSelections(n, 0);
2161
+ }
2162
+ function Ar(e, t, r) {
2163
+ for (var n = 0; n < e.length; n++) {
2164
+ var i = he(e[n].anchor, t), a = he(e[n].head, t);
2165
+ if (i || a)
2166
+ return n;
2167
+ }
2168
+ return -1;
2169
+ }
2170
+ function Or(e, t) {
2171
+ var r = e.listSelections(), n = r[0], i = r[r.length - 1], a = q(n.anchor, n.head) ? n.anchor : n.head, s = q(i.anchor, i.head) ? i.head : i.anchor;
2172
+ return [a, s];
2173
+ }
2174
+ function Tt(e, t) {
2175
+ var r = t.sel.anchor, n = t.sel.head;
2176
+ t.lastPastedText && (n = e.posFromIndex(e.indexFromPos(r) + t.lastPastedText.length), t.lastPastedText = void 0), t.lastSelection = {
2177
+ anchorMark: e.setBookmark(r),
2178
+ headMark: e.setBookmark(n),
2179
+ anchor: V(r),
2180
+ head: V(n),
2181
+ visualMode: t.visualMode,
2182
+ visualLine: t.visualLine,
2183
+ visualBlock: t.visualBlock
2184
+ };
2185
+ }
2186
+ function Er(e, t, r, n) {
2187
+ var i = e.state.vim.sel, a = n ? t : i.head, s = n ? t : i.anchor, l;
2188
+ return q(r, t) && (l = r, r = t, t = l), q(a, s) ? (a = ne(t, a), s = Te(s, r)) : (s = ne(t, s), a = Te(a, r), a = G(a, 0, -1), a.ch == -1 && a.line != e.firstLine() && (a = new o(a.line - 1, te(e, a.line - 1)))), [s, a];
2189
+ }
2190
+ function _e(e, t, r) {
2191
+ var n = e.state.vim;
2192
+ t = t || n.sel, r || (r = n.visualLine ? "line" : n.visualBlock ? "block" : "char");
2193
+ var i = it(e, t, r);
2194
+ e.setSelections(i.ranges, i.primary);
2195
+ }
2196
+ function it(e, t, r, n) {
2197
+ var i = V(t.head), a = V(t.anchor);
2198
+ if (r == "char") {
2199
+ var s = !n && !q(t.head, t.anchor) ? 1 : 0, l = q(t.head, t.anchor) ? 1 : 0;
2200
+ return i = G(t.head, 0, s), a = G(t.anchor, 0, l), {
2201
+ ranges: [{ anchor: a, head: i }],
2202
+ primary: 0
2203
+ };
2204
+ } else if (r == "line") {
2205
+ if (q(t.head, t.anchor))
2206
+ i.ch = 0, a.ch = te(e, a.line);
2207
+ else {
2208
+ a.ch = 0;
2209
+ var u = e.lastLine();
2210
+ i.line > u && (i.line = u), i.ch = te(e, i.line);
2211
+ }
2212
+ return {
2213
+ ranges: [{ anchor: a, head: i }],
2214
+ primary: 0
2215
+ };
2216
+ } else if (r == "block") {
2217
+ var d = Math.min(a.line, i.line), h = a.ch, g = Math.max(a.line, i.line), C = i.ch;
2218
+ h < C ? C += 1 : h += 1;
2219
+ for (var m = g - d + 1, v = i.line == d ? 0 : m - 1, w = [], S = 0; S < m; S++)
2220
+ w.push({
2221
+ anchor: new o(d + S, h),
2222
+ head: new o(d + S, C)
2223
+ });
2224
+ return {
2225
+ ranges: w,
2226
+ primary: v
2227
+ };
2228
+ }
2229
+ throw "never happens";
2230
+ }
2231
+ function Rr(e) {
2232
+ var t = e.getCursor("head");
2233
+ return e.getSelection().length == 1 && (t = ne(t, e.getCursor("anchor"))), t;
2234
+ }
2235
+ function Se(e, t) {
2236
+ var r = e.state.vim;
2237
+ t !== !1 && e.setCursor(re(e, r.sel.head)), Tt(e, r), r.visualMode = !1, r.visualLine = !1, r.visualBlock = !1, r.insertMode || f.signal(e, "vim-mode-change", { mode: "normal" });
2238
+ }
2239
+ function Ir(e, t, r) {
2240
+ var n = e.getRange(t, r);
2241
+ if (/\n\s*$/.test(n)) {
2242
+ var i = n.split(`
2243
+ `);
2244
+ i.pop();
2245
+ for (var a = i.pop(); i.length > 0 && a && Z(a); a = i.pop())
2246
+ r.line--, r.ch = 0;
2247
+ a ? (r.line--, r.ch = te(e, r.line)) : r.ch = 0;
2248
+ }
2249
+ }
2250
+ function Br(e, t, r) {
2251
+ t.ch = 0, r.ch = 0, r.line++;
2252
+ }
2253
+ function xe(e) {
2254
+ if (!e)
2255
+ return 0;
2256
+ var t = e.search(/\S/);
2257
+ return t == -1 ? e.length : t;
2258
+ }
2259
+ function at(e, { inclusive: t, innerWord: r, bigWord: n, noSymbol: i, multiline: a }, s) {
2260
+ var l = s || Rr(e), u = e.getLine(l.line), d = u, h = l.line, g = h, C = l.ch, m, v = i ? j[0] : B[0];
2261
+ if (r && /\s/.test(u.charAt(C)))
2262
+ v = function(N) {
2263
+ return /\s/.test(N);
2264
+ };
2265
+ else {
2266
+ for (; !v(u.charAt(C)); )
2267
+ if (C++, C >= u.length) {
2268
+ if (!a) return null;
2269
+ C--, m = Rt(e, l, !0, n, !0);
2270
+ break;
2271
+ }
2272
+ n ? v = B[0] : (v = j[0], v(u.charAt(C)) || (v = j[1]));
2273
+ }
2274
+ for (var w = C, S = C; v(u.charAt(S)) && S >= 0; )
2275
+ S--;
2276
+ if (S++, m)
2277
+ w = m.to, g = m.line, d = e.getLine(g), !d && w == 0 && w++;
2278
+ else
2279
+ for (; v(u.charAt(w)) && w < u.length; )
2280
+ w++;
2281
+ if (t) {
2282
+ var A = w, M = l.ch <= S && /\s/.test(u.charAt(l.ch));
2283
+ if (!M)
2284
+ for (; /\s/.test(d.charAt(w)) && w < d.length; )
2285
+ w++;
2286
+ if (A == w || M) {
2287
+ for (var E = S; /\s/.test(u.charAt(S - 1)) && S > 0; )
2288
+ S--;
2289
+ !S && !M && (S = E);
2290
+ }
2291
+ }
2292
+ return { start: new o(h, S), end: new o(g, w) };
2293
+ }
2294
+ function Nr(e, t, r) {
2295
+ var n = t;
2296
+ if (!f.findMatchingTag || !f.findEnclosingTag)
2297
+ return { start: n, end: n };
2298
+ var i = f.findMatchingTag(e, t) || f.findEnclosingTag(e, t);
2299
+ return !i || !i.open || !i.close ? { start: n, end: n } : r ? { start: i.open.from, end: i.close.to } : { start: i.open.to, end: i.close.from };
2300
+ }
2301
+ function At(e, t, r) {
2302
+ he(t, r) || T.jumpList.add(e, t, r);
2303
+ }
2304
+ function Ot(e, t) {
2305
+ T.lastCharacterSearch.increment = e, T.lastCharacterSearch.forward = t.forward, T.lastCharacterSearch.selectedCharacter = t.selectedCharacter;
2306
+ }
2307
+ var Pr = {
2308
+ "(": "bracket",
2309
+ ")": "bracket",
2310
+ "{": "bracket",
2311
+ "}": "bracket",
2312
+ "[": "section",
2313
+ "]": "section",
2314
+ "*": "comment",
2315
+ "/": "comment",
2316
+ m: "method",
2317
+ M: "method",
2318
+ "#": "preprocess"
2319
+ }, Et = {
2320
+ bracket: {
2321
+ isComplete: function(e) {
2322
+ if (e.nextCh === e.symb) {
2323
+ if (e.depth++, e.depth >= 1) return !0;
2324
+ } else e.nextCh === e.reverseSymb && e.depth--;
2325
+ return !1;
2326
+ }
2327
+ },
2328
+ section: {
2329
+ init: function(e) {
2330
+ e.curMoveThrough = !0, e.symb = (e.forward ? "]" : "[") === e.symb ? "{" : "}";
2331
+ },
2332
+ isComplete: function(e) {
2333
+ return e.index === 0 && e.nextCh === e.symb;
2334
+ }
2335
+ },
2336
+ comment: {
2337
+ isComplete: function(e) {
2338
+ var t = e.lastCh === "*" && e.nextCh === "/";
2339
+ return e.lastCh = e.nextCh, t;
2340
+ }
2341
+ },
2342
+ // TODO: The original Vim implementation only operates on level 1 and 2.
2343
+ // The current implementation doesn't check for code block level and
2344
+ // therefore it operates on any levels.
2345
+ method: {
2346
+ init: function(e) {
2347
+ e.symb = e.symb === "m" ? "{" : "}", e.reverseSymb = e.symb === "{" ? "}" : "{";
2348
+ },
2349
+ isComplete: function(e) {
2350
+ return e.nextCh === e.symb;
2351
+ }
2352
+ },
2353
+ preprocess: {
2354
+ init: function(e) {
2355
+ e.index = 0;
2356
+ },
2357
+ isComplete: function(e) {
2358
+ var r;
2359
+ if (e.nextCh === "#") {
2360
+ var t = (r = e.lineText.match(/^#(\w+)/)) == null ? void 0 : r[1];
2361
+ if (t === "endif") {
2362
+ if (e.forward && e.depth === 0)
2363
+ return !0;
2364
+ e.depth++;
2365
+ } else if (t === "if") {
2366
+ if (!e.forward && e.depth === 0)
2367
+ return !0;
2368
+ e.depth--;
2369
+ }
2370
+ if (t === "else" && e.depth === 0) return !0;
2371
+ }
2372
+ return !1;
2373
+ }
2374
+ }
2375
+ };
2376
+ function Kr(e, t, r, n) {
2377
+ var i = V(e.getCursor()), a = r ? 1 : -1, s = r ? e.lineCount() : -1, l = i.ch, u = i.line, d = e.getLine(u), h = {
2378
+ lineText: d,
2379
+ nextCh: d.charAt(l),
2380
+ lastCh: null,
2381
+ index: l,
2382
+ symb: n,
2383
+ reverseSymb: (r ? { ")": "(", "}": "{" } : { "(": ")", "{": "}" })[n],
2384
+ forward: r,
2385
+ depth: 0,
2386
+ curMoveThrough: !1
2387
+ }, g = Pr[n];
2388
+ if (!g) return i;
2389
+ var C = Et[g].init, m = Et[g].isComplete;
2390
+ for (C && C(h); u !== s && t; ) {
2391
+ if (h.index += a, h.nextCh = h.lineText.charAt(h.index), !h.nextCh) {
2392
+ if (u += a, h.lineText = e.getLine(u) || "", a > 0)
2393
+ h.index = 0;
2394
+ else {
2395
+ var v = h.lineText.length;
2396
+ h.index = v > 0 ? v - 1 : 0;
2397
+ }
2398
+ h.nextCh = h.lineText.charAt(h.index);
2399
+ }
2400
+ m(h) && (i.line = u, i.ch = h.index, t--);
2401
+ }
2402
+ return h.nextCh || h.curMoveThrough ? new o(u, h.index) : i;
2403
+ }
2404
+ function Rt(e, t, r, n, i) {
2405
+ var a = t.line, s = t.ch, l = e.getLine(a), u = r ? 1 : -1, d = n ? B : j;
2406
+ if (i && l == "") {
2407
+ if (a += u, l = e.getLine(a), !ie(e, a))
2408
+ return null;
2409
+ s = r ? 0 : l.length;
2410
+ }
2411
+ for (; ; ) {
2412
+ if (i && l == "")
2413
+ return { from: 0, to: 0, line: a };
2414
+ for (var h = u > 0 ? l.length : -1, g = h, C = h; s != h; ) {
2415
+ for (var m = !1, v = 0; v < d.length && !m; ++v)
2416
+ if (d[v](l.charAt(s))) {
2417
+ for (g = s; s != h && d[v](l.charAt(s)); )
2418
+ s += u;
2419
+ if (C = s, m = g != C, g == t.ch && a == t.line && C == g + u)
2420
+ continue;
2421
+ return {
2422
+ from: Math.min(g, C + 1),
2423
+ to: Math.max(g, C),
2424
+ line: a
2425
+ };
2426
+ }
2427
+ m || (s += u);
2428
+ }
2429
+ if (a += u, !ie(e, a))
2430
+ return null;
2431
+ l = e.getLine(a), s = u > 0 ? 0 : l.length;
2432
+ }
2433
+ }
2434
+ function Dr(e, t, r, n, i, a) {
2435
+ var s = V(t), l = [];
2436
+ (n && !i || !n && i) && r++;
2437
+ for (var u = !(n && i), d = 0; d < r; d++) {
2438
+ var h = Rt(e, t, n, a, u);
2439
+ if (!h) {
2440
+ var g = te(e, e.lastLine());
2441
+ l.push(n ? { line: e.lastLine(), from: g, to: g } : { line: 0, from: 0, to: 0 });
2442
+ break;
2443
+ }
2444
+ l.push(h), t = new o(h.line, n ? h.to - 1 : h.from);
2445
+ }
2446
+ var C = l.length != r, m = l[0], v = l.pop();
2447
+ return n && !i ? (!C && (m.from != s.ch || m.line != s.line) && (v = l.pop()), v && new o(v.line, v.from)) : n && i ? v && new o(v.line, v.to - 1) : !n && i ? (!C && (m.to != s.ch || m.line != s.line) && (v = l.pop()), v && new o(v.line, v.to)) : v && new o(v.line, v.from);
2448
+ }
2449
+ function It(e, t, r, n, i) {
2450
+ var a = t, s = new o(a.line + r.repeat - 1, 1 / 0), l = e.clipPos(s);
2451
+ return l.ch--, i || (n.lastHPos = 1 / 0, n.lastHSPos = e.charCoords(l, "div").left), s;
2452
+ }
2453
+ function ot(e, t, r, n, i) {
2454
+ if (n) {
2455
+ for (var a = i || e.getCursor(), s = a.ch, l, u = 0; u < t; u++) {
2456
+ var d = e.getLine(a.line);
2457
+ if (l = Fr(s, d, n, r), l == -1)
2458
+ return;
2459
+ s = l;
2460
+ }
2461
+ if (l != null)
2462
+ return new o(e.getCursor().line, l);
2463
+ }
2464
+ }
2465
+ function _r(e, t) {
2466
+ var r = e.getCursor().line;
2467
+ return re(e, new o(r, t - 1));
2468
+ }
2469
+ function be(e, t, r, n) {
2470
+ !Ze(r, _) && !W.test(r) || (t.marks[r] && t.marks[r].clear(), t.marks[r] = e.setBookmark(n));
2471
+ }
2472
+ function Fr(e, t, r, n, i) {
2473
+ var a;
2474
+ return n ? a = t.indexOf(r, e + 1) : a = t.lastIndexOf(r, e - 1), a;
2475
+ }
2476
+ function Bt(e, t, r, n, i) {
2477
+ var a = t.line, s = e.firstLine(), l = e.lastLine(), u, d, h = a;
2478
+ function g(S) {
2479
+ return !e.getLine(S);
2480
+ }
2481
+ function C(S, A, M) {
2482
+ return M ? g(S) != g(S + A) : !g(S) && g(S + A);
2483
+ }
2484
+ if (n) {
2485
+ for (; s <= h && h <= l && r > 0; )
2486
+ C(h, n) && r--, h += n;
2487
+ return { start: new o(h, 0), end: t };
2488
+ }
2489
+ var m = e.state.vim;
2490
+ if (m.visualLine && C(a, 1, !0)) {
2491
+ var v = m.sel.anchor;
2492
+ C(v.line, -1, !0) && (!i || v.line != a) && (a += 1);
2493
+ }
2494
+ var w = g(a);
2495
+ for (h = a; h <= l && r; h++)
2496
+ C(h, 1, !0) && (!i || g(h) != w) && r--;
2497
+ for (d = new o(h, 0), h > l && !w ? w = !0 : i = !1, h = a; h > s && !((!i || g(h) == w || h == a) && C(h, -1, !0)); h--)
2498
+ ;
2499
+ return u = new o(h, 0), { start: u, end: d };
2500
+ }
2501
+ function Nt(e, t, r, n, i) {
2502
+ function a(d) {
2503
+ d.line !== null && (d.pos + d.dir < 0 || d.pos + d.dir >= d.line.length ? d.line = null : d.pos += d.dir);
2504
+ }
2505
+ function s(d, h, g, C) {
2506
+ var m = d.getLine(h), v = {
2507
+ line: m,
2508
+ ln: h,
2509
+ pos: g,
2510
+ dir: C
2511
+ };
2512
+ if (v.line === "")
2513
+ return { ln: v.ln, pos: v.pos };
2514
+ var w = v.pos;
2515
+ for (a(v); v.line !== null; ) {
2516
+ if (w = v.pos, Ie(v.line[v.pos]))
2517
+ if (i) {
2518
+ for (a(v); v.line !== null && Z(v.line[v.pos]); )
2519
+ w = v.pos, a(v);
2520
+ return { ln: v.ln, pos: w + 1 };
2521
+ } else
2522
+ return { ln: v.ln, pos: v.pos + 1 };
2523
+ a(v);
2524
+ }
2525
+ return { ln: v.ln, pos: w + 1 };
2526
+ }
2527
+ function l(d, h, g, C) {
2528
+ var m = d.getLine(h), v = {
2529
+ line: m,
2530
+ ln: h,
2531
+ pos: g,
2532
+ dir: C
2533
+ };
2534
+ if (v.line === "")
2535
+ return { ln: v.ln, pos: v.pos };
2536
+ var w = v.pos;
2537
+ for (a(v); v.line !== null; ) {
2538
+ if (!Z(v.line[v.pos]) && !Ie(v.line[v.pos]))
2539
+ w = v.pos;
2540
+ else if (Ie(v.line[v.pos]))
2541
+ return i ? Z(v.line[v.pos + 1]) ? { ln: v.ln, pos: v.pos + 1 } : { ln: v.ln, pos: w } : { ln: v.ln, pos: w };
2542
+ a(v);
2543
+ }
2544
+ return v.line = m, i && Z(v.line[v.pos]) ? { ln: v.ln, pos: v.pos } : { ln: v.ln, pos: w };
2545
+ }
2546
+ for (var u = {
2547
+ ln: t.line,
2548
+ pos: t.ch
2549
+ }; r > 0; )
2550
+ n < 0 ? u = l(e, u.ln, u.pos, n) : u = s(e, u.ln, u.pos, n), r--;
2551
+ return new o(u.ln, u.pos);
2552
+ }
2553
+ function Hr(e, t, r, n) {
2554
+ function i(u, d) {
2555
+ if (d.line !== null)
2556
+ if (d.pos + d.dir < 0 || d.pos + d.dir >= d.line.length) {
2557
+ if (d.ln += d.dir, !ie(u, d.ln)) {
2558
+ d.line = null;
2559
+ return;
2560
+ }
2561
+ d.line = u.getLine(d.ln), d.pos = d.dir > 0 ? 0 : d.line.length - 1;
2562
+ } else
2563
+ d.pos += d.dir;
2564
+ }
2565
+ function a(u, d, h, g) {
2566
+ var S = u.getLine(d), C = S === "", m = {
2567
+ line: S,
2568
+ ln: d,
2569
+ pos: h,
2570
+ dir: g
2571
+ }, v = {
2572
+ ln: m.ln,
2573
+ pos: m.pos
2574
+ }, w = m.line === "";
2575
+ for (i(u, m); m.line !== null; ) {
2576
+ if (v.ln = m.ln, v.pos = m.pos, m.line === "" && !w)
2577
+ return { ln: m.ln, pos: m.pos };
2578
+ if (C && m.line !== "" && !Z(m.line[m.pos]))
2579
+ return { ln: m.ln, pos: m.pos };
2580
+ Ie(m.line[m.pos]) && !C && (m.pos === m.line.length - 1 || Z(m.line[m.pos + 1])) && (C = !0), i(u, m);
2581
+ }
2582
+ var S = u.getLine(v.ln);
2583
+ v.pos = 0;
2584
+ for (var A = S.length - 1; A >= 0; --A)
2585
+ if (!Z(S[A])) {
2586
+ v.pos = A;
2587
+ break;
2588
+ }
2589
+ return v;
2590
+ }
2591
+ function s(u, d, h, g) {
2592
+ var S = u.getLine(d), C = {
2593
+ line: S,
2594
+ ln: d,
2595
+ pos: h,
2596
+ dir: g
2597
+ }, m = C.ln, v = null, w = C.line === "";
2598
+ for (i(u, C); C.line !== null; ) {
2599
+ if (C.line === "" && !w)
2600
+ return v !== null ? { ln: m, pos: v } : { ln: C.ln, pos: C.pos };
2601
+ if (Ie(C.line[C.pos]) && v !== null && !(C.ln === m && C.pos + 1 === v))
2602
+ return { ln: m, pos: v };
2603
+ C.line !== "" && !Z(C.line[C.pos]) && (w = !1, m = C.ln, v = C.pos), i(u, C);
2604
+ }
2605
+ var S = u.getLine(m);
2606
+ v = 0;
2607
+ for (var A = 0; A < S.length; ++A)
2608
+ if (!Z(S[A])) {
2609
+ v = A;
2610
+ break;
2611
+ }
2612
+ return { ln: m, pos: v };
2613
+ }
2614
+ for (var l = {
2615
+ ln: t.line,
2616
+ pos: t.ch
2617
+ }; r > 0; )
2618
+ n < 0 ? l = s(e, l.ln, l.pos, n) : l = a(e, l.ln, l.pos, n), r--;
2619
+ return new o(l.ln, l.pos);
2620
+ }
2621
+ function Pt(e, t, r, n) {
2622
+ var i = t, a = {
2623
+ "(": /[()]/,
2624
+ ")": /[()]/,
2625
+ "[": /[[\]]/,
2626
+ "]": /[[\]]/,
2627
+ "{": /[{}]/,
2628
+ "}": /[{}]/,
2629
+ "<": /[<>]/,
2630
+ ">": /[<>]/
2631
+ }[r], s = {
2632
+ "(": "(",
2633
+ ")": "(",
2634
+ "[": "[",
2635
+ "]": "[",
2636
+ "{": "{",
2637
+ "}": "{",
2638
+ "<": "<",
2639
+ ">": "<"
2640
+ }[r], l = e.getLine(i.line).charAt(i.ch), u = l === s ? 1 : 0, d = e.scanForBracket(new o(i.line, i.ch + u), -1, void 0, { bracketRegex: a }), h = e.scanForBracket(new o(i.line, i.ch + u), 1, void 0, { bracketRegex: a });
2641
+ if (!d || !h) return null;
2642
+ var g = d.pos, C = h.pos;
2643
+ if (g.line == C.line && g.ch > C.ch || g.line > C.line) {
2644
+ var m = g;
2645
+ g = C, C = m;
2646
+ }
2647
+ return n ? C.ch += 1 : g.ch += 1, { start: g, end: C };
2648
+ }
2649
+ function Vr(e, t, r, n) {
2650
+ var i = V(t), a = e.getLine(i.line), s = a.split(""), l, u, d, h, g = s.indexOf(r);
2651
+ if (i.ch < g)
2652
+ i.ch = g;
2653
+ else if (g < i.ch && s[i.ch] == r) {
2654
+ var C = /string/.test(e.getTokenTypeAt(G(t, 0, 1))), m = /string/.test(e.getTokenTypeAt(t)), v = C && !m;
2655
+ v || (u = i.ch, --i.ch);
2656
+ }
2657
+ if (s[i.ch] == r && !u)
2658
+ l = i.ch + 1;
2659
+ else
2660
+ for (d = i.ch; d > -1 && !l; d--)
2661
+ s[d] == r && (l = d + 1);
2662
+ if (l && !u)
2663
+ for (d = l, h = s.length; d < h && !u; d++)
2664
+ s[d] == r && (u = d);
2665
+ return !l || !u ? { start: i, end: i } : (n && (--l, ++u), {
2666
+ start: new o(i.line, l),
2667
+ end: new o(i.line, u)
2668
+ });
2669
+ }
2670
+ Be("pcre", !0, "boolean");
2671
+ class $r {
2672
+ constructor() {
2673
+ this.highlightTimeout;
2674
+ }
2675
+ getQuery() {
2676
+ return T.query;
2677
+ }
2678
+ setQuery(t) {
2679
+ T.query = t;
2680
+ }
2681
+ getOverlay() {
2682
+ return this.searchOverlay;
2683
+ }
2684
+ setOverlay(t) {
2685
+ this.searchOverlay = t;
2686
+ }
2687
+ isReversed() {
2688
+ return T.isReversed;
2689
+ }
2690
+ setReversed(t) {
2691
+ T.isReversed = t;
2692
+ }
2693
+ getScrollbarAnnotate() {
2694
+ return this.annotate;
2695
+ }
2696
+ setScrollbarAnnotate(t) {
2697
+ this.annotate = t;
2698
+ }
2699
+ }
2700
+ function ye(e) {
2701
+ var t = e.state.vim;
2702
+ return t.searchState_ || (t.searchState_ = new $r());
2703
+ }
2704
+ function Wr(e) {
2705
+ return Kt(e, "/");
2706
+ }
2707
+ function jr(e) {
2708
+ return Dt(e, "/");
2709
+ }
2710
+ function Kt(e, t) {
2711
+ var r = Dt(e, t) || [];
2712
+ if (!r.length) return [];
2713
+ var n = [];
2714
+ if (r[0] === 0) {
2715
+ for (var i = 0; i < r.length; i++)
2716
+ typeof r[i] == "number" && n.push(e.substring(r[i] + 1, r[i + 1]));
2717
+ return n;
2718
+ }
2719
+ }
2720
+ function Dt(e, t) {
2721
+ t || (t = "/");
2722
+ for (var r = !1, n = [], i = 0; i < e.length; i++) {
2723
+ var a = e.charAt(i);
2724
+ !r && a == t && n.push(i), r = !r && a == "\\";
2725
+ }
2726
+ return n;
2727
+ }
2728
+ function Ur(e) {
2729
+ var t = {
2730
+ V: "|(){+?*.[$^",
2731
+ // verynomagic
2732
+ M: "|(){+?*.[",
2733
+ // nomagic
2734
+ m: "|(){+?",
2735
+ // magic
2736
+ v: "<>"
2737
+ // verymagic
2738
+ }, r = {
2739
+ ">": "(?<=[\\w])(?=[^\\w]|$)",
2740
+ "<": "(?<=[^\\w]|^)(?=[\\w])"
2741
+ }, n = t.m, i = e.replace(/\\.|[\[|(){+*?.$^<>]/g, function(s) {
2742
+ if (s[0] === "\\") {
2743
+ var l = s[1];
2744
+ return l === "}" || n.indexOf(l) != -1 ? l : l in t ? (n = t[l], "") : l in r ? r[l] : s;
2745
+ } else
2746
+ return n.indexOf(s) != -1 ? r[s] || "\\" + s : s;
2747
+ }), a = i.indexOf("\\zs");
2748
+ return a != -1 && (i = "(?<=" + i.slice(0, a) + ")" + i.slice(a + 3)), a = i.indexOf("\\ze"), a != -1 && (i = i.slice(0, a) + "(?=" + i.slice(a + 3) + ")"), i;
2749
+ }
2750
+ var _t = { "\\n": `
2751
+ `, "\\r": "\r", "\\t": " " };
2752
+ function Qr(e) {
2753
+ for (var t = !1, r = [], n = -1; n < e.length; n++) {
2754
+ var i = e.charAt(n) || "", a = e.charAt(n + 1) || "";
2755
+ _t[i + a] ? (r.push(_t[i + a]), n++) : t ? (r.push(i), t = !1) : i === "\\" ? (t = !0, oe(a) || a === "$" ? r.push("$") : a !== "/" && a !== "\\" && r.push("\\")) : (i === "$" && r.push("$"), r.push(i), a === "/" && r.push("\\"));
2756
+ }
2757
+ return r.join("");
2758
+ }
2759
+ var Ft = { "\\/": "/", "\\\\": "\\", "\\n": `
2760
+ `, "\\r": "\r", "\\t": " ", "\\&": "&" };
2761
+ function Jr(e) {
2762
+ for (var t = new f.StringStream(e), r = []; !t.eol(); ) {
2763
+ for (; t.peek() && t.peek() != "\\"; )
2764
+ r.push(t.next());
2765
+ var n = !1;
2766
+ for (var i in Ft)
2767
+ if (t.match(i, !0)) {
2768
+ n = !0, r.push(Ft[i]);
2769
+ break;
2770
+ }
2771
+ n || r.push(t.next());
2772
+ }
2773
+ return r.join("");
2774
+ }
2775
+ function Ht(e, t, r) {
2776
+ var n = T.registerController.getRegister("/");
2777
+ n.setText(e);
2778
+ var i = jr(e), a, s;
2779
+ if (!i.length)
2780
+ a = e;
2781
+ else {
2782
+ a = e.substring(0, i[0]);
2783
+ var l = e.substring(i[0]);
2784
+ s = l.indexOf("i") != -1;
2785
+ }
2786
+ if (!a)
2787
+ return null;
2788
+ le("pcre") || (a = Ur(a)), r && (t = /^[^A-Z]*$/.test(a));
2789
+ var u = new RegExp(
2790
+ a,
2791
+ t || s ? "im" : "m"
2792
+ );
2793
+ return u;
2794
+ }
2795
+ function me(e) {
2796
+ typeof e == "string" && (e = document.createElement(e));
2797
+ for (var t = 1; t < arguments.length; t++) {
2798
+ var r = arguments[t];
2799
+ if (r)
2800
+ if (typeof r != "object" && (r = document.createTextNode(r)), r.nodeType) e.appendChild(r);
2801
+ else for (var n in r)
2802
+ Object.prototype.hasOwnProperty.call(r, n) && (n[0] === "$" ? e.style[n.slice(1)] = r[n] : typeof r[n] == "function" ? e[n] = r[n] : e.setAttribute(n, r[n]));
2803
+ }
2804
+ return e;
2805
+ }
2806
+ function K(e, t, r) {
2807
+ var n = me("div", { $color: "red", $whiteSpace: "pre", class: "cm-vim-message" }, t);
2808
+ e.openNotification ? r ? (n = me("div", {}, n, me("div", {}, "Press ENTER or type command to continue")), e.state.closeVimNotification && e.state.closeVimNotification(), e.state.closeVimNotification = e.openNotification(n, { bottom: !0, duration: 0 })) : e.openNotification(n, { bottom: !0, duration: 15e3 }) : alert(n.innerText);
2809
+ }
2810
+ function zr(e, t) {
2811
+ return me(
2812
+ "div",
2813
+ { $display: "flex", $flex: 1 },
2814
+ me(
2815
+ "span",
2816
+ { $fontFamily: "monospace", $whiteSpace: "pre", $flex: 1, $display: "flex" },
2817
+ e,
2818
+ me("input", {
2819
+ type: "text",
2820
+ autocorrect: "off",
2821
+ autocapitalize: "off",
2822
+ spellcheck: "false",
2823
+ $flex: 1
2824
+ })
2825
+ ),
2826
+ t && me("span", { $color: "#888" }, t)
2827
+ );
2828
+ }
2829
+ function Xe(e, t) {
2830
+ var i;
2831
+ if (Pe.length) {
2832
+ t.value || (t.value = ""), X = t;
2833
+ return;
2834
+ }
2835
+ var r = zr(t.prefix, t.desc);
2836
+ if (e.openDialog)
2837
+ e.openDialog(r, t.onClose, {
2838
+ onKeyDown: t.onKeyDown,
2839
+ onKeyUp: t.onKeyUp,
2840
+ bottom: !0,
2841
+ selectValueOnOpen: !1,
2842
+ value: t.value
2843
+ });
2844
+ else {
2845
+ var n = "";
2846
+ typeof t.prefix != "string" && t.prefix && (n += t.prefix.textContent), t.desc && (n += " " + t.desc), (i = t.onClose) == null || i.call(t, prompt(n, ""));
2847
+ }
2848
+ }
2849
+ function qr(e, t) {
2850
+ return e instanceof RegExp && t instanceof RegExp ? e.flags == t.flags && e.source == t.source : !1;
2851
+ }
2852
+ function je(e, t, r, n) {
2853
+ if (t) {
2854
+ var i = ye(e), a = Ht(t, !!r, !!n);
2855
+ if (a)
2856
+ return st(e, a), qr(a, i.getQuery()) || i.setQuery(a), a;
2857
+ }
2858
+ }
2859
+ function Xr(e) {
2860
+ if (e.source.charAt(0) == "^")
2861
+ var t = !0;
2862
+ return {
2863
+ token: function(r) {
2864
+ if (t && !r.sol()) {
2865
+ r.skipToEnd();
2866
+ return;
2867
+ }
2868
+ var n = r.match(e, !1);
2869
+ if (n)
2870
+ return n[0].length == 0 ? (r.next(), "searching") : !r.sol() && (r.backUp(1), !e.exec(r.next() + n[0])) ? (r.next(), null) : (r.match(e), "searching");
2871
+ for (; !r.eol() && (r.next(), !r.match(e, !1)); )
2872
+ ;
2873
+ },
2874
+ query: e
2875
+ };
2876
+ }
2877
+ var Ue = 0;
2878
+ function st(e, t) {
2879
+ clearTimeout(Ue);
2880
+ var r = ye(e);
2881
+ r.highlightTimeout = Ue, Ue = setTimeout(function() {
2882
+ if (e.state.vim) {
2883
+ var n = ye(e);
2884
+ n.highlightTimeout = void 0;
2885
+ var i = n.getOverlay();
2886
+ (!i || t != i.query) && (i && e.removeOverlay(i), i = Xr(t), e.addOverlay(i), e.showMatchesOnScrollbar && (n.getScrollbarAnnotate() && n.getScrollbarAnnotate().clear(), n.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))), n.setOverlay(i));
2887
+ }
2888
+ }, 50);
2889
+ }
2890
+ function Vt(e, t, r, n) {
2891
+ return e.operation(function() {
2892
+ n === void 0 && (n = 1);
2893
+ for (var i = e.getCursor(), a = e.getSearchCursor(r, i), s = 0; s < n; s++) {
2894
+ var l = a.find(t);
2895
+ if (s == 0 && l && he(a.from(), i)) {
2896
+ var u = t ? a.from() : a.to();
2897
+ l = a.find(t), l && !l[0] && he(a.from(), u) && e.getLine(u.line).length == u.ch && (l = a.find(t));
2898
+ }
2899
+ if (!l && (a = e.getSearchCursor(
2900
+ r,
2901
+ // @ts-ignore
2902
+ t ? new o(e.lastLine()) : new o(e.firstLine(), 0)
2903
+ ), !a.find(t)))
2904
+ return;
2905
+ }
2906
+ return a.from();
2907
+ });
2908
+ }
2909
+ function Gr(e, t, r, n, i) {
2910
+ return e.operation(function() {
2911
+ n === void 0 && (n = 1);
2912
+ var a = e.getCursor(), s = e.getSearchCursor(r, a), l = s.find(!t);
2913
+ !i.visualMode && l && he(s.from(), a) && s.find(!t);
2914
+ for (var u = 0; u < n; u++)
2915
+ if (l = s.find(t), !l && (s = e.getSearchCursor(
2916
+ r,
2917
+ // @ts-ignore
2918
+ t ? new o(e.lastLine()) : new o(e.firstLine(), 0)
2919
+ ), !s.find(t)))
2920
+ return;
2921
+ var d = s.from(), h = s.to();
2922
+ return d && h && [d, h];
2923
+ });
2924
+ }
2925
+ function Fe(e) {
2926
+ var t = ye(e);
2927
+ t.highlightTimeout && (clearTimeout(t.highlightTimeout), t.highlightTimeout = void 0), e.removeOverlay(ye(e).getOverlay()), t.setOverlay(null), t.getScrollbarAnnotate() && (t.getScrollbarAnnotate().clear(), t.setScrollbarAnnotate(null));
2928
+ }
2929
+ function Yr(e, t, r) {
2930
+ return typeof e != "number" && (e = e.line), t instanceof Array ? Ze(e, t) : typeof r == "number" ? e >= t && e <= r : e == t;
2931
+ }
2932
+ function lt(e) {
2933
+ var t = e.getScrollInfo(), r = 6, n = 10, i = e.coordsChar({ left: 0, top: r + t.top }, "local"), a = t.clientHeight - n + t.top, s = e.coordsChar({ left: 0, top: a }, "local");
2934
+ return { top: i.line, bottom: s.line };
2935
+ }
2936
+ function Ge(e, t, r) {
2937
+ if (r == "'" || r == "`")
2938
+ return T.jumpList.find(e, -1) || new o(0, 0);
2939
+ if (r == ".")
2940
+ return $t(e);
2941
+ var n = t.marks[r];
2942
+ return n && n.find();
2943
+ }
2944
+ function $t(e) {
2945
+ if (e.getLastEditEnd)
2946
+ return e.getLastEditEnd();
2947
+ for (var t = (
2948
+ /**@type{any}*/
2949
+ e.doc.history.done
2950
+ ), r = t.length; r--; )
2951
+ if (t[r].changes)
2952
+ return V(t[r].changes[0].to);
2953
+ }
2954
+ class Zr {
2955
+ constructor() {
2956
+ this.commandMap_, this.buildCommandMap_();
2957
+ }
2958
+ /**
2959
+ * @arg {CodeMirrorV} cm
2960
+ * @arg {string} input
2961
+ * @arg {{ callback: () => void; } | undefined} [opt_params]
2962
+ */
2963
+ processCommand(t, r, n) {
2964
+ var i = this;
2965
+ t.operation(function() {
2966
+ t.curOp && (t.curOp.isVimOp = !0), i._processCommand(t, r, n);
2967
+ });
2968
+ }
2969
+ /**
2970
+ * @arg {CodeMirrorV} cm
2971
+ * @arg {string} input
2972
+ * @arg {{ callback?: () => void; input?: string, line?: string, commandName?: string } } [opt_params]
2973
+ */
2974
+ _processCommand(t, r, n) {
2975
+ var i = t.state.vim, a = T.registerController.getRegister(":"), s = a.toString(), l = new f.StringStream(r);
2976
+ a.setText(r);
2977
+ var u = n || {};
2978
+ u.input = r;
2979
+ try {
2980
+ this.parseInput_(t, l, u);
2981
+ } catch (g) {
2982
+ throw K(t, g + ""), g;
2983
+ }
2984
+ i.visualMode && Se(t);
2985
+ var d, h;
2986
+ if (!u.commandName)
2987
+ u.line !== void 0 && (h = "move");
2988
+ else if (d = this.matchCommand_(u.commandName), d) {
2989
+ if (h = d.name, d.excludeFromCommandHistory && a.setText(s), this.parseCommandArgs_(l, u, d), d.type == "exToKey") {
2990
+ $e(t, d.toKeys || "", d);
2991
+ return;
2992
+ } else if (d.type == "exToEx") {
2993
+ this.processCommand(t, d.toInput || "");
2994
+ return;
2995
+ }
2996
+ }
2997
+ if (!h) {
2998
+ K(t, 'Not an editor command ":' + r + '"');
2999
+ return;
3000
+ }
3001
+ try {
3002
+ Wt[h](t, u), (!d || !d.possiblyAsync) && u.callback && u.callback();
3003
+ } catch (g) {
3004
+ throw K(t, g + ""), g;
3005
+ }
3006
+ }
3007
+ /**
3008
+ * @param {CodeMirrorV} cm
3009
+ * @param {import("@codemirror/language").StringStream} inputStream
3010
+ * @param {{ callback?: (() => void) | undefined; input?: string | undefined; line?: any; commandName?: any; lineEnd?: any; selectionLine?: any; selectionLineEnd?: any; }} result
3011
+ */
3012
+ parseInput_(t, r, n) {
3013
+ var a, s;
3014
+ r.eatWhile(":"), r.eat("%") ? (n.line = t.firstLine(), n.lineEnd = t.lastLine()) : (n.line = this.parseLineSpec_(t, r), n.line !== void 0 && r.eat(",") && (n.lineEnd = this.parseLineSpec_(t, r))), n.line == null ? t.state.vim.visualMode ? (n.selectionLine = (a = Ge(t, t.state.vim, "<")) == null ? void 0 : a.line, n.selectionLineEnd = (s = Ge(t, t.state.vim, ">")) == null ? void 0 : s.line) : n.selectionLine = t.getCursor().line : (n.selectionLine = n.line, n.selectionLineEnd = n.lineEnd);
3015
+ var i = r.match(/^(\w+|!!|@@|[!#&*<=>@~])/);
3016
+ return i ? n.commandName = i[1] : n.commandName = (r.match(/.*/) || [""])[0], n;
3017
+ }
3018
+ /**
3019
+ * @param {CodeMirrorV} cm
3020
+ * @param {import("@codemirror/language").StringStream} inputStream
3021
+ */
3022
+ parseLineSpec_(t, r) {
3023
+ var n = r.match(/^(\d+)/);
3024
+ if (n)
3025
+ return parseInt(n[1], 10) - 1;
3026
+ switch (r.next()) {
3027
+ case ".":
3028
+ return this.parseLineSpecOffset_(r, t.getCursor().line);
3029
+ case "$":
3030
+ return this.parseLineSpecOffset_(r, t.lastLine());
3031
+ case "'":
3032
+ var i = r.next() || "", a = Ge(t, t.state.vim, i);
3033
+ if (!a) throw new Error("Mark not set");
3034
+ return this.parseLineSpecOffset_(r, a.line);
3035
+ case "-":
3036
+ case "+":
3037
+ return r.backUp(1), this.parseLineSpecOffset_(r, t.getCursor().line);
3038
+ default:
3039
+ r.backUp(1);
3040
+ return;
3041
+ }
3042
+ }
3043
+ /**
3044
+ * @param {string | import("@codemirror/language").StringStream} inputStream
3045
+ * @param {number} line
3046
+ */
3047
+ parseLineSpecOffset_(t, r) {
3048
+ var n = t.match(/^([+-])?(\d+)/);
3049
+ if (n) {
3050
+ var i = parseInt(n[2], 10);
3051
+ n[1] == "-" ? r -= i : r += i;
3052
+ }
3053
+ return r;
3054
+ }
3055
+ /**
3056
+ * @param {import("@codemirror/language").StringStream} inputStream
3057
+ * @param {import("./types").exCommandArgs} params
3058
+ * @param {import("./types").exCommandDefinition} command
3059
+ */
3060
+ parseCommandArgs_(t, r, n) {
3061
+ var s;
3062
+ if (!t.eol()) {
3063
+ r.argString = (s = t.match(/.*/)) == null ? void 0 : s[0];
3064
+ var i = n.argDelimiter || /\s+/, a = nt(r.argString || "").split(i);
3065
+ a.length && a[0] && (r.args = a);
3066
+ }
3067
+ }
3068
+ /**
3069
+ * @arg {string} commandName
3070
+ */
3071
+ matchCommand_(t) {
3072
+ for (var r = t.length; r > 0; r--) {
3073
+ var n = t.substring(0, r);
3074
+ if (this.commandMap_[n]) {
3075
+ var i = this.commandMap_[n];
3076
+ if (i.name.indexOf(t) === 0)
3077
+ return i;
3078
+ }
3079
+ }
3080
+ }
3081
+ buildCommandMap_() {
3082
+ this.commandMap_ = {};
3083
+ for (var t = 0; t < L.length; t++) {
3084
+ var r = L[t], n = r.shortName || r.name;
3085
+ this.commandMap_[n] = r;
3086
+ }
3087
+ }
3088
+ /**@type {(lhs: string, rhs: string, ctx: string|void, noremap?: boolean) => void} */
3089
+ map(t, r, n, i) {
3090
+ if (t != ":" && t.charAt(0) == ":") {
3091
+ if (n)
3092
+ throw Error("Mode not supported for ex mappings");
3093
+ var a = t.substring(1);
3094
+ r != ":" && r.charAt(0) == ":" ? this.commandMap_[a] = {
3095
+ name: a,
3096
+ type: "exToEx",
3097
+ toInput: r.substring(1),
3098
+ user: !0
3099
+ } : this.commandMap_[a] = {
3100
+ name: a,
3101
+ type: "exToKey",
3102
+ toKeys: r,
3103
+ user: !0
3104
+ };
3105
+ } else {
3106
+ var s = {
3107
+ keys: t,
3108
+ type: "keyToKey",
3109
+ toKeys: r,
3110
+ noremap: !!i
3111
+ };
3112
+ n && (s.context = n), ut(s);
3113
+ }
3114
+ }
3115
+ /**@type {(lhs: string, ctx: string) => boolean|void} */
3116
+ unmap(t, r) {
3117
+ if (t != ":" && t.charAt(0) == ":") {
3118
+ if (r)
3119
+ throw Error("Mode not supported for ex mappings");
3120
+ var n = t.substring(1);
3121
+ if (this.commandMap_[n] && this.commandMap_[n].user)
3122
+ return delete this.commandMap_[n], !0;
3123
+ } else
3124
+ for (var i = t, a = 0; a < p.length; a++)
3125
+ if (i == p[a].keys && p[a].context === r)
3126
+ return p.splice(a, 1), rn(i), !0;
3127
+ }
3128
+ }
3129
+ var Wt = {
3130
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3131
+ colorscheme: function(e, t) {
3132
+ if (!t.args || t.args.length < 1) {
3133
+ K(e, e.getOption("theme"));
3134
+ return;
3135
+ }
3136
+ e.setOption("theme", t.args[0]);
3137
+ },
3138
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params @arg {'insert'|'normal'|string} [ctx] @arg {boolean} [defaultOnly]*/
3139
+ map: function(e, t, r, n) {
3140
+ var i = t.args;
3141
+ if (!i || i.length < 2) {
3142
+ e && K(e, "Invalid mapping: " + t.input);
3143
+ return;
3144
+ }
3145
+ se.map(i[0], i[1], r, n);
3146
+ },
3147
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3148
+ imap: function(e, t) {
3149
+ this.map(e, t, "insert");
3150
+ },
3151
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3152
+ nmap: function(e, t) {
3153
+ this.map(e, t, "normal");
3154
+ },
3155
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3156
+ vmap: function(e, t) {
3157
+ this.map(e, t, "visual");
3158
+ },
3159
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3160
+ omap: function(e, t) {
3161
+ this.map(e, t, "operatorPending");
3162
+ },
3163
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3164
+ noremap: function(e, t) {
3165
+ this.map(e, t, void 0, !0);
3166
+ },
3167
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3168
+ inoremap: function(e, t) {
3169
+ this.map(e, t, "insert", !0);
3170
+ },
3171
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3172
+ nnoremap: function(e, t) {
3173
+ this.map(e, t, "normal", !0);
3174
+ },
3175
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3176
+ vnoremap: function(e, t) {
3177
+ this.map(e, t, "visual", !0);
3178
+ },
3179
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3180
+ onoremap: function(e, t) {
3181
+ this.map(e, t, "operatorPending", !0);
3182
+ },
3183
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params @arg {string} ctx*/
3184
+ unmap: function(e, t, r) {
3185
+ var n = t.args;
3186
+ (!n || n.length < 1 || !se.unmap(n[0], r)) && e && K(e, "No such mapping: " + t.input);
3187
+ },
3188
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3189
+ mapclear: function(e, t) {
3190
+ ue.mapclear();
3191
+ },
3192
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3193
+ imapclear: function(e, t) {
3194
+ ue.mapclear("insert");
3195
+ },
3196
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3197
+ nmapclear: function(e, t) {
3198
+ ue.mapclear("normal");
3199
+ },
3200
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3201
+ vmapclear: function(e, t) {
3202
+ ue.mapclear("visual");
3203
+ },
3204
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3205
+ omapclear: function(e, t) {
3206
+ ue.mapclear("operatorPending");
3207
+ },
3208
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3209
+ move: function(e, t) {
3210
+ Oe.processCommand(e, e.state.vim, {
3211
+ keys: "",
3212
+ type: "motion",
3213
+ motion: "moveToLineOrEdgeOfDocument",
3214
+ motionArgs: { forward: !1, explicitRepeat: !0, linewise: !0 },
3215
+ repeatOverride: t.line + 1
3216
+ });
3217
+ },
3218
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3219
+ set: function(e, t) {
3220
+ var r = t.args, n = t.setCfg || {};
3221
+ if (!r || r.length < 1) {
3222
+ e && K(e, "Invalid mapping: " + t.input);
3223
+ return;
3224
+ }
3225
+ var i = r[0].split("="), a = i.shift() || "", s = i.length > 0 ? i.join("=") : void 0, l = !1, u = !1;
3226
+ if (a.charAt(a.length - 1) == "?") {
3227
+ if (s)
3228
+ throw Error("Trailing characters: " + t.argString);
3229
+ a = a.substring(0, a.length - 1), l = !0;
3230
+ } else a.charAt(a.length - 1) == "!" && (a = a.substring(0, a.length - 1), u = !0);
3231
+ s === void 0 && a.substring(0, 2) == "no" && (a = a.substring(2), s = !1);
3232
+ var d = Le[a] && Le[a].type == "boolean";
3233
+ if (d && (u ? s = !le(a, e, n) : s == null && (s = !0)), !d && s === void 0 || l) {
3234
+ var h = le(a, e, n);
3235
+ h instanceof Error ? K(e, h.message) : h === !0 || h === !1 ? K(e, " " + (h ? "" : "no") + a) : K(e, " " + a + "=" + h);
3236
+ } else {
3237
+ var g = Je(a, s, e, n);
3238
+ g instanceof Error && K(e, g.message);
3239
+ }
3240
+ },
3241
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3242
+ setlocal: function(e, t) {
3243
+ t.setCfg = { scope: "local" }, this.set(e, t);
3244
+ },
3245
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3246
+ setglobal: function(e, t) {
3247
+ t.setCfg = { scope: "global" }, this.set(e, t);
3248
+ },
3249
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3250
+ registers: function(e, t) {
3251
+ var r = t.args, n = T.registerController.registers, i = `----------Registers----------
3252
+
3253
+ `;
3254
+ if (r)
3255
+ for (var l = r.join(""), u = 0; u < l.length; u++) {
3256
+ var a = l.charAt(u);
3257
+ if (T.registerController.isValidRegister(a)) {
3258
+ var d = n[a] || new ke();
3259
+ i += '"' + a + " " + d.toString() + `
3260
+ `;
3261
+ }
3262
+ }
3263
+ else
3264
+ for (var a in n) {
3265
+ var s = n[a].toString();
3266
+ s.length && (i += '"' + a + " " + s + `
3267
+ `);
3268
+ }
3269
+ K(e, i, !0);
3270
+ },
3271
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3272
+ marks: function(e, t) {
3273
+ var r = t.args, n = e.state.vim.marks, i = `-----------Marks-----------
3274
+ mark line col
3275
+
3276
+ `;
3277
+ if (r)
3278
+ for (var l = r.join(""), u = 0; u < l.length; u++) {
3279
+ var a = l.charAt(u), s = n[a] && n[a].find();
3280
+ s && (i += a + " " + s.line + " " + s.ch + `
3281
+ `);
3282
+ }
3283
+ else
3284
+ for (var a in n) {
3285
+ var s = n[a] && n[a].find();
3286
+ s && (i += a + " " + s.line + " " + s.ch + `
3287
+ `);
3288
+ }
3289
+ K(e, i, !0);
3290
+ },
3291
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3292
+ sort: function(e, t) {
3293
+ var r, n, i, a, s;
3294
+ function l() {
3295
+ if (t.argString) {
3296
+ var P = new f.StringStream(t.argString);
3297
+ if (P.eat("!") && (r = !0), P.eol())
3298
+ return;
3299
+ if (!P.eatSpace())
3300
+ return "Invalid arguments";
3301
+ var O = P.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);
3302
+ if (!O || !P.eol())
3303
+ return "Invalid arguments";
3304
+ if (O[1]) {
3305
+ n = O[1].indexOf("i") != -1, i = O[1].indexOf("u") != -1;
3306
+ var $ = O[1].indexOf("d") != -1 || O[1].indexOf("n") != -1, de = O[1].indexOf("x") != -1, ee = O[1].indexOf("o") != -1;
3307
+ if (Number($) + Number(de) + Number(ee) > 1)
3308
+ return "Invalid arguments";
3309
+ a = $ && "decimal" || de && "hex" || ee && "octal";
3310
+ }
3311
+ O[2] && (s = new RegExp(O[2].substr(1, O[2].length - 2), n ? "i" : ""));
3312
+ }
3313
+ }
3314
+ var u = l();
3315
+ if (u) {
3316
+ K(e, u + ": " + t.argString);
3317
+ return;
3318
+ }
3319
+ var d = t.line || e.firstLine(), h = t.lineEnd || t.line || e.lastLine();
3320
+ if (d == h)
3321
+ return;
3322
+ var g = new o(d, 0), C = new o(h, te(e, h)), m = e.getRange(g, C).split(`
3323
+ `), v = a == "decimal" ? /(-?)([\d]+)/ : a == "hex" ? /(-?)(?:0x)?([0-9a-f]+)/i : a == "octal" ? /([0-7]+)/ : null, w = a == "decimal" ? 10 : a == "hex" ? 16 : a == "octal" ? 8 : void 0, S = [], A = [];
3324
+ if (a || s)
3325
+ for (var M = 0; M < m.length; M++) {
3326
+ var E = s ? m[M].match(s) : null;
3327
+ E && E[0] != "" ? S.push(E) : v && v.exec(m[M]) ? S.push(m[M]) : A.push(m[M]);
3328
+ }
3329
+ else
3330
+ A = m;
3331
+ function N(P, O) {
3332
+ if (r) {
3333
+ var $;
3334
+ $ = P, P = O, O = $;
3335
+ }
3336
+ n && (P = P.toLowerCase(), O = O.toLowerCase());
3337
+ var de = v && v.exec(P), ee = v && v.exec(O);
3338
+ if (!de || !ee)
3339
+ return P < O ? -1 : 1;
3340
+ var pe = parseInt((de[1] + de[2]).toLowerCase(), w), Ee = parseInt((ee[1] + ee[2]).toLowerCase(), w);
3341
+ return pe - Ee;
3342
+ }
3343
+ function R(P, O) {
3344
+ if (r) {
3345
+ var $;
3346
+ $ = P, P = O, O = $;
3347
+ }
3348
+ return n && (P[0] = P[0].toLowerCase(), O[0] = O[0].toLowerCase()), P[0] < O[0] ? -1 : 1;
3349
+ }
3350
+ if (S.sort(s ? R : N), s)
3351
+ for (var M = 0; M < S.length; M++)
3352
+ S[M] = S[M].input;
3353
+ else a || A.sort(N);
3354
+ if (m = r ? S.concat(A) : A.concat(S), i) {
3355
+ var U = m, J;
3356
+ m = [];
3357
+ for (var M = 0; M < U.length; M++)
3358
+ U[M] != J && m.push(U[M]), J = U[M];
3359
+ }
3360
+ e.replaceRange(m.join(`
3361
+ `), g, C);
3362
+ },
3363
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3364
+ vglobal: function(e, t) {
3365
+ this.global(e, t);
3366
+ },
3367
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3368
+ normal: function(e, t) {
3369
+ var r = !1, n = t.argString;
3370
+ if (n && n[0] == "!" && (n = n.slice(1), r = !0), n = n.trimStart(), !n) {
3371
+ K(e, "Argument is required.");
3372
+ return;
3373
+ }
3374
+ var i = t.line;
3375
+ if (typeof i == "number")
3376
+ for (var a = isNaN(t.lineEnd) ? i : t.lineEnd, s = i; s <= a; s++)
3377
+ e.setCursor(s, 0), $e(e, t.argString.trimStart(), { noremap: r }), e.state.vim.insertMode && Ae(e, !0);
3378
+ else
3379
+ $e(e, t.argString.trimStart(), { noremap: r }), e.state.vim.insertMode && Ae(e, !0);
3380
+ },
3381
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3382
+ global: function(e, t) {
3383
+ var r = t.argString;
3384
+ if (!r) {
3385
+ K(e, "Regular Expression missing from global");
3386
+ return;
3387
+ }
3388
+ var n = t.commandName[0] === "v";
3389
+ r[0] === "!" && t.commandName[0] === "g" && (n = !0, r = r.slice(1));
3390
+ var i = t.line !== void 0 ? t.line : e.firstLine(), a = t.lineEnd || t.line || e.lastLine(), s = Wr(r), l = r, u = "";
3391
+ if (s && s.length && (l = s[0], u = s.slice(1, s.length).join("/")), l)
3392
+ try {
3393
+ je(
3394
+ e,
3395
+ l,
3396
+ !0,
3397
+ !0
3398
+ /** smartCase */
3399
+ );
3400
+ } catch {
3401
+ K(e, "Invalid regex: " + l);
3402
+ return;
3403
+ }
3404
+ for (var d = ye(e).getQuery(), h = [], g = i; g <= a; g++) {
3405
+ var C = e.getLine(g), m = d.test(C);
3406
+ m !== n && h.push(u ? e.getLineHandle(g) : C);
3407
+ }
3408
+ if (!u) {
3409
+ K(e, h.join(`
3410
+ `));
3411
+ return;
3412
+ }
3413
+ var v = 0, w = function() {
3414
+ if (v < h.length) {
3415
+ var S = h[v++], A = e.getLineNumber(S);
3416
+ if (A == null) {
3417
+ w();
3418
+ return;
3419
+ }
3420
+ var M = A + 1 + u;
3421
+ se.processCommand(e, M, {
3422
+ callback: w
3423
+ });
3424
+ } else e.releaseLineHandles && e.releaseLineHandles();
3425
+ };
3426
+ w();
3427
+ },
3428
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3429
+ substitute: function(e, t) {
3430
+ if (!e.getSearchCursor)
3431
+ throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");
3432
+ var r = t.argString, n = r ? Kt(r, r[0]) : [], i = "", a = "", s, l, u, d = !1, h = !1;
3433
+ if (n && n.length)
3434
+ i = n[0], le("pcre") && i !== "" && (i = new RegExp(i).source), a = n[1], a !== void 0 && (le("pcre") ? a = Jr(a.replace(/([^\\])&/g, "$1$$&")) : a = Qr(a), T.lastSubstituteReplacePart = a), s = n[2] ? n[2].split(" ") : [];
3435
+ else if (r && r.length) {
3436
+ K(e, "Substitutions should be of the form :s/pattern/replace/");
3437
+ return;
3438
+ }
3439
+ if (s && (l = s[0], u = parseInt(s[1]), l && (l.indexOf("c") != -1 && (d = !0), l.indexOf("g") != -1 && (h = !0), le("pcre") ? i = i + "/" + l : i = i.replace(/\//g, "\\/") + "/" + l)), i)
3440
+ try {
3441
+ je(
3442
+ e,
3443
+ i,
3444
+ !0,
3445
+ !0
3446
+ /** smartCase */
3447
+ );
3448
+ } catch {
3449
+ K(e, "Invalid regex: " + i);
3450
+ return;
3451
+ }
3452
+ if (a = a || T.lastSubstituteReplacePart, a === void 0) {
3453
+ K(e, "No previous substitute regular expression");
3454
+ return;
3455
+ }
3456
+ var g = ye(e), C = g.getQuery(), m = t.line !== void 0 ? t.line : e.getCursor().line, v = t.lineEnd || m;
3457
+ m == e.firstLine() && v == e.lastLine() && (v = 1 / 0), u && (m = v, v = m + u - 1);
3458
+ var w = re(e, new o(m, 0)), S = e.getSearchCursor(C, w);
3459
+ en(e, d, h, m, v, S, C, a, t.callback);
3460
+ },
3461
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3462
+ startinsert: function(e, t) {
3463
+ $e(e, t.argString == "!" ? "A" : "i", {});
3464
+ },
3465
+ redo: f.commands.redo,
3466
+ undo: f.commands.undo,
3467
+ /** @arg {CodeMirrorV} cm */
3468
+ write: function(e) {
3469
+ f.commands.save ? f.commands.save(e) : e.save && e.save();
3470
+ },
3471
+ /** @arg {CodeMirrorV} cm */
3472
+ nohlsearch: function(e) {
3473
+ Fe(e);
3474
+ },
3475
+ /** @arg {CodeMirrorV} cm */
3476
+ yank: function(e) {
3477
+ var t = V(e.getCursor()), r = t.line, n = e.getLine(r);
3478
+ T.registerController.pushText(
3479
+ "0",
3480
+ "yank",
3481
+ n,
3482
+ !0,
3483
+ !0
3484
+ );
3485
+ },
3486
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3487
+ delete: function(e, t) {
3488
+ var r = t.selectionLine, n = isNaN(t.selectionLineEnd) ? r : t.selectionLineEnd;
3489
+ rt.delete(e, { linewise: !0 }, [
3490
+ {
3491
+ anchor: new o(r, 0),
3492
+ head: new o(n + 1, 0)
3493
+ }
3494
+ ]);
3495
+ },
3496
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3497
+ join: function(e, t) {
3498
+ var r = t.selectionLine, n = isNaN(t.selectionLineEnd) ? r : t.selectionLineEnd;
3499
+ e.setCursor(new o(r, 0)), De.joinLines(e, { repeat: n - r }, e.state.vim);
3500
+ },
3501
+ /** @arg {CodeMirrorV} cm @arg {ExParams} params*/
3502
+ delmarks: function(e, t) {
3503
+ if (!t.argString || !nt(t.argString)) {
3504
+ K(e, "Argument required");
3505
+ return;
3506
+ }
3507
+ for (var r = e.state.vim, n = new f.StringStream(nt(t.argString)); !n.eol(); ) {
3508
+ n.eatSpace();
3509
+ var i = n.pos;
3510
+ if (!n.match(/[a-zA-Z]/, !1)) {
3511
+ K(e, "Invalid argument: " + t.argString.substring(i));
3512
+ return;
3513
+ }
3514
+ var a = n.next();
3515
+ if (n.match("-", !0)) {
3516
+ if (!n.match(/[a-zA-Z]/, !1)) {
3517
+ K(e, "Invalid argument: " + t.argString.substring(i));
3518
+ return;
3519
+ }
3520
+ var s = a, l = n.next();
3521
+ if (s && l && ae(s) == ae(l)) {
3522
+ var u = s.charCodeAt(0), d = l.charCodeAt(0);
3523
+ if (u >= d) {
3524
+ K(e, "Invalid argument: " + t.argString.substring(i));
3525
+ return;
3526
+ }
3527
+ for (var h = 0; h <= d - u; h++) {
3528
+ var g = String.fromCharCode(u + h);
3529
+ delete r.marks[g];
3530
+ }
3531
+ } else {
3532
+ K(e, "Invalid argument: " + s + "-");
3533
+ return;
3534
+ }
3535
+ } else a && delete r.marks[a];
3536
+ }
3537
+ }
3538
+ }, se = new Zr();
3539
+ ue.defineEx("version", "ve", (e) => {
3540
+ K(e, "Codemirror-vim version: 6.3.0");
3541
+ });
3542
+ function en(e, t, r, n, i, a, s, l, u) {
3543
+ e.state.vim.exMode = !0;
3544
+ var d = !1, h = 0, g, C, m;
3545
+ function v() {
3546
+ e.operation(function() {
3547
+ for (; !d; )
3548
+ w(), A();
3549
+ M();
3550
+ });
3551
+ }
3552
+ function w() {
3553
+ var N = "", R = a.match || a.pos && a.pos.match;
3554
+ if (R)
3555
+ N = l.replace(/\$(\d{1,3}|[$&])/g, function(P, O) {
3556
+ if (O == "$") return "$";
3557
+ if (O == "&") return R[0];
3558
+ for (var $ = O; parseInt($) >= R.length && $.length > 0; )
3559
+ $ = $.slice(0, $.length - 1);
3560
+ return $ ? R[$] + O.slice($.length, O.length) : P;
3561
+ });
3562
+ else {
3563
+ var U = e.getRange(a.from(), a.to());
3564
+ N = U.replace(s, l);
3565
+ }
3566
+ var J = a.to().line;
3567
+ a.replace(N), C = a.to().line, i += C - J, m = C < J;
3568
+ }
3569
+ function S() {
3570
+ var N = g && V(a.to()), R = a.findNext();
3571
+ return R && !R[0] && N && he(a.from(), N) && (R = a.findNext()), R && h++, R;
3572
+ }
3573
+ function A() {
3574
+ for (; S() && Yr(a.from(), n, i); )
3575
+ if (!(!r && a.from().line == C && !m)) {
3576
+ e.scrollIntoView(a.from(), 30), e.setSelection(a.from(), a.to()), g = a.from(), d = !1;
3577
+ return;
3578
+ }
3579
+ d = !0;
3580
+ }
3581
+ function M(N) {
3582
+ if (N && N(), e.focus(), g) {
3583
+ e.setCursor(g);
3584
+ var R = e.state.vim;
3585
+ R.exMode = !1, R.lastHPos = R.lastHSPos = g.ch;
3586
+ }
3587
+ u ? u() : d && K(
3588
+ e,
3589
+ (h ? "Found " + h + " matches" : "No matches found") + " for pattern: " + s + (le("pcre") ? " (set nopcre to use Vim regexps)" : "")
3590
+ );
3591
+ }
3592
+ function E(N, R, U) {
3593
+ f.e_stop(N);
3594
+ var J = We(N);
3595
+ switch (J) {
3596
+ case "y":
3597
+ w(), A();
3598
+ break;
3599
+ case "n":
3600
+ A();
3601
+ break;
3602
+ case "a":
3603
+ var P = u;
3604
+ u = void 0, e.operation(v), u = P;
3605
+ break;
3606
+ case "l":
3607
+ w();
3608
+ case "q":
3609
+ case "<Esc>":
3610
+ case "<C-c>":
3611
+ case "<C-[>":
3612
+ M(U);
3613
+ break;
3614
+ }
3615
+ return d && M(U), !0;
3616
+ }
3617
+ if (A(), d) {
3618
+ K(e, "No matches for " + s + (le("pcre") ? " (set nopcre to use vim regexps)" : ""));
3619
+ return;
3620
+ }
3621
+ if (!t) {
3622
+ v(), u && u();
3623
+ return;
3624
+ }
3625
+ Xe(e, {
3626
+ prefix: me("span", "replace with ", me("strong", l), " (y/n/a/q/l)"),
3627
+ onKeyDown: E
3628
+ });
3629
+ }
3630
+ function Ae(e, t) {
3631
+ var r = e.state.vim, n = T.macroModeState, i = T.registerController.getRegister("."), a = n.isPlaying, s = n.lastInsertModeChanges;
3632
+ a || (e.off("change", jt), r.insertEnd && r.insertEnd.clear(), r.insertEnd = void 0, f.off(e.getInputField(), "keydown", Jt)), !a && r.insertModeRepeat && r.insertModeRepeat > 1 && (zt(
3633
+ e,
3634
+ r,
3635
+ r.insertModeRepeat - 1,
3636
+ !0
3637
+ /** repeatForInsert */
3638
+ ), r.lastEditInputState.repeatOverride = r.insertModeRepeat), delete r.insertModeRepeat, r.insertMode = !1, t || e.setCursor(e.getCursor().line, e.getCursor().ch - 1), e.setOption("keyMap", "vim"), e.setOption("disableInput", !0), e.toggleOverwrite(!1), i.setText(s.changes.join("")), f.signal(e, "vim-mode-change", { mode: "normal" }), n.isRecording && sn(n);
3639
+ }
3640
+ function ut(e) {
3641
+ p.unshift(e), e.keys && tn(e.keys);
3642
+ }
3643
+ function tn(e) {
3644
+ e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t) {
3645
+ t && (y[t] || (y[t] = 0), y[t]++);
3646
+ });
3647
+ }
3648
+ function rn(e) {
3649
+ e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t) {
3650
+ y[t] && y[t]--;
3651
+ });
3652
+ }
3653
+ function nn(e, t, r, n, i) {
3654
+ var a = { keys: e, type: t };
3655
+ a[t] = r, a[t + "Args"] = n;
3656
+ for (var s in i)
3657
+ a[s] = i[s];
3658
+ ut(a);
3659
+ }
3660
+ Be("insertModeEscKeysTimeout", 200, "number");
3661
+ function an(e, t, r, n) {
3662
+ var i = T.registerController.getRegister(n);
3663
+ if (n == ":") {
3664
+ i.keyBuffer[0] && se.processCommand(e, i.keyBuffer[0]), r.isPlaying = !1;
3665
+ return;
3666
+ }
3667
+ var a = i.keyBuffer, s = 0;
3668
+ r.isPlaying = !0, r.replaySearchQueries = i.searchQueries.slice(0);
3669
+ for (var l = 0; l < a.length; l++)
3670
+ for (var u = a[l], d, h, g = /<(?:[CSMA]-)*\w+>|./gi; d = g.exec(u); )
3671
+ if (h = d[0], ue.handleKey(e, h, "macro"), t.insertMode) {
3672
+ var C = i.insertModeChanges[s++].changes;
3673
+ T.macroModeState.lastInsertModeChanges.changes = C, Xt(e, C, 1), Ae(e);
3674
+ }
3675
+ r.isPlaying = !1;
3676
+ }
3677
+ function on(e, t) {
3678
+ if (!e.isPlaying) {
3679
+ var r = e.latestRegister, n = T.registerController.getRegister(r);
3680
+ n && n.pushText(t);
3681
+ }
3682
+ }
3683
+ function sn(e) {
3684
+ if (!e.isPlaying) {
3685
+ var t = e.latestRegister, r = T.registerController.getRegister(t);
3686
+ r && r.pushInsertModeChanges && r.pushInsertModeChanges(e.lastInsertModeChanges);
3687
+ }
3688
+ }
3689
+ function ln(e, t) {
3690
+ if (!e.isPlaying) {
3691
+ var r = e.latestRegister, n = T.registerController.getRegister(r);
3692
+ n && n.pushSearchQuery && n.pushSearchQuery(t);
3693
+ }
3694
+ }
3695
+ function jt(e, t) {
3696
+ var r = T.macroModeState, n = r.lastInsertModeChanges;
3697
+ if (!r.isPlaying)
3698
+ for (var i = e.state.vim; t; ) {
3699
+ if (n.expectCursorActivityForChange = !0, n.ignoreCount > 1)
3700
+ n.ignoreCount--;
3701
+ else if (t.origin == "+input" || t.origin == "paste" || t.origin === void 0) {
3702
+ var a = e.listSelections().length;
3703
+ a > 1 && (n.ignoreCount = a);
3704
+ var s = t.text.join(`
3705
+ `);
3706
+ if (n.maybeReset && (n.changes = [], n.maybeReset = !1), s)
3707
+ if (e.state.overwrite && !/\n/.test(s))
3708
+ n.changes.push([s]);
3709
+ else {
3710
+ if (s.length > 1) {
3711
+ var l = i && i.insertEnd && i.insertEnd.find(), u = e.getCursor();
3712
+ if (l && l.line == u.line) {
3713
+ var d = l.ch - u.ch;
3714
+ d > 0 && d < s.length && (n.changes.push([s, d]), s = "");
3715
+ }
3716
+ }
3717
+ s && n.changes.push(s);
3718
+ }
3719
+ }
3720
+ t = t.next;
3721
+ }
3722
+ }
3723
+ function Ut(e) {
3724
+ var i;
3725
+ var t = e.state.vim;
3726
+ if (t.insertMode) {
3727
+ var r = T.macroModeState;
3728
+ if (r.isPlaying)
3729
+ return;
3730
+ var n = r.lastInsertModeChanges;
3731
+ n.expectCursorActivityForChange ? n.expectCursorActivityForChange = !1 : (n.maybeReset = !0, t.insertEnd && t.insertEnd.clear(), t.insertEnd = e.setBookmark(e.getCursor(), { insertLeft: !0 }));
3732
+ } else (i = e.curOp) != null && i.isVimOp || Qt(e, t);
3733
+ }
3734
+ function Qt(e, t) {
3735
+ var r = e.getCursor("anchor"), n = e.getCursor("head");
3736
+ if (t.visualMode && !e.somethingSelected() ? Se(e, !1) : !t.visualMode && !t.insertMode && e.somethingSelected() && (t.visualMode = !0, t.visualLine = !1, f.signal(e, "vim-mode-change", { mode: "visual" })), t.visualMode) {
3737
+ var i = q(n, r) ? 0 : -1, a = q(n, r) ? -1 : 0;
3738
+ n = G(n, 0, i), r = G(r, 0, a), t.sel = {
3739
+ anchor: r,
3740
+ head: n
3741
+ }, be(e, t, "<", ne(n, r)), be(e, t, ">", Te(n, r));
3742
+ } else t.insertMode || (t.lastHPos = e.getCursor().ch);
3743
+ }
3744
+ function Jt(e) {
3745
+ var t = T.macroModeState, r = t.lastInsertModeChanges, n = f.keyName ? f.keyName(e) : e.key;
3746
+ n && (n.indexOf("Delete") != -1 || n.indexOf("Backspace") != -1) && (r.maybeReset && (r.changes = [], r.maybeReset = !1), r.changes.push(new et(n, e)));
3747
+ }
3748
+ function zt(e, t, r, n) {
3749
+ var i = T.macroModeState;
3750
+ i.isPlaying = !0;
3751
+ var a = t.lastEditActionCommand, s = t.inputState;
3752
+ function l() {
3753
+ a ? Oe.processAction(e, t, a) : Oe.evalInput(e, t);
3754
+ }
3755
+ function u(h) {
3756
+ if (i.lastInsertModeChanges.changes.length > 0) {
3757
+ h = t.lastEditActionCommand ? h : 1;
3758
+ var g = i.lastInsertModeChanges;
3759
+ Xt(e, g.changes, h);
3760
+ }
3761
+ }
3762
+ if (t.inputState = t.lastEditInputState, a && a.interlaceInsertRepeat)
3763
+ for (var d = 0; d < r; d++)
3764
+ l(), u(1);
3765
+ else
3766
+ n || l(), u(r);
3767
+ t.inputState = s, t.insertMode && !n && Ae(e), i.isPlaying = !1;
3768
+ }
3769
+ function qt(e, t) {
3770
+ f.lookupKey(t, "vim-insert", function(n) {
3771
+ return typeof n == "string" ? f.commands[n](e) : n(e), !0;
3772
+ });
3773
+ }
3774
+ function Xt(e, t, r) {
3775
+ var n = e.getCursor("head"), i = T.macroModeState.lastInsertModeChanges.visualBlock;
3776
+ i && (bt(e, n, i + 1), r = e.listSelections().length, e.setCursor(n));
3777
+ for (var a = 0; a < r; a++) {
3778
+ i && e.setCursor(G(n, a, 0));
3779
+ for (var s = 0; s < t.length; s++) {
3780
+ var l = t[s];
3781
+ if (l instanceof et)
3782
+ qt(e, l.keyName);
3783
+ else if (typeof l == "string")
3784
+ e.replaceSelection(l);
3785
+ else {
3786
+ var u = e.getCursor(), d = G(u, 0, l[0].length - (l[1] || 0));
3787
+ e.replaceRange(l[0], u, l[1] ? u : d), e.setCursor(d);
3788
+ }
3789
+ }
3790
+ }
3791
+ i && e.setCursor(G(n, 0, 1));
3792
+ }
3793
+ function ft(e) {
3794
+ var t = new e.constructor();
3795
+ return Object.keys(e).forEach(function(r) {
3796
+ if (r != "insertEnd") {
3797
+ var n = e[r];
3798
+ Array.isArray(n) ? n = n.slice() : n && typeof n == "object" && n.constructor != Object && (n = ft(n)), t[r] = n;
3799
+ }
3800
+ }), e.sel && (t.sel = {
3801
+ head: e.sel.head && V(e.sel.head),
3802
+ anchor: e.sel.anchor && V(e.sel.anchor)
3803
+ }), t;
3804
+ }
3805
+ function un(e, t, r) {
3806
+ var a = Ne(e), n = (
3807
+ /**@type {CodeMirrorV}*/
3808
+ e
3809
+ ), i = !1, a = ue.maybeInitVimState_(n), s = a.visualBlock || a.wasInVisualBlock;
3810
+ if (n.state.closeVimNotification) {
3811
+ var l = n.state.closeVimNotification;
3812
+ if (n.state.closeVimNotification = null, l(), t == "<CR>")
3813
+ return Y(n), !0;
3814
+ }
3815
+ var u = n.isInMultiSelectMode();
3816
+ if (a.wasInVisualBlock && !u ? a.wasInVisualBlock = !1 : u && a.visualBlock && (a.wasInVisualBlock = !0), t == "<Esc>" && !a.insertMode && !a.visualMode && u && a.status == "<Esc>")
3817
+ Y(n);
3818
+ else if (s || !u || n.inVirtualSelectionMode)
3819
+ i = ue.handleKey(n, t, r);
3820
+ else {
3821
+ var d = ft(a), h = a.inputState.changeQueueList || [];
3822
+ n.operation(function() {
3823
+ var C;
3824
+ n.curOp && (n.curOp.isVimOp = !0);
3825
+ var g = 0;
3826
+ n.forEachSelection(function() {
3827
+ n.state.vim.inputState.changeQueue = h[g];
3828
+ var m = n.getCursor("head"), v = n.getCursor("anchor"), w = q(m, v) ? 0 : -1, S = q(m, v) ? -1 : 0;
3829
+ m = G(m, 0, w), v = G(v, 0, S), n.state.vim.sel.head = m, n.state.vim.sel.anchor = v, i = ue.handleKey(n, t, r), n.virtualSelection && (h[g] = n.state.vim.inputState.changeQueue, n.state.vim = ft(d)), g++;
3830
+ }), (C = n.curOp) != null && C.cursorActivity && !i && (n.curOp.cursorActivity = !1), n.state.vim = a, a.inputState.changeQueueList = h, a.inputState.changeQueue = null;
3831
+ }, !0);
3832
+ }
3833
+ return i && !a.visualMode && !a.insertMode && a.visualMode != n.somethingSelected() && Qt(n, a), i;
3834
+ }
3835
+ return yt(), ue;
3836
+ }
3837
+ function fe(f, o) {
3838
+ var c = o.ch, p = o.line + 1;
3839
+ p < 1 && (p = 1, c = 0), p > f.lines && (p = f.lines, c = Number.MAX_VALUE);
3840
+ var y = f.line(p);
3841
+ return Math.min(y.from + Math.max(0, c), y.to);
3842
+ }
3843
+ function ve(f, o) {
3844
+ let c = f.lineAt(o);
3845
+ return { line: c.number - 1, ch: o - c.from };
3846
+ }
3847
+ class Me {
3848
+ constructor(o, c) {
3849
+ this.line = o, this.ch = c;
3850
+ }
3851
+ }
3852
+ function ar(f, o, c) {
3853
+ if (f.addEventListener)
3854
+ f.addEventListener(o, c, !1);
3855
+ else {
3856
+ var p = f._handlers || (f._handlers = {});
3857
+ p[o] = (p[o] || []).concat(c);
3858
+ }
3859
+ }
3860
+ function or(f, o, c) {
3861
+ if (f.removeEventListener)
3862
+ f.removeEventListener(o, c, !1);
3863
+ else {
3864
+ var p = f._handlers, y = p && p[o];
3865
+ if (y) {
3866
+ var k = y.indexOf(c);
3867
+ k > -1 && (p[o] = y.slice(0, k).concat(y.slice(k + 1)));
3868
+ }
3869
+ }
3870
+ }
3871
+ function sr(f, o, ...c) {
3872
+ var p, y = (p = f._handlers) === null || p === void 0 ? void 0 : p[o];
3873
+ if (y)
3874
+ for (var k = 0; k < y.length; ++k)
3875
+ y[k](...c);
3876
+ }
3877
+ function Zt(f, ...o) {
3878
+ if (f)
3879
+ for (var c = 0; c < f.length; ++c)
3880
+ f[c](...o);
3881
+ }
3882
+ let pt;
3883
+ try {
3884
+ pt = /* @__PURE__ */ new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]", "u");
3885
+ } catch {
3886
+ pt = /[\w]/;
3887
+ }
3888
+ function Qe(f, o) {
3889
+ var c = f.cm6;
3890
+ if (!c.state.readOnly) {
3891
+ var p = "input.type.compose";
3892
+ if (f.curOp && (f.curOp.lastChange || (p = "input.type.compose.start")), o.annotations)
3893
+ try {
3894
+ o.annotations.some(function(y) {
3895
+ y.value == "input" && (y.value = p);
3896
+ });
3897
+ } catch (y) {
3898
+ console.error(y);
3899
+ }
3900
+ else
3901
+ o.userEvent = p;
3902
+ return c.dispatch(o);
3903
+ }
3904
+ }
3905
+ function er(f, o) {
3906
+ var c;
3907
+ f.curOp && (f.curOp.$changeStart = void 0), (o ? En : Rn)(f.cm6);
3908
+ let p = (c = f.curOp) === null || c === void 0 ? void 0 : c.$changeStart;
3909
+ p != null && f.cm6.dispatch({ selection: { anchor: p } });
3910
+ }
3911
+ var Bn = {
3912
+ Left: (f) => He(f.cm6, { key: "Left" }, "editor"),
3913
+ Right: (f) => He(f.cm6, { key: "Right" }, "editor"),
3914
+ Up: (f) => He(f.cm6, { key: "Up" }, "editor"),
3915
+ Down: (f) => He(f.cm6, { key: "Down" }, "editor"),
3916
+ Backspace: (f) => He(f.cm6, { key: "Backspace" }, "editor"),
3917
+ Delete: (f) => He(f.cm6, { key: "Delete" }, "editor")
3918
+ };
3919
+ class I {
3920
+ // --------------------------
3921
+ openDialog(o, c, p) {
3922
+ return Pn(this, o, c, p);
3923
+ }
3924
+ openNotification(o, c) {
3925
+ return Nn(this, o, c);
3926
+ }
3927
+ constructor(o) {
3928
+ this.state = {}, this.marks = /* @__PURE__ */ Object.create(null), this.$mid = 0, this.options = {}, this._handlers = {}, this.$lastChangeEndOffset = 0, this.virtualSelection = null, this.cm6 = o, this.onChange = this.onChange.bind(this), this.onSelectionChange = this.onSelectionChange.bind(this);
3929
+ }
3930
+ on(o, c) {
3931
+ ar(this, o, c);
3932
+ }
3933
+ off(o, c) {
3934
+ or(this, o, c);
3935
+ }
3936
+ signal(o, c, p) {
3937
+ sr(this, o, c, p);
3938
+ }
3939
+ indexFromPos(o) {
3940
+ return fe(this.cm6.state.doc, o);
3941
+ }
3942
+ posFromIndex(o) {
3943
+ return ve(this.cm6.state.doc, o);
3944
+ }
3945
+ foldCode(o) {
3946
+ let c = this.cm6, p = c.state.selection.ranges, y = this.cm6.state.doc, k = fe(y, o), L = Ce.create([Ce.range(k, k)], 0).ranges;
3947
+ c.state.selection.ranges = L, vn(c), c.state.selection.ranges = p;
3948
+ }
3949
+ firstLine() {
3950
+ return 0;
3951
+ }
3952
+ lastLine() {
3953
+ return this.cm6.state.doc.lines - 1;
3954
+ }
3955
+ lineCount() {
3956
+ return this.cm6.state.doc.lines;
3957
+ }
3958
+ setCursor(o, c) {
3959
+ typeof o == "object" && (c = o.ch, o = o.line);
3960
+ var p = fe(this.cm6.state.doc, { line: o, ch: c || 0 });
3961
+ this.cm6.dispatch({ selection: { anchor: p } }, { scrollIntoView: !this.curOp }), this.curOp && !this.curOp.isVimOp && this.onBeforeEndOperation();
3962
+ }
3963
+ getCursor(o) {
3964
+ var c = this.cm6.state.selection.main, p = o == "head" || !o ? c.head : o == "anchor" ? c.anchor : o == "start" ? c.from : o == "end" ? c.to : null;
3965
+ if (p == null)
3966
+ throw new Error("Invalid cursor type");
3967
+ return this.posFromIndex(p);
3968
+ }
3969
+ listSelections() {
3970
+ var o = this.cm6.state.doc;
3971
+ return this.cm6.state.selection.ranges.map((c) => ({
3972
+ anchor: ve(o, c.anchor),
3973
+ head: ve(o, c.head)
3974
+ }));
3975
+ }
3976
+ setSelections(o, c) {
3977
+ var p = this.cm6.state.doc, y = o.map((k) => {
3978
+ var L = fe(p, k.head), x = fe(p, k.anchor);
3979
+ return L == x ? Ce.cursor(L, 1) : Ce.range(x, L);
3980
+ });
3981
+ this.cm6.dispatch({
3982
+ selection: Ce.create(y, c)
3983
+ });
3984
+ }
3985
+ setSelection(o, c, p) {
3986
+ this.setSelections([{ anchor: o, head: c }], 0), p && p.origin == "*mouse" && this.onBeforeEndOperation();
3987
+ }
3988
+ getLine(o) {
3989
+ var c = this.cm6.state.doc;
3990
+ return o < 0 || o >= c.lines ? "" : this.cm6.state.doc.line(o + 1).text;
3991
+ }
3992
+ getLineHandle(o) {
3993
+ return this.$lineHandleChanges || (this.$lineHandleChanges = []), { row: o, index: this.indexFromPos(new Me(o, 0)) };
3994
+ }
3995
+ getLineNumber(o) {
3996
+ var c = this.$lineHandleChanges;
3997
+ if (!c)
3998
+ return null;
3999
+ for (var p = o.index, y = 0; y < c.length; y++)
4000
+ if (p = c[y].changes.mapPos(p, 1, rr.TrackAfter), p == null)
4001
+ return null;
4002
+ var k = this.posFromIndex(p);
4003
+ return k.ch == 0 ? k.line : null;
4004
+ }
4005
+ releaseLineHandles() {
4006
+ this.$lineHandleChanges = void 0;
4007
+ }
4008
+ getRange(o, c) {
4009
+ var p = this.cm6.state.doc;
4010
+ return this.cm6.state.sliceDoc(fe(p, o), fe(p, c));
4011
+ }
4012
+ replaceRange(o, c, p, y) {
4013
+ p || (p = c);
4014
+ var k = this.cm6.state.doc, L = fe(k, c), x = fe(k, p);
4015
+ Qe(this, { changes: { from: L, to: x, insert: o } });
4016
+ }
4017
+ replaceSelection(o) {
4018
+ Qe(this, this.cm6.state.replaceSelection(o));
4019
+ }
4020
+ replaceSelections(o) {
4021
+ var c = this.cm6.state.selection.ranges, p = c.map((y, k) => ({ from: y.from, to: y.to, insert: o[k] || "" }));
4022
+ Qe(this, { changes: p });
4023
+ }
4024
+ getSelection() {
4025
+ return this.getSelections().join(`
4026
+ `);
4027
+ }
4028
+ getSelections() {
4029
+ var o = this.cm6;
4030
+ return o.state.selection.ranges.map((c) => o.state.sliceDoc(c.from, c.to));
4031
+ }
4032
+ somethingSelected() {
4033
+ return this.cm6.state.selection.ranges.some((o) => !o.empty);
4034
+ }
4035
+ getInputField() {
4036
+ return this.cm6.contentDOM;
4037
+ }
4038
+ clipPos(o) {
4039
+ var c = this.cm6.state.doc, p = o.ch, y = o.line + 1;
4040
+ y < 1 && (y = 1, p = 0), y > c.lines && (y = c.lines, p = Number.MAX_VALUE);
4041
+ var k = c.line(y);
4042
+ return p = Math.min(Math.max(0, p), k.to - k.from), new Me(y - 1, p);
4043
+ }
4044
+ getValue() {
4045
+ return this.cm6.state.doc.toString();
4046
+ }
4047
+ setValue(o) {
4048
+ var c = this.cm6;
4049
+ return c.dispatch({
4050
+ changes: { from: 0, to: c.state.doc.length, insert: o },
4051
+ selection: Ce.range(0, 0)
4052
+ });
4053
+ }
4054
+ focus() {
4055
+ return this.cm6.focus();
4056
+ }
4057
+ blur() {
4058
+ return this.cm6.contentDOM.blur();
4059
+ }
4060
+ defaultTextHeight() {
4061
+ return this.cm6.defaultLineHeight;
4062
+ }
4063
+ findMatchingBracket(o, c) {
4064
+ var p = this.cm6.state, y = fe(p.doc, o), k = Gt(p, y + 1, -1);
4065
+ return k && k.end ? { to: ve(p.doc, k.end.from) } : (k = Gt(p, y, 1), k && k.end ? { to: ve(p.doc, k.end.from) } : { to: void 0 });
4066
+ }
4067
+ scanForBracket(o, c, p, y) {
4068
+ return _n(this, o, c, p, y);
4069
+ }
4070
+ indentLine(o, c) {
4071
+ c ? this.indentMore() : this.indentLess();
4072
+ }
4073
+ indentMore() {
4074
+ Sn(this.cm6);
4075
+ }
4076
+ indentLess() {
4077
+ xn(this.cm6);
4078
+ }
4079
+ execCommand(o) {
4080
+ if (o == "indentAuto")
4081
+ I.commands.indentAuto(this);
4082
+ else if (o == "goLineLeft")
4083
+ Mn(this.cm6);
4084
+ else if (o == "goLineRight") {
4085
+ Ln(this.cm6);
4086
+ let c = this.cm6.state, p = c.selection.main.head;
4087
+ p < c.doc.length && c.sliceDoc(p, p + 1) !== `
4088
+ ` && bn(this.cm6);
4089
+ } else
4090
+ console.log(o + " is not implemented");
4091
+ }
4092
+ setBookmark(o, c) {
4093
+ var p = c != null && c.insertLeft ? 1 : -1, y = this.indexFromPos(o), k = new Vn(this, y, p);
4094
+ return k;
4095
+ }
4096
+ addOverlay({ query: o }) {
4097
+ let c = new kn({
4098
+ regexp: !0,
4099
+ search: o.source,
4100
+ caseSensitive: !/i/.test(o.flags)
4101
+ });
4102
+ if (c.valid) {
4103
+ c.forVim = !0, this.cm6Query = c;
4104
+ let p = dt.of(c);
4105
+ return this.cm6.dispatch({ effects: p }), c;
4106
+ }
4107
+ }
4108
+ removeOverlay(o) {
4109
+ if (!this.cm6Query)
4110
+ return;
4111
+ this.cm6Query.forVim = !1;
4112
+ let c = dt.of(this.cm6Query);
4113
+ this.cm6.dispatch({ effects: c });
4114
+ }
4115
+ getSearchCursor(o, c) {
4116
+ var p = this, y = null, k = null, L = !1;
4117
+ c.ch == null && (c.ch = Number.MAX_VALUE);
4118
+ var x = fe(p.cm6.state.doc, c), b = o.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g, function(B, _) {
4119
+ return _ || "\\" + B;
4120
+ });
4121
+ function F(B, _ = 0, Q = B.length) {
4122
+ return new wn(B, b, { ignoreCase: o.ignoreCase }, _, Q);
4123
+ }
4124
+ function D(B) {
4125
+ var _ = p.cm6.state.doc;
4126
+ if (B > _.length)
4127
+ return null;
4128
+ let Q = F(_, B).next();
4129
+ return Q.done ? null : Q.value;
4130
+ }
4131
+ var H = 1e4;
4132
+ function j(B, _) {
4133
+ var Q = p.cm6.state.doc;
4134
+ for (let W = 1; ; W++) {
4135
+ let z = Math.max(B, _ - W * H), ie = F(Q, z, _), ae = null;
4136
+ for (; !ie.next().done; )
4137
+ ae = ie.value;
4138
+ if (ae && (z == B || ae.from > z + 10))
4139
+ return ae;
4140
+ if (z == B)
4141
+ return null;
4142
+ }
4143
+ }
4144
+ return {
4145
+ findNext: function() {
4146
+ return this.find(!1);
4147
+ },
4148
+ findPrevious: function() {
4149
+ return this.find(!0);
4150
+ },
4151
+ find: function(B) {
4152
+ var _ = p.cm6.state.doc;
4153
+ if (B) {
4154
+ let Q = y ? L ? y.to - 1 : y.from : x;
4155
+ y = j(0, Q);
4156
+ } else {
4157
+ let Q = y ? L ? y.to + 1 : y.to : x;
4158
+ y = D(Q);
4159
+ }
4160
+ return k = y && {
4161
+ from: ve(_, y.from),
4162
+ to: ve(_, y.to),
4163
+ match: y.match
4164
+ }, L = y ? y.from == y.to : !1, y && y.match;
4165
+ },
4166
+ from: function() {
4167
+ return k == null ? void 0 : k.from;
4168
+ },
4169
+ to: function() {
4170
+ return k == null ? void 0 : k.to;
4171
+ },
4172
+ replace: function(B) {
4173
+ y && (Qe(p, {
4174
+ changes: { from: y.from, to: y.to, insert: B }
4175
+ }), y.to = y.from + B.length, k && (k.to = ve(p.cm6.state.doc, y.to)));
4176
+ },
4177
+ get match() {
4178
+ return k && k.match;
4179
+ }
4180
+ };
4181
+ }
4182
+ findPosV(o, c, p, y) {
4183
+ let { cm6: k } = this;
4184
+ const L = k.state.doc;
4185
+ let x = p == "page" ? k.dom.clientHeight : 0;
4186
+ const b = fe(L, o);
4187
+ let F = Ce.cursor(b, 1, void 0, y), D = Math.round(Math.abs(c));
4188
+ for (let j = 0; j < D; j++)
4189
+ p == "page" ? F = k.moveVertically(F, c > 0, x) : p == "line" && (F = k.moveVertically(F, c > 0));
4190
+ let H = ve(L, F.head);
4191
+ return (c < 0 && F.head == 0 && y != 0 && o.line == 0 && o.ch != 0 || c > 0 && F.head == L.length && H.ch != y && o.line == H.line) && (H.hitSide = !0), H;
4192
+ }
4193
+ charCoords(o, c) {
4194
+ var p = this.cm6.contentDOM.getBoundingClientRect(), y = fe(this.cm6.state.doc, o), k = this.cm6.coordsAtPos(y), L = -p.top;
4195
+ return { left: ((k == null ? void 0 : k.left) || 0) - p.left, top: ((k == null ? void 0 : k.top) || 0) + L, bottom: ((k == null ? void 0 : k.bottom) || 0) + L };
4196
+ }
4197
+ coordsChar(o, c) {
4198
+ var p = this.cm6.contentDOM.getBoundingClientRect(), y = this.cm6.posAtCoords({ x: o.left + p.left, y: o.top + p.top }) || 0;
4199
+ return ve(this.cm6.state.doc, y);
4200
+ }
4201
+ getScrollInfo() {
4202
+ var o = this.cm6.scrollDOM;
4203
+ return {
4204
+ left: o.scrollLeft,
4205
+ top: o.scrollTop,
4206
+ height: o.scrollHeight,
4207
+ width: o.scrollWidth,
4208
+ clientHeight: o.clientHeight,
4209
+ clientWidth: o.clientWidth
4210
+ };
4211
+ }
4212
+ scrollTo(o, c) {
4213
+ o != null && (this.cm6.scrollDOM.scrollLeft = o), c != null && (this.cm6.scrollDOM.scrollTop = c);
4214
+ }
4215
+ scrollIntoView(o, c) {
4216
+ if (o) {
4217
+ var p = this.indexFromPos(o);
4218
+ this.cm6.dispatch({
4219
+ effects: Ye.scrollIntoView(p)
4220
+ });
4221
+ } else
4222
+ this.cm6.dispatch({ scrollIntoView: !0, userEvent: "scroll" });
4223
+ }
4224
+ getWrapperElement() {
4225
+ return this.cm6.dom;
4226
+ }
4227
+ // for tests
4228
+ getMode() {
4229
+ return { name: this.getOption("mode") };
4230
+ }
4231
+ setSize(o, c) {
4232
+ this.cm6.dom.style.width = o + 4 + "px", this.cm6.dom.style.height = c + "px", this.refresh();
4233
+ }
4234
+ refresh() {
4235
+ this.cm6.measure();
4236
+ }
4237
+ // event listeners
4238
+ destroy() {
4239
+ this.removeOverlay();
4240
+ }
4241
+ getLastEditEnd() {
4242
+ return this.posFromIndex(this.$lastChangeEndOffset);
4243
+ }
4244
+ onChange(o) {
4245
+ this.$lineHandleChanges && this.$lineHandleChanges.push(o);
4246
+ for (let p in this.marks)
4247
+ this.marks[p].update(o.changes);
4248
+ this.virtualSelection && (this.virtualSelection.ranges = this.virtualSelection.ranges.map((p) => p.map(o.changes)));
4249
+ var c = this.curOp = this.curOp || {};
4250
+ o.changes.iterChanges((p, y, k, L, x) => {
4251
+ (c.$changeStart == null || c.$changeStart > k) && (c.$changeStart = k), this.$lastChangeEndOffset = L;
4252
+ var b = { text: x.toJSON() };
4253
+ c.lastChange ? c.lastChange.next = c.lastChange = b : c.lastChange = c.change = b;
4254
+ }, !0), c.changeHandlers || (c.changeHandlers = this._handlers.change && this._handlers.change.slice());
4255
+ }
4256
+ onSelectionChange() {
4257
+ var o = this.curOp = this.curOp || {};
4258
+ o.cursorActivityHandlers || (o.cursorActivityHandlers = this._handlers.cursorActivity && this._handlers.cursorActivity.slice()), this.curOp.cursorActivity = !0;
4259
+ }
4260
+ operation(o, c) {
4261
+ this.curOp || (this.curOp = { $d: 0 }), this.curOp.$d++;
4262
+ try {
4263
+ var p = o();
4264
+ } finally {
4265
+ this.curOp && (this.curOp.$d--, this.curOp.$d || this.onBeforeEndOperation());
4266
+ }
4267
+ return p;
4268
+ }
4269
+ onBeforeEndOperation() {
4270
+ var o = this.curOp, c = !1;
4271
+ o && (o.change && Zt(o.changeHandlers, this, o.change), o && o.cursorActivity && (Zt(o.cursorActivityHandlers, this, null), o.isVimOp && (c = !0)), this.curOp = null), c && this.scrollIntoView();
4272
+ }
4273
+ moveH(o, c) {
4274
+ if (c == "char") {
4275
+ var p = this.getCursor();
4276
+ this.setCursor(p.line, p.ch + o);
4277
+ }
4278
+ }
4279
+ setOption(o, c) {
4280
+ switch (o) {
4281
+ case "keyMap":
4282
+ this.state.keyMap = c;
4283
+ break;
4284
+ case "textwidth":
4285
+ this.state.textwidth = c;
4286
+ break;
4287
+ }
4288
+ }
4289
+ getOption(o) {
4290
+ switch (o) {
4291
+ case "firstLineNumber":
4292
+ return 1;
4293
+ case "tabSize":
4294
+ return this.cm6.state.tabSize || 4;
4295
+ case "readOnly":
4296
+ return this.cm6.state.readOnly;
4297
+ case "indentWithTabs":
4298
+ return this.cm6.state.facet(Yt) == " ";
4299
+ case "indentUnit":
4300
+ return this.cm6.state.facet(Yt).length || 2;
4301
+ case "textwidth":
4302
+ return this.state.textwidth;
4303
+ case "keyMap":
4304
+ return this.state.keyMap || "vim";
4305
+ }
4306
+ }
4307
+ toggleOverwrite(o) {
4308
+ this.state.overwrite = o;
4309
+ }
4310
+ getTokenTypeAt(o) {
4311
+ var c, p = this.indexFromPos(o), y = nr(this.cm6.state, p), k = y == null ? void 0 : y.resolve(p), L = ((c = k == null ? void 0 : k.type) === null || c === void 0 ? void 0 : c.name) || "";
4312
+ return /comment/i.test(L) ? "comment" : /string/i.test(L) ? "string" : "";
4313
+ }
4314
+ overWriteSelection(o) {
4315
+ var c = this.cm6.state.doc, p = this.cm6.state.selection, y = p.ranges.map((k) => {
4316
+ if (k.empty) {
4317
+ var L = k.to < c.length ? c.sliceString(k.from, k.to + 1) : "";
4318
+ if (L && !/\n/.test(L))
4319
+ return Ce.range(k.from, k.to + 1);
4320
+ }
4321
+ return k;
4322
+ });
4323
+ this.cm6.dispatch({
4324
+ selection: Ce.create(y, p.mainIndex)
4325
+ }), this.replaceSelection(o);
4326
+ }
4327
+ /*** multiselect ****/
4328
+ isInMultiSelectMode() {
4329
+ return this.cm6.state.selection.ranges.length > 1;
4330
+ }
4331
+ virtualSelectionMode() {
4332
+ return !!this.virtualSelection;
4333
+ }
4334
+ forEachSelection(o) {
4335
+ var c = this.cm6.state.selection;
4336
+ this.virtualSelection = Ce.create(c.ranges, c.mainIndex);
4337
+ for (var p = 0; p < this.virtualSelection.ranges.length; p++) {
4338
+ var y = this.virtualSelection.ranges[p];
4339
+ y && (this.cm6.dispatch({ selection: Ce.create([y]) }), o(), this.virtualSelection.ranges[p] = this.cm6.state.selection.ranges[0]);
4340
+ }
4341
+ this.cm6.dispatch({ selection: this.virtualSelection }), this.virtualSelection = null;
4342
+ }
4343
+ hardWrap(o) {
4344
+ return $n(this, o);
4345
+ }
4346
+ }
4347
+ I.isMac = typeof navigator < "u" && /* @__PURE__ */ /Mac/.test(navigator.platform);
4348
+ I.Pos = Me;
4349
+ I.StringStream = gn;
4350
+ I.commands = {
4351
+ cursorCharLeft: function(f) {
4352
+ On(f.cm6);
4353
+ },
4354
+ redo: function(f) {
4355
+ er(f, !1);
4356
+ },
4357
+ undo: function(f) {
4358
+ er(f, !0);
4359
+ },
4360
+ newlineAndIndent: function(f) {
4361
+ An({
4362
+ state: f.cm6.state,
4363
+ dispatch: (o) => Qe(f, o)
4364
+ });
4365
+ },
4366
+ indentAuto: function(f) {
4367
+ Tn(f.cm6);
4368
+ },
4369
+ newlineAndIndentContinueComment: void 0,
4370
+ save: void 0
4371
+ };
4372
+ I.isWordChar = function(f) {
4373
+ return pt.test(f);
4374
+ };
4375
+ I.keys = Bn;
4376
+ I.addClass = function(f, o) {
4377
+ };
4378
+ I.rmClass = function(f, o) {
4379
+ };
4380
+ I.e_preventDefault = function(f) {
4381
+ f.preventDefault();
4382
+ };
4383
+ I.e_stop = function(f) {
4384
+ var o, c;
4385
+ (o = f == null ? void 0 : f.stopPropagation) === null || o === void 0 || o.call(f), (c = f == null ? void 0 : f.preventDefault) === null || c === void 0 || c.call(f);
4386
+ };
4387
+ I.lookupKey = function(o, c, p) {
4388
+ var y = I.keys[o];
4389
+ !y && /^Arrow/.test(o) && (y = I.keys[o.slice(5)]), y && p(y);
4390
+ };
4391
+ I.on = ar;
4392
+ I.off = or;
4393
+ I.signal = sr;
4394
+ I.findMatchingTag = Fn;
4395
+ I.findEnclosingTag = Hn;
4396
+ I.keyName = void 0;
4397
+ function lr(f, o, c) {
4398
+ var p = document.createElement("div");
4399
+ return p.appendChild(o), p;
4400
+ }
4401
+ function ur(f, o) {
4402
+ f.state.currentNotificationClose && f.state.currentNotificationClose(), f.state.currentNotificationClose = o;
4403
+ }
4404
+ function Nn(f, o, c) {
4405
+ ur(f, x);
4406
+ var p = lr(f, o, c && c.bottom), y = !1, k, L = c && typeof c.duration < "u" ? c.duration : 5e3;
4407
+ function x() {
4408
+ y || (y = !0, clearTimeout(k), p.remove(), cr(f, p));
4409
+ }
4410
+ return p.onclick = function(b) {
4411
+ b.preventDefault(), x();
4412
+ }, fr(f, p), L && (k = setTimeout(x, L)), x;
4413
+ }
4414
+ function fr(f, o) {
4415
+ var c = f.state.dialog;
4416
+ f.state.dialog = o, o.style.flex = "1", o && c !== o && (c && c.contains(document.activeElement) && f.focus(), c && c.parentElement ? c.parentElement.replaceChild(o, c) : c && c.remove(), I.signal(f, "dialog"));
4417
+ }
4418
+ function cr(f, o) {
4419
+ f.state.dialog == o && (f.state.dialog = null, I.signal(f, "dialog"));
4420
+ }
4421
+ function Pn(f, o, c, p) {
4422
+ p || (p = {}), ur(f, void 0);
4423
+ var y = lr(f, o, p.bottom), k = !1;
4424
+ fr(f, y);
4425
+ function L(b) {
4426
+ if (typeof b == "string")
4427
+ x.value = b;
4428
+ else {
4429
+ if (k)
4430
+ return;
4431
+ k = !0, cr(f, y), f.state.dialog || f.focus(), p.onClose && p.onClose(y);
4432
+ }
4433
+ }
4434
+ var x = y.getElementsByTagName("input")[0];
4435
+ return x && (p.value && (x.value = p.value, p.selectValueOnOpen !== !1 && x.select()), p.onInput && I.on(x, "input", function(b) {
4436
+ p.onInput(b, x.value, L);
4437
+ }), p.onKeyUp && I.on(x, "keyup", function(b) {
4438
+ p.onKeyUp(b, x.value, L);
4439
+ }), I.on(x, "keydown", function(b) {
4440
+ p && p.onKeyDown && p.onKeyDown(b, x.value, L) || (b.keyCode == 13 && c && c(x.value), (b.keyCode == 27 || p.closeOnEnter !== !1 && b.keyCode == 13) && (x.blur(), I.e_stop(b), L()));
4441
+ }), p.closeOnBlur !== !1 && I.on(x, "blur", function() {
4442
+ setTimeout(function() {
4443
+ document.activeElement !== x && L();
4444
+ });
4445
+ }), x.focus()), L;
4446
+ }
4447
+ var Kn = { "(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<" };
4448
+ function Dn(f) {
4449
+ return f && f.bracketRegex || /[(){}[\]]/;
4450
+ }
4451
+ function _n(f, o, c, p, y) {
4452
+ for (var k = y && y.maxScanLineLength || 1e4, L = y && y.maxScanLines || 1e3, x = [], b = Dn(y), F = c > 0 ? Math.min(o.line + L, f.lastLine() + 1) : Math.max(f.firstLine() - 1, o.line - L), D = o.line; D != F; D += c) {
4453
+ var H = f.getLine(D);
4454
+ if (H) {
4455
+ var j = c > 0 ? 0 : H.length - 1, B = c > 0 ? H.length : -1;
4456
+ if (!(H.length > k))
4457
+ for (D == o.line && (j = o.ch - (c < 0 ? 1 : 0)); j != B; j += c) {
4458
+ var _ = H.charAt(j);
4459
+ if (b.test(_)) {
4460
+ var Q = Kn[_];
4461
+ if (Q && Q.charAt(1) == ">" == c > 0)
4462
+ x.push(_);
4463
+ else if (x.length)
4464
+ x.pop();
4465
+ else
4466
+ return { pos: new Me(D, j), ch: _ };
4467
+ }
4468
+ }
4469
+ }
4470
+ }
4471
+ return D - c == (c > 0 ? f.lastLine() : f.firstLine()) ? !1 : null;
4472
+ }
4473
+ function Fn(f, o) {
4474
+ return null;
4475
+ }
4476
+ function Hn(f, o) {
4477
+ var c, p, y = f.cm6.state, k = f.indexFromPos(o);
4478
+ if (k < y.doc.length) {
4479
+ var L = y.sliceDoc(k, k + 1);
4480
+ L == "<" && k++;
4481
+ }
4482
+ for (var x = nr(y, k), b = (x == null ? void 0 : x.resolve(k)) || null; b; ) {
4483
+ if (((c = b.firstChild) === null || c === void 0 ? void 0 : c.type.name) == "OpenTag" && ((p = b.lastChild) === null || p === void 0 ? void 0 : p.type.name) == "CloseTag")
4484
+ return {
4485
+ open: tr(y.doc, b.firstChild),
4486
+ close: tr(y.doc, b.lastChild)
4487
+ };
4488
+ b = b.parent;
4489
+ }
4490
+ }
4491
+ function tr(f, o) {
4492
+ return {
4493
+ from: ve(f, o.from),
4494
+ to: ve(f, o.to)
4495
+ };
4496
+ }
4497
+ class Vn {
4498
+ constructor(o, c, p) {
4499
+ this.cm = o, this.id = o.$mid++, this.offset = c, this.assoc = p, o.marks[this.id] = this;
4500
+ }
4501
+ clear() {
4502
+ delete this.cm.marks[this.id];
4503
+ }
4504
+ find() {
4505
+ return this.offset == null ? null : this.cm.posFromIndex(this.offset);
4506
+ }
4507
+ update(o) {
4508
+ this.offset != null && (this.offset = o.mapPos(this.offset, this.assoc, rr.TrackDel));
4509
+ }
4510
+ }
4511
+ function $n(f, o) {
4512
+ for (var c, p = o.column || f.getOption("textwidth") || 80, y = o.allowMerge != !1, k = Math.min(o.from, o.to), L = Math.max(o.from, o.to); k <= L; ) {
4513
+ var x = f.getLine(k);
4514
+ if (x.length > p) {
4515
+ var b = _(x, p, 5);
4516
+ if (b) {
4517
+ var F = (c = /^\s*/.exec(x)) === null || c === void 0 ? void 0 : c[0];
4518
+ f.replaceRange(`
4519
+ ` + F, new Me(k, b.start), new Me(k, b.end));
4520
+ }
4521
+ L++;
4522
+ } else if (y && /\S/.test(x) && k != L) {
4523
+ var D = f.getLine(k + 1);
4524
+ if (D && /\S/.test(D)) {
4525
+ var H = x.replace(/\s+$/, ""), j = D.replace(/^\s+/, ""), B = H + " " + j, b = _(B, p, 5);
4526
+ b && b.start > H.length || B.length < p ? (f.replaceRange(" ", new Me(k, H.length), new Me(k + 1, D.length - j.length)), k--, L--) : H.length < x.length && f.replaceRange("", new Me(k, H.length), new Me(k, x.length));
4527
+ }
4528
+ }
4529
+ k++;
4530
+ }
4531
+ return k;
4532
+ function _(Q, W, z) {
4533
+ if (!(Q.length < W)) {
4534
+ var ie = Q.slice(0, W), ae = Q.slice(W), ce = /^(?:(\s+)|(\S+)(\s+))/.exec(ae), oe = /(?:(\s+)|(\s+)(\S+))$/.exec(ie), ge = 0, Z = 0;
4535
+ if (oe && !oe[2] && (ge = W - oe[1].length, Z = W), ce && !ce[2] && (ge || (ge = W), Z = W + ce[1].length), ge)
4536
+ return {
4537
+ start: ge,
4538
+ end: Z
4539
+ };
4540
+ if (oe && oe[2] && oe.index > z)
4541
+ return {
4542
+ start: oe.index,
4543
+ end: oe.index + oe[2].length
4544
+ };
4545
+ if (ce && ce[2])
4546
+ return ge = W + ce[2].length, {
4547
+ start: ge,
4548
+ end: ge + ce[3].length
4549
+ };
4550
+ }
4551
+ }
4552
+ }
4553
+ let vt = mn || /* @__PURE__ */ function() {
4554
+ let f = { cursorBlinkRate: 1200 };
4555
+ return function() {
4556
+ return f;
4557
+ };
4558
+ }();
4559
+ class Wn {
4560
+ constructor(o, c, p, y, k, L, x, b, F, D) {
4561
+ this.left = o, this.top = c, this.height = p, this.fontFamily = y, this.fontSize = k, this.fontWeight = L, this.color = x, this.className = b, this.letter = F, this.partial = D;
4562
+ }
4563
+ draw() {
4564
+ let o = document.createElement("div");
4565
+ return o.className = this.className, this.adjust(o), o;
4566
+ }
4567
+ adjust(o) {
4568
+ o.style.left = this.left + "px", o.style.top = this.top + "px", o.style.height = this.height + "px", o.style.lineHeight = this.height + "px", o.style.fontFamily = this.fontFamily, o.style.fontSize = this.fontSize, o.style.fontWeight = this.fontWeight, o.style.color = this.partial ? "transparent" : this.color, o.className = this.className, o.textContent = this.letter;
4569
+ }
4570
+ eq(o) {
4571
+ return this.left == o.left && this.top == o.top && this.height == o.height && this.fontFamily == o.fontFamily && this.fontSize == o.fontSize && this.fontWeight == o.fontWeight && this.color == o.color && this.className == o.className && this.letter == o.letter;
4572
+ }
4573
+ }
4574
+ class jn {
4575
+ constructor(o, c) {
4576
+ this.view = o, this.rangePieces = [], this.cursors = [], this.cm = c, this.measureReq = { read: this.readPos.bind(this), write: this.drawSel.bind(this) }, this.cursorLayer = o.scrollDOM.appendChild(document.createElement("div")), this.cursorLayer.className = "cm-cursorLayer cm-vimCursorLayer", this.cursorLayer.setAttribute("aria-hidden", "true"), o.requestMeasure(this.measureReq), this.setBlinkRate();
4577
+ }
4578
+ setBlinkRate() {
4579
+ let c = vt(this.cm.cm6.state).cursorBlinkRate;
4580
+ this.cursorLayer.style.animationDuration = c + "ms";
4581
+ }
4582
+ update(o) {
4583
+ (o.selectionSet || o.geometryChanged || o.viewportChanged) && (this.view.requestMeasure(this.measureReq), this.cursorLayer.style.animationName = this.cursorLayer.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink"), Un(o) && this.setBlinkRate();
4584
+ }
4585
+ scheduleRedraw() {
4586
+ this.view.requestMeasure(this.measureReq);
4587
+ }
4588
+ readPos() {
4589
+ let { state: o } = this.view, c = [];
4590
+ for (let p of o.selection.ranges) {
4591
+ let y = p == o.selection.main, k = qn(this.cm, this.view, p, y);
4592
+ k && c.push(k);
4593
+ }
4594
+ return { cursors: c };
4595
+ }
4596
+ drawSel({ cursors: o }) {
4597
+ if (o.length != this.cursors.length || o.some((c, p) => !c.eq(this.cursors[p]))) {
4598
+ let c = this.cursorLayer.children;
4599
+ if (c.length !== o.length) {
4600
+ this.cursorLayer.textContent = "";
4601
+ for (const p of o)
4602
+ this.cursorLayer.appendChild(p.draw());
4603
+ } else
4604
+ o.forEach((p, y) => p.adjust(c[y]));
4605
+ this.cursors = o;
4606
+ }
4607
+ }
4608
+ destroy() {
4609
+ this.cursorLayer.remove();
4610
+ }
4611
+ }
4612
+ function Un(f) {
4613
+ return vt(f.startState) != vt(f.state);
4614
+ }
4615
+ const Qn = {
4616
+ ".cm-vimMode .cm-line": {
4617
+ "& ::selection": { backgroundColor: "transparent !important" },
4618
+ "&::selection": { backgroundColor: "transparent !important" },
4619
+ caretColor: "transparent !important"
4620
+ },
4621
+ ".cm-fat-cursor": {
4622
+ position: "absolute",
4623
+ background: "#ff9696",
4624
+ border: "none",
4625
+ whiteSpace: "pre"
4626
+ },
4627
+ "&:not(.cm-focused) .cm-fat-cursor": {
4628
+ background: "none",
4629
+ outline: "solid 1px #ff9696",
4630
+ color: "transparent !important"
4631
+ }
4632
+ }, Jn = /* @__PURE__ */ cn.highest(/* @__PURE__ */ Ye.theme(Qn));
4633
+ function zn(f) {
4634
+ let o = f.scrollDOM.getBoundingClientRect();
4635
+ return { left: (f.textDirection == Cn.LTR ? o.left : o.right - f.scrollDOM.clientWidth) - f.scrollDOM.scrollLeft * f.scaleX, top: o.top - f.scrollDOM.scrollTop * f.scaleY };
4636
+ }
4637
+ function qn(f, o, c, p) {
4638
+ var y, k, L, x;
4639
+ let b = c.head, F = !1, D = 1, H = f.state.vim;
4640
+ if (H && (!H.insertMode || f.state.overwrite)) {
4641
+ if (F = !0, H.visualBlock && !p)
4642
+ return null;
4643
+ c.anchor < c.head && (b < o.state.doc.length && o.state.sliceDoc(b, b + 1)) != `
4644
+ ` && b--, f.state.overwrite ? D = 0.2 : H.status && (D = 0.5);
4645
+ }
4646
+ if (F) {
4647
+ let B = b < o.state.doc.length && o.state.sliceDoc(b, b + 1);
4648
+ B && /[\uDC00-\uDFFF]/.test(B) && b > 1 && (b--, B = o.state.sliceDoc(b, b + 1));
4649
+ let _ = o.coordsAtPos(b, 1);
4650
+ if (!_)
4651
+ return null;
4652
+ let Q = zn(o), W = o.domAtPos(b), z = W ? W.node : o.contentDOM;
4653
+ for (z instanceof Text && W.offset >= z.data.length && !((y = z.parentElement) === null || y === void 0) && y.nextSibling && (z = (k = z.parentElement) === null || k === void 0 ? void 0 : k.nextSibling, W = { node: z, offset: 0 }); W && W.node instanceof HTMLElement; )
4654
+ z = W.node, W = { node: W.node.childNodes[W.offset], offset: 0 };
4655
+ if (!(z instanceof HTMLElement)) {
4656
+ if (!z.parentNode)
4657
+ return null;
4658
+ z = z.parentNode;
4659
+ }
4660
+ let ie = getComputedStyle(z), ae = _.left, ce = (x = (L = o).coordsForChar) === null || x === void 0 ? void 0 : x.call(L, b);
4661
+ if (ce && (ae = ce.left), !B || B == `
4662
+ ` || B == "\r")
4663
+ B = " ";
4664
+ else if (B == " ") {
4665
+ B = " ";
4666
+ var j = o.coordsAtPos(b + 1, -1);
4667
+ j && (ae = j.left - (j.left - _.left) / parseInt(ie.tabSize));
4668
+ } else /[\uD800-\uDBFF]/.test(B) && b < o.state.doc.length - 1 && (B += o.state.sliceDoc(b + 1, b + 2));
4669
+ let oe = _.bottom - _.top;
4670
+ return new Wn((ae - Q.left) / o.scaleX, (_.top - Q.top + oe * (1 - D)) / o.scaleY, oe * D / o.scaleY, ie.fontFamily, ie.fontSize, ie.fontWeight, ie.color, p ? "cm-fat-cursor cm-cursor-primary" : "cm-fat-cursor cm-cursor-secondary", B, D != 1);
4671
+ } else
4672
+ return null;
4673
+ }
4674
+ var Xn = typeof navigator < "u" && /* @__PURE__ */ /linux/i.test(navigator.platform) && /* @__PURE__ */ / Gecko\/\d+/.exec(navigator.userAgent);
4675
+ const Re = /* @__PURE__ */ In(I), Gn = 250, Yn = /* @__PURE__ */ Ye.baseTheme({
4676
+ ".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)": {
4677
+ display: "none"
4678
+ },
4679
+ ".cm-vim-panel": {
4680
+ padding: "0px 10px",
4681
+ fontFamily: "monospace",
4682
+ minHeight: "1.3em",
4683
+ display: "flex"
4684
+ },
4685
+ ".cm-vim-panel input": {
4686
+ border: "none",
4687
+ outline: "none",
4688
+ backgroundColor: "inherit"
4689
+ },
4690
+ "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
4691
+ "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" }
4692
+ }), Zn = /* @__PURE__ */ yn.fromClass(class {
4693
+ constructor(f) {
4694
+ this.status = "", this.query = null, this.decorations = ht.none, this.waitForCopy = !1, this.lastKeydown = "", this.useNextTextInput = !1, this.compositionText = "", this.view = f;
4695
+ const o = this.cm = new I(f);
4696
+ Re.enterVimMode(this.cm), this.view.cm = this.cm, this.cm.state.vimPlugin = this, this.blockCursor = new jn(f, o), this.updateClass(), this.cm.on("vim-command-done", () => {
4697
+ o.state.vim && (o.state.vim.status = ""), this.blockCursor.scheduleRedraw(), this.updateStatus();
4698
+ }), this.cm.on("vim-mode-change", (c) => {
4699
+ o.state.vim && (o.state.vim.mode = c.mode, c.subMode && (o.state.vim.mode += " block"), o.state.vim.status = "", this.blockCursor.scheduleRedraw(), this.updateClass(), this.updateStatus());
4700
+ }), this.cm.on("dialog", () => {
4701
+ this.cm.state.statusbar ? this.updateStatus() : f.dispatch({
4702
+ effects: hr.of(!!this.cm.state.dialog)
4703
+ });
4704
+ }), this.dom = document.createElement("span"), this.spacer = document.createElement("span"), this.spacer.style.flex = "1", this.statusButton = document.createElement("span"), this.statusButton.onclick = (c) => {
4705
+ Re.handleKey(this.cm, "<Esc>", "user"), this.cm.focus();
4706
+ }, this.statusButton.style.cssText = "cursor: pointer";
4707
+ }
4708
+ update(f) {
4709
+ var o;
4710
+ if ((f.viewportChanged || f.docChanged) && this.query && this.highlight(this.query), f.docChanged && this.cm.onChange(f), f.selectionSet && this.cm.onSelectionChange(), f.viewportChanged, this.cm.curOp && !this.cm.curOp.isVimOp && this.cm.onBeforeEndOperation(), f.transactions) {
4711
+ for (let c of f.transactions)
4712
+ for (let p of c.effects)
4713
+ if (p.is(dt))
4714
+ if (!((o = p.value) === null || o === void 0 ? void 0 : o.forVim))
4715
+ this.highlight(null);
4716
+ else {
4717
+ let k = p.value.create();
4718
+ this.highlight(k);
4719
+ }
4720
+ }
4721
+ this.blockCursor.update(f);
4722
+ }
4723
+ updateClass() {
4724
+ const f = this.cm.state;
4725
+ !f.vim || f.vim.insertMode && !f.overwrite ? this.view.scrollDOM.classList.remove("cm-vimMode") : this.view.scrollDOM.classList.add("cm-vimMode");
4726
+ }
4727
+ updateStatus() {
4728
+ let f = this.cm.state.statusbar, o = this.cm.state.vim;
4729
+ if (!f || !o)
4730
+ return;
4731
+ let c = this.cm.state.dialog;
4732
+ if (c)
4733
+ c.parentElement != f && (f.textContent = "", f.appendChild(c));
4734
+ else {
4735
+ f.textContent = "";
4736
+ var p = (o.mode || "normal").toUpperCase();
4737
+ o.insertModeReturn && (p += "(C-O)"), this.statusButton.textContent = `--${p}--`, f.appendChild(this.statusButton), f.appendChild(this.spacer);
4738
+ }
4739
+ this.dom.textContent = o.status, f.appendChild(this.dom);
4740
+ }
4741
+ destroy() {
4742
+ Re.leaveVimMode(this.cm), this.updateClass(), this.blockCursor.destroy(), delete this.view.cm;
4743
+ }
4744
+ highlight(f) {
4745
+ if (this.query = f, !f)
4746
+ return this.decorations = ht.none;
4747
+ let { view: o } = this, c = new pn();
4748
+ for (let p = 0, y = o.visibleRanges, k = y.length; p < k; p++) {
4749
+ let { from: L, to: x } = y[p];
4750
+ for (; p < k - 1 && x > y[p + 1].from - 2 * Gn; )
4751
+ x = y[++p].to;
4752
+ f.highlight(o.state, L, x, (b, F) => {
4753
+ c.add(b, F, ti);
4754
+ });
4755
+ }
4756
+ return this.decorations = c.finish();
4757
+ }
4758
+ handleKey(f, o) {
4759
+ const c = this.cm;
4760
+ let p = c.state.vim;
4761
+ if (!p)
4762
+ return;
4763
+ const y = Re.vimKeyFromEvent(f, p);
4764
+ if (I.signal(this.cm, "inputEvent", { type: "handleKey", key: y }), !y)
4765
+ return;
4766
+ if (y == "<Esc>" && !p.insertMode && !p.visualMode && this.query) {
4767
+ const x = p.searchState_;
4768
+ x && (c.removeOverlay(x.getOverlay()), x.setOverlay(null));
4769
+ }
4770
+ if (y === "<C-c>" && !I.isMac && c.somethingSelected())
4771
+ return this.waitForCopy = !0, !0;
4772
+ p.status = (p.status || "") + y;
4773
+ let L = Re.multiSelectHandleKey(c, y, "user");
4774
+ return p = Re.maybeInitVimState_(c), !L && p.insertMode && c.state.overwrite && (f.key && f.key.length == 1 && !/\n/.test(f.key) ? (L = !0, c.overWriteSelection(f.key)) : f.key == "Backspace" && (L = !0, I.commands.cursorCharLeft(c))), L && (I.signal(this.cm, "vim-keypress", y), f.preventDefault(), f.stopPropagation(), this.blockCursor.scheduleRedraw()), this.updateStatus(), !!L;
4775
+ }
4776
+ }, {
4777
+ eventHandlers: {
4778
+ copy: function(f, o) {
4779
+ this.waitForCopy && (this.waitForCopy = !1, Promise.resolve().then(() => {
4780
+ var c = this.cm, p = c.state.vim;
4781
+ p && (p.insertMode ? c.setSelection(c.getCursor(), c.getCursor()) : c.operation(() => {
4782
+ c.curOp && (c.curOp.isVimOp = !0), Re.handleKey(c, "<Esc>", "user");
4783
+ }));
4784
+ }));
4785
+ },
4786
+ compositionstart: function(f, o) {
4787
+ this.useNextTextInput = !0, I.signal(this.cm, "inputEvent", f);
4788
+ },
4789
+ compositionupdate: function(f, o) {
4790
+ I.signal(this.cm, "inputEvent", f);
4791
+ },
4792
+ compositionend: function(f, o) {
4793
+ I.signal(this.cm, "inputEvent", f);
4794
+ },
4795
+ keypress: function(f, o) {
4796
+ I.signal(this.cm, "inputEvent", f), this.lastKeydown == "Dead" && this.handleKey(f, o);
4797
+ },
4798
+ keydown: function(f, o) {
4799
+ I.signal(this.cm, "inputEvent", f), this.lastKeydown = f.key, this.lastKeydown == "Unidentified" || this.lastKeydown == "Process" || this.lastKeydown == "Dead" ? this.useNextTextInput = !0 : (this.useNextTextInput = !1, this.handleKey(f, o));
4800
+ }
4801
+ },
4802
+ provide: () => [
4803
+ Ye.inputHandler.of((f, o, c, p) => {
4804
+ var y, k, L = ai(f);
4805
+ if (!L)
4806
+ return !1;
4807
+ var x = (y = L.state) === null || y === void 0 ? void 0 : y.vim, b = L.state.vimPlugin;
4808
+ if (x && !x.insertMode && !(!((k = L.curOp) === null || k === void 0) && k.isVimOp)) {
4809
+ if (p === "\0\0")
4810
+ return !0;
4811
+ if (I.signal(L, "inputEvent", {
4812
+ type: "text",
4813
+ text: p,
4814
+ from: o,
4815
+ to: c
4816
+ }), p.length == 1 && b.useNextTextInput) {
4817
+ if (x.expectLiteralNext && f.composing)
4818
+ return b.compositionText = p, !1;
4819
+ if (b.compositionText) {
4820
+ var F = b.compositionText;
4821
+ b.compositionText = "";
4822
+ var D = f.state.selection.main.head, H = f.state.sliceDoc(D - F.length, D);
4823
+ if (F === H) {
4824
+ var j = L.getCursor();
4825
+ L.replaceRange("", L.posFromIndex(D - F.length), j);
4826
+ }
4827
+ }
4828
+ return b.handleKey({
4829
+ key: p,
4830
+ preventDefault: () => {
4831
+ },
4832
+ stopPropagation: () => {
4833
+ }
4834
+ }), ei(f), !0;
4835
+ }
4836
+ }
4837
+ return !1;
4838
+ })
4839
+ ],
4840
+ decorations: (f) => f.decorations
4841
+ });
4842
+ function ei(f) {
4843
+ var o = f.scrollDOM.parentElement;
4844
+ if (o) {
4845
+ if (Xn) {
4846
+ f.contentDOM.textContent = "\0\0", f.contentDOM.dispatchEvent(new CustomEvent("compositionend"));
4847
+ return;
4848
+ }
4849
+ var c = f.scrollDOM.nextSibling, p = window.getSelection(), y = p && {
4850
+ anchorNode: p.anchorNode,
4851
+ anchorOffset: p.anchorOffset,
4852
+ focusNode: p.focusNode,
4853
+ focusOffset: p.focusOffset
4854
+ };
4855
+ f.scrollDOM.remove(), o.insertBefore(f.scrollDOM, c);
4856
+ try {
4857
+ y && p && (p.setPosition(y.anchorNode, y.anchorOffset), y.focusNode && p.extend(y.focusNode, y.focusOffset));
4858
+ } catch (k) {
4859
+ console.error(k);
4860
+ }
4861
+ f.focus(), f.contentDOM.dispatchEvent(new CustomEvent("compositionend"));
4862
+ }
4863
+ }
4864
+ const ti = /* @__PURE__ */ ht.mark({ class: "cm-searchMatch" }), hr = /* @__PURE__ */ dn.define(), ri = /* @__PURE__ */ hn.define({
4865
+ create: () => !1,
4866
+ update(f, o) {
4867
+ for (let c of o.effects)
4868
+ c.is(hr) && (f = c.value);
4869
+ return f;
4870
+ },
4871
+ provide: (f) => ir.from(f, (o) => o ? ni : null)
4872
+ });
4873
+ function ni(f) {
4874
+ let o = document.createElement("div");
4875
+ o.className = "cm-vim-panel";
4876
+ let c = f.cm;
4877
+ return c.state.dialog && o.appendChild(c.state.dialog), { top: !1, dom: o };
4878
+ }
4879
+ function ii(f) {
4880
+ let o = document.createElement("div");
4881
+ o.className = "cm-vim-panel";
4882
+ let c = f.cm;
4883
+ return c.state.statusbar = o, c.state.vimPlugin.updateStatus(), { dom: o };
4884
+ }
4885
+ function ci(f = {}) {
4886
+ return [
4887
+ Yn,
4888
+ Zn,
4889
+ Jn,
4890
+ f.status ? ir.of(ii) : ri
4891
+ ];
4892
+ }
4893
+ function ai(f) {
4894
+ return f.cm || null;
4895
+ }
4896
+ export {
4897
+ I as CodeMirror,
4898
+ Re as Vim,
4899
+ ai as getCM,
4900
+ ci as vim
4901
+ };