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