@onereach/ui-components 4.2.0-beta.2549.0 → 4.2.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 (458) hide show
  1. package/dist/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.js +145 -0
  2. package/dist/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +91 -0
  3. package/dist/bundled/v2/components/OrCheckboxGroupV3/index.d.ts +1 -0
  4. package/dist/bundled/v2/components/OrCheckboxGroupV3/index.js +31 -0
  5. package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.js +226 -0
  6. package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +91 -0
  7. package/dist/bundled/v2/components/OrCheckboxTreeV3/index.d.ts +2 -0
  8. package/dist/bundled/v2/components/OrCheckboxTreeV3/index.js +23 -0
  9. package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.d.ts +2 -0
  10. package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.js +10 -0
  11. package/dist/bundled/v2/components/OrCheckboxTreeV3/types.d.ts +8 -0
  12. package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.js +37 -39
  13. package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
  14. package/dist/bundled/v2/components/OrCheckboxV3/index.js +1 -0
  15. package/dist/bundled/v2/components/OrCode/OrCode.js +3727 -6
  16. package/dist/bundled/v2/components/OrCode/index.js +2 -6
  17. package/dist/bundled/v2/components/OrCode/lang.js +3 -3897
  18. package/dist/bundled/v2/components/OrCode/theme.js +1 -2
  19. package/dist/bundled/v2/components/OrConfirm/OrConfirm.js +0 -1
  20. package/dist/bundled/v2/components/OrConfirm/index.js +0 -1
  21. package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.js +127 -0
  22. package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.vue.d.ts +87 -0
  23. package/dist/bundled/v2/components/OrFormGroupV3/index.d.ts +2 -0
  24. package/dist/bundled/v2/components/OrFormGroupV3/index.js +12 -0
  25. package/dist/bundled/v2/components/OrFormGroupV3/props.d.ts +4 -0
  26. package/dist/bundled/v2/components/OrFormGroupV3/props.js +7 -0
  27. package/dist/bundled/v2/components/OrFormGroupV3/styles.d.ts +5 -0
  28. package/dist/bundled/v2/components/OrFormGroupV3/styles.js +17 -0
  29. package/dist/bundled/v2/components/OrModal/OrModal.js +1266 -3
  30. package/dist/bundled/v2/components/OrModal/index.js +0 -1
  31. package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.js +132 -0
  32. package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
  33. package/dist/bundled/v2/components/OrRadioGroupV3/index.d.ts +1 -0
  34. package/dist/bundled/v2/components/OrRadioGroupV3/index.js +19 -0
  35. package/dist/bundled/v2/components/OrSelectV3/OrSelect.js +1 -1
  36. package/dist/bundled/v2/components/OrSelectV3/index.js +1 -1
  37. package/dist/bundled/v2/components/OrTooltipContent/OrTooltipContent.js +2 -2
  38. package/dist/bundled/v2/components/index.d.ts +0 -1
  39. package/dist/bundled/v2/components/index.js +2 -15
  40. package/dist/bundled/v2/{index-f5487f12.js → index-6976c52a.js} +115 -3
  41. package/dist/bundled/v2/index.d.ts +1 -0
  42. package/dist/bundled/v2/index.js +8 -20
  43. package/dist/bundled/v2/{index-70ca38c5.js → lang-02d2bb2d.js} +3965 -73
  44. package/dist/bundled/v2/utils/functions/flattenDeep.d.ts +2 -0
  45. package/dist/bundled/v2/utils/functions/flattenDeep.js +5 -0
  46. package/dist/bundled/v3/{OrAvatar.vue_vue_type_script_lang-29e8ad0e.js → OrAvatar.vue_vue_type_script_lang-6511e348.js} +1 -1
  47. package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-a4a16fe5.js → OrButton.vue_vue_type_script_lang-da7f7ed0.js} +1 -1
  48. package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-c1d83552.js → OrCardCollection.vue_vue_type_script_lang-7a2e1332.js} +3 -3
  49. package/dist/bundled/v3/{OrCarousel.vue_vue_type_script_lang-0e87c56b.js → OrCarousel.vue_vue_type_script_lang-6976844a.js} +1 -1
  50. package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-6ff51af9.js → OrCheckbox.vue_vue_type_script_lang-11b16d93.js} +1 -1
  51. package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-60cefcbd.js → OrCheckbox.vue_vue_type_script_lang-b274a5ee.js} +27 -11
  52. package/dist/bundled/v3/OrCheckboxTree.vue_vue_type_script_lang-f9807b75.js +115 -0
  53. package/dist/bundled/v3/{OrChip.vue_vue_type_script_lang-ceebbd82.js → OrChip.vue_vue_type_script_lang-5a390853.js} +1 -1
  54. package/dist/bundled/v3/{OrChips.vue_vue_type_script_lang-94b456c7.js → OrChips.vue_vue_type_script_lang-d4bb44eb.js} +1 -1
  55. package/dist/bundled/{v2/index-16aee5bc.js → v3/OrCode.vue_vue_type_script_lang-5397df6a.js} +234 -14
  56. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-36318ca2.js → OrConfirm.vue_vue_type_script_lang-89febea7.js} +2 -2
  57. package/dist/bundled/v3/{OrDateTimePicker.vue_vue_type_script_lang-5c1a5d4a.js → OrDateTimePicker.vue_vue_type_script_lang-8ff54abd.js} +1 -1
  58. package/dist/bundled/v3/OrFormGroup.vue_vue_type_script_lang-1c6844d6.js +63 -0
  59. package/dist/bundled/v3/{OrIconButton.vue_vue_type_script_lang-5d204461.js → OrIconButton.vue_vue_type_script_lang-96cb5b59.js} +2 -2
  60. package/dist/bundled/v3/{OrInlineTextEdit.vue_vue_type_script_lang-424e2c26.js → OrInlineTextEdit.vue_vue_type_script_lang-45987769.js} +1 -1
  61. package/dist/bundled/v3/{OrList.vue_vue_type_script_lang-c65271b9.js → OrList.vue_vue_type_script_lang-2c7537cc.js} +3 -3
  62. package/dist/bundled/v3/{OrListOfInputs.vue_vue_type_script_lang-d3dce7b8.js → OrListOfInputs.vue_vue_type_script_lang-009f62a5.js} +3 -3
  63. package/dist/bundled/v3/{useFocusTrap-9567b3c8.js → OrModal.vue_vue_type_script_lang-c53617ae.js} +105 -3
  64. package/dist/bundled/v3/{OrNotification.vue_vue_type_script_lang-ef4f2661.js → OrNotification.vue_vue_type_script_lang-efb05bb2.js} +2 -2
  65. package/dist/bundled/v3/{OrOverflowMenu.vue_vue_type_script_lang-0c461991.js → OrOverflowMenu.vue_vue_type_script_lang-ba50133f.js} +2 -2
  66. package/dist/bundled/v3/{OrPassword.vue_vue_type_script_lang-3d308fef.js → OrPassword.vue_vue_type_script_lang-37f52611.js} +1 -1
  67. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-86f4f5c7.js → OrSearch.vue_vue_type_script_lang-bcb935c3.js} +1 -1
  68. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-f7601423.js → OrSelect.vue_vue_type_script_lang-098ea3ab.js} +1 -1
  69. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-d2fecd97.js → OrSelect.vue_vue_type_script_lang-c82d8f58.js} +3 -3
  70. package/dist/bundled/v3/{OrSlider.vue_vue_type_script_lang-900036a2.js → OrSlider.vue_vue_type_script_lang-45ecddbe.js} +1 -1
  71. package/dist/bundled/v3/{OrStepper.vue_vue_type_script_lang-2821c496.js → OrStepper.vue_vue_type_script_lang-975a4df6.js} +1 -1
  72. package/dist/bundled/v3/{OrTag.vue_vue_type_script_lang-f06b54a2.js → OrTag.vue_vue_type_script_lang-621e9307.js} +1 -1
  73. package/dist/bundled/v3/{OrTextbox.vue_vue_type_script_lang-b8d5341b.js → OrTextbox.vue_vue_type_script_lang-812f302d.js} +1 -1
  74. package/dist/bundled/v3/components/OrAvatar/OrAvatar.js +3 -3
  75. package/dist/bundled/v3/components/OrAvatar/index.js +2 -2
  76. package/dist/bundled/v3/components/OrButtonV2/OrButton.js +3 -3
  77. package/dist/bundled/v3/components/OrButtonV2/index.js +4 -4
  78. package/dist/bundled/v3/components/OrCardCollection/OrCardCollection.js +6 -6
  79. package/dist/bundled/v3/components/OrCardCollection/index.js +5 -5
  80. package/dist/bundled/v3/components/OrCarousel/OrCarousel.js +3 -3
  81. package/dist/bundled/v3/components/OrCarousel/index.js +2 -2
  82. package/dist/bundled/v3/components/OrCheckbox/OrCheckbox.js +3 -3
  83. package/dist/bundled/v3/components/OrCheckbox/index.js +2 -2
  84. package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.js +121 -0
  85. package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +91 -0
  86. package/dist/bundled/v3/components/OrCheckboxGroupV3/index.d.ts +1 -0
  87. package/dist/bundled/v3/components/OrCheckboxGroupV3/index.js +40 -0
  88. package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.js +90 -0
  89. package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +91 -0
  90. package/dist/bundled/v3/components/OrCheckboxTreeV3/index.d.ts +2 -0
  91. package/dist/bundled/v3/components/OrCheckboxTreeV3/index.js +28 -0
  92. package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.d.ts +2 -0
  93. package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.js +10 -0
  94. package/dist/bundled/v3/components/OrCheckboxTreeV3/types.d.ts +8 -0
  95. package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.js +12 -9
  96. package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
  97. package/dist/bundled/v3/components/OrCheckboxV3/index.js +2 -1
  98. package/dist/bundled/v3/components/OrChip/OrChip.js +3 -3
  99. package/dist/bundled/v3/components/OrChip/index.js +2 -2
  100. package/dist/bundled/v3/components/OrChips/OrChips.js +4 -4
  101. package/dist/bundled/v3/components/OrChips/index.js +3 -3
  102. package/dist/bundled/v3/components/OrCode/OrCode.js +9 -13
  103. package/dist/bundled/v3/components/OrCode/index.js +7 -11
  104. package/dist/bundled/v3/components/OrCode/lang.js +3 -3897
  105. package/dist/bundled/v3/components/OrCode/theme.js +1 -2
  106. package/dist/bundled/v3/components/OrConfirm/OrConfirm.js +7 -8
  107. package/dist/bundled/v3/components/OrConfirm/index.js +6 -7
  108. package/dist/bundled/v3/components/OrDateTimePicker/OrDateTimePicker.js +5 -5
  109. package/dist/bundled/v3/components/OrDateTimePicker/index.js +4 -4
  110. package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.js +59 -0
  111. package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.vue.d.ts +87 -0
  112. package/dist/bundled/v3/components/OrFormGroupV3/index.d.ts +2 -0
  113. package/dist/bundled/v3/components/OrFormGroupV3/index.js +15 -0
  114. package/dist/bundled/v3/components/OrFormGroupV3/props.d.ts +4 -0
  115. package/dist/bundled/v3/components/OrFormGroupV3/props.js +7 -0
  116. package/dist/bundled/v3/components/OrFormGroupV3/styles.d.ts +5 -0
  117. package/dist/bundled/v3/components/OrFormGroupV3/styles.js +17 -0
  118. package/dist/bundled/v3/components/OrIcon/OrIcon.js +2 -2
  119. package/dist/bundled/v3/components/OrIcon/index.js +1 -1
  120. package/dist/bundled/v3/components/OrIconButtonV2/OrIconButton.js +4 -4
  121. package/dist/bundled/v3/components/OrIconButtonV2/index.js +3 -3
  122. package/dist/bundled/v3/components/OrInlineTextEdit/OrInlineTextEdit.js +5 -5
  123. package/dist/bundled/v3/components/OrInlineTextEdit/index.js +4 -4
  124. package/dist/bundled/v3/components/OrList/OrList.js +6 -6
  125. package/dist/bundled/v3/components/OrList/index.js +5 -5
  126. package/dist/bundled/v3/components/OrListOfInputs/OrListOfInputs.js +7 -7
  127. package/dist/bundled/v3/components/OrListOfInputs/index.js +6 -6
  128. package/dist/bundled/v3/components/OrModal/OrModal.js +5 -6
  129. package/dist/bundled/v3/components/OrModal/index.js +4 -5
  130. package/dist/bundled/v3/components/OrNotification/OrNotification.js +5 -5
  131. package/dist/bundled/v3/components/OrNotification/index.js +4 -4
  132. package/dist/bundled/v3/components/OrOverflowMenu/OrOverflowMenu.js +6 -6
  133. package/dist/bundled/v3/components/OrOverflowMenu/index.js +5 -5
  134. package/dist/bundled/v3/components/OrPassword/OrPassword.js +5 -5
  135. package/dist/bundled/v3/components/OrPassword/index.js +4 -4
  136. package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.js +104 -0
  137. package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
  138. package/dist/bundled/v3/components/OrRadioGroupV3/index.d.ts +1 -0
  139. package/dist/bundled/v3/components/OrRadioGroupV3/index.js +24 -0
  140. package/dist/bundled/v3/components/OrSearch/OrSearch.js +5 -5
  141. package/dist/bundled/v3/components/OrSearch/index.js +4 -4
  142. package/dist/bundled/v3/components/OrSelect/OrSelect.js +5 -5
  143. package/dist/bundled/v3/components/OrSelect/index.js +4 -4
  144. package/dist/bundled/v3/components/OrSelectV3/OrSelect.js +4 -4
  145. package/dist/bundled/v3/components/OrSelectV3/index.js +3 -3
  146. package/dist/bundled/v3/components/OrSlider/OrSlider.js +3 -3
  147. package/dist/bundled/v3/components/OrSlider/index.js +2 -2
  148. package/dist/bundled/v3/components/OrStepper/OrStepper.js +4 -4
  149. package/dist/bundled/v3/components/OrStepper/index.js +3 -3
  150. package/dist/bundled/v3/components/OrTag/OrTag.js +3 -3
  151. package/dist/bundled/v3/components/OrTag/index.js +2 -2
  152. package/dist/bundled/v3/components/OrTextbox/OrTextbox.js +5 -5
  153. package/dist/bundled/v3/components/OrTextbox/index.js +4 -4
  154. package/dist/bundled/v3/components/OrToast/OrToast.js +3 -3
  155. package/dist/bundled/v3/components/OrToast/index.js +4 -4
  156. package/dist/bundled/v3/components/OrToastContainer/OrToastContainer.js +5 -5
  157. package/dist/bundled/v3/components/OrToastContainer/index.js +4 -4
  158. package/dist/bundled/v3/components/OrTooltip/OrTooltip.js +2 -2
  159. package/dist/bundled/v3/components/OrTooltip/index.js +1 -1
  160. package/dist/bundled/v3/components/OrTooltipContent/OrTooltipContent.js +1 -1
  161. package/dist/bundled/v3/components/index.d.ts +0 -1
  162. package/dist/bundled/v3/components/index.js +31 -45
  163. package/dist/bundled/v3/{index-f5487f12.js → index-6976c52a.js} +115 -3
  164. package/dist/bundled/v3/index.d.ts +1 -0
  165. package/dist/bundled/v3/index.js +39 -53
  166. package/dist/bundled/v3/{index-70ca38c5.js → lang-02d2bb2d.js} +3965 -73
  167. package/dist/bundled/v3/utils/functions/flattenDeep.d.ts +2 -0
  168. package/dist/bundled/v3/utils/functions/flattenDeep.js +5 -0
  169. package/dist/esm/v2/{OrAvatar-da5cba16.js → OrAvatar-7c024521.js} +1 -1
  170. package/dist/esm/v2/{OrButton-bdddd8d4.js → OrButton-4e532ddb.js} +1 -1
  171. package/dist/esm/v2/{OrButton.vue_rollup-plugin-vue_styles.0-3dbd90b4.js → OrButton.vue_rollup-plugin-vue_styles.0-48c5883e.js} +2 -2
  172. package/dist/esm/v2/{OrCardCollection-4e014d25.js → OrCardCollection-9bf513b7.js} +5 -5
  173. package/dist/esm/v2/{OrCarousel-3c809a13.js → OrCarousel-e0c2e387.js} +1 -1
  174. package/dist/esm/v2/{OrCheckbox-dc587ec9.js → OrCheckbox-39c94019.js} +37 -40
  175. package/dist/esm/v2/{OrCheckbox-bf34eb0f.js → OrCheckbox-7b98fc08.js} +1 -1
  176. package/dist/esm/v2/OrCheckboxTree-7b81e76c.js +220 -0
  177. package/dist/esm/v2/{OrChip-416e848e.js → OrChip-8a1abfc5.js} +1 -1
  178. package/dist/esm/v2/{OrChips-77e789e9.js → OrChips-a01d8520.js} +1 -1
  179. package/dist/esm/v2/{OrChips.vue_rollup-plugin-vue_styles.0-e05c5ca8.js → OrChips.vue_rollup-plugin-vue_styles.0-3cbb0871.js} +1 -1
  180. package/dist/esm/v2/{OrCode-dcb0132a.js → OrCode-e54e09f7.js} +4 -4
  181. package/dist/esm/v2/{OrConfirm-497cd260.js → OrConfirm-5d5dd9bc.js} +3 -3
  182. package/dist/esm/v2/{OrDateTimePicker-c88ca716.js → OrDateTimePicker-6e2853ec.js} +3 -3
  183. package/dist/esm/v2/OrFormGroup-29a514db.js +141 -0
  184. package/dist/esm/v2/{OrIcon-8a6d663a.js → OrIcon-a40e60af.js} +2 -2
  185. package/dist/esm/v2/{OrIconButton-97bfd51d.js → OrIconButton-23972f7d.js} +1 -1
  186. package/dist/esm/v2/{OrIconButton.vue_rollup-plugin-vue_styles.0-e3806cef.js → OrIconButton.vue_rollup-plugin-vue_styles.0-277ce06c.js} +3 -3
  187. package/dist/esm/v2/{OrInlineTextEdit-e8414fb6.js → OrInlineTextEdit-9541b625.js} +3 -3
  188. package/dist/esm/v2/{OrList-a46d6306.js → OrList-61c7b8ea.js} +4 -4
  189. package/dist/esm/v2/{OrListOfInputs-33a7bf87.js → OrListOfInputs-e1b09290.js} +5 -5
  190. package/dist/esm/v2/{OrModal-6d84829c.js → OrModal-b9cfb8ec.js} +3 -3
  191. package/dist/esm/v2/{OrNotification-7945568d.js → OrNotification-fdb88eec.js} +4 -4
  192. package/dist/esm/v2/{OrOverflowMenu-5ce7171b.js → OrOverflowMenu-83540c76.js} +4 -4
  193. package/dist/esm/v2/{OrPassword-3597153d.js → OrPassword-022e10fd.js} +3 -3
  194. package/dist/esm/v2/{OrSearch-49ceaac4.js → OrSearch-620d5d76.js} +3 -3
  195. package/dist/esm/v2/{OrSelect-40183874.js → OrSelect-1865c781.js} +1 -1
  196. package/dist/esm/v2/{OrSelect-eb5cc918.js → OrSelect-d887118b.js} +4 -4
  197. package/dist/esm/v2/{OrSlider-32a14ca4.js → OrSlider-c0a7f9cf.js} +1 -1
  198. package/dist/esm/v2/{OrStepper-462bc9e6.js → OrStepper-b00f7531.js} +2 -2
  199. package/dist/esm/v2/{OrTag-a1fff567.js → OrTag-6349049b.js} +1 -1
  200. package/dist/esm/v2/{OrTextbox-0a89a533.js → OrTextbox-0373bd6a.js} +3 -3
  201. package/dist/esm/v2/{OrToastContainer-5ce15a5b.js → OrToastContainer-1625b803.js} +3 -3
  202. package/dist/esm/v2/{OrTooltip-cfb56e8f.js → OrTooltip-97a42707.js} +1 -1
  203. package/dist/esm/v2/{OrTooltip.vue_rollup-plugin-vue_styles.0-122f7804.js → OrTooltip.vue_rollup-plugin-vue_styles.0-a256ac18.js} +1 -1
  204. package/dist/esm/v2/{OrTooltipContent-c9540548.js → OrTooltipContent-d85e1071.js} +2 -2
  205. package/dist/esm/v2/components/index.d.ts +0 -1
  206. package/dist/esm/v2/components/index.js +34 -58
  207. package/dist/esm/v2/components/or-avatar/index.js +4 -4
  208. package/dist/esm/v2/components/or-button-v2/index.js +8 -8
  209. package/dist/esm/v2/components/or-card-collection/index.js +9 -9
  210. package/dist/esm/v2/components/or-carousel/index.js +4 -4
  211. package/dist/esm/v2/components/or-checkbox/index.js +4 -4
  212. package/dist/esm/v2/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +91 -0
  213. package/dist/esm/v2/components/or-checkbox-group-v3/index.d.ts +1 -0
  214. package/dist/esm/v2/components/or-checkbox-group-v3/index.js +130 -0
  215. package/dist/esm/v2/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +91 -0
  216. package/dist/esm/v2/components/or-checkbox-tree-v3/index.d.ts +2 -0
  217. package/dist/esm/v2/components/or-checkbox-tree-v3/index.js +12 -0
  218. package/dist/esm/v2/components/or-checkbox-tree-v3/styles.d.ts +2 -0
  219. package/dist/esm/v2/components/or-checkbox-tree-v3/types.d.ts +8 -0
  220. package/dist/esm/v2/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
  221. package/dist/esm/v2/components/or-checkbox-v3/index.js +2 -2
  222. package/dist/esm/v2/components/or-chips/index.js +6 -6
  223. package/dist/esm/v2/components/or-chips/or-chip/index.js +4 -4
  224. package/dist/esm/v2/components/or-code/index.js +9 -9
  225. package/dist/esm/v2/components/or-confirm/index.js +10 -10
  226. package/dist/esm/v2/components/or-date-time-picker/index.js +8 -8
  227. package/dist/esm/v2/components/or-form-group-v3/OrFormGroup.vue.d.ts +87 -0
  228. package/dist/esm/v2/components/or-form-group-v3/index.d.ts +2 -0
  229. package/dist/esm/v2/components/or-form-group-v3/index.js +6 -0
  230. package/dist/esm/v2/components/or-form-group-v3/props.d.ts +4 -0
  231. package/dist/esm/v2/components/or-form-group-v3/styles.d.ts +5 -0
  232. package/dist/esm/v2/components/or-icon/index.js +3 -3
  233. package/dist/esm/v2/components/or-icon-button-v2/index.js +6 -6
  234. package/dist/esm/v2/components/or-inline-text-edit/index.js +8 -8
  235. package/dist/esm/v2/components/or-list/index.js +9 -9
  236. package/dist/esm/v2/components/or-list-of-inputs/index.js +10 -10
  237. package/dist/esm/v2/components/or-modal/index.js +8 -8
  238. package/dist/esm/v2/components/or-notification/index.js +8 -8
  239. package/dist/esm/v2/components/or-overflow-menu/index.js +9 -9
  240. package/dist/esm/v2/components/or-password/index.js +8 -8
  241. package/dist/esm/v2/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
  242. package/dist/esm/v2/components/or-radio-group-v3/index.d.ts +1 -0
  243. package/dist/esm/v2/components/or-radio-group-v3/index.js +124 -0
  244. package/dist/esm/v2/components/or-search/index.js +8 -8
  245. package/dist/esm/v2/components/or-select/index.js +7 -7
  246. package/dist/esm/v2/components/or-select-v3/index.js +2 -2
  247. package/dist/esm/v2/components/or-slider/index.js +4 -4
  248. package/dist/esm/v2/components/or-stepper/index.js +8 -8
  249. package/dist/esm/v2/components/or-tag/index.js +4 -4
  250. package/dist/esm/v2/components/or-textbox/index.js +8 -8
  251. package/dist/esm/v2/components/or-toast/index.js +8 -8
  252. package/dist/esm/v2/components/or-toast/or-toast-container/index.js +8 -8
  253. package/dist/esm/v2/components/or-tooltip/index.js +3 -3
  254. package/dist/esm/v2/components/or-tooltip/or-tooltip-content/index.js +1 -1
  255. package/dist/esm/v2/flattenDeep-e7a8b995.js +5 -0
  256. package/dist/esm/v2/index.d.ts +1 -0
  257. package/dist/esm/v2/index.js +35 -58
  258. package/dist/esm/v2/utils/functions/flattenDeep.d.ts +2 -0
  259. package/dist/esm/v3/{OrAvatar-b18f2208.js → OrAvatar-14a5c5f0.js} +1 -1
  260. package/dist/esm/v3/{OrButton-170b493f.js → OrButton-f8b10d79.js} +2 -2
  261. package/dist/esm/v3/{OrCardCollection-dc158967.js → OrCardCollection-ffbb9eda.js} +4 -4
  262. package/dist/esm/v3/{OrCarousel-8de5d65b.js → OrCarousel-03597740.js} +1 -1
  263. package/dist/esm/v3/{OrCheckbox-56f849f7.js → OrCheckbox-488b6915.js} +36 -19
  264. package/dist/esm/v3/{OrCheckbox-c2d9cf53.js → OrCheckbox-7efd5f26.js} +1 -1
  265. package/dist/esm/v3/OrCheckboxTree-87d0528b.js +182 -0
  266. package/dist/esm/v3/{OrChip-ccd4b331.js → OrChip-97a85e10.js} +1 -1
  267. package/dist/esm/v3/{OrChips-9a19aa03.js → OrChips-64b86761.js} +1 -1
  268. package/dist/esm/v3/{OrCode-b0b514ab.js → OrCode-6f2e4d99.js} +3 -3
  269. package/dist/esm/v3/{OrConfirm-1ffb7ed6.js → OrConfirm-ab04201f.js} +3 -3
  270. package/dist/esm/v3/{OrDateTimePicker-02c6de49.js → OrDateTimePicker-014f7819.js} +2 -2
  271. package/dist/esm/v3/OrFormGroup-9f581536.js +122 -0
  272. package/dist/esm/v3/{OrIcon-9b3d24cc.js → OrIcon-925c5413.js} +2 -2
  273. package/dist/esm/v3/{OrIconButton-9d08aa44.js → OrIconButton-5387fd59.js} +3 -3
  274. package/dist/esm/v3/{OrInlineTextEdit-8cfde85c.js → OrInlineTextEdit-6f97629f.js} +2 -2
  275. package/dist/esm/v3/{OrList-d3e330be.js → OrList-b8799cf4.js} +3 -3
  276. package/dist/esm/v3/{OrListOfInputs-3c8eaf97.js → OrListOfInputs-16ba8358.js} +4 -4
  277. package/dist/esm/v3/{OrModal-f8ae7146.js → OrModal-e6513e8c.js} +2 -2
  278. package/dist/esm/v3/{OrNotification-24192897.js → OrNotification-4c56f7ea.js} +3 -3
  279. package/dist/esm/v3/{OrOverflowMenu-a7568f8d.js → OrOverflowMenu-fe77e22c.js} +2 -2
  280. package/dist/esm/v3/{OrPassword-88a67993.js → OrPassword-9c8a458d.js} +2 -2
  281. package/dist/esm/v3/{OrSearch-fb2dd591.js → OrSearch-c4caf04e.js} +2 -2
  282. package/dist/esm/v3/{OrSelect-5502d82d.js → OrSelect-35b41c3f.js} +1 -1
  283. package/dist/esm/v3/{OrSelect-3d923250.js → OrSelect-d8a78242.js} +4 -4
  284. package/dist/esm/v3/{OrSlider-ae7b8a11.js → OrSlider-80e0f2e6.js} +1 -1
  285. package/dist/esm/v3/{OrStepper-446007c5.js → OrStepper-3a586401.js} +2 -2
  286. package/dist/esm/v3/{OrTag-38d1ba92.js → OrTag-e7adb078.js} +1 -1
  287. package/dist/esm/v3/{OrTextbox-7de2b10c.js → OrTextbox-f7388a30.js} +2 -2
  288. package/dist/esm/v3/{OrToastContainer-c3ecb1c8.js → OrToastContainer-94ba2803.js} +2 -2
  289. package/dist/esm/v3/{OrTooltip-be7209e5.js → OrTooltip-618ce7c9.js} +1 -1
  290. package/dist/esm/v3/{OrTooltipContent-68c34911.js → OrTooltipContent-37a5f562.js} +1 -1
  291. package/dist/esm/v3/components/index.d.ts +0 -1
  292. package/dist/esm/v3/components/index.js +30 -54
  293. package/dist/esm/v3/components/or-avatar/index.js +4 -4
  294. package/dist/esm/v3/components/or-button-v2/index.js +5 -5
  295. package/dist/esm/v3/components/or-card-collection/index.js +7 -7
  296. package/dist/esm/v3/components/or-carousel/index.js +4 -4
  297. package/dist/esm/v3/components/or-checkbox/index.js +4 -4
  298. package/dist/esm/v3/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +91 -0
  299. package/dist/esm/v3/components/or-checkbox-group-v3/index.d.ts +1 -0
  300. package/dist/esm/v3/components/or-checkbox-group-v3/index.js +97 -0
  301. package/dist/esm/v3/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +91 -0
  302. package/dist/esm/v3/components/or-checkbox-tree-v3/index.d.ts +2 -0
  303. package/dist/esm/v3/components/or-checkbox-tree-v3/index.js +12 -0
  304. package/dist/esm/v3/components/or-checkbox-tree-v3/styles.d.ts +2 -0
  305. package/dist/esm/v3/components/or-checkbox-tree-v3/types.d.ts +8 -0
  306. package/dist/esm/v3/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
  307. package/dist/esm/v3/components/or-checkbox-v3/index.js +2 -2
  308. package/dist/esm/v3/components/or-chips/index.js +5 -5
  309. package/dist/esm/v3/components/or-chips/or-chip/index.js +4 -4
  310. package/dist/esm/v3/components/or-code/index.js +7 -7
  311. package/dist/esm/v3/components/or-confirm/index.js +7 -7
  312. package/dist/esm/v3/components/or-date-time-picker/index.js +6 -6
  313. package/dist/esm/v3/components/or-form-group-v3/OrFormGroup.vue.d.ts +87 -0
  314. package/dist/esm/v3/components/or-form-group-v3/index.d.ts +2 -0
  315. package/dist/esm/v3/components/or-form-group-v3/index.js +6 -0
  316. package/dist/esm/v3/components/or-form-group-v3/props.d.ts +4 -0
  317. package/dist/esm/v3/components/or-form-group-v3/styles.d.ts +5 -0
  318. package/dist/esm/v3/components/or-icon/index.js +3 -3
  319. package/dist/esm/v3/components/or-icon-button-v2/index.js +4 -4
  320. package/dist/esm/v3/components/or-inline-text-edit/index.js +6 -6
  321. package/dist/esm/v3/components/or-list/index.js +6 -6
  322. package/dist/esm/v3/components/or-list-of-inputs/index.js +7 -7
  323. package/dist/esm/v3/components/or-modal/index.js +6 -6
  324. package/dist/esm/v3/components/or-notification/index.js +6 -6
  325. package/dist/esm/v3/components/or-overflow-menu/index.js +6 -6
  326. package/dist/esm/v3/components/or-password/index.js +6 -6
  327. package/dist/esm/v3/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
  328. package/dist/esm/v3/components/or-radio-group-v3/index.d.ts +1 -0
  329. package/dist/esm/v3/components/or-radio-group-v3/index.js +91 -0
  330. package/dist/esm/v3/components/or-search/index.js +6 -6
  331. package/dist/esm/v3/components/or-select/index.js +7 -7
  332. package/dist/esm/v3/components/or-select-v3/index.js +2 -2
  333. package/dist/esm/v3/components/or-slider/index.js +4 -4
  334. package/dist/esm/v3/components/or-stepper/index.js +6 -6
  335. package/dist/esm/v3/components/or-tag/index.js +4 -4
  336. package/dist/esm/v3/components/or-textbox/index.js +6 -6
  337. package/dist/esm/v3/components/or-toast/index.js +6 -6
  338. package/dist/esm/v3/components/or-toast/or-toast-container/index.js +6 -6
  339. package/dist/esm/v3/components/or-tooltip/index.js +2 -2
  340. package/dist/esm/v3/components/or-tooltip/or-tooltip-content/index.js +1 -1
  341. package/dist/esm/v3/flattenDeep-e7a8b995.js +5 -0
  342. package/dist/esm/v3/index.d.ts +1 -0
  343. package/dist/esm/v3/index.js +31 -54
  344. package/dist/esm/v3/utils/functions/flattenDeep.d.ts +2 -0
  345. package/package.json +5 -25
  346. package/src/components/index.ts +0 -1
  347. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.docs.mdx +7 -0
  348. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.stories3.ts +373 -0
  349. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.vue +80 -0
  350. package/src/components/or-checkbox-group-v3/index.ts +1 -0
  351. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.docs.mdx +7 -0
  352. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.stories3.ts +112 -0
  353. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.vue +192 -0
  354. package/src/components/or-checkbox-tree-v3/index.ts +2 -0
  355. package/src/components/or-checkbox-tree-v3/styles.ts +15 -0
  356. package/src/components/or-checkbox-tree-v3/types.ts +8 -0
  357. package/src/components/or-checkbox-v3/OrCheckbox.vue +33 -13
  358. package/src/components/or-form-group-v3/OrFormGroup.stories3.ts +114 -0
  359. package/src/components/or-form-group-v3/OrFormGroup.vue +116 -0
  360. package/src/components/or-form-group-v3/index.ts +2 -0
  361. package/src/components/or-form-group-v3/props.ts +4 -0
  362. package/src/components/or-form-group-v3/styles.ts +33 -0
  363. package/src/components/or-radio-group-v3/OrRadioGroup.stories3.ts +81 -0
  364. package/src/components/or-radio-group-v3/OrRadioGroup.vue +80 -0
  365. package/src/components/or-radio-group-v3/index.ts +1 -0
  366. package/src/components/or-radio-v3/OrRadio.stories3.ts +1 -1
  367. package/src/components/or-tooltip/or-tooltip-content/OrTooltipContent.vue +0 -1
  368. package/src/index.ts +1 -0
  369. package/src/utils/functions/flattenDeep.ts +5 -0
  370. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +0 -1990
  371. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +0 -170
  372. package/dist/bundled/v2/components/OrRichTextEditorV3/index.d.ts +0 -1
  373. package/dist/bundled/v2/components/OrRichTextEditorV3/index.js +0 -68
  374. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.d.ts +0 -6
  375. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.js +0 -38
  376. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.d.ts +0 -3
  377. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +0 -45
  378. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.d.ts +0 -27
  379. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +0 -184
  380. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/index.d.ts +0 -1
  381. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/index.js +0 -5
  382. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/theme.d.ts +0 -24
  383. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/theme.js +0 -190
  384. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/types.d.ts +0 -19
  385. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.d.ts +0 -3
  386. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.js +0 -5
  387. package/dist/bundled/v2/index-62c3221b.js +0 -6956
  388. package/dist/bundled/v2/index.es-3f39f316.js +0 -115
  389. package/dist/bundled/v2/markdown-516daba9.js +0 -18737
  390. package/dist/bundled/v2/tiptap-core.esm-f85402b1.js +0 -9360
  391. package/dist/bundled/v2/useFocusTrap-9567b3c8.js +0 -1268
  392. package/dist/bundled/v3/OrCode.vue_vue_type_script_lang-f6f74339.js +0 -236
  393. package/dist/bundled/v3/OrModal.vue_vue_type_script_lang-af0c4288.js +0 -107
  394. package/dist/bundled/v3/OrRichTextEditor.vue_vue_type_script_lang-fec87993.js +0 -1765
  395. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +0 -228
  396. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +0 -170
  397. package/dist/bundled/v3/components/OrRichTextEditorV3/index.d.ts +0 -1
  398. package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +0 -84
  399. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.d.ts +0 -6
  400. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +0 -38
  401. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.d.ts +0 -3
  402. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +0 -45
  403. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.d.ts +0 -27
  404. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +0 -184
  405. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.d.ts +0 -1
  406. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +0 -5
  407. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.d.ts +0 -24
  408. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +0 -190
  409. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/types.d.ts +0 -19
  410. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.d.ts +0 -3
  411. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +0 -5
  412. package/dist/bundled/v3/index-16aee5bc.js +0 -3740
  413. package/dist/bundled/v3/index-62c3221b.js +0 -6956
  414. package/dist/bundled/v3/index.es-3f39f316.js +0 -115
  415. package/dist/bundled/v3/markdown-516daba9.js +0 -18737
  416. package/dist/bundled/v3/tiptap-core.esm-f85402b1.js +0 -9360
  417. package/dist/esm/v2/OrRichTextEditor-b3da3217.js +0 -724
  418. package/dist/esm/v2/codemirrorView-be2c7423.js +0 -353
  419. package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -170
  420. package/dist/esm/v2/components/or-rich-text-editor-v3/index.d.ts +0 -1
  421. package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +0 -59
  422. package/dist/esm/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -6
  423. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.d.ts +0 -3
  424. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.d.ts +0 -27
  425. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/index.d.ts +0 -1
  426. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/index.js +0 -7
  427. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/theme.d.ts +0 -24
  428. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/types.d.ts +0 -19
  429. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/markdown.d.ts +0 -3
  430. package/dist/esm/v3/OrRichTextEditor-39eb04a8.js +0 -687
  431. package/dist/esm/v3/codemirrorView-be2c7423.js +0 -353
  432. package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -170
  433. package/dist/esm/v3/components/or-rich-text-editor-v3/index.d.ts +0 -1
  434. package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +0 -57
  435. package/dist/esm/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -6
  436. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.d.ts +0 -3
  437. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.d.ts +0 -27
  438. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/index.d.ts +0 -1
  439. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/index.js +0 -7
  440. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/theme.d.ts +0 -24
  441. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/types.d.ts +0 -19
  442. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/markdown.d.ts +0 -3
  443. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.docs.mdx +0 -7
  444. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.ts +0 -102
  445. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +0 -624
  446. package/src/components/or-rich-text-editor-v3/index.ts +0 -1
  447. package/src/components/or-rich-text-editor-v3/styles.ts +0 -64
  448. package/src/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.ts +0 -40
  449. package/src/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.ts +0 -254
  450. package/src/components/or-rich-text-editor-v3/utils/codemirror/index.ts +0 -1
  451. package/src/components/or-rich-text-editor-v3/utils/codemirror/theme.ts +0 -213
  452. package/src/components/or-rich-text-editor-v3/utils/codemirror/types.ts +0 -22
  453. package/src/components/or-rich-text-editor-v3/utils/markdown.ts +0 -117
  454. /package/dist/bundled/v2/components/{OrRichTextEditorV3/utils/codemirror → OrCheckboxTreeV3}/types.js +0 -0
  455. /package/dist/bundled/v3/{OrIcon.vue_vue_type_script_lang-e3152dc5.js → OrIcon.vue_vue_type_script_lang-e5349e49.js} +0 -0
  456. /package/dist/bundled/v3/{OrToastContainer.vue_vue_type_script_lang-0811fd48.js → OrToastContainer.vue_vue_type_script_lang-70cc38be.js} +0 -0
  457. /package/dist/bundled/v3/{OrTooltip.vue_vue_type_script_lang-b8594f7e.js → OrTooltip.vue_vue_type_script_lang-76a6b7f4.js} +0 -0
  458. /package/dist/bundled/v3/components/{OrRichTextEditorV3/utils/codemirror → OrCheckboxTreeV3}/types.js +0 -0
@@ -1,10 +1,9 @@
1
- import { E as EditorView, a as EditorState, k as keymap } from '../../index-f5487f12.js';
2
- import { b as basicSetup, i as indentWithTab } from '../../index-16aee5bc.js';
1
+ import { E as EditorView, F as Facet, c as combineConfig, S as StateField, a as EditorSelection, T as Transaction, C as ChangeSet, b as ChangeDesc, I as IndentContext, g as getIndentation, i as indentString, d as Text, e as indentUnit, f as countColumn, h as getIndentUnit, A as Annotation, j as StateEffect, m as matchBrackets, s as syntaxTree, N as NodeProp, D as Direction, k as findClusterBreak, V as ViewPlugin, l as Decoration, n as codePointAt, o as codePointSize, p as getPanel, q as CharCategory, P as Prec, r as fromCodePoint, t as showPanel, R as RangeSetBuilder, u as EditorState, v as runScopeHandlers, w as hoverTooltip, W as WidgetType, x as logException, y as lineNumbers, z as highlightActiveLineGutter, B as highlightSpecialChars, G as foldGutter, H as drawSelection, J as dropCursor, K as indentOnInput, L as syntaxHighlighting, M as defaultHighlightStyle, O as bracketMatching, Q as rectangularSelection, U as crosshairCursor, X as highlightActiveLine, Y as keymap, Z as foldKeymap } from '../../index-6976c52a.js';
2
+ import { c as closeBrackets, a as autocompletion, b as closeBracketsKeymap, d as completionKeymap, l as languages } from '../../lang-02d2bb2d.js';
3
3
  import { useElementHover } from '@vueuse/core';
4
4
  import { defineComponent, ref } from 'vue-demi';
5
5
  import __vue_component__$3 from '../OrTeleport/OrTeleport.js';
6
6
  import { OrCodeLanguages } from './constants.js';
7
- import languages from './lang.js';
8
7
  import theme from './theme.js';
9
8
  import __vue_component__$1 from '../OrIconButtonV2/OrIconButton.js';
10
9
  import __vue_component__$2 from '../OrModal/OrModal.js';
@@ -13,8 +12,6 @@ import __vue_component__$5 from '../OrHint/OrHint.js';
13
12
  import __vue_component__$6 from '../OrLabel/OrLabel.js';
14
13
  import { s as styleInject } from '../../style-inject.es-4c6f2515.js';
15
14
  import { n as normalizeComponent } from '../../normalize-component-6e8e3d80.js';
16
- import '../../index.es-3f39f316.js';
17
- import '../../index-70ca38c5.js';
18
15
  import 'portal-vue/dist/portal-vue.esm.js';
19
16
  import '../OrTeleport/constants.js';
20
17
  import '../OrTooltip/OrTooltip.js';
@@ -31,9 +28,3733 @@ import '../../utils/functions/px-to-rem.js';
31
28
  import '../OrLoader/OrLoader.js';
32
29
  import '../OrLoader/constants.js';
33
30
  import '../OrModal/constants.js';
34
- import '../../useFocusTrap-9567b3c8.js';
35
31
  import '../OrOverlay/OrOverlay.js';
36
32
 
33
+ /**
34
+ Comment or uncomment the current selection. Will use line comments
35
+ if available, otherwise falling back to block comments.
36
+ */
37
+ const toggleComment = target => {
38
+ let {
39
+ state
40
+ } = target,
41
+ line = state.doc.lineAt(state.selection.main.head),
42
+ config = getConfig(target.state, line.from);
43
+ return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
44
+ };
45
+ function command(f, option) {
46
+ return ({
47
+ state,
48
+ dispatch
49
+ }) => {
50
+ if (state.readOnly) return false;
51
+ let tr = f(option, state);
52
+ if (!tr) return false;
53
+ dispatch(state.update(tr));
54
+ return true;
55
+ };
56
+ }
57
+ /**
58
+ Comment or uncomment the current selection using line comments.
59
+ The line comment syntax is taken from the
60
+ [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
61
+ data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
62
+ */
63
+ const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);
64
+ /**
65
+ Comment or uncomment the current selection using block comments.
66
+ The block comment syntax is taken from the
67
+ [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
68
+ data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
69
+ */
70
+ const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);
71
+ /**
72
+ Comment or uncomment the lines around the current selection using
73
+ block comments.
74
+ */
75
+ const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);
76
+ function getConfig(state, pos) {
77
+ let data = state.languageDataAt("commentTokens", pos);
78
+ return data.length ? data[0] : {};
79
+ }
80
+ const SearchMargin = 50;
81
+ /**
82
+ Determines if the given range is block-commented in the given
83
+ state.
84
+ */
85
+ function findBlockComment(state, {
86
+ open,
87
+ close
88
+ }, from, to) {
89
+ let textBefore = state.sliceDoc(from - SearchMargin, from);
90
+ let textAfter = state.sliceDoc(to, to + SearchMargin);
91
+ let spaceBefore = /\s*$/.exec(textBefore)[0].length,
92
+ spaceAfter = /^\s*/.exec(textAfter)[0].length;
93
+ let beforeOff = textBefore.length - spaceBefore;
94
+ if (textBefore.slice(beforeOff - open.length, beforeOff) == open && textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
95
+ return {
96
+ open: {
97
+ pos: from - spaceBefore,
98
+ margin: spaceBefore && 1
99
+ },
100
+ close: {
101
+ pos: to + spaceAfter,
102
+ margin: spaceAfter && 1
103
+ }
104
+ };
105
+ }
106
+ let startText, endText;
107
+ if (to - from <= 2 * SearchMargin) {
108
+ startText = endText = state.sliceDoc(from, to);
109
+ } else {
110
+ startText = state.sliceDoc(from, from + SearchMargin);
111
+ endText = state.sliceDoc(to - SearchMargin, to);
112
+ }
113
+ let startSpace = /^\s*/.exec(startText)[0].length,
114
+ endSpace = /\s*$/.exec(endText)[0].length;
115
+ let endOff = endText.length - endSpace - close.length;
116
+ if (startText.slice(startSpace, startSpace + open.length) == open && endText.slice(endOff, endOff + close.length) == close) {
117
+ return {
118
+ open: {
119
+ pos: from + startSpace + open.length,
120
+ margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0
121
+ },
122
+ close: {
123
+ pos: to - endSpace - close.length,
124
+ margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0
125
+ }
126
+ };
127
+ }
128
+ return null;
129
+ }
130
+ function selectedLineRanges(state) {
131
+ let ranges = [];
132
+ for (let r of state.selection.ranges) {
133
+ let fromLine = state.doc.lineAt(r.from);
134
+ let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
135
+ let last = ranges.length - 1;
136
+ if (last >= 0 && ranges[last].to > fromLine.from) ranges[last].to = toLine.to;else ranges.push({
137
+ from: fromLine.from,
138
+ to: toLine.to
139
+ });
140
+ }
141
+ return ranges;
142
+ }
143
+ // Performs toggle, comment and uncomment of block comments in
144
+ // languages that support them.
145
+ function changeBlockComment(option, state, ranges = state.selection.ranges) {
146
+ let tokens = ranges.map(r => getConfig(state, r.from).block);
147
+ if (!tokens.every(c => c)) return null;
148
+ let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
149
+ if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {
150
+ return {
151
+ changes: state.changes(ranges.map((range, i) => {
152
+ if (comments[i]) return [];
153
+ return [{
154
+ from: range.from,
155
+ insert: tokens[i].open + " "
156
+ }, {
157
+ from: range.to,
158
+ insert: " " + tokens[i].close
159
+ }];
160
+ }))
161
+ };
162
+ } else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {
163
+ let changes = [];
164
+ for (let i = 0, comment; i < comments.length; i++) if (comment = comments[i]) {
165
+ let token = tokens[i],
166
+ {
167
+ open,
168
+ close
169
+ } = comment;
170
+ changes.push({
171
+ from: open.pos - token.open.length,
172
+ to: open.pos + open.margin
173
+ }, {
174
+ from: close.pos - close.margin,
175
+ to: close.pos + token.close.length
176
+ });
177
+ }
178
+ return {
179
+ changes
180
+ };
181
+ }
182
+ return null;
183
+ }
184
+ // Performs toggle, comment and uncomment of line comments.
185
+ function changeLineComment(option, state, ranges = state.selection.ranges) {
186
+ let lines = [];
187
+ let prevLine = -1;
188
+ for (let {
189
+ from,
190
+ to
191
+ } of ranges) {
192
+ let startI = lines.length,
193
+ minIndent = 1e9;
194
+ for (let pos = from; pos <= to;) {
195
+ let line = state.doc.lineAt(pos);
196
+ if (line.from > prevLine && (from == to || to > line.from)) {
197
+ prevLine = line.from;
198
+ let token = getConfig(state, line.from).line;
199
+ if (!token) continue;
200
+ let indent = /^\s*/.exec(line.text)[0].length;
201
+ let empty = indent == line.length;
202
+ let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
203
+ if (indent < line.text.length && indent < minIndent) minIndent = indent;
204
+ lines.push({
205
+ line,
206
+ comment,
207
+ token,
208
+ indent,
209
+ empty,
210
+ single: false
211
+ });
212
+ }
213
+ pos = line.to + 1;
214
+ }
215
+ if (minIndent < 1e9) for (let i = startI; i < lines.length; i++) if (lines[i].indent < lines[i].line.text.length) lines[i].indent = minIndent;
216
+ if (lines.length == startI + 1) lines[startI].single = true;
217
+ }
218
+ if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
219
+ let changes = [];
220
+ for (let {
221
+ line,
222
+ token,
223
+ indent,
224
+ empty,
225
+ single
226
+ } of lines) if (single || !empty) changes.push({
227
+ from: line.from + indent,
228
+ insert: token + " "
229
+ });
230
+ let changeSet = state.changes(changes);
231
+ return {
232
+ changes: changeSet,
233
+ selection: state.selection.map(changeSet, 1)
234
+ };
235
+ } else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {
236
+ let changes = [];
237
+ for (let {
238
+ line,
239
+ comment,
240
+ token
241
+ } of lines) if (comment >= 0) {
242
+ let from = line.from + comment,
243
+ to = from + token.length;
244
+ if (line.text[to - line.from] == " ") to++;
245
+ changes.push({
246
+ from,
247
+ to
248
+ });
249
+ }
250
+ return {
251
+ changes
252
+ };
253
+ }
254
+ return null;
255
+ }
256
+ const fromHistory = /*@__PURE__*/Annotation.define();
257
+ /**
258
+ Transaction annotation that will prevent that transaction from
259
+ being combined with other transactions in the undo history. Given
260
+ `"before"`, it'll prevent merging with previous transactions. With
261
+ `"after"`, subsequent transactions won't be combined with this
262
+ one. With `"full"`, the transaction is isolated on both sides.
263
+ */
264
+ const isolateHistory = /*@__PURE__*/Annotation.define();
265
+ /**
266
+ This facet provides a way to register functions that, given a
267
+ transaction, provide a set of effects that the history should
268
+ store when inverting the transaction. This can be used to
269
+ integrate some kinds of effects in the history, so that they can
270
+ be undone (and redone again).
271
+ */
272
+ const invertedEffects = /*@__PURE__*/Facet.define();
273
+ const historyConfig = /*@__PURE__*/Facet.define({
274
+ combine(configs) {
275
+ return combineConfig(configs, {
276
+ minDepth: 100,
277
+ newGroupDelay: 500,
278
+ joinToEvent: (_t, isAdjacent) => isAdjacent
279
+ }, {
280
+ minDepth: Math.max,
281
+ newGroupDelay: Math.min,
282
+ joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)
283
+ });
284
+ }
285
+ });
286
+ function changeEnd(changes) {
287
+ let end = 0;
288
+ changes.iterChangedRanges((_, to) => end = to);
289
+ return end;
290
+ }
291
+ const historyField_ = /*@__PURE__*/StateField.define({
292
+ create() {
293
+ return HistoryState.empty;
294
+ },
295
+ update(state, tr) {
296
+ let config = tr.state.facet(historyConfig);
297
+ let fromHist = tr.annotation(fromHistory);
298
+ if (fromHist) {
299
+ let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
300
+ let item = HistEvent.fromTransaction(tr, selection),
301
+ from = fromHist.side;
302
+ let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;
303
+ if (item) other = updateBranch(other, other.length, config.minDepth, item);else other = addSelection(other, tr.startState.selection);
304
+ return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);
305
+ }
306
+ let isolate = tr.annotation(isolateHistory);
307
+ if (isolate == "full" || isolate == "before") state = state.isolate();
308
+ if (tr.annotation(Transaction.addToHistory) === false) return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
309
+ let event = HistEvent.fromTransaction(tr);
310
+ let time = tr.annotation(Transaction.time),
311
+ userEvent = tr.annotation(Transaction.userEvent);
312
+ if (event) state = state.addChanges(event, time, userEvent, config, tr);else if (tr.selection) state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
313
+ if (isolate == "full" || isolate == "after") state = state.isolate();
314
+ return state;
315
+ },
316
+ toJSON(value) {
317
+ return {
318
+ done: value.done.map(e => e.toJSON()),
319
+ undone: value.undone.map(e => e.toJSON())
320
+ };
321
+ },
322
+ fromJSON(json) {
323
+ return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
324
+ }
325
+ });
326
+ /**
327
+ Create a history extension with the given configuration.
328
+ */
329
+ function history(config = {}) {
330
+ return [historyField_, historyConfig.of(config), EditorView.domEventHandlers({
331
+ beforeinput(e, view) {
332
+ let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
333
+ if (!command) return false;
334
+ e.preventDefault();
335
+ return command(view);
336
+ }
337
+ })];
338
+ }
339
+ function cmd(side, selection) {
340
+ return function ({
341
+ state,
342
+ dispatch
343
+ }) {
344
+ if (!selection && state.readOnly) return false;
345
+ let historyState = state.field(historyField_, false);
346
+ if (!historyState) return false;
347
+ let tr = historyState.pop(side, state, selection);
348
+ if (!tr) return false;
349
+ dispatch(tr);
350
+ return true;
351
+ };
352
+ }
353
+ /**
354
+ Undo a single group of history events. Returns false if no group
355
+ was available.
356
+ */
357
+ const undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);
358
+ /**
359
+ Redo a group of history events. Returns false if no group was
360
+ available.
361
+ */
362
+ const redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);
363
+ /**
364
+ Undo a change or selection change.
365
+ */
366
+ const undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);
367
+ /**
368
+ Redo a change or selection change.
369
+ */
370
+ const redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);
371
+ // History events store groups of changes or effects that need to be
372
+ // undone/redone together.
373
+ class HistEvent {
374
+ constructor(
375
+ // The changes in this event. Normal events hold at least one
376
+ // change or effect. But it may be necessary to store selection
377
+ // events before the first change, in which case a special type of
378
+ // instance is created which doesn't hold any changes, with
379
+ // changes == startSelection == undefined
380
+ changes,
381
+ // The effects associated with this event
382
+ effects,
383
+ // Accumulated mapping (from addToHistory==false) that should be
384
+ // applied to events below this one.
385
+ mapped,
386
+ // The selection before this event
387
+ startSelection,
388
+ // Stores selection changes after this event, to be used for
389
+ // selection undo/redo.
390
+ selectionsAfter) {
391
+ this.changes = changes;
392
+ this.effects = effects;
393
+ this.mapped = mapped;
394
+ this.startSelection = startSelection;
395
+ this.selectionsAfter = selectionsAfter;
396
+ }
397
+ setSelAfter(after) {
398
+ return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
399
+ }
400
+ toJSON() {
401
+ var _a, _b, _c;
402
+ return {
403
+ changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
404
+ mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
405
+ startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
406
+ selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
407
+ };
408
+ }
409
+ static fromJSON(json) {
410
+ return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON));
411
+ }
412
+ // This does not check `addToHistory` and such, it assumes the
413
+ // transaction needs to be converted to an item. Returns null when
414
+ // there are no changes or effects in the transaction.
415
+ static fromTransaction(tr, selection) {
416
+ let effects = none;
417
+ for (let invert of tr.startState.facet(invertedEffects)) {
418
+ let result = invert(tr);
419
+ if (result.length) effects = effects.concat(result);
420
+ }
421
+ if (!effects.length && tr.changes.empty) return null;
422
+ return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none);
423
+ }
424
+ static selection(selections) {
425
+ return new HistEvent(undefined, none, undefined, undefined, selections);
426
+ }
427
+ }
428
+ function updateBranch(branch, to, maxLen, newEvent) {
429
+ let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
430
+ let newBranch = branch.slice(start, to);
431
+ newBranch.push(newEvent);
432
+ return newBranch;
433
+ }
434
+ function isAdjacent(a, b) {
435
+ let ranges = [],
436
+ isAdjacent = false;
437
+ a.iterChangedRanges((f, t) => ranges.push(f, t));
438
+ b.iterChangedRanges((_f, _t, f, t) => {
439
+ for (let i = 0; i < ranges.length;) {
440
+ let from = ranges[i++],
441
+ to = ranges[i++];
442
+ if (t >= from && f <= to) isAdjacent = true;
443
+ }
444
+ });
445
+ return isAdjacent;
446
+ }
447
+ function eqSelectionShape(a, b) {
448
+ return a.ranges.length == b.ranges.length && a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
449
+ }
450
+ function conc(a, b) {
451
+ return !a.length ? b : !b.length ? a : a.concat(b);
452
+ }
453
+ const none = [];
454
+ const MaxSelectionsPerEvent = 200;
455
+ function addSelection(branch, selection) {
456
+ if (!branch.length) {
457
+ return [HistEvent.selection([selection])];
458
+ } else {
459
+ let lastEvent = branch[branch.length - 1];
460
+ let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
461
+ if (sels.length && sels[sels.length - 1].eq(selection)) return branch;
462
+ sels.push(selection);
463
+ return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
464
+ }
465
+ }
466
+ // Assumes the top item has one or more selectionAfter values
467
+ function popSelection(branch) {
468
+ let last = branch[branch.length - 1];
469
+ let newBranch = branch.slice();
470
+ newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
471
+ return newBranch;
472
+ }
473
+ // Add a mapping to the top event in the given branch. If this maps
474
+ // away all the changes and effects in that item, drop it and
475
+ // propagate the mapping to the next item.
476
+ function addMappingToBranch(branch, mapping) {
477
+ if (!branch.length) return branch;
478
+ let length = branch.length,
479
+ selections = none;
480
+ while (length) {
481
+ let event = mapEvent(branch[length - 1], mapping, selections);
482
+ if (event.changes && !event.changes.empty || event.effects.length) {
483
+ // Event survived mapping
484
+ let result = branch.slice(0, length);
485
+ result[length - 1] = event;
486
+ return result;
487
+ } else {
488
+ // Drop this event, since there's no changes or effects left
489
+ mapping = event.mapped;
490
+ length--;
491
+ selections = event.selectionsAfter;
492
+ }
493
+ }
494
+ return selections.length ? [HistEvent.selection(selections)] : none;
495
+ }
496
+ function mapEvent(event, mapping, extraSelections) {
497
+ let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections);
498
+ // Change-less events don't store mappings (they are always the last event in a branch)
499
+ if (!event.changes) return HistEvent.selection(selections);
500
+ let mappedChanges = event.changes.map(mapping),
501
+ before = mapping.mapDesc(event.changes, true);
502
+ let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
503
+ return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
504
+ }
505
+ const joinableUserEvent = /^(input\.type|delete)($|\.)/;
506
+ class HistoryState {
507
+ constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
508
+ this.done = done;
509
+ this.undone = undone;
510
+ this.prevTime = prevTime;
511
+ this.prevUserEvent = prevUserEvent;
512
+ }
513
+ isolate() {
514
+ return this.prevTime ? new HistoryState(this.done, this.undone) : this;
515
+ }
516
+ addChanges(event, time, userEvent, config, tr) {
517
+ let done = this.done,
518
+ lastEvent = done[done.length - 1];
519
+ if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes && (!userEvent || joinableUserEvent.test(userEvent)) && (!lastEvent.selectionsAfter.length && time - this.prevTime < config.newGroupDelay && config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes)) ||
520
+ // For compose (but not compose.start) events, always join with previous event
521
+ userEvent == "input.type.compose")) {
522
+ done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));
523
+ } else {
524
+ done = updateBranch(done, done.length, config.minDepth, event);
525
+ }
526
+ return new HistoryState(done, none, time, userEvent);
527
+ }
528
+ addSelection(selection, time, userEvent, newGroupDelay) {
529
+ let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none;
530
+ if (last.length > 0 && time - this.prevTime < newGroupDelay && userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) && eqSelectionShape(last[last.length - 1], selection)) return this;
531
+ return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
532
+ }
533
+ addMapping(mapping) {
534
+ return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
535
+ }
536
+ pop(side, state, selection) {
537
+ let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;
538
+ if (branch.length == 0) return null;
539
+ let event = branch[branch.length - 1];
540
+ if (selection && event.selectionsAfter.length) {
541
+ return state.update({
542
+ selection: event.selectionsAfter[event.selectionsAfter.length - 1],
543
+ annotations: fromHistory.of({
544
+ side,
545
+ rest: popSelection(branch)
546
+ }),
547
+ userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo",
548
+ scrollIntoView: true
549
+ });
550
+ } else if (!event.changes) {
551
+ return null;
552
+ } else {
553
+ let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1);
554
+ if (event.mapped) rest = addMappingToBranch(rest, event.mapped);
555
+ return state.update({
556
+ changes: event.changes,
557
+ selection: event.startSelection,
558
+ effects: event.effects,
559
+ annotations: fromHistory.of({
560
+ side,
561
+ rest
562
+ }),
563
+ filter: false,
564
+ userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo",
565
+ scrollIntoView: true
566
+ });
567
+ }
568
+ }
569
+ }
570
+ HistoryState.empty = /*@__PURE__*/new HistoryState(none, none);
571
+ /**
572
+ Default key bindings for the undo history.
573
+
574
+ - Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
575
+ - Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
576
+ - Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
577
+ - Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
578
+ */
579
+ const historyKeymap = [{
580
+ key: "Mod-z",
581
+ run: undo,
582
+ preventDefault: true
583
+ }, {
584
+ key: "Mod-y",
585
+ mac: "Mod-Shift-z",
586
+ run: redo,
587
+ preventDefault: true
588
+ }, {
589
+ linux: "Ctrl-Shift-z",
590
+ run: redo,
591
+ preventDefault: true
592
+ }, {
593
+ key: "Mod-u",
594
+ run: undoSelection,
595
+ preventDefault: true
596
+ }, {
597
+ key: "Alt-u",
598
+ mac: "Mod-Shift-u",
599
+ run: redoSelection,
600
+ preventDefault: true
601
+ }];
602
+ function updateSel(sel, by) {
603
+ return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
604
+ }
605
+ function setSel(state, selection) {
606
+ return state.update({
607
+ selection,
608
+ scrollIntoView: true,
609
+ userEvent: "select"
610
+ });
611
+ }
612
+ function moveSel({
613
+ state,
614
+ dispatch
615
+ }, how) {
616
+ let selection = updateSel(state.selection, how);
617
+ if (selection.eq(state.selection)) return false;
618
+ dispatch(setSel(state, selection));
619
+ return true;
620
+ }
621
+ function rangeEnd(range, forward) {
622
+ return EditorSelection.cursor(forward ? range.to : range.from);
623
+ }
624
+ function cursorByChar(view, forward) {
625
+ return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
626
+ }
627
+ function ltrAtCursor(view) {
628
+ return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
629
+ }
630
+ /**
631
+ Move the selection one character to the left (which is backward in
632
+ left-to-right text, forward in right-to-left text).
633
+ */
634
+ const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
635
+ /**
636
+ Move the selection one character to the right.
637
+ */
638
+ const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
639
+ function cursorByGroup(view, forward) {
640
+ return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
641
+ }
642
+ /**
643
+ Move the selection to the left across one group of word or
644
+ non-word (but also non-space) characters.
645
+ */
646
+ const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
647
+ /**
648
+ Move the selection one group to the right.
649
+ */
650
+ const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
651
+ function interestingNode(state, node, bracketProp) {
652
+ if (node.type.prop(bracketProp)) return true;
653
+ let len = node.to - node.from;
654
+ return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
655
+ }
656
+ function moveBySyntax(state, start, forward) {
657
+ let pos = syntaxTree(state).resolveInner(start.head);
658
+ let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;
659
+ // Scan forward through child nodes to see if there's an interesting
660
+ // node ahead.
661
+ for (let at = start.head;;) {
662
+ let next = forward ? pos.childAfter(at) : pos.childBefore(at);
663
+ if (!next) break;
664
+ if (interestingNode(state, next, bracketProp)) pos = next;else at = forward ? next.to : next.from;
665
+ }
666
+ let bracket = pos.type.prop(bracketProp),
667
+ match,
668
+ newPos;
669
+ if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched) newPos = forward ? match.end.to : match.end.from;else newPos = forward ? pos.to : pos.from;
670
+ return EditorSelection.cursor(newPos, forward ? -1 : 1);
671
+ }
672
+ /**
673
+ Move the cursor over the next syntactic element to the left.
674
+ */
675
+ const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
676
+ /**
677
+ Move the cursor over the next syntactic element to the right.
678
+ */
679
+ const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
680
+ function cursorByLine(view, forward) {
681
+ return moveSel(view, range => {
682
+ if (!range.empty) return rangeEnd(range, forward);
683
+ let moved = view.moveVertically(range, forward);
684
+ return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
685
+ });
686
+ }
687
+ /**
688
+ Move the selection one line up.
689
+ */
690
+ const cursorLineUp = view => cursorByLine(view, false);
691
+ /**
692
+ Move the selection one line down.
693
+ */
694
+ const cursorLineDown = view => cursorByLine(view, true);
695
+ function pageInfo(view) {
696
+ let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2;
697
+ let marginTop = 0,
698
+ marginBottom = 0,
699
+ height;
700
+ if (selfScroll) {
701
+ for (let source of view.state.facet(EditorView.scrollMargins)) {
702
+ let margins = source(view);
703
+ if (margins === null || margins === void 0 ? void 0 : margins.top) marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop);
704
+ if (margins === null || margins === void 0 ? void 0 : margins.bottom) marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom);
705
+ }
706
+ height = view.scrollDOM.clientHeight - marginTop - marginBottom;
707
+ } else {
708
+ height = (view.dom.ownerDocument.defaultView || window).innerHeight;
709
+ }
710
+ return {
711
+ marginTop,
712
+ marginBottom,
713
+ selfScroll,
714
+ height: Math.max(view.defaultLineHeight, height - 5)
715
+ };
716
+ }
717
+ function cursorByPage(view, forward) {
718
+ let page = pageInfo(view);
719
+ let {
720
+ state
721
+ } = view,
722
+ selection = updateSel(state.selection, range => {
723
+ return range.empty ? view.moveVertically(range, forward, page.height) : rangeEnd(range, forward);
724
+ });
725
+ if (selection.eq(state.selection)) return false;
726
+ let effect;
727
+ if (page.selfScroll) {
728
+ let startPos = view.coordsAtPos(state.selection.main.head);
729
+ let scrollRect = view.scrollDOM.getBoundingClientRect();
730
+ let scrollTop = scrollRect.top + page.marginTop,
731
+ scrollBottom = scrollRect.bottom - page.marginBottom;
732
+ if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom) effect = EditorView.scrollIntoView(selection.main.head, {
733
+ y: "start",
734
+ yMargin: startPos.top - scrollTop
735
+ });
736
+ }
737
+ view.dispatch(setSel(state, selection), {
738
+ effects: effect
739
+ });
740
+ return true;
741
+ }
742
+ /**
743
+ Move the selection one page up.
744
+ */
745
+ const cursorPageUp = view => cursorByPage(view, false);
746
+ /**
747
+ Move the selection one page down.
748
+ */
749
+ const cursorPageDown = view => cursorByPage(view, true);
750
+ function moveByLineBoundary(view, start, forward) {
751
+ let line = view.lineBlockAt(start.head),
752
+ moved = view.moveToLineBoundary(start, forward);
753
+ if (moved.head == start.head && moved.head != (forward ? line.to : line.from)) moved = view.moveToLineBoundary(start, forward, false);
754
+ if (!forward && moved.head == line.from && line.length) {
755
+ let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
756
+ if (space && start.head != line.from + space) moved = EditorSelection.cursor(line.from + space);
757
+ }
758
+ return moved;
759
+ }
760
+ /**
761
+ Move the selection to the next line wrap point, or to the end of
762
+ the line if there isn't one left on this line.
763
+ */
764
+ const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
765
+ /**
766
+ Move the selection to previous line wrap point, or failing that to
767
+ the start of the line. If the line is indented, and the cursor
768
+ isn't already at the end of the indentation, this will move to the
769
+ end of the indentation instead of the start of the line.
770
+ */
771
+ const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
772
+ /**
773
+ Move the selection one line wrap point to the left.
774
+ */
775
+ const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
776
+ /**
777
+ Move the selection one line wrap point to the right.
778
+ */
779
+ const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
780
+ /**
781
+ Move the selection to the start of the line.
782
+ */
783
+ const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
784
+ /**
785
+ Move the selection to the end of the line.
786
+ */
787
+ const cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));
788
+ function toMatchingBracket(state, dispatch, extend) {
789
+ let found = false,
790
+ selection = updateSel(state.selection, range => {
791
+ let matching = matchBrackets(state, range.head, -1) || matchBrackets(state, range.head, 1) || range.head > 0 && matchBrackets(state, range.head - 1, 1) || range.head < state.doc.length && matchBrackets(state, range.head + 1, -1);
792
+ if (!matching || !matching.end) return range;
793
+ found = true;
794
+ let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
795
+ return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);
796
+ });
797
+ if (!found) return false;
798
+ dispatch(setSel(state, selection));
799
+ return true;
800
+ }
801
+ /**
802
+ Move the selection to the bracket matching the one it is currently
803
+ on, if any.
804
+ */
805
+ const cursorMatchingBracket = ({
806
+ state,
807
+ dispatch
808
+ }) => toMatchingBracket(state, dispatch, false);
809
+ function extendSel(view, how) {
810
+ let selection = updateSel(view.state.selection, range => {
811
+ let head = how(range);
812
+ return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);
813
+ });
814
+ if (selection.eq(view.state.selection)) return false;
815
+ view.dispatch(setSel(view.state, selection));
816
+ return true;
817
+ }
818
+ function selectByChar(view, forward) {
819
+ return extendSel(view, range => view.moveByChar(range, forward));
820
+ }
821
+ /**
822
+ Move the selection head one character to the left, while leaving
823
+ the anchor in place.
824
+ */
825
+ const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
826
+ /**
827
+ Move the selection head one character to the right.
828
+ */
829
+ const selectCharRight = view => selectByChar(view, ltrAtCursor(view));
830
+ function selectByGroup(view, forward) {
831
+ return extendSel(view, range => view.moveByGroup(range, forward));
832
+ }
833
+ /**
834
+ Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
835
+ the left.
836
+ */
837
+ const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
838
+ /**
839
+ Move the selection head one group to the right.
840
+ */
841
+ const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
842
+ /**
843
+ Move the selection head over the next syntactic element to the left.
844
+ */
845
+ const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
846
+ /**
847
+ Move the selection head over the next syntactic element to the right.
848
+ */
849
+ const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
850
+ function selectByLine(view, forward) {
851
+ return extendSel(view, range => view.moveVertically(range, forward));
852
+ }
853
+ /**
854
+ Move the selection head one line up.
855
+ */
856
+ const selectLineUp = view => selectByLine(view, false);
857
+ /**
858
+ Move the selection head one line down.
859
+ */
860
+ const selectLineDown = view => selectByLine(view, true);
861
+ function selectByPage(view, forward) {
862
+ return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height));
863
+ }
864
+ /**
865
+ Move the selection head one page up.
866
+ */
867
+ const selectPageUp = view => selectByPage(view, false);
868
+ /**
869
+ Move the selection head one page down.
870
+ */
871
+ const selectPageDown = view => selectByPage(view, true);
872
+ /**
873
+ Move the selection head to the next line boundary.
874
+ */
875
+ const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
876
+ /**
877
+ Move the selection head to the previous line boundary.
878
+ */
879
+ const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
880
+ /**
881
+ Move the selection head one line boundary to the left.
882
+ */
883
+ const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
884
+ /**
885
+ Move the selection head one line boundary to the right.
886
+ */
887
+ const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
888
+ /**
889
+ Move the selection head to the start of the line.
890
+ */
891
+ const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));
892
+ /**
893
+ Move the selection head to the end of the line.
894
+ */
895
+ const selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));
896
+ /**
897
+ Move the selection to the start of the document.
898
+ */
899
+ const cursorDocStart = ({
900
+ state,
901
+ dispatch
902
+ }) => {
903
+ dispatch(setSel(state, {
904
+ anchor: 0
905
+ }));
906
+ return true;
907
+ };
908
+ /**
909
+ Move the selection to the end of the document.
910
+ */
911
+ const cursorDocEnd = ({
912
+ state,
913
+ dispatch
914
+ }) => {
915
+ dispatch(setSel(state, {
916
+ anchor: state.doc.length
917
+ }));
918
+ return true;
919
+ };
920
+ /**
921
+ Move the selection head to the start of the document.
922
+ */
923
+ const selectDocStart = ({
924
+ state,
925
+ dispatch
926
+ }) => {
927
+ dispatch(setSel(state, {
928
+ anchor: state.selection.main.anchor,
929
+ head: 0
930
+ }));
931
+ return true;
932
+ };
933
+ /**
934
+ Move the selection head to the end of the document.
935
+ */
936
+ const selectDocEnd = ({
937
+ state,
938
+ dispatch
939
+ }) => {
940
+ dispatch(setSel(state, {
941
+ anchor: state.selection.main.anchor,
942
+ head: state.doc.length
943
+ }));
944
+ return true;
945
+ };
946
+ /**
947
+ Select the entire document.
948
+ */
949
+ const selectAll = ({
950
+ state,
951
+ dispatch
952
+ }) => {
953
+ dispatch(state.update({
954
+ selection: {
955
+ anchor: 0,
956
+ head: state.doc.length
957
+ },
958
+ userEvent: "select"
959
+ }));
960
+ return true;
961
+ };
962
+ /**
963
+ Expand the selection to cover entire lines.
964
+ */
965
+ const selectLine = ({
966
+ state,
967
+ dispatch
968
+ }) => {
969
+ let ranges = selectedLineBlocks(state).map(({
970
+ from,
971
+ to
972
+ }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));
973
+ dispatch(state.update({
974
+ selection: EditorSelection.create(ranges),
975
+ userEvent: "select"
976
+ }));
977
+ return true;
978
+ };
979
+ /**
980
+ Select the next syntactic construct that is larger than the
981
+ selection. Note that this will only work insofar as the language
982
+ [provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
983
+ syntax tree.
984
+ */
985
+ const selectParentSyntax = ({
986
+ state,
987
+ dispatch
988
+ }) => {
989
+ let selection = updateSel(state.selection, range => {
990
+ var _a;
991
+ let context = syntaxTree(state).resolveInner(range.head, 1);
992
+ while (!(context.from < range.from && context.to >= range.to || context.to > range.to && context.from <= range.from || !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent))) context = context.parent;
993
+ return EditorSelection.range(context.to, context.from);
994
+ });
995
+ dispatch(setSel(state, selection));
996
+ return true;
997
+ };
998
+ /**
999
+ Simplify the current selection. When multiple ranges are selected,
1000
+ reduce it to its main range. Otherwise, if the selection is
1001
+ non-empty, convert it to a cursor selection.
1002
+ */
1003
+ const simplifySelection = ({
1004
+ state,
1005
+ dispatch
1006
+ }) => {
1007
+ let cur = state.selection,
1008
+ selection = null;
1009
+ if (cur.ranges.length > 1) selection = EditorSelection.create([cur.main]);else if (!cur.main.empty) selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);
1010
+ if (!selection) return false;
1011
+ dispatch(setSel(state, selection));
1012
+ return true;
1013
+ };
1014
+ function deleteBy(target, by) {
1015
+ if (target.state.readOnly) return false;
1016
+ let event = "delete.selection",
1017
+ {
1018
+ state
1019
+ } = target;
1020
+ let changes = state.changeByRange(range => {
1021
+ let {
1022
+ from,
1023
+ to
1024
+ } = range;
1025
+ if (from == to) {
1026
+ let towards = by(from);
1027
+ if (towards < from) {
1028
+ event = "delete.backward";
1029
+ towards = skipAtomic(target, towards, false);
1030
+ } else if (towards > from) {
1031
+ event = "delete.forward";
1032
+ towards = skipAtomic(target, towards, true);
1033
+ }
1034
+ from = Math.min(from, towards);
1035
+ to = Math.max(to, towards);
1036
+ } else {
1037
+ from = skipAtomic(target, from, false);
1038
+ to = skipAtomic(target, to, true);
1039
+ }
1040
+ return from == to ? {
1041
+ range
1042
+ } : {
1043
+ changes: {
1044
+ from,
1045
+ to
1046
+ },
1047
+ range: EditorSelection.cursor(from)
1048
+ };
1049
+ });
1050
+ if (changes.changes.empty) return false;
1051
+ target.dispatch(state.update(changes, {
1052
+ scrollIntoView: true,
1053
+ userEvent: event,
1054
+ effects: event == "delete.selection" ? EditorView.announce.of(state.phrase("Selection deleted")) : undefined
1055
+ }));
1056
+ return true;
1057
+ }
1058
+ function skipAtomic(target, pos, forward) {
1059
+ if (target instanceof EditorView) for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target))) ranges.between(pos, pos, (from, to) => {
1060
+ if (from < pos && to > pos) pos = forward ? to : from;
1061
+ });
1062
+ return pos;
1063
+ }
1064
+ const deleteByChar = (target, forward) => deleteBy(target, pos => {
1065
+ let {
1066
+ state
1067
+ } = target,
1068
+ line = state.doc.lineAt(pos),
1069
+ before,
1070
+ targetPos;
1071
+ if (!forward && pos > line.from && pos < line.from + 200 && !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
1072
+ if (before[before.length - 1] == "\t") return pos - 1;
1073
+ let col = countColumn(before, state.tabSize),
1074
+ drop = col % getIndentUnit(state) || getIndentUnit(state);
1075
+ for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++) pos--;
1076
+ targetPos = pos;
1077
+ } else {
1078
+ targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;
1079
+ if (targetPos == pos && line.number != (forward ? state.doc.lines : 1)) targetPos += forward ? 1 : -1;
1080
+ }
1081
+ return targetPos;
1082
+ });
1083
+ /**
1084
+ Delete the selection, or, for cursor selections, the character
1085
+ before the cursor.
1086
+ */
1087
+ const deleteCharBackward = view => deleteByChar(view, false);
1088
+ /**
1089
+ Delete the selection or the character after the cursor.
1090
+ */
1091
+ const deleteCharForward = view => deleteByChar(view, true);
1092
+ const deleteByGroup = (target, forward) => deleteBy(target, start => {
1093
+ let pos = start,
1094
+ {
1095
+ state
1096
+ } = target,
1097
+ line = state.doc.lineAt(pos);
1098
+ let categorize = state.charCategorizer(pos);
1099
+ for (let cat = null;;) {
1100
+ if (pos == (forward ? line.to : line.from)) {
1101
+ if (pos == start && line.number != (forward ? state.doc.lines : 1)) pos += forward ? 1 : -1;
1102
+ break;
1103
+ }
1104
+ let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;
1105
+ let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
1106
+ let nextCat = categorize(nextChar);
1107
+ if (cat != null && nextCat != cat) break;
1108
+ if (nextChar != " " || pos != start) cat = nextCat;
1109
+ pos = next;
1110
+ }
1111
+ return pos;
1112
+ });
1113
+ /**
1114
+ Delete the selection or backward until the end of the next
1115
+ [group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
1116
+ whitespace when they consist of a single space.
1117
+ */
1118
+ const deleteGroupBackward = target => deleteByGroup(target, false);
1119
+ /**
1120
+ Delete the selection or forward until the end of the next group.
1121
+ */
1122
+ const deleteGroupForward = target => deleteByGroup(target, true);
1123
+ /**
1124
+ Delete the selection, or, if it is a cursor selection, delete to
1125
+ the end of the line. If the cursor is directly at the end of the
1126
+ line, delete the line break after it.
1127
+ */
1128
+ const deleteToLineEnd = view => deleteBy(view, pos => {
1129
+ let lineEnd = view.lineBlockAt(pos).to;
1130
+ return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);
1131
+ });
1132
+ /**
1133
+ Delete the selection, or, if it is a cursor selection, delete to
1134
+ the start of the line. If the cursor is directly at the start of the
1135
+ line, delete the line break before it.
1136
+ */
1137
+ const deleteToLineStart = view => deleteBy(view, pos => {
1138
+ let lineStart = view.lineBlockAt(pos).from;
1139
+ return pos > lineStart ? lineStart : Math.max(0, pos - 1);
1140
+ });
1141
+ /**
1142
+ Replace each selection range with a line break, leaving the cursor
1143
+ on the line before the break.
1144
+ */
1145
+ const splitLine = ({
1146
+ state,
1147
+ dispatch
1148
+ }) => {
1149
+ if (state.readOnly) return false;
1150
+ let changes = state.changeByRange(range => {
1151
+ return {
1152
+ changes: {
1153
+ from: range.from,
1154
+ to: range.to,
1155
+ insert: Text.of(["", ""])
1156
+ },
1157
+ range: EditorSelection.cursor(range.from)
1158
+ };
1159
+ });
1160
+ dispatch(state.update(changes, {
1161
+ scrollIntoView: true,
1162
+ userEvent: "input"
1163
+ }));
1164
+ return true;
1165
+ };
1166
+ /**
1167
+ Flip the characters before and after the cursor(s).
1168
+ */
1169
+ const transposeChars = ({
1170
+ state,
1171
+ dispatch
1172
+ }) => {
1173
+ if (state.readOnly) return false;
1174
+ let changes = state.changeByRange(range => {
1175
+ if (!range.empty || range.from == 0 || range.from == state.doc.length) return {
1176
+ range
1177
+ };
1178
+ let pos = range.from,
1179
+ line = state.doc.lineAt(pos);
1180
+ let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;
1181
+ let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;
1182
+ return {
1183
+ changes: {
1184
+ from,
1185
+ to,
1186
+ insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos))
1187
+ },
1188
+ range: EditorSelection.cursor(to)
1189
+ };
1190
+ });
1191
+ if (changes.changes.empty) return false;
1192
+ dispatch(state.update(changes, {
1193
+ scrollIntoView: true,
1194
+ userEvent: "move.character"
1195
+ }));
1196
+ return true;
1197
+ };
1198
+ function selectedLineBlocks(state) {
1199
+ let blocks = [],
1200
+ upto = -1;
1201
+ for (let range of state.selection.ranges) {
1202
+ let startLine = state.doc.lineAt(range.from),
1203
+ endLine = state.doc.lineAt(range.to);
1204
+ if (!range.empty && range.to == endLine.from) endLine = state.doc.lineAt(range.to - 1);
1205
+ if (upto >= startLine.number) {
1206
+ let prev = blocks[blocks.length - 1];
1207
+ prev.to = endLine.to;
1208
+ prev.ranges.push(range);
1209
+ } else {
1210
+ blocks.push({
1211
+ from: startLine.from,
1212
+ to: endLine.to,
1213
+ ranges: [range]
1214
+ });
1215
+ }
1216
+ upto = endLine.number + 1;
1217
+ }
1218
+ return blocks;
1219
+ }
1220
+ function moveLine(state, dispatch, forward) {
1221
+ if (state.readOnly) return false;
1222
+ let changes = [],
1223
+ ranges = [];
1224
+ for (let block of selectedLineBlocks(state)) {
1225
+ if (forward ? block.to == state.doc.length : block.from == 0) continue;
1226
+ let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
1227
+ let size = nextLine.length + 1;
1228
+ if (forward) {
1229
+ changes.push({
1230
+ from: block.to,
1231
+ to: nextLine.to
1232
+ }, {
1233
+ from: block.from,
1234
+ insert: nextLine.text + state.lineBreak
1235
+ });
1236
+ for (let r of block.ranges) ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
1237
+ } else {
1238
+ changes.push({
1239
+ from: nextLine.from,
1240
+ to: block.from
1241
+ }, {
1242
+ from: block.to,
1243
+ insert: state.lineBreak + nextLine.text
1244
+ });
1245
+ for (let r of block.ranges) ranges.push(EditorSelection.range(r.anchor - size, r.head - size));
1246
+ }
1247
+ }
1248
+ if (!changes.length) return false;
1249
+ dispatch(state.update({
1250
+ changes,
1251
+ scrollIntoView: true,
1252
+ selection: EditorSelection.create(ranges, state.selection.mainIndex),
1253
+ userEvent: "move.line"
1254
+ }));
1255
+ return true;
1256
+ }
1257
+ /**
1258
+ Move the selected lines up one line.
1259
+ */
1260
+ const moveLineUp = ({
1261
+ state,
1262
+ dispatch
1263
+ }) => moveLine(state, dispatch, false);
1264
+ /**
1265
+ Move the selected lines down one line.
1266
+ */
1267
+ const moveLineDown = ({
1268
+ state,
1269
+ dispatch
1270
+ }) => moveLine(state, dispatch, true);
1271
+ function copyLine(state, dispatch, forward) {
1272
+ if (state.readOnly) return false;
1273
+ let changes = [];
1274
+ for (let block of selectedLineBlocks(state)) {
1275
+ if (forward) changes.push({
1276
+ from: block.from,
1277
+ insert: state.doc.slice(block.from, block.to) + state.lineBreak
1278
+ });else changes.push({
1279
+ from: block.to,
1280
+ insert: state.lineBreak + state.doc.slice(block.from, block.to)
1281
+ });
1282
+ }
1283
+ dispatch(state.update({
1284
+ changes,
1285
+ scrollIntoView: true,
1286
+ userEvent: "input.copyline"
1287
+ }));
1288
+ return true;
1289
+ }
1290
+ /**
1291
+ Create a copy of the selected lines. Keep the selection in the top copy.
1292
+ */
1293
+ const copyLineUp = ({
1294
+ state,
1295
+ dispatch
1296
+ }) => copyLine(state, dispatch, false);
1297
+ /**
1298
+ Create a copy of the selected lines. Keep the selection in the bottom copy.
1299
+ */
1300
+ const copyLineDown = ({
1301
+ state,
1302
+ dispatch
1303
+ }) => copyLine(state, dispatch, true);
1304
+ /**
1305
+ Delete selected lines.
1306
+ */
1307
+ const deleteLine = view => {
1308
+ if (view.state.readOnly) return false;
1309
+ let {
1310
+ state
1311
+ } = view,
1312
+ changes = state.changes(selectedLineBlocks(state).map(({
1313
+ from,
1314
+ to
1315
+ }) => {
1316
+ if (from > 0) from--;else if (to < state.doc.length) to++;
1317
+ return {
1318
+ from,
1319
+ to
1320
+ };
1321
+ }));
1322
+ let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
1323
+ view.dispatch({
1324
+ changes,
1325
+ selection,
1326
+ scrollIntoView: true,
1327
+ userEvent: "delete.line"
1328
+ });
1329
+ return true;
1330
+ };
1331
+ function isBetweenBrackets(state, pos) {
1332
+ if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1))) return {
1333
+ from: pos,
1334
+ to: pos
1335
+ };
1336
+ let context = syntaxTree(state).resolveInner(pos);
1337
+ let before = context.childBefore(pos),
1338
+ after = context.childAfter(pos),
1339
+ closedBy;
1340
+ if (before && after && before.to <= pos && after.from >= pos && (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 && state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from) return {
1341
+ from: before.to,
1342
+ to: after.from
1343
+ };
1344
+ return null;
1345
+ }
1346
+ /**
1347
+ Replace the selection with a newline and indent the newly created
1348
+ line(s). If the current line consists only of whitespace, this
1349
+ will also delete that whitespace. When the cursor is between
1350
+ matching brackets, an additional newline will be inserted after
1351
+ the cursor.
1352
+ */
1353
+ const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
1354
+ /**
1355
+ Create a blank, indented line below the current line.
1356
+ */
1357
+ const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);
1358
+ function newlineAndIndent(atEof) {
1359
+ return ({
1360
+ state,
1361
+ dispatch
1362
+ }) => {
1363
+ if (state.readOnly) return false;
1364
+ let changes = state.changeByRange(range => {
1365
+ let {
1366
+ from,
1367
+ to
1368
+ } = range,
1369
+ line = state.doc.lineAt(from);
1370
+ let explode = !atEof && from == to && isBetweenBrackets(state, from);
1371
+ if (atEof) from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
1372
+ let cx = new IndentContext(state, {
1373
+ simulateBreak: from,
1374
+ simulateDoubleBreak: !!explode
1375
+ });
1376
+ let indent = getIndentation(cx, from);
1377
+ if (indent == null) indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;
1378
+ while (to < line.to && /\s/.test(line.text[to - line.from])) to++;
1379
+ if (explode) ({
1380
+ from,
1381
+ to
1382
+ } = explode);else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from))) from = line.from;
1383
+ let insert = ["", indentString(state, indent)];
1384
+ if (explode) insert.push(indentString(state, cx.lineIndent(line.from, -1)));
1385
+ return {
1386
+ changes: {
1387
+ from,
1388
+ to,
1389
+ insert: Text.of(insert)
1390
+ },
1391
+ range: EditorSelection.cursor(from + 1 + insert[1].length)
1392
+ };
1393
+ });
1394
+ dispatch(state.update(changes, {
1395
+ scrollIntoView: true,
1396
+ userEvent: "input"
1397
+ }));
1398
+ return true;
1399
+ };
1400
+ }
1401
+ function changeBySelectedLine(state, f) {
1402
+ let atLine = -1;
1403
+ return state.changeByRange(range => {
1404
+ let changes = [];
1405
+ for (let pos = range.from; pos <= range.to;) {
1406
+ let line = state.doc.lineAt(pos);
1407
+ if (line.number > atLine && (range.empty || range.to > line.from)) {
1408
+ f(line, changes, range);
1409
+ atLine = line.number;
1410
+ }
1411
+ pos = line.to + 1;
1412
+ }
1413
+ let changeSet = state.changes(changes);
1414
+ return {
1415
+ changes,
1416
+ range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))
1417
+ };
1418
+ });
1419
+ }
1420
+ /**
1421
+ Auto-indent the selected lines. This uses the [indentation service
1422
+ facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
1423
+ information.
1424
+ */
1425
+ const indentSelection = ({
1426
+ state,
1427
+ dispatch
1428
+ }) => {
1429
+ if (state.readOnly) return false;
1430
+ let updated = Object.create(null);
1431
+ let context = new IndentContext(state, {
1432
+ overrideIndentation: start => {
1433
+ let found = updated[start];
1434
+ return found == null ? -1 : found;
1435
+ }
1436
+ });
1437
+ let changes = changeBySelectedLine(state, (line, changes, range) => {
1438
+ let indent = getIndentation(context, line.from);
1439
+ if (indent == null) return;
1440
+ if (!/\S/.test(line.text)) indent = 0;
1441
+ let cur = /^\s*/.exec(line.text)[0];
1442
+ let norm = indentString(state, indent);
1443
+ if (cur != norm || range.from < line.from + cur.length) {
1444
+ updated[line.from] = indent;
1445
+ changes.push({
1446
+ from: line.from,
1447
+ to: line.from + cur.length,
1448
+ insert: norm
1449
+ });
1450
+ }
1451
+ });
1452
+ if (!changes.changes.empty) dispatch(state.update(changes, {
1453
+ userEvent: "indent"
1454
+ }));
1455
+ return true;
1456
+ };
1457
+ /**
1458
+ Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
1459
+ lines.
1460
+ */
1461
+ const indentMore = ({
1462
+ state,
1463
+ dispatch
1464
+ }) => {
1465
+ if (state.readOnly) return false;
1466
+ dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
1467
+ changes.push({
1468
+ from: line.from,
1469
+ insert: state.facet(indentUnit)
1470
+ });
1471
+ }), {
1472
+ userEvent: "input.indent"
1473
+ }));
1474
+ return true;
1475
+ };
1476
+ /**
1477
+ Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
1478
+ selected lines.
1479
+ */
1480
+ const indentLess = ({
1481
+ state,
1482
+ dispatch
1483
+ }) => {
1484
+ if (state.readOnly) return false;
1485
+ dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
1486
+ let space = /^\s*/.exec(line.text)[0];
1487
+ if (!space) return;
1488
+ let col = countColumn(space, state.tabSize),
1489
+ keep = 0;
1490
+ let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));
1491
+ while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep)) keep++;
1492
+ changes.push({
1493
+ from: line.from + keep,
1494
+ to: line.from + space.length,
1495
+ insert: insert.slice(keep)
1496
+ });
1497
+ }), {
1498
+ userEvent: "delete.dedent"
1499
+ }));
1500
+ return true;
1501
+ };
1502
+ /**
1503
+ Array of key bindings containing the Emacs-style bindings that are
1504
+ available on macOS by default.
1505
+
1506
+ - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
1507
+ - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
1508
+ - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
1509
+ - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
1510
+ - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
1511
+ - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
1512
+ - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
1513
+ - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
1514
+ - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
1515
+ - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
1516
+ - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
1517
+ - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
1518
+ - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
1519
+ - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
1520
+ */
1521
+ const emacsStyleKeymap = [{
1522
+ key: "Ctrl-b",
1523
+ run: cursorCharLeft,
1524
+ shift: selectCharLeft,
1525
+ preventDefault: true
1526
+ }, {
1527
+ key: "Ctrl-f",
1528
+ run: cursorCharRight,
1529
+ shift: selectCharRight
1530
+ }, {
1531
+ key: "Ctrl-p",
1532
+ run: cursorLineUp,
1533
+ shift: selectLineUp
1534
+ }, {
1535
+ key: "Ctrl-n",
1536
+ run: cursorLineDown,
1537
+ shift: selectLineDown
1538
+ }, {
1539
+ key: "Ctrl-a",
1540
+ run: cursorLineStart,
1541
+ shift: selectLineStart
1542
+ }, {
1543
+ key: "Ctrl-e",
1544
+ run: cursorLineEnd,
1545
+ shift: selectLineEnd
1546
+ }, {
1547
+ key: "Ctrl-d",
1548
+ run: deleteCharForward
1549
+ }, {
1550
+ key: "Ctrl-h",
1551
+ run: deleteCharBackward
1552
+ }, {
1553
+ key: "Ctrl-k",
1554
+ run: deleteToLineEnd
1555
+ }, {
1556
+ key: "Ctrl-Alt-h",
1557
+ run: deleteGroupBackward
1558
+ }, {
1559
+ key: "Ctrl-o",
1560
+ run: splitLine
1561
+ }, {
1562
+ key: "Ctrl-t",
1563
+ run: transposeChars
1564
+ }, {
1565
+ key: "Ctrl-v",
1566
+ run: cursorPageDown
1567
+ }];
1568
+ /**
1569
+ An array of key bindings closely sticking to platform-standard or
1570
+ widely used bindings. (This includes the bindings from
1571
+ [`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
1572
+ property changed to `mac`.)
1573
+
1574
+ - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
1575
+ - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
1576
+ - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
1577
+ - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
1578
+ - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
1579
+ - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
1580
+ - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
1581
+ - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
1582
+ - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
1583
+ - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
1584
+ - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
1585
+ - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
1586
+ - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
1587
+ - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
1588
+ - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
1589
+ - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
1590
+ - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
1591
+ - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
1592
+ - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
1593
+ - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
1594
+ - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
1595
+ - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
1596
+ - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
1597
+ - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
1598
+ - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
1599
+ - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
1600
+ */
1601
+ const standardKeymap = /*@__PURE__*/[{
1602
+ key: "ArrowLeft",
1603
+ run: cursorCharLeft,
1604
+ shift: selectCharLeft,
1605
+ preventDefault: true
1606
+ }, {
1607
+ key: "Mod-ArrowLeft",
1608
+ mac: "Alt-ArrowLeft",
1609
+ run: cursorGroupLeft,
1610
+ shift: selectGroupLeft,
1611
+ preventDefault: true
1612
+ }, {
1613
+ mac: "Cmd-ArrowLeft",
1614
+ run: cursorLineBoundaryLeft,
1615
+ shift: selectLineBoundaryLeft,
1616
+ preventDefault: true
1617
+ }, {
1618
+ key: "ArrowRight",
1619
+ run: cursorCharRight,
1620
+ shift: selectCharRight,
1621
+ preventDefault: true
1622
+ }, {
1623
+ key: "Mod-ArrowRight",
1624
+ mac: "Alt-ArrowRight",
1625
+ run: cursorGroupRight,
1626
+ shift: selectGroupRight,
1627
+ preventDefault: true
1628
+ }, {
1629
+ mac: "Cmd-ArrowRight",
1630
+ run: cursorLineBoundaryRight,
1631
+ shift: selectLineBoundaryRight,
1632
+ preventDefault: true
1633
+ }, {
1634
+ key: "ArrowUp",
1635
+ run: cursorLineUp,
1636
+ shift: selectLineUp,
1637
+ preventDefault: true
1638
+ }, {
1639
+ mac: "Cmd-ArrowUp",
1640
+ run: cursorDocStart,
1641
+ shift: selectDocStart
1642
+ }, {
1643
+ mac: "Ctrl-ArrowUp",
1644
+ run: cursorPageUp,
1645
+ shift: selectPageUp
1646
+ }, {
1647
+ key: "ArrowDown",
1648
+ run: cursorLineDown,
1649
+ shift: selectLineDown,
1650
+ preventDefault: true
1651
+ }, {
1652
+ mac: "Cmd-ArrowDown",
1653
+ run: cursorDocEnd,
1654
+ shift: selectDocEnd
1655
+ }, {
1656
+ mac: "Ctrl-ArrowDown",
1657
+ run: cursorPageDown,
1658
+ shift: selectPageDown
1659
+ }, {
1660
+ key: "PageUp",
1661
+ run: cursorPageUp,
1662
+ shift: selectPageUp
1663
+ }, {
1664
+ key: "PageDown",
1665
+ run: cursorPageDown,
1666
+ shift: selectPageDown
1667
+ }, {
1668
+ key: "Home",
1669
+ run: cursorLineBoundaryBackward,
1670
+ shift: selectLineBoundaryBackward,
1671
+ preventDefault: true
1672
+ }, {
1673
+ key: "Mod-Home",
1674
+ run: cursorDocStart,
1675
+ shift: selectDocStart
1676
+ }, {
1677
+ key: "End",
1678
+ run: cursorLineBoundaryForward,
1679
+ shift: selectLineBoundaryForward,
1680
+ preventDefault: true
1681
+ }, {
1682
+ key: "Mod-End",
1683
+ run: cursorDocEnd,
1684
+ shift: selectDocEnd
1685
+ }, {
1686
+ key: "Enter",
1687
+ run: insertNewlineAndIndent
1688
+ }, {
1689
+ key: "Mod-a",
1690
+ run: selectAll
1691
+ }, {
1692
+ key: "Backspace",
1693
+ run: deleteCharBackward,
1694
+ shift: deleteCharBackward
1695
+ }, {
1696
+ key: "Delete",
1697
+ run: deleteCharForward
1698
+ }, {
1699
+ key: "Mod-Backspace",
1700
+ mac: "Alt-Backspace",
1701
+ run: deleteGroupBackward
1702
+ }, {
1703
+ key: "Mod-Delete",
1704
+ mac: "Alt-Delete",
1705
+ run: deleteGroupForward
1706
+ }, {
1707
+ mac: "Mod-Backspace",
1708
+ run: deleteToLineStart
1709
+ }, {
1710
+ mac: "Mod-Delete",
1711
+ run: deleteToLineEnd
1712
+ }].concat( /*@__PURE__*/emacsStyleKeymap.map(b => ({
1713
+ mac: b.key,
1714
+ run: b.run,
1715
+ shift: b.shift
1716
+ })));
1717
+ /**
1718
+ The default keymap. Includes all bindings from
1719
+ [`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
1720
+
1721
+ - Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
1722
+ - Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
1723
+ - Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
1724
+ - Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
1725
+ - Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
1726
+ - Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
1727
+ - Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
1728
+ - Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
1729
+ - Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
1730
+ - Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
1731
+ - Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
1732
+ - Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
1733
+ - Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
1734
+ - Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
1735
+ - Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
1736
+ - Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
1737
+ - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
1738
+ */
1739
+ const defaultKeymap = /*@__PURE__*/[{
1740
+ key: "Alt-ArrowLeft",
1741
+ mac: "Ctrl-ArrowLeft",
1742
+ run: cursorSyntaxLeft,
1743
+ shift: selectSyntaxLeft
1744
+ }, {
1745
+ key: "Alt-ArrowRight",
1746
+ mac: "Ctrl-ArrowRight",
1747
+ run: cursorSyntaxRight,
1748
+ shift: selectSyntaxRight
1749
+ }, {
1750
+ key: "Alt-ArrowUp",
1751
+ run: moveLineUp
1752
+ }, {
1753
+ key: "Shift-Alt-ArrowUp",
1754
+ run: copyLineUp
1755
+ }, {
1756
+ key: "Alt-ArrowDown",
1757
+ run: moveLineDown
1758
+ }, {
1759
+ key: "Shift-Alt-ArrowDown",
1760
+ run: copyLineDown
1761
+ }, {
1762
+ key: "Escape",
1763
+ run: simplifySelection
1764
+ }, {
1765
+ key: "Mod-Enter",
1766
+ run: insertBlankLine
1767
+ }, {
1768
+ key: "Alt-l",
1769
+ mac: "Ctrl-l",
1770
+ run: selectLine
1771
+ }, {
1772
+ key: "Mod-i",
1773
+ run: selectParentSyntax,
1774
+ preventDefault: true
1775
+ }, {
1776
+ key: "Mod-[",
1777
+ run: indentLess
1778
+ }, {
1779
+ key: "Mod-]",
1780
+ run: indentMore
1781
+ }, {
1782
+ key: "Mod-Alt-\\",
1783
+ run: indentSelection
1784
+ }, {
1785
+ key: "Shift-Mod-k",
1786
+ run: deleteLine
1787
+ }, {
1788
+ key: "Shift-Mod-\\",
1789
+ run: cursorMatchingBracket
1790
+ }, {
1791
+ key: "Mod-/",
1792
+ run: toggleComment
1793
+ }, {
1794
+ key: "Alt-A",
1795
+ run: toggleBlockComment
1796
+ }].concat(standardKeymap);
1797
+ /**
1798
+ A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
1799
+ Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
1800
+ Please see the [Tab example](../../examples/tab/) before using
1801
+ this.
1802
+ */
1803
+ const indentWithTab = {
1804
+ key: "Tab",
1805
+ run: indentMore,
1806
+ shift: indentLess
1807
+ };
1808
+
1809
+ function crelt() {
1810
+ var elt = arguments[0];
1811
+ if (typeof elt == "string") elt = document.createElement(elt);
1812
+ var i = 1,
1813
+ next = arguments[1];
1814
+ if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
1815
+ for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
1816
+ var value = next[name];
1817
+ if (typeof value == "string") elt.setAttribute(name, value);else if (value != null) elt[name] = value;
1818
+ }
1819
+ i++;
1820
+ }
1821
+ for (; i < arguments.length; i++) add(elt, arguments[i]);
1822
+ return elt;
1823
+ }
1824
+ function add(elt, child) {
1825
+ if (typeof child == "string") {
1826
+ elt.appendChild(document.createTextNode(child));
1827
+ } else if (child == null) ; else if (child.nodeType != null) {
1828
+ elt.appendChild(child);
1829
+ } else if (Array.isArray(child)) {
1830
+ for (var i = 0; i < child.length; i++) add(elt, child[i]);
1831
+ } else {
1832
+ throw new RangeError("Unsupported child node: " + child);
1833
+ }
1834
+ }
1835
+
1836
+ const basicNormalize = typeof String.prototype.normalize == "function" ? x => x.normalize("NFKD") : x => x;
1837
+ /**
1838
+ A search cursor provides an iterator over text matches in a
1839
+ document.
1840
+ */
1841
+ class SearchCursor {
1842
+ /**
1843
+ Create a text cursor. The query is the search string, `from` to
1844
+ `to` provides the region to search.
1845
+
1846
+ When `normalize` is given, it will be called, on both the query
1847
+ string and the content it is matched against, before comparing.
1848
+ You can, for example, create a case-insensitive search by
1849
+ passing `s => s.toLowerCase()`.
1850
+
1851
+ Text is always normalized with
1852
+ [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
1853
+ (when supported).
1854
+ */
1855
+ constructor(text, query, from = 0, to = text.length, normalize, test) {
1856
+ this.test = test;
1857
+ /**
1858
+ The current match (only holds a meaningful value after
1859
+ [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
1860
+ `done` is false).
1861
+ */
1862
+ this.value = {
1863
+ from: 0,
1864
+ to: 0
1865
+ };
1866
+ /**
1867
+ Whether the end of the iterated region has been reached.
1868
+ */
1869
+ this.done = false;
1870
+ this.matches = [];
1871
+ this.buffer = "";
1872
+ this.bufferPos = 0;
1873
+ this.iter = text.iterRange(from, to);
1874
+ this.bufferStart = from;
1875
+ this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;
1876
+ this.query = this.normalize(query);
1877
+ }
1878
+ peek() {
1879
+ if (this.bufferPos == this.buffer.length) {
1880
+ this.bufferStart += this.buffer.length;
1881
+ this.iter.next();
1882
+ if (this.iter.done) return -1;
1883
+ this.bufferPos = 0;
1884
+ this.buffer = this.iter.value;
1885
+ }
1886
+ return codePointAt(this.buffer, this.bufferPos);
1887
+ }
1888
+ /**
1889
+ Look for the next match. Updates the iterator's
1890
+ [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
1891
+ [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
1892
+ at least once before using the cursor.
1893
+ */
1894
+ next() {
1895
+ while (this.matches.length) this.matches.pop();
1896
+ return this.nextOverlapping();
1897
+ }
1898
+ /**
1899
+ The `next` method will ignore matches that partially overlap a
1900
+ previous match. This method behaves like `next`, but includes
1901
+ such matches.
1902
+ */
1903
+ nextOverlapping() {
1904
+ for (;;) {
1905
+ let next = this.peek();
1906
+ if (next < 0) {
1907
+ this.done = true;
1908
+ return this;
1909
+ }
1910
+ let str = fromCodePoint(next),
1911
+ start = this.bufferStart + this.bufferPos;
1912
+ this.bufferPos += codePointSize(next);
1913
+ let norm = this.normalize(str);
1914
+ for (let i = 0, pos = start;; i++) {
1915
+ let code = norm.charCodeAt(i);
1916
+ let match = this.match(code, pos);
1917
+ if (match) {
1918
+ this.value = match;
1919
+ return this;
1920
+ }
1921
+ if (i == norm.length - 1) break;
1922
+ if (pos == start && i < str.length && str.charCodeAt(i) == code) pos++;
1923
+ }
1924
+ }
1925
+ }
1926
+ match(code, pos) {
1927
+ let match = null;
1928
+ for (let i = 0; i < this.matches.length; i += 2) {
1929
+ let index = this.matches[i],
1930
+ keep = false;
1931
+ if (this.query.charCodeAt(index) == code) {
1932
+ if (index == this.query.length - 1) {
1933
+ match = {
1934
+ from: this.matches[i + 1],
1935
+ to: pos + 1
1936
+ };
1937
+ } else {
1938
+ this.matches[i]++;
1939
+ keep = true;
1940
+ }
1941
+ }
1942
+ if (!keep) {
1943
+ this.matches.splice(i, 2);
1944
+ i -= 2;
1945
+ }
1946
+ }
1947
+ if (this.query.charCodeAt(0) == code) {
1948
+ if (this.query.length == 1) match = {
1949
+ from: pos,
1950
+ to: pos + 1
1951
+ };else this.matches.push(1, pos);
1952
+ }
1953
+ if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferPos)) match = null;
1954
+ return match;
1955
+ }
1956
+ }
1957
+ if (typeof Symbol != "undefined") SearchCursor.prototype[Symbol.iterator] = function () {
1958
+ return this;
1959
+ };
1960
+ const empty = {
1961
+ from: -1,
1962
+ to: -1,
1963
+ match: /*@__PURE__*/ /.*/.exec("")
1964
+ };
1965
+ const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
1966
+ /**
1967
+ This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
1968
+ but searches for a regular expression pattern instead of a plain
1969
+ string.
1970
+ */
1971
+ class RegExpCursor {
1972
+ /**
1973
+ Create a cursor that will search the given range in the given
1974
+ document. `query` should be the raw pattern (as you'd pass it to
1975
+ `new RegExp`).
1976
+ */
1977
+ constructor(text, query, options, from = 0, to = text.length) {
1978
+ this.text = text;
1979
+ this.to = to;
1980
+ this.curLine = "";
1981
+ /**
1982
+ Set to `true` when the cursor has reached the end of the search
1983
+ range.
1984
+ */
1985
+ this.done = false;
1986
+ /**
1987
+ Will contain an object with the extent of the match and the
1988
+ match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
1989
+ sucessfully finds a match.
1990
+ */
1991
+ this.value = empty;
1992
+ if (/\\[sWDnr]|\n|\r|\[\^/.test(query)) return new MultilineRegExpCursor(text, query, options, from, to);
1993
+ this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
1994
+ this.test = options === null || options === void 0 ? void 0 : options.test;
1995
+ this.iter = text.iter();
1996
+ let startLine = text.lineAt(from);
1997
+ this.curLineStart = startLine.from;
1998
+ this.matchPos = toCharEnd(text, from);
1999
+ this.getLine(this.curLineStart);
2000
+ }
2001
+ getLine(skip) {
2002
+ this.iter.next(skip);
2003
+ if (this.iter.lineBreak) {
2004
+ this.curLine = "";
2005
+ } else {
2006
+ this.curLine = this.iter.value;
2007
+ if (this.curLineStart + this.curLine.length > this.to) this.curLine = this.curLine.slice(0, this.to - this.curLineStart);
2008
+ this.iter.next();
2009
+ }
2010
+ }
2011
+ nextLine() {
2012
+ this.curLineStart = this.curLineStart + this.curLine.length + 1;
2013
+ if (this.curLineStart > this.to) this.curLine = "";else this.getLine(0);
2014
+ }
2015
+ /**
2016
+ Move to the next match, if there is one.
2017
+ */
2018
+ next() {
2019
+ for (let off = this.matchPos - this.curLineStart;;) {
2020
+ this.re.lastIndex = off;
2021
+ let match = this.matchPos <= this.to && this.re.exec(this.curLine);
2022
+ if (match) {
2023
+ let from = this.curLineStart + match.index,
2024
+ to = from + match[0].length;
2025
+ this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
2026
+ if (from == this.curLineStart + this.curLine.length) this.nextLine();
2027
+ if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
2028
+ this.value = {
2029
+ from,
2030
+ to,
2031
+ match
2032
+ };
2033
+ return this;
2034
+ }
2035
+ off = this.matchPos - this.curLineStart;
2036
+ } else if (this.curLineStart + this.curLine.length < this.to) {
2037
+ this.nextLine();
2038
+ off = 0;
2039
+ } else {
2040
+ this.done = true;
2041
+ return this;
2042
+ }
2043
+ }
2044
+ }
2045
+ }
2046
+ const flattened = /*@__PURE__*/new WeakMap();
2047
+ // Reusable (partially) flattened document strings
2048
+ class FlattenedDoc {
2049
+ constructor(from, text) {
2050
+ this.from = from;
2051
+ this.text = text;
2052
+ }
2053
+ get to() {
2054
+ return this.from + this.text.length;
2055
+ }
2056
+ static get(doc, from, to) {
2057
+ let cached = flattened.get(doc);
2058
+ if (!cached || cached.from >= to || cached.to <= from) {
2059
+ let flat = new FlattenedDoc(from, doc.sliceString(from, to));
2060
+ flattened.set(doc, flat);
2061
+ return flat;
2062
+ }
2063
+ if (cached.from == from && cached.to == to) return cached;
2064
+ let {
2065
+ text,
2066
+ from: cachedFrom
2067
+ } = cached;
2068
+ if (cachedFrom > from) {
2069
+ text = doc.sliceString(from, cachedFrom) + text;
2070
+ cachedFrom = from;
2071
+ }
2072
+ if (cached.to < to) text += doc.sliceString(cached.to, to);
2073
+ flattened.set(doc, new FlattenedDoc(cachedFrom, text));
2074
+ return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
2075
+ }
2076
+ }
2077
+ class MultilineRegExpCursor {
2078
+ constructor(text, query, options, from, to) {
2079
+ this.text = text;
2080
+ this.to = to;
2081
+ this.done = false;
2082
+ this.value = empty;
2083
+ this.matchPos = toCharEnd(text, from);
2084
+ this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
2085
+ this.test = options === null || options === void 0 ? void 0 : options.test;
2086
+ this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));
2087
+ }
2088
+
2089
+ chunkEnd(pos) {
2090
+ return pos >= this.to ? this.to : this.text.lineAt(pos).to;
2091
+ }
2092
+ next() {
2093
+ for (;;) {
2094
+ let off = this.re.lastIndex = this.matchPos - this.flat.from;
2095
+ let match = this.re.exec(this.flat.text);
2096
+ // Skip empty matches directly after the last match
2097
+ if (match && !match[0] && match.index == off) {
2098
+ this.re.lastIndex = off + 1;
2099
+ match = this.re.exec(this.flat.text);
2100
+ }
2101
+ if (match) {
2102
+ let from = this.flat.from + match.index,
2103
+ to = from + match[0].length;
2104
+ // If a match goes almost to the end of a noncomplete chunk, try
2105
+ // again, since it'll likely be able to match more
2106
+ if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) && (!this.test || this.test(from, to, match))) {
2107
+ this.value = {
2108
+ from,
2109
+ to,
2110
+ match
2111
+ };
2112
+ this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
2113
+ return this;
2114
+ }
2115
+ }
2116
+ if (this.flat.to == this.to) {
2117
+ this.done = true;
2118
+ return this;
2119
+ }
2120
+ // Grow the flattened doc
2121
+ this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
2122
+ }
2123
+ }
2124
+ }
2125
+ if (typeof Symbol != "undefined") {
2126
+ RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] = function () {
2127
+ return this;
2128
+ };
2129
+ }
2130
+ function validRegExp(source) {
2131
+ try {
2132
+ new RegExp(source, baseFlags);
2133
+ return true;
2134
+ } catch (_a) {
2135
+ return false;
2136
+ }
2137
+ }
2138
+ function toCharEnd(text, pos) {
2139
+ if (pos >= text.length) return pos;
2140
+ let line = text.lineAt(pos),
2141
+ next;
2142
+ while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 0xDC00 && next < 0xE000) pos++;
2143
+ return pos;
2144
+ }
2145
+ function createLineDialog(view) {
2146
+ let input = crelt("input", {
2147
+ class: "cm-textfield",
2148
+ name: "line"
2149
+ });
2150
+ let dom = crelt("form", {
2151
+ class: "cm-gotoLine",
2152
+ onkeydown: event => {
2153
+ if (event.keyCode == 27) {
2154
+ // Escape
2155
+ event.preventDefault();
2156
+ view.dispatch({
2157
+ effects: dialogEffect.of(false)
2158
+ });
2159
+ view.focus();
2160
+ } else if (event.keyCode == 13) {
2161
+ // Enter
2162
+ event.preventDefault();
2163
+ go();
2164
+ }
2165
+ },
2166
+ onsubmit: event => {
2167
+ event.preventDefault();
2168
+ go();
2169
+ }
2170
+ }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", {
2171
+ class: "cm-button",
2172
+ type: "submit"
2173
+ }, view.state.phrase("go")));
2174
+ function go() {
2175
+ let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
2176
+ if (!match) return;
2177
+ let {
2178
+ state
2179
+ } = view,
2180
+ startLine = state.doc.lineAt(state.selection.main.head);
2181
+ let [, sign, ln, cl, percent] = match;
2182
+ let col = cl ? +cl.slice(1) : 0;
2183
+ let line = ln ? +ln : startLine.number;
2184
+ if (ln && percent) {
2185
+ let pc = line / 100;
2186
+ if (sign) pc = pc * (sign == "-" ? -1 : 1) + startLine.number / state.doc.lines;
2187
+ line = Math.round(state.doc.lines * pc);
2188
+ } else if (ln && sign) {
2189
+ line = line * (sign == "-" ? -1 : 1) + startLine.number;
2190
+ }
2191
+ let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
2192
+ view.dispatch({
2193
+ effects: dialogEffect.of(false),
2194
+ selection: EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))),
2195
+ scrollIntoView: true
2196
+ });
2197
+ view.focus();
2198
+ }
2199
+ return {
2200
+ dom
2201
+ };
2202
+ }
2203
+ const dialogEffect = /*@__PURE__*/StateEffect.define();
2204
+ const dialogField = /*@__PURE__*/StateField.define({
2205
+ create() {
2206
+ return true;
2207
+ },
2208
+ update(value, tr) {
2209
+ for (let e of tr.effects) if (e.is(dialogEffect)) value = e.value;
2210
+ return value;
2211
+ },
2212
+ provide: f => showPanel.from(f, val => val ? createLineDialog : null)
2213
+ });
2214
+ /**
2215
+ Command that shows a dialog asking the user for a line number, and
2216
+ when a valid position is provided, moves the cursor to that line.
2217
+
2218
+ Supports line numbers, relative line offsets prefixed with `+` or
2219
+ `-`, document percentages suffixed with `%`, and an optional
2220
+ column position by adding `:` and a second number after the line
2221
+ number.
2222
+
2223
+ The dialog can be styled with the `panel.gotoLine` theme
2224
+ selector.
2225
+ */
2226
+ const gotoLine = view => {
2227
+ let panel = getPanel(view, createLineDialog);
2228
+ if (!panel) {
2229
+ let effects = [dialogEffect.of(true)];
2230
+ if (view.state.field(dialogField, false) == null) effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1]));
2231
+ view.dispatch({
2232
+ effects
2233
+ });
2234
+ panel = getPanel(view, createLineDialog);
2235
+ }
2236
+ if (panel) panel.dom.querySelector("input").focus();
2237
+ return true;
2238
+ };
2239
+ const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
2240
+ ".cm-panel.cm-gotoLine": {
2241
+ padding: "2px 6px 4px",
2242
+ "& label": {
2243
+ fontSize: "80%"
2244
+ }
2245
+ }
2246
+ });
2247
+ const defaultHighlightOptions = {
2248
+ highlightWordAroundCursor: false,
2249
+ minSelectionLength: 1,
2250
+ maxMatches: 100,
2251
+ wholeWords: false
2252
+ };
2253
+ const highlightConfig = /*@__PURE__*/Facet.define({
2254
+ combine(options) {
2255
+ return combineConfig(options, defaultHighlightOptions, {
2256
+ highlightWordAroundCursor: (a, b) => a || b,
2257
+ minSelectionLength: Math.min,
2258
+ maxMatches: Math.min
2259
+ });
2260
+ }
2261
+ });
2262
+ /**
2263
+ This extension highlights text that matches the selection. It uses
2264
+ the `"cm-selectionMatch"` class for the highlighting. When
2265
+ `highlightWordAroundCursor` is enabled, the word at the cursor
2266
+ itself will be highlighted with `"cm-selectionMatch-main"`.
2267
+ */
2268
+ function highlightSelectionMatches(options) {
2269
+ let ext = [defaultTheme, matchHighlighter];
2270
+ if (options) ext.push(highlightConfig.of(options));
2271
+ return ext;
2272
+ }
2273
+ const matchDeco = /*@__PURE__*/Decoration.mark({
2274
+ class: "cm-selectionMatch"
2275
+ });
2276
+ const mainMatchDeco = /*@__PURE__*/Decoration.mark({
2277
+ class: "cm-selectionMatch cm-selectionMatch-main"
2278
+ });
2279
+ // Whether the characters directly outside the given positions are non-word characters
2280
+ function insideWordBoundaries(check, state, from, to) {
2281
+ return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) && (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);
2282
+ }
2283
+ // Whether the characters directly at the given positions are word characters
2284
+ function insideWord(check, state, from, to) {
2285
+ return check(state.sliceDoc(from, from + 1)) == CharCategory.Word && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;
2286
+ }
2287
+ const matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
2288
+ constructor(view) {
2289
+ this.decorations = this.getDeco(view);
2290
+ }
2291
+ update(update) {
2292
+ if (update.selectionSet || update.docChanged || update.viewportChanged) this.decorations = this.getDeco(update.view);
2293
+ }
2294
+ getDeco(view) {
2295
+ let conf = view.state.facet(highlightConfig);
2296
+ let {
2297
+ state
2298
+ } = view,
2299
+ sel = state.selection;
2300
+ if (sel.ranges.length > 1) return Decoration.none;
2301
+ let range = sel.main,
2302
+ query,
2303
+ check = null;
2304
+ if (range.empty) {
2305
+ if (!conf.highlightWordAroundCursor) return Decoration.none;
2306
+ let word = state.wordAt(range.head);
2307
+ if (!word) return Decoration.none;
2308
+ check = state.charCategorizer(range.head);
2309
+ query = state.sliceDoc(word.from, word.to);
2310
+ } else {
2311
+ let len = range.to - range.from;
2312
+ if (len < conf.minSelectionLength || len > 200) return Decoration.none;
2313
+ if (conf.wholeWords) {
2314
+ query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?
2315
+ check = state.charCategorizer(range.head);
2316
+ if (!(insideWordBoundaries(check, state, range.from, range.to) && insideWord(check, state, range.from, range.to))) return Decoration.none;
2317
+ } else {
2318
+ query = state.sliceDoc(range.from, range.to).trim();
2319
+ if (!query) return Decoration.none;
2320
+ }
2321
+ }
2322
+ let deco = [];
2323
+ for (let part of view.visibleRanges) {
2324
+ let cursor = new SearchCursor(state.doc, query, part.from, part.to);
2325
+ while (!cursor.next().done) {
2326
+ let {
2327
+ from,
2328
+ to
2329
+ } = cursor.value;
2330
+ if (!check || insideWordBoundaries(check, state, from, to)) {
2331
+ if (range.empty && from <= range.from && to >= range.to) deco.push(mainMatchDeco.range(from, to));else if (from >= range.to || to <= range.from) deco.push(matchDeco.range(from, to));
2332
+ if (deco.length > conf.maxMatches) return Decoration.none;
2333
+ }
2334
+ }
2335
+ }
2336
+ return Decoration.set(deco);
2337
+ }
2338
+ }, {
2339
+ decorations: v => v.decorations
2340
+ });
2341
+ const defaultTheme = /*@__PURE__*/EditorView.baseTheme({
2342
+ ".cm-selectionMatch": {
2343
+ backgroundColor: "#99ff7780"
2344
+ },
2345
+ ".cm-searchMatch .cm-selectionMatch": {
2346
+ backgroundColor: "transparent"
2347
+ }
2348
+ });
2349
+ // Select the words around the cursors.
2350
+ const selectWord = ({
2351
+ state,
2352
+ dispatch
2353
+ }) => {
2354
+ let {
2355
+ selection
2356
+ } = state;
2357
+ let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);
2358
+ if (newSel.eq(selection)) return false;
2359
+ dispatch(state.update({
2360
+ selection: newSel
2361
+ }));
2362
+ return true;
2363
+ };
2364
+ // Find next occurrence of query relative to last cursor. Wrap around
2365
+ // the document if there are no more matches.
2366
+ function findNextOccurrence(state, query) {
2367
+ let {
2368
+ main,
2369
+ ranges
2370
+ } = state.selection;
2371
+ let word = state.wordAt(main.head),
2372
+ fullWord = word && word.from == main.from && word.to == main.to;
2373
+ for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
2374
+ cursor.next();
2375
+ if (cursor.done) {
2376
+ if (cycled) return null;
2377
+ cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
2378
+ cycled = true;
2379
+ } else {
2380
+ if (cycled && ranges.some(r => r.from == cursor.value.from)) continue;
2381
+ if (fullWord) {
2382
+ let word = state.wordAt(cursor.value.from);
2383
+ if (!word || word.from != cursor.value.from || word.to != cursor.value.to) continue;
2384
+ }
2385
+ return cursor.value;
2386
+ }
2387
+ }
2388
+ }
2389
+ /**
2390
+ Select next occurrence of the current selection. Expand selection
2391
+ to the surrounding word when the selection is empty.
2392
+ */
2393
+ const selectNextOccurrence = ({
2394
+ state,
2395
+ dispatch
2396
+ }) => {
2397
+ let {
2398
+ ranges
2399
+ } = state.selection;
2400
+ if (ranges.some(sel => sel.from === sel.to)) return selectWord({
2401
+ state,
2402
+ dispatch
2403
+ });
2404
+ let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
2405
+ if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText)) return false;
2406
+ let range = findNextOccurrence(state, searchedText);
2407
+ if (!range) return false;
2408
+ dispatch(state.update({
2409
+ selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),
2410
+ effects: EditorView.scrollIntoView(range.to)
2411
+ }));
2412
+ return true;
2413
+ };
2414
+ const searchConfigFacet = /*@__PURE__*/Facet.define({
2415
+ combine(configs) {
2416
+ return combineConfig(configs, {
2417
+ top: false,
2418
+ caseSensitive: false,
2419
+ literal: false,
2420
+ wholeWord: false,
2421
+ createPanel: view => new SearchPanel(view)
2422
+ });
2423
+ }
2424
+ });
2425
+ /**
2426
+ A search query. Part of the editor's search state.
2427
+ */
2428
+ class SearchQuery {
2429
+ /**
2430
+ Create a query object.
2431
+ */
2432
+ constructor(config) {
2433
+ this.search = config.search;
2434
+ this.caseSensitive = !!config.caseSensitive;
2435
+ this.literal = !!config.literal;
2436
+ this.regexp = !!config.regexp;
2437
+ this.replace = config.replace || "";
2438
+ this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
2439
+ this.unquoted = this.unquote(this.search);
2440
+ this.wholeWord = !!config.wholeWord;
2441
+ }
2442
+ /**
2443
+ @internal
2444
+ */
2445
+ unquote(text) {
2446
+ return this.literal ? text : text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
2447
+ }
2448
+ /**
2449
+ Compare this query to another query.
2450
+ */
2451
+ eq(other) {
2452
+ return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
2453
+ }
2454
+ /**
2455
+ @internal
2456
+ */
2457
+ create() {
2458
+ return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
2459
+ }
2460
+ /**
2461
+ Get a search cursor for this query, searching through the given
2462
+ range in the given state.
2463
+ */
2464
+ getCursor(state, from = 0, to) {
2465
+ let st = state.doc ? state : EditorState.create({
2466
+ doc: state
2467
+ });
2468
+ if (to == null) to = st.doc.length;
2469
+ return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);
2470
+ }
2471
+ }
2472
+ class QueryType {
2473
+ constructor(spec) {
2474
+ this.spec = spec;
2475
+ }
2476
+ }
2477
+ function stringCursor(spec, state, from, to) {
2478
+ return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);
2479
+ }
2480
+ function stringWordTest(doc, categorizer) {
2481
+ return (from, to, buf, bufPos) => {
2482
+ if (bufPos > from || bufPos + buf.length < to) {
2483
+ bufPos = Math.max(0, from - 2);
2484
+ buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));
2485
+ }
2486
+ return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word || categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) && (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word || categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);
2487
+ };
2488
+ }
2489
+ class StringQuery extends QueryType {
2490
+ constructor(spec) {
2491
+ super(spec);
2492
+ }
2493
+ nextMatch(state, curFrom, curTo) {
2494
+ let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();
2495
+ if (cursor.done) cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();
2496
+ return cursor.done ? null : cursor.value;
2497
+ }
2498
+ // Searching in reverse is, rather than implementing inverted search
2499
+ // cursor, done by scanning chunk after chunk forward.
2500
+ prevMatchInRange(state, from, to) {
2501
+ for (let pos = to;;) {
2502
+ let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);
2503
+ let cursor = stringCursor(this.spec, state, start, pos),
2504
+ range = null;
2505
+ while (!cursor.nextOverlapping().done) range = cursor.value;
2506
+ if (range) return range;
2507
+ if (start == from) return null;
2508
+ pos -= 10000 /* FindPrev.ChunkSize */;
2509
+ }
2510
+ }
2511
+
2512
+ prevMatch(state, curFrom, curTo) {
2513
+ return this.prevMatchInRange(state, 0, curFrom) || this.prevMatchInRange(state, curTo, state.doc.length);
2514
+ }
2515
+ getReplacement(_result) {
2516
+ return this.spec.unquote(this.spec.replace);
2517
+ }
2518
+ matchAll(state, limit) {
2519
+ let cursor = stringCursor(this.spec, state, 0, state.doc.length),
2520
+ ranges = [];
2521
+ while (!cursor.next().done) {
2522
+ if (ranges.length >= limit) return null;
2523
+ ranges.push(cursor.value);
2524
+ }
2525
+ return ranges;
2526
+ }
2527
+ highlight(state, from, to, add) {
2528
+ let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));
2529
+ while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
2530
+ }
2531
+ }
2532
+ function regexpCursor(spec, state, from, to) {
2533
+ return new RegExpCursor(state.doc, spec.search, {
2534
+ ignoreCase: !spec.caseSensitive,
2535
+ test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined
2536
+ }, from, to);
2537
+ }
2538
+ function charBefore(str, index) {
2539
+ return str.slice(findClusterBreak(str, index, false), index);
2540
+ }
2541
+ function charAfter(str, index) {
2542
+ return str.slice(index, findClusterBreak(str, index));
2543
+ }
2544
+ function regexpWordTest(categorizer) {
2545
+ return (_from, _to, match) => !match[0].length || (categorizer(charBefore(match.input, match.index)) != CharCategory.Word || categorizer(charAfter(match.input, match.index)) != CharCategory.Word) && (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word || categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);
2546
+ }
2547
+ class RegExpQuery extends QueryType {
2548
+ nextMatch(state, curFrom, curTo) {
2549
+ let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();
2550
+ if (cursor.done) cursor = regexpCursor(this.spec, state, 0, curFrom).next();
2551
+ return cursor.done ? null : cursor.value;
2552
+ }
2553
+ prevMatchInRange(state, from, to) {
2554
+ for (let size = 1;; size++) {
2555
+ let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);
2556
+ let cursor = regexpCursor(this.spec, state, start, to),
2557
+ range = null;
2558
+ while (!cursor.next().done) range = cursor.value;
2559
+ if (range && (start == from || range.from > start + 10)) return range;
2560
+ if (start == from) return null;
2561
+ }
2562
+ }
2563
+ prevMatch(state, curFrom, curTo) {
2564
+ return this.prevMatchInRange(state, 0, curFrom) || this.prevMatchInRange(state, curTo, state.doc.length);
2565
+ }
2566
+ getReplacement(result) {
2567
+ return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$" : i == "&" ? result.match[0] : i != "0" && +i < result.match.length ? result.match[i] : m));
2568
+ }
2569
+ matchAll(state, limit) {
2570
+ let cursor = regexpCursor(this.spec, state, 0, state.doc.length),
2571
+ ranges = [];
2572
+ while (!cursor.next().done) {
2573
+ if (ranges.length >= limit) return null;
2574
+ ranges.push(cursor.value);
2575
+ }
2576
+ return ranges;
2577
+ }
2578
+ highlight(state, from, to, add) {
2579
+ let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));
2580
+ while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
2581
+ }
2582
+ }
2583
+ /**
2584
+ A state effect that updates the current search query. Note that
2585
+ this only has an effect if the search state has been initialized
2586
+ (by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
2587
+ by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
2588
+ once).
2589
+ */
2590
+ const setSearchQuery = /*@__PURE__*/StateEffect.define();
2591
+ const togglePanel$1 = /*@__PURE__*/StateEffect.define();
2592
+ const searchState = /*@__PURE__*/StateField.define({
2593
+ create(state) {
2594
+ return new SearchState(defaultQuery(state).create(), null);
2595
+ },
2596
+ update(value, tr) {
2597
+ for (let effect of tr.effects) {
2598
+ if (effect.is(setSearchQuery)) value = new SearchState(effect.value.create(), value.panel);else if (effect.is(togglePanel$1)) value = new SearchState(value.query, effect.value ? createSearchPanel : null);
2599
+ }
2600
+ return value;
2601
+ },
2602
+ provide: f => showPanel.from(f, val => val.panel)
2603
+ });
2604
+ class SearchState {
2605
+ constructor(query, panel) {
2606
+ this.query = query;
2607
+ this.panel = panel;
2608
+ }
2609
+ }
2610
+ const matchMark = /*@__PURE__*/Decoration.mark({
2611
+ class: "cm-searchMatch"
2612
+ }),
2613
+ selectedMatchMark = /*@__PURE__*/Decoration.mark({
2614
+ class: "cm-searchMatch cm-searchMatch-selected"
2615
+ });
2616
+ const searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
2617
+ constructor(view) {
2618
+ this.view = view;
2619
+ this.decorations = this.highlight(view.state.field(searchState));
2620
+ }
2621
+ update(update) {
2622
+ let state = update.state.field(searchState);
2623
+ if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged) this.decorations = this.highlight(state);
2624
+ }
2625
+ highlight({
2626
+ query,
2627
+ panel
2628
+ }) {
2629
+ if (!panel || !query.spec.valid) return Decoration.none;
2630
+ let {
2631
+ view
2632
+ } = this;
2633
+ let builder = new RangeSetBuilder();
2634
+ for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
2635
+ let {
2636
+ from,
2637
+ to
2638
+ } = ranges[i];
2639
+ while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */) to = ranges[++i].to;
2640
+ query.highlight(view.state, from, to, (from, to) => {
2641
+ let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
2642
+ builder.add(from, to, selected ? selectedMatchMark : matchMark);
2643
+ });
2644
+ }
2645
+ return builder.finish();
2646
+ }
2647
+ }, {
2648
+ decorations: v => v.decorations
2649
+ });
2650
+ function searchCommand(f) {
2651
+ return view => {
2652
+ let state = view.state.field(searchState, false);
2653
+ return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
2654
+ };
2655
+ }
2656
+ /**
2657
+ Open the search panel if it isn't already open, and move the
2658
+ selection to the first match after the current main selection.
2659
+ Will wrap around to the start of the document when it reaches the
2660
+ end.
2661
+ */
2662
+ const findNext = /*@__PURE__*/searchCommand((view, {
2663
+ query
2664
+ }) => {
2665
+ let {
2666
+ to
2667
+ } = view.state.selection.main;
2668
+ let next = query.nextMatch(view.state, to, to);
2669
+ if (!next) return false;
2670
+ view.dispatch({
2671
+ selection: {
2672
+ anchor: next.from,
2673
+ head: next.to
2674
+ },
2675
+ scrollIntoView: true,
2676
+ effects: announceMatch(view, next),
2677
+ userEvent: "select.search"
2678
+ });
2679
+ return true;
2680
+ });
2681
+ /**
2682
+ Move the selection to the previous instance of the search query,
2683
+ before the current main selection. Will wrap past the start
2684
+ of the document to start searching at the end again.
2685
+ */
2686
+ const findPrevious = /*@__PURE__*/searchCommand((view, {
2687
+ query
2688
+ }) => {
2689
+ let {
2690
+ state
2691
+ } = view,
2692
+ {
2693
+ from
2694
+ } = state.selection.main;
2695
+ let range = query.prevMatch(state, from, from);
2696
+ if (!range) return false;
2697
+ view.dispatch({
2698
+ selection: {
2699
+ anchor: range.from,
2700
+ head: range.to
2701
+ },
2702
+ scrollIntoView: true,
2703
+ effects: announceMatch(view, range),
2704
+ userEvent: "select.search"
2705
+ });
2706
+ return true;
2707
+ });
2708
+ /**
2709
+ Select all instances of the search query.
2710
+ */
2711
+ const selectMatches = /*@__PURE__*/searchCommand((view, {
2712
+ query
2713
+ }) => {
2714
+ let ranges = query.matchAll(view.state, 1000);
2715
+ if (!ranges || !ranges.length) return false;
2716
+ view.dispatch({
2717
+ selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),
2718
+ userEvent: "select.search.matches"
2719
+ });
2720
+ return true;
2721
+ });
2722
+ /**
2723
+ Select all instances of the currently selected text.
2724
+ */
2725
+ const selectSelectionMatches = ({
2726
+ state,
2727
+ dispatch
2728
+ }) => {
2729
+ let sel = state.selection;
2730
+ if (sel.ranges.length > 1 || sel.main.empty) return false;
2731
+ let {
2732
+ from,
2733
+ to
2734
+ } = sel.main;
2735
+ let ranges = [],
2736
+ main = 0;
2737
+ for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
2738
+ if (ranges.length > 1000) return false;
2739
+ if (cur.value.from == from) main = ranges.length;
2740
+ ranges.push(EditorSelection.range(cur.value.from, cur.value.to));
2741
+ }
2742
+ dispatch(state.update({
2743
+ selection: EditorSelection.create(ranges, main),
2744
+ userEvent: "select.search.matches"
2745
+ }));
2746
+ return true;
2747
+ };
2748
+ /**
2749
+ Replace the current match of the search query.
2750
+ */
2751
+ const replaceNext = /*@__PURE__*/searchCommand((view, {
2752
+ query
2753
+ }) => {
2754
+ let {
2755
+ state
2756
+ } = view,
2757
+ {
2758
+ from,
2759
+ to
2760
+ } = state.selection.main;
2761
+ if (state.readOnly) return false;
2762
+ let next = query.nextMatch(state, from, from);
2763
+ if (!next) return false;
2764
+ let changes = [],
2765
+ selection,
2766
+ replacement;
2767
+ let announce = [];
2768
+ if (next.from == from && next.to == to) {
2769
+ replacement = state.toText(query.getReplacement(next));
2770
+ changes.push({
2771
+ from: next.from,
2772
+ to: next.to,
2773
+ insert: replacement
2774
+ });
2775
+ next = query.nextMatch(state, next.from, next.to);
2776
+ announce.push(EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
2777
+ }
2778
+ if (next) {
2779
+ let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;
2780
+ selection = {
2781
+ anchor: next.from - off,
2782
+ head: next.to - off
2783
+ };
2784
+ announce.push(announceMatch(view, next));
2785
+ }
2786
+ view.dispatch({
2787
+ changes,
2788
+ selection,
2789
+ scrollIntoView: !!selection,
2790
+ effects: announce,
2791
+ userEvent: "input.replace"
2792
+ });
2793
+ return true;
2794
+ });
2795
+ /**
2796
+ Replace all instances of the search query with the given
2797
+ replacement.
2798
+ */
2799
+ const replaceAll = /*@__PURE__*/searchCommand((view, {
2800
+ query
2801
+ }) => {
2802
+ if (view.state.readOnly) return false;
2803
+ let changes = query.matchAll(view.state, 1e9).map(match => {
2804
+ let {
2805
+ from,
2806
+ to
2807
+ } = match;
2808
+ return {
2809
+ from,
2810
+ to,
2811
+ insert: query.getReplacement(match)
2812
+ };
2813
+ });
2814
+ if (!changes.length) return false;
2815
+ let announceText = view.state.phrase("replaced $ matches", changes.length) + ".";
2816
+ view.dispatch({
2817
+ changes,
2818
+ effects: EditorView.announce.of(announceText),
2819
+ userEvent: "input.replace.all"
2820
+ });
2821
+ return true;
2822
+ });
2823
+ function createSearchPanel(view) {
2824
+ return view.state.facet(searchConfigFacet).createPanel(view);
2825
+ }
2826
+ function defaultQuery(state, fallback) {
2827
+ var _a, _b, _c, _d;
2828
+ let sel = state.selection.main;
2829
+ let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
2830
+ if (fallback && !selText) return fallback;
2831
+ let config = state.facet(searchConfigFacet);
2832
+ return new SearchQuery({
2833
+ search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\n/g, "\\n"),
2834
+ caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,
2835
+ literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,
2836
+ wholeWord: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _d !== void 0 ? _d : config.wholeWord
2837
+ });
2838
+ }
2839
+ /**
2840
+ Make sure the search panel is open and focused.
2841
+ */
2842
+ const openSearchPanel = view => {
2843
+ let state = view.state.field(searchState, false);
2844
+ if (state && state.panel) {
2845
+ let panel = getPanel(view, createSearchPanel);
2846
+ if (!panel) return false;
2847
+ let searchInput = panel.dom.querySelector("[main-field]");
2848
+ if (searchInput && searchInput != view.root.activeElement) {
2849
+ let query = defaultQuery(view.state, state.query.spec);
2850
+ if (query.valid) view.dispatch({
2851
+ effects: setSearchQuery.of(query)
2852
+ });
2853
+ searchInput.focus();
2854
+ searchInput.select();
2855
+ }
2856
+ } else {
2857
+ view.dispatch({
2858
+ effects: [togglePanel$1.of(true), state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)]
2859
+ });
2860
+ }
2861
+ return true;
2862
+ };
2863
+ /**
2864
+ Close the search panel.
2865
+ */
2866
+ const closeSearchPanel = view => {
2867
+ let state = view.state.field(searchState, false);
2868
+ if (!state || !state.panel) return false;
2869
+ let panel = getPanel(view, createSearchPanel);
2870
+ if (panel && panel.dom.contains(view.root.activeElement)) view.focus();
2871
+ view.dispatch({
2872
+ effects: togglePanel$1.of(false)
2873
+ });
2874
+ return true;
2875
+ };
2876
+ /**
2877
+ Default search-related key bindings.
2878
+
2879
+ - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
2880
+ - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
2881
+ - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
2882
+ - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
2883
+ - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
2884
+ */
2885
+ const searchKeymap = [{
2886
+ key: "Mod-f",
2887
+ run: openSearchPanel,
2888
+ scope: "editor search-panel"
2889
+ }, {
2890
+ key: "F3",
2891
+ run: findNext,
2892
+ shift: findPrevious,
2893
+ scope: "editor search-panel",
2894
+ preventDefault: true
2895
+ }, {
2896
+ key: "Mod-g",
2897
+ run: findNext,
2898
+ shift: findPrevious,
2899
+ scope: "editor search-panel",
2900
+ preventDefault: true
2901
+ }, {
2902
+ key: "Escape",
2903
+ run: closeSearchPanel,
2904
+ scope: "editor search-panel"
2905
+ }, {
2906
+ key: "Mod-Shift-l",
2907
+ run: selectSelectionMatches
2908
+ }, {
2909
+ key: "Alt-g",
2910
+ run: gotoLine
2911
+ }, {
2912
+ key: "Mod-d",
2913
+ run: selectNextOccurrence,
2914
+ preventDefault: true
2915
+ }];
2916
+ class SearchPanel {
2917
+ constructor(view) {
2918
+ this.view = view;
2919
+ let query = this.query = view.state.field(searchState).query.spec;
2920
+ this.commit = this.commit.bind(this);
2921
+ this.searchField = crelt("input", {
2922
+ value: query.search,
2923
+ placeholder: phrase(view, "Find"),
2924
+ "aria-label": phrase(view, "Find"),
2925
+ class: "cm-textfield",
2926
+ name: "search",
2927
+ form: "",
2928
+ "main-field": "true",
2929
+ onchange: this.commit,
2930
+ onkeyup: this.commit
2931
+ });
2932
+ this.replaceField = crelt("input", {
2933
+ value: query.replace,
2934
+ placeholder: phrase(view, "Replace"),
2935
+ "aria-label": phrase(view, "Replace"),
2936
+ class: "cm-textfield",
2937
+ name: "replace",
2938
+ form: "",
2939
+ onchange: this.commit,
2940
+ onkeyup: this.commit
2941
+ });
2942
+ this.caseField = crelt("input", {
2943
+ type: "checkbox",
2944
+ name: "case",
2945
+ form: "",
2946
+ checked: query.caseSensitive,
2947
+ onchange: this.commit
2948
+ });
2949
+ this.reField = crelt("input", {
2950
+ type: "checkbox",
2951
+ name: "re",
2952
+ form: "",
2953
+ checked: query.regexp,
2954
+ onchange: this.commit
2955
+ });
2956
+ this.wordField = crelt("input", {
2957
+ type: "checkbox",
2958
+ name: "word",
2959
+ form: "",
2960
+ checked: query.wholeWord,
2961
+ onchange: this.commit
2962
+ });
2963
+ function button(name, onclick, content) {
2964
+ return crelt("button", {
2965
+ class: "cm-button",
2966
+ name,
2967
+ onclick,
2968
+ type: "button"
2969
+ }, content);
2970
+ }
2971
+ this.dom = crelt("div", {
2972
+ onkeydown: e => this.keydown(e),
2973
+ class: "cm-search"
2974
+ }, [this.searchField, button("next", () => findNext(view), [phrase(view, "next")]), button("prev", () => findPrevious(view), [phrase(view, "previous")]), button("select", () => selectMatches(view), [phrase(view, "all")]), crelt("label", null, [this.caseField, phrase(view, "match case")]), crelt("label", null, [this.reField, phrase(view, "regexp")]), crelt("label", null, [this.wordField, phrase(view, "by word")]), ...(view.state.readOnly ? [] : [crelt("br"), this.replaceField, button("replace", () => replaceNext(view), [phrase(view, "replace")]), button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")])]), crelt("button", {
2975
+ name: "close",
2976
+ onclick: () => closeSearchPanel(view),
2977
+ "aria-label": phrase(view, "close"),
2978
+ type: "button"
2979
+ }, ["×"])]);
2980
+ }
2981
+ commit() {
2982
+ let query = new SearchQuery({
2983
+ search: this.searchField.value,
2984
+ caseSensitive: this.caseField.checked,
2985
+ regexp: this.reField.checked,
2986
+ wholeWord: this.wordField.checked,
2987
+ replace: this.replaceField.value
2988
+ });
2989
+ if (!query.eq(this.query)) {
2990
+ this.query = query;
2991
+ this.view.dispatch({
2992
+ effects: setSearchQuery.of(query)
2993
+ });
2994
+ }
2995
+ }
2996
+ keydown(e) {
2997
+ if (runScopeHandlers(this.view, e, "search-panel")) {
2998
+ e.preventDefault();
2999
+ } else if (e.keyCode == 13 && e.target == this.searchField) {
3000
+ e.preventDefault();
3001
+ (e.shiftKey ? findPrevious : findNext)(this.view);
3002
+ } else if (e.keyCode == 13 && e.target == this.replaceField) {
3003
+ e.preventDefault();
3004
+ replaceNext(this.view);
3005
+ }
3006
+ }
3007
+ update(update) {
3008
+ for (let tr of update.transactions) for (let effect of tr.effects) {
3009
+ if (effect.is(setSearchQuery) && !effect.value.eq(this.query)) this.setQuery(effect.value);
3010
+ }
3011
+ }
3012
+ setQuery(query) {
3013
+ this.query = query;
3014
+ this.searchField.value = query.search;
3015
+ this.replaceField.value = query.replace;
3016
+ this.caseField.checked = query.caseSensitive;
3017
+ this.reField.checked = query.regexp;
3018
+ this.wordField.checked = query.wholeWord;
3019
+ }
3020
+ mount() {
3021
+ this.searchField.select();
3022
+ }
3023
+ get pos() {
3024
+ return 80;
3025
+ }
3026
+ get top() {
3027
+ return this.view.state.facet(searchConfigFacet).top;
3028
+ }
3029
+ }
3030
+ function phrase(view, phrase) {
3031
+ return view.state.phrase(phrase);
3032
+ }
3033
+ const AnnounceMargin = 30;
3034
+ const Break = /[\s\.,:;?!]/;
3035
+ function announceMatch(view, {
3036
+ from,
3037
+ to
3038
+ }) {
3039
+ let line = view.state.doc.lineAt(from),
3040
+ lineEnd = view.state.doc.lineAt(to).to;
3041
+ let start = Math.max(line.from, from - AnnounceMargin),
3042
+ end = Math.min(lineEnd, to + AnnounceMargin);
3043
+ let text = view.state.sliceDoc(start, end);
3044
+ if (start != line.from) {
3045
+ for (let i = 0; i < AnnounceMargin; i++) if (!Break.test(text[i + 1]) && Break.test(text[i])) {
3046
+ text = text.slice(i);
3047
+ break;
3048
+ }
3049
+ }
3050
+ if (end != lineEnd) {
3051
+ for (let i = text.length - 1; i > text.length - AnnounceMargin; i--) if (!Break.test(text[i - 1]) && Break.test(text[i])) {
3052
+ text = text.slice(0, i);
3053
+ break;
3054
+ }
3055
+ }
3056
+ return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${line.number}.`);
3057
+ }
3058
+ const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
3059
+ ".cm-panel.cm-search": {
3060
+ padding: "2px 6px 4px",
3061
+ position: "relative",
3062
+ "& [name=close]": {
3063
+ position: "absolute",
3064
+ top: "0",
3065
+ right: "4px",
3066
+ backgroundColor: "inherit",
3067
+ border: "none",
3068
+ font: "inherit",
3069
+ padding: 0,
3070
+ margin: 0
3071
+ },
3072
+ "& input, & button, & label": {
3073
+ margin: ".2em .6em .2em 0"
3074
+ },
3075
+ "& input[type=checkbox]": {
3076
+ marginRight: ".2em"
3077
+ },
3078
+ "& label": {
3079
+ fontSize: "80%",
3080
+ whiteSpace: "pre"
3081
+ }
3082
+ },
3083
+ "&light .cm-searchMatch": {
3084
+ backgroundColor: "#ffff0054"
3085
+ },
3086
+ "&dark .cm-searchMatch": {
3087
+ backgroundColor: "#00ffff8a"
3088
+ },
3089
+ "&light .cm-searchMatch-selected": {
3090
+ backgroundColor: "#ff6a0054"
3091
+ },
3092
+ "&dark .cm-searchMatch-selected": {
3093
+ backgroundColor: "#ff00ff8a"
3094
+ }
3095
+ });
3096
+ const searchExtensions = [searchState, /*@__PURE__*/Prec.lowest(searchHighlighter), baseTheme$2];
3097
+
3098
+ class SelectedDiagnostic {
3099
+ constructor(from, to, diagnostic) {
3100
+ this.from = from;
3101
+ this.to = to;
3102
+ this.diagnostic = diagnostic;
3103
+ }
3104
+ }
3105
+ class LintState {
3106
+ constructor(diagnostics, panel, selected) {
3107
+ this.diagnostics = diagnostics;
3108
+ this.panel = panel;
3109
+ this.selected = selected;
3110
+ }
3111
+ static init(diagnostics, panel, state) {
3112
+ // Filter the list of diagnostics for which to create markers
3113
+ let markedDiagnostics = diagnostics;
3114
+ let diagnosticFilter = state.facet(lintConfig).markerFilter;
3115
+ if (diagnosticFilter) markedDiagnostics = diagnosticFilter(markedDiagnostics);
3116
+ let ranges = Decoration.set(markedDiagnostics.map(d => {
3117
+ // For zero-length ranges or ranges covering only a line break, create a widget
3118
+ return d.from == d.to || d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from ? Decoration.widget({
3119
+ widget: new DiagnosticWidget(d),
3120
+ diagnostic: d
3121
+ }).range(d.from) : Decoration.mark({
3122
+ attributes: {
3123
+ class: "cm-lintRange cm-lintRange-" + d.severity
3124
+ },
3125
+ diagnostic: d
3126
+ }).range(d.from, d.to);
3127
+ }), true);
3128
+ return new LintState(ranges, panel, findDiagnostic(ranges));
3129
+ }
3130
+ }
3131
+ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
3132
+ let found = null;
3133
+ diagnostics.between(after, 1e9, (from, to, {
3134
+ spec
3135
+ }) => {
3136
+ if (diagnostic && spec.diagnostic != diagnostic) return;
3137
+ found = new SelectedDiagnostic(from, to, spec.diagnostic);
3138
+ return false;
3139
+ });
3140
+ return found;
3141
+ }
3142
+ function hideTooltip(tr, tooltip) {
3143
+ return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
3144
+ }
3145
+ function maybeEnableLint(state, effects) {
3146
+ return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([lintState, EditorView.decorations.compute([lintState], state => {
3147
+ let {
3148
+ selected,
3149
+ panel
3150
+ } = state.field(lintState);
3151
+ return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([activeMark.range(selected.from, selected.to)]);
3152
+ }), hoverTooltip(lintTooltip, {
3153
+ hideOn: hideTooltip
3154
+ }), baseTheme]));
3155
+ }
3156
+ /**
3157
+ Returns a transaction spec which updates the current set of
3158
+ diagnostics, and enables the lint extension if if wasn't already
3159
+ active.
3160
+ */
3161
+ function setDiagnostics(state, diagnostics) {
3162
+ return {
3163
+ effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
3164
+ };
3165
+ }
3166
+ /**
3167
+ The state effect that updates the set of active diagnostics. Can
3168
+ be useful when writing an extension that needs to track these.
3169
+ */
3170
+ const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
3171
+ const togglePanel = /*@__PURE__*/StateEffect.define();
3172
+ const movePanelSelection = /*@__PURE__*/StateEffect.define();
3173
+ const lintState = /*@__PURE__*/StateField.define({
3174
+ create() {
3175
+ return new LintState(Decoration.none, null, null);
3176
+ },
3177
+ update(value, tr) {
3178
+ if (tr.docChanged) {
3179
+ let mapped = value.diagnostics.map(tr.changes),
3180
+ selected = null;
3181
+ if (value.selected) {
3182
+ let selPos = tr.changes.mapPos(value.selected.from, 1);
3183
+ selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
3184
+ }
3185
+ value = new LintState(mapped, value.panel, selected);
3186
+ }
3187
+ for (let effect of tr.effects) {
3188
+ if (effect.is(setDiagnosticsEffect)) {
3189
+ value = LintState.init(effect.value, value.panel, tr.state);
3190
+ } else if (effect.is(togglePanel)) {
3191
+ value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
3192
+ } else if (effect.is(movePanelSelection)) {
3193
+ value = new LintState(value.diagnostics, value.panel, effect.value);
3194
+ }
3195
+ }
3196
+ return value;
3197
+ },
3198
+ provide: f => [showPanel.from(f, val => val.panel), EditorView.decorations.from(f, s => s.diagnostics)]
3199
+ });
3200
+ const activeMark = /*@__PURE__*/Decoration.mark({
3201
+ class: "cm-lintRange cm-lintRange-active"
3202
+ });
3203
+ function lintTooltip(view, pos, side) {
3204
+ let {
3205
+ diagnostics
3206
+ } = view.state.field(lintState);
3207
+ let found = [],
3208
+ stackStart = 2e8,
3209
+ stackEnd = 0;
3210
+ diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, {
3211
+ spec
3212
+ }) => {
3213
+ if (pos >= from && pos <= to && (from == to || (pos > from || side > 0) && (pos < to || side < 0))) {
3214
+ found.push(spec.diagnostic);
3215
+ stackStart = Math.min(from, stackStart);
3216
+ stackEnd = Math.max(to, stackEnd);
3217
+ }
3218
+ });
3219
+ let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
3220
+ if (diagnosticFilter) found = diagnosticFilter(found);
3221
+ if (!found.length) return null;
3222
+ return {
3223
+ pos: stackStart,
3224
+ end: stackEnd,
3225
+ above: view.state.doc.lineAt(stackStart).to < stackEnd,
3226
+ create() {
3227
+ return {
3228
+ dom: diagnosticsTooltip(view, found)
3229
+ };
3230
+ }
3231
+ };
3232
+ }
3233
+ function diagnosticsTooltip(view, diagnostics) {
3234
+ return crelt("ul", {
3235
+ class: "cm-tooltip-lint"
3236
+ }, diagnostics.map(d => renderDiagnostic(view, d, false)));
3237
+ }
3238
+ /**
3239
+ Command to open and focus the lint panel.
3240
+ */
3241
+ const openLintPanel = view => {
3242
+ let field = view.state.field(lintState, false);
3243
+ if (!field || !field.panel) view.dispatch({
3244
+ effects: maybeEnableLint(view.state, [togglePanel.of(true)])
3245
+ });
3246
+ let panel = getPanel(view, LintPanel.open);
3247
+ if (panel) panel.dom.querySelector(".cm-panel-lint ul").focus();
3248
+ return true;
3249
+ };
3250
+ /**
3251
+ Command to close the lint panel, when open.
3252
+ */
3253
+ const closeLintPanel = view => {
3254
+ let field = view.state.field(lintState, false);
3255
+ if (!field || !field.panel) return false;
3256
+ view.dispatch({
3257
+ effects: togglePanel.of(false)
3258
+ });
3259
+ return true;
3260
+ };
3261
+ /**
3262
+ Move the selection to the next diagnostic.
3263
+ */
3264
+ const nextDiagnostic = view => {
3265
+ let field = view.state.field(lintState, false);
3266
+ if (!field) return false;
3267
+ let sel = view.state.selection.main,
3268
+ next = field.diagnostics.iter(sel.to + 1);
3269
+ if (!next.value) {
3270
+ next = field.diagnostics.iter(0);
3271
+ if (!next.value || next.from == sel.from && next.to == sel.to) return false;
3272
+ }
3273
+ view.dispatch({
3274
+ selection: {
3275
+ anchor: next.from,
3276
+ head: next.to
3277
+ },
3278
+ scrollIntoView: true
3279
+ });
3280
+ return true;
3281
+ };
3282
+ /**
3283
+ A set of default key bindings for the lint functionality.
3284
+
3285
+ - Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
3286
+ - F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
3287
+ */
3288
+ const lintKeymap = [{
3289
+ key: "Mod-Shift-m",
3290
+ run: openLintPanel,
3291
+ preventDefault: true
3292
+ }, {
3293
+ key: "F8",
3294
+ run: nextDiagnostic
3295
+ }];
3296
+ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
3297
+ constructor(view) {
3298
+ this.view = view;
3299
+ this.timeout = -1;
3300
+ this.set = true;
3301
+ let {
3302
+ delay
3303
+ } = view.state.facet(lintConfig);
3304
+ this.lintTime = Date.now() + delay;
3305
+ this.run = this.run.bind(this);
3306
+ this.timeout = setTimeout(this.run, delay);
3307
+ }
3308
+ run() {
3309
+ let now = Date.now();
3310
+ if (now < this.lintTime - 10) {
3311
+ setTimeout(this.run, this.lintTime - now);
3312
+ } else {
3313
+ this.set = false;
3314
+ let {
3315
+ state
3316
+ } = this.view,
3317
+ {
3318
+ sources
3319
+ } = state.facet(lintConfig);
3320
+ Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
3321
+ let all = annotations.reduce((a, b) => a.concat(b));
3322
+ if (this.view.state.doc == state.doc) this.view.dispatch(setDiagnostics(this.view.state, all));
3323
+ }, error => {
3324
+ logException(this.view.state, error);
3325
+ });
3326
+ }
3327
+ }
3328
+ update(update) {
3329
+ let config = update.state.facet(lintConfig);
3330
+ if (update.docChanged || config != update.startState.facet(lintConfig)) {
3331
+ this.lintTime = Date.now() + config.delay;
3332
+ if (!this.set) {
3333
+ this.set = true;
3334
+ this.timeout = setTimeout(this.run, config.delay);
3335
+ }
3336
+ }
3337
+ }
3338
+ force() {
3339
+ if (this.set) {
3340
+ this.lintTime = Date.now();
3341
+ this.run();
3342
+ }
3343
+ }
3344
+ destroy() {
3345
+ clearTimeout(this.timeout);
3346
+ }
3347
+ });
3348
+ const lintConfig = /*@__PURE__*/Facet.define({
3349
+ combine(input) {
3350
+ return Object.assign({
3351
+ sources: input.map(i => i.source)
3352
+ }, combineConfig(input.map(i => i.config), {
3353
+ delay: 750,
3354
+ markerFilter: null,
3355
+ tooltipFilter: null
3356
+ }));
3357
+ },
3358
+ enables: lintPlugin
3359
+ });
3360
+ function assignKeys(actions) {
3361
+ let assigned = [];
3362
+ if (actions) actions: for (let {
3363
+ name
3364
+ } of actions) {
3365
+ for (let i = 0; i < name.length; i++) {
3366
+ let ch = name[i];
3367
+ if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
3368
+ assigned.push(ch);
3369
+ continue actions;
3370
+ }
3371
+ }
3372
+ assigned.push("");
3373
+ }
3374
+ return assigned;
3375
+ }
3376
+ function renderDiagnostic(view, diagnostic, inPanel) {
3377
+ var _a;
3378
+ let keys = inPanel ? assignKeys(diagnostic.actions) : [];
3379
+ return crelt("li", {
3380
+ class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity
3381
+ }, crelt("span", {
3382
+ class: "cm-diagnosticText"
3383
+ }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
3384
+ let click = e => {
3385
+ e.preventDefault();
3386
+ let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
3387
+ if (found) action.apply(view, found.from, found.to);
3388
+ };
3389
+ let {
3390
+ name
3391
+ } = action,
3392
+ keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
3393
+ let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex), crelt("u", name.slice(keyIndex, keyIndex + 1)), name.slice(keyIndex + 1)];
3394
+ return crelt("button", {
3395
+ type: "button",
3396
+ class: "cm-diagnosticAction",
3397
+ onclick: click,
3398
+ onmousedown: click,
3399
+ "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
3400
+ }, nameElt);
3401
+ }), diagnostic.source && crelt("div", {
3402
+ class: "cm-diagnosticSource"
3403
+ }, diagnostic.source));
3404
+ }
3405
+ class DiagnosticWidget extends WidgetType {
3406
+ constructor(diagnostic) {
3407
+ super();
3408
+ this.diagnostic = diagnostic;
3409
+ }
3410
+ eq(other) {
3411
+ return other.diagnostic == this.diagnostic;
3412
+ }
3413
+ toDOM() {
3414
+ return crelt("span", {
3415
+ class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity
3416
+ });
3417
+ }
3418
+ }
3419
+ class PanelItem {
3420
+ constructor(view, diagnostic) {
3421
+ this.diagnostic = diagnostic;
3422
+ this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
3423
+ this.dom = renderDiagnostic(view, diagnostic, true);
3424
+ this.dom.id = this.id;
3425
+ this.dom.setAttribute("role", "option");
3426
+ }
3427
+ }
3428
+ class LintPanel {
3429
+ constructor(view) {
3430
+ this.view = view;
3431
+ this.items = [];
3432
+ let onkeydown = event => {
3433
+ if (event.keyCode == 27) {
3434
+ // Escape
3435
+ closeLintPanel(this.view);
3436
+ this.view.focus();
3437
+ } else if (event.keyCode == 38 || event.keyCode == 33) {
3438
+ // ArrowUp, PageUp
3439
+ this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
3440
+ } else if (event.keyCode == 40 || event.keyCode == 34) {
3441
+ // ArrowDown, PageDown
3442
+ this.moveSelection((this.selectedIndex + 1) % this.items.length);
3443
+ } else if (event.keyCode == 36) {
3444
+ // Home
3445
+ this.moveSelection(0);
3446
+ } else if (event.keyCode == 35) {
3447
+ // End
3448
+ this.moveSelection(this.items.length - 1);
3449
+ } else if (event.keyCode == 13) {
3450
+ // Enter
3451
+ this.view.focus();
3452
+ } else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) {
3453
+ // A-Z
3454
+ let {
3455
+ diagnostic
3456
+ } = this.items[this.selectedIndex],
3457
+ keys = assignKeys(diagnostic.actions);
3458
+ for (let i = 0; i < keys.length; i++) if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
3459
+ let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
3460
+ if (found) diagnostic.actions[i].apply(view, found.from, found.to);
3461
+ }
3462
+ } else {
3463
+ return;
3464
+ }
3465
+ event.preventDefault();
3466
+ };
3467
+ let onclick = event => {
3468
+ for (let i = 0; i < this.items.length; i++) {
3469
+ if (this.items[i].dom.contains(event.target)) this.moveSelection(i);
3470
+ }
3471
+ };
3472
+ this.list = crelt("ul", {
3473
+ tabIndex: 0,
3474
+ role: "listbox",
3475
+ "aria-label": this.view.state.phrase("Diagnostics"),
3476
+ onkeydown,
3477
+ onclick
3478
+ });
3479
+ this.dom = crelt("div", {
3480
+ class: "cm-panel-lint"
3481
+ }, this.list, crelt("button", {
3482
+ type: "button",
3483
+ name: "close",
3484
+ "aria-label": this.view.state.phrase("close"),
3485
+ onclick: () => closeLintPanel(this.view)
3486
+ }, "×"));
3487
+ this.update();
3488
+ }
3489
+ get selectedIndex() {
3490
+ let selected = this.view.state.field(lintState).selected;
3491
+ if (!selected) return -1;
3492
+ for (let i = 0; i < this.items.length; i++) if (this.items[i].diagnostic == selected.diagnostic) return i;
3493
+ return -1;
3494
+ }
3495
+ update() {
3496
+ let {
3497
+ diagnostics,
3498
+ selected
3499
+ } = this.view.state.field(lintState);
3500
+ let i = 0,
3501
+ needsSync = false,
3502
+ newSelectedItem = null;
3503
+ diagnostics.between(0, this.view.state.doc.length, (_start, _end, {
3504
+ spec
3505
+ }) => {
3506
+ let found = -1,
3507
+ item;
3508
+ for (let j = i; j < this.items.length; j++) if (this.items[j].diagnostic == spec.diagnostic) {
3509
+ found = j;
3510
+ break;
3511
+ }
3512
+ if (found < 0) {
3513
+ item = new PanelItem(this.view, spec.diagnostic);
3514
+ this.items.splice(i, 0, item);
3515
+ needsSync = true;
3516
+ } else {
3517
+ item = this.items[found];
3518
+ if (found > i) {
3519
+ this.items.splice(i, found - i);
3520
+ needsSync = true;
3521
+ }
3522
+ }
3523
+ if (selected && item.diagnostic == selected.diagnostic) {
3524
+ if (!item.dom.hasAttribute("aria-selected")) {
3525
+ item.dom.setAttribute("aria-selected", "true");
3526
+ newSelectedItem = item;
3527
+ }
3528
+ } else if (item.dom.hasAttribute("aria-selected")) {
3529
+ item.dom.removeAttribute("aria-selected");
3530
+ }
3531
+ i++;
3532
+ });
3533
+ while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
3534
+ needsSync = true;
3535
+ this.items.pop();
3536
+ }
3537
+ if (this.items.length == 0) {
3538
+ this.items.push(new PanelItem(this.view, {
3539
+ from: -1,
3540
+ to: -1,
3541
+ severity: "info",
3542
+ message: this.view.state.phrase("No diagnostics")
3543
+ }));
3544
+ needsSync = true;
3545
+ }
3546
+ if (newSelectedItem) {
3547
+ this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
3548
+ this.view.requestMeasure({
3549
+ key: this,
3550
+ read: () => ({
3551
+ sel: newSelectedItem.dom.getBoundingClientRect(),
3552
+ panel: this.list.getBoundingClientRect()
3553
+ }),
3554
+ write: ({
3555
+ sel,
3556
+ panel
3557
+ }) => {
3558
+ if (sel.top < panel.top) this.list.scrollTop -= panel.top - sel.top;else if (sel.bottom > panel.bottom) this.list.scrollTop += sel.bottom - panel.bottom;
3559
+ }
3560
+ });
3561
+ } else if (this.selectedIndex < 0) {
3562
+ this.list.removeAttribute("aria-activedescendant");
3563
+ }
3564
+ if (needsSync) this.sync();
3565
+ }
3566
+ sync() {
3567
+ let domPos = this.list.firstChild;
3568
+ function rm() {
3569
+ let prev = domPos;
3570
+ domPos = prev.nextSibling;
3571
+ prev.remove();
3572
+ }
3573
+ for (let item of this.items) {
3574
+ if (item.dom.parentNode == this.list) {
3575
+ while (domPos != item.dom) rm();
3576
+ domPos = item.dom.nextSibling;
3577
+ } else {
3578
+ this.list.insertBefore(item.dom, domPos);
3579
+ }
3580
+ }
3581
+ while (domPos) rm();
3582
+ }
3583
+ moveSelection(selectedIndex) {
3584
+ if (this.selectedIndex < 0) return;
3585
+ let field = this.view.state.field(lintState);
3586
+ let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
3587
+ if (!selection) return;
3588
+ this.view.dispatch({
3589
+ selection: {
3590
+ anchor: selection.from,
3591
+ head: selection.to
3592
+ },
3593
+ scrollIntoView: true,
3594
+ effects: movePanelSelection.of(selection)
3595
+ });
3596
+ }
3597
+ static open(view) {
3598
+ return new LintPanel(view);
3599
+ }
3600
+ }
3601
+ function svg(content, attrs = `viewBox="0 0 40 40"`) {
3602
+ return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
3603
+ }
3604
+ function underline(color) {
3605
+ return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
3606
+ }
3607
+ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
3608
+ ".cm-diagnostic": {
3609
+ padding: "3px 6px 3px 8px",
3610
+ marginLeft: "-1px",
3611
+ display: "block",
3612
+ whiteSpace: "pre-wrap"
3613
+ },
3614
+ ".cm-diagnostic-error": {
3615
+ borderLeft: "5px solid #d11"
3616
+ },
3617
+ ".cm-diagnostic-warning": {
3618
+ borderLeft: "5px solid orange"
3619
+ },
3620
+ ".cm-diagnostic-info": {
3621
+ borderLeft: "5px solid #999"
3622
+ },
3623
+ ".cm-diagnosticAction": {
3624
+ font: "inherit",
3625
+ border: "none",
3626
+ padding: "2px 4px",
3627
+ backgroundColor: "#444",
3628
+ color: "white",
3629
+ borderRadius: "3px",
3630
+ marginLeft: "8px"
3631
+ },
3632
+ ".cm-diagnosticSource": {
3633
+ fontSize: "70%",
3634
+ opacity: .7
3635
+ },
3636
+ ".cm-lintRange": {
3637
+ backgroundPosition: "left bottom",
3638
+ backgroundRepeat: "repeat-x",
3639
+ paddingBottom: "0.7px"
3640
+ },
3641
+ ".cm-lintRange-error": {
3642
+ backgroundImage: /*@__PURE__*/underline("#d11")
3643
+ },
3644
+ ".cm-lintRange-warning": {
3645
+ backgroundImage: /*@__PURE__*/underline("orange")
3646
+ },
3647
+ ".cm-lintRange-info": {
3648
+ backgroundImage: /*@__PURE__*/underline("#999")
3649
+ },
3650
+ ".cm-lintRange-active": {
3651
+ backgroundColor: "#ffdd9980"
3652
+ },
3653
+ ".cm-tooltip-lint": {
3654
+ padding: 0,
3655
+ margin: 0
3656
+ },
3657
+ ".cm-lintPoint": {
3658
+ position: "relative",
3659
+ "&:after": {
3660
+ content: '""',
3661
+ position: "absolute",
3662
+ bottom: 0,
3663
+ left: "-2px",
3664
+ borderLeft: "3px solid transparent",
3665
+ borderRight: "3px solid transparent",
3666
+ borderBottom: "4px solid #d11"
3667
+ }
3668
+ },
3669
+ ".cm-lintPoint-warning": {
3670
+ "&:after": {
3671
+ borderBottomColor: "orange"
3672
+ }
3673
+ },
3674
+ ".cm-lintPoint-info": {
3675
+ "&:after": {
3676
+ borderBottomColor: "#999"
3677
+ }
3678
+ },
3679
+ ".cm-panel.cm-panel-lint": {
3680
+ position: "relative",
3681
+ "& ul": {
3682
+ maxHeight: "100px",
3683
+ overflowY: "auto",
3684
+ "& [aria-selected]": {
3685
+ backgroundColor: "#ddd",
3686
+ "& u": {
3687
+ textDecoration: "underline"
3688
+ }
3689
+ },
3690
+ "&:focus [aria-selected]": {
3691
+ background_fallback: "#bdf",
3692
+ backgroundColor: "Highlight",
3693
+ color_fallback: "white",
3694
+ color: "HighlightText"
3695
+ },
3696
+ "& u": {
3697
+ textDecoration: "none"
3698
+ },
3699
+ padding: 0,
3700
+ margin: 0
3701
+ },
3702
+ "& [name=close]": {
3703
+ position: "absolute",
3704
+ top: "0",
3705
+ right: "2px",
3706
+ background: "inherit",
3707
+ border: "none",
3708
+ font: "inherit",
3709
+ padding: 0,
3710
+ margin: 0
3711
+ }
3712
+ }
3713
+ });
3714
+
3715
+ // (The superfluous function calls around the list of extensions work
3716
+ // around current limitations in tree-shaking software.)
3717
+ /**
3718
+ This is an extension value that just pulls together a number of
3719
+ extensions that you might want in a basic editor. It is meant as a
3720
+ convenient helper to quickly set up CodeMirror without installing
3721
+ and importing a lot of separate packages.
3722
+
3723
+ Specifically, it includes...
3724
+
3725
+ - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
3726
+ - [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
3727
+ - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
3728
+ - [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
3729
+ - [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
3730
+ - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
3731
+ - [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
3732
+ - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
3733
+ - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
3734
+ - [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
3735
+ - [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
3736
+ - [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
3737
+ - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
3738
+ - [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
3739
+ - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
3740
+ - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
3741
+ - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
3742
+ - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
3743
+ - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
3744
+
3745
+ (You'll probably want to add some language package to your setup
3746
+ too.)
3747
+
3748
+ This extension does not allow customization. The idea is that,
3749
+ once you decide you want to configure your editor more precisely,
3750
+ you take this package's source (which is just a bunch of imports
3751
+ and an array literal), copy it into your own code, and adjust it
3752
+ as desired.
3753
+ */
3754
+ const basicSetup = /*@__PURE__*/(() => [lineNumbers(), highlightActiveLineGutter(), highlightSpecialChars(), history(), foldGutter(), drawSelection(), dropCursor(), EditorState.allowMultipleSelections.of(true), indentOnInput(), syntaxHighlighting(defaultHighlightStyle, {
3755
+ fallback: true
3756
+ }), bracketMatching(), closeBrackets(), autocompletion(), rectangularSelection(), crosshairCursor(), highlightActiveLine(), highlightSelectionMatches(), keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...searchKeymap, ...historyKeymap, ...foldKeymap, ...completionKeymap, ...lintKeymap])])();
3757
+
37
3758
  //partially based on https://github.com/logue/vue-codemirror6/blob/master/src/components/CodeMirror.vue
38
3759
  var script = defineComponent({
39
3760
  name: 'OrCode',