@heartlandone/vega 2.76.0 → 2.77.1

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 (508) hide show
  1. package/dist/cjs/{app-globals-12b7d808.js → app-globals-1021e33e.js} +7 -7
  2. package/dist/cjs/aria-attributes-value-mapper-9a41b9cf.js +143 -0
  3. package/dist/cjs/{child-nodes-event-prevent-slimmer-84435957.js → child-nodes-event-prevent-slimmer-cc6d2919.js} +1 -1
  4. package/dist/cjs/{code-block-f1480ec3.js → code-block-f9b86a25.js} +1 -1
  5. package/dist/cjs/{component-value-history-controller-slimmer.abstract-a9264cc8.js → component-value-history-controller-slimmer.abstract-6bcff70b.js} +3 -3
  6. package/dist/cjs/{date-required-rule-912469e0.js → date-required-rule-d3c2d088.js} +1 -1
  7. package/dist/cjs/{design-token-41baf118.js → design-token-b21879b6.js} +2 -2
  8. package/dist/cjs/{dto-renderer-manager-809c947b.js → dto-renderer-manager-e2823eb8.js} +2 -2
  9. package/dist/cjs/{element-appender-slimmer-34e4eb56.js → element-appender-slimmer-40d39bba.js} +179 -20
  10. package/dist/cjs/{form-field-controller-slimmer-102f37c7.js → form-field-controller-slimmer-1b3a1388.js} +1 -1
  11. package/dist/cjs/{image-annotation-action-8d9fa20c.js → image-annotation-action-b83283d4.js} +2 -2
  12. package/dist/cjs/index.cjs.js +13 -13
  13. package/dist/cjs/{inject-keyboard-manager-0f5bd568.js → inject-keyboard-manager-ea5c598e.js} +1 -1
  14. package/dist/cjs/{internal-translation-controller-053eb0f1.js → internal-translation-controller-1f84ab0a.js} +15 -0
  15. package/dist/cjs/{keyboard-manager-055e9f67.js → keyboard-manager-16494c34.js} +1 -1
  16. package/dist/cjs/{keyboard-manager-slimmer-0cc0c1c7.js → keyboard-manager-slimmer-5b8fa209.js} +1 -1
  17. package/dist/cjs/legend-input-processor-1e53e5bc.js +2126 -0
  18. package/dist/cjs/loader.cjs.js +9 -9
  19. package/dist/cjs/{month-view-generator-6a6dd527.js → month-view-generator-1a57578d.js} +1 -1
  20. package/dist/cjs/{public-rules-922849f3.js → public-rules-5bd1624d.js} +7 -7
  21. package/dist/cjs/{range-8aa49b08.js → range-7a038973.js} +1 -1
  22. package/dist/cjs/{responsive-format-facade-ea59bdcd.js → responsive-format-facade-0b65ce4a.js} +2 -2
  23. package/dist/cjs/{rich-text-editor-required-rule-22225840.js → rich-text-editor-required-rule-d984c0b6.js} +1 -1
  24. package/dist/cjs/{string-format-strategy.abstract-f2575647.js → string-format-strategy.abstract-714bfad2.js} +1 -1
  25. package/dist/cjs/{string-input-formatter-slimmer-0a334fc6.js → string-input-formatter-slimmer-9ef2ec7a.js} +1 -1
  26. package/dist/cjs/{string-mask-strategy-dda58395.js → string-mask-strategy-bd2c18df.js} +2 -2
  27. package/dist/cjs/{style-formatter-0c3ced39.js → style-formatter-7a4e9811.js} +2 -2
  28. package/dist/cjs/{time-required-rule-d6fa7aa8.js → time-required-rule-50784b9f.js} +1 -1
  29. package/dist/cjs/{token-extension-07cac85d.js → token-extension-5a1c473e.js} +102 -81
  30. package/dist/cjs/{translation-slimmer-4533bd67.js → translation-slimmer-2c207e34.js} +1 -1
  31. package/dist/cjs/{type-guard-407ba0b8.js → type-guard-cd0376d4.js} +36 -1
  32. package/dist/cjs/{valid-credit-card-number-rule-41a8b51b.js → valid-credit-card-number-rule-3f8dc897.js} +1 -1
  33. package/dist/cjs/vega-accordion.cjs.entry.js +7 -7
  34. package/dist/cjs/vega-app-header-button.cjs.entry.js +39 -146
  35. package/dist/cjs/vega-banner.cjs.entry.js +1 -1
  36. package/dist/cjs/vega-bar-chart.cjs.entry.js +2 -2
  37. package/dist/cjs/vega-box.cjs.entry.js +6 -6
  38. package/dist/cjs/vega-breadcrumb.cjs.entry.js +2 -2
  39. package/dist/cjs/vega-button-circle.cjs.entry.js +23 -8
  40. package/dist/cjs/vega-button-group_2.cjs.entry.js +2 -2
  41. package/dist/cjs/vega-button-link.cjs.entry.js +18 -2
  42. package/dist/cjs/vega-button.cjs.entry.js +5 -5
  43. package/dist/cjs/vega-calendar_4.cjs.entry.js +7 -7
  44. package/dist/cjs/vega-card.cjs.entry.js +5 -5
  45. package/dist/cjs/vega-carousel.cjs.entry.js +4 -4
  46. package/dist/cjs/vega-checkbox_2.cjs.entry.js +4 -4
  47. package/dist/cjs/vega-chip.cjs.entry.js +6 -6
  48. package/dist/cjs/vega-code-block.cjs.entry.js +10 -10
  49. package/dist/cjs/vega-color-picker.cjs.entry.js +2 -2
  50. package/dist/cjs/vega-combo-box.cjs.entry.js +7 -7
  51. package/dist/cjs/vega-date-picker_2.cjs.entry.js +128 -25
  52. package/dist/cjs/vega-dialog_2.cjs.entry.js +6 -6
  53. package/dist/cjs/vega-divider.cjs.entry.js +5 -5
  54. package/dist/cjs/vega-dropdown_5.cjs.entry.js +33 -9
  55. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  56. package/dist/cjs/vega-file-uploader.cjs.entry.js +3 -3
  57. package/dist/cjs/vega-flag-icon.cjs.entry.js +5 -5
  58. package/dist/cjs/vega-flex.cjs.entry.js +6 -6
  59. package/dist/cjs/vega-font.cjs.entry.js +5 -5
  60. package/dist/cjs/vega-form.cjs.entry.js +5 -5
  61. package/dist/cjs/vega-grid.cjs.entry.js +5 -5
  62. package/dist/cjs/vega-icon.cjs.entry.js +5 -5
  63. package/dist/cjs/vega-image-uploader.cjs.entry.js +7 -7
  64. package/dist/cjs/vega-input-credit-card.cjs.entry.js +8 -8
  65. package/dist/cjs/vega-input-numeric.cjs.entry.js +7 -7
  66. package/dist/cjs/vega-input-passcode.cjs.entry.js +39 -9
  67. package/dist/cjs/vega-input-phone-number.cjs.entry.js +4757 -5589
  68. package/dist/cjs/vega-input-range.cjs.entry.js +5 -5
  69. package/dist/cjs/vega-input-select.cjs.entry.js +7 -7
  70. package/dist/cjs/vega-input.cjs.entry.js +220 -125
  71. package/dist/cjs/vega-left-nav_5.cjs.entry.js +7 -8
  72. package/dist/cjs/vega-line-chart.cjs.entry.js +325 -23
  73. package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +4 -4
  74. package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +2 -2
  75. package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +2 -2
  76. package/dist/cjs/vega-pagination.cjs.entry.js +6 -6
  77. package/dist/cjs/vega-pie-chart.cjs.entry.js +5 -88
  78. package/dist/cjs/vega-popover_2.cjs.entry.js +9 -9
  79. package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +4 -4
  80. package/dist/cjs/vega-radio_2.cjs.entry.js +7 -7
  81. package/dist/cjs/vega-rich-text-content.cjs.entry.js +26 -6
  82. package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +129 -31
  83. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +6 -6
  84. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +4 -4
  85. package/dist/cjs/vega-sidenav_3.cjs.entry.js +4 -4
  86. package/dist/cjs/vega-signature-capture.cjs.entry.js +7 -7
  87. package/dist/cjs/vega-stepper.cjs.entry.js +4 -4
  88. package/dist/cjs/vega-tab-group_2.cjs.entry.js +2 -2
  89. package/dist/cjs/vega-table_11.cjs.entry.js +6 -6
  90. package/dist/cjs/vega-textarea.cjs.entry.js +4 -4
  91. package/dist/cjs/vega-time-picker_2.cjs.entry.js +11 -11
  92. package/dist/cjs/vega-toggle-switch.cjs.entry.js +2 -2
  93. package/dist/cjs/vega-tooltip_2.cjs.entry.js +8 -8
  94. package/dist/cjs/vega.cjs.js +9 -9
  95. package/dist/cjs/y-axis-input-processor-54a26515.js +832 -0
  96. package/dist/collection/components/vega-accordion/slimmers/vega-accordion-renderer.js +1 -1
  97. package/dist/collection/components/vega-accordion/vega-accordion.css +5 -0
  98. package/dist/collection/components/vega-app-header-button/vega-app-header-button.js +44 -2
  99. package/dist/collection/components/vega-button-circle/vega-button-circle.js +17 -3
  100. package/dist/collection/components/vega-button-link/vega-button-link.js +16 -1
  101. package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-event-preview-popover-renderer.js +1 -1
  102. package/dist/collection/components/vega-date-picker/slimmers/controllers/vega-date-picker-calendar-open-state-controller.js +64 -0
  103. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-selection-controller.js +3 -0
  104. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-header-render.js +3 -3
  105. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-renderer.js +19 -1
  106. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-year-month-switcher-renderer.js +3 -2
  107. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.js +18 -3
  108. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.css +196 -207
  109. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.js +32 -0
  110. package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-appender-controller.js +25 -0
  111. package/dist/collection/components/vega-input/slimmers/controllers/vega-input-render-mode-controller.js +1 -3
  112. package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-container-renderer.js +1 -5
  113. package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-renderer.js +1 -4
  114. package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-suggestions-renderer.js +5 -2
  115. package/dist/collection/components/vega-input/vega-input.js +24 -1
  116. package/dist/collection/components/vega-input-passcode/slimmers/controllers/vega-input-passcode-keyboard-controller.js +2 -0
  117. package/dist/collection/components/vega-input-passcode/slimmers/renderers/vega-input-passcode-renderer.js +30 -2
  118. package/dist/collection/components/vega-input-phone-number/slimmers/controllers/country-select-controller.js +1 -1
  119. package/dist/collection/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.js +1 -1
  120. package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +1 -1
  121. package/dist/collection/components/vega-input-phone-number/slimmers/renderers/phone-number-input-renderer.js +1 -1
  122. package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +4 -4
  123. package/dist/collection/components/vega-nav/vega-left-nav-link/slimmers/renderers/vega-left-nav-link-renderer.js +2 -3
  124. package/dist/collection/components/vega-popover/vega-popover-content-box/vega-popover-content-box.css +5 -0
  125. package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +15 -0
  126. package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.js +7 -1
  127. package/dist/collection/components/vega-rich-text-editor/extensions/base-extension-renderer.js +11 -0
  128. package/dist/collection/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.js +15 -1
  129. package/dist/collection/components/vega-rich-text-editor/extensions/extension.abstract.js +2 -0
  130. package/dist/collection/components/vega-rich-text-editor/extensions/functions/function-extension.js +0 -11
  131. package/dist/collection/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.js +23 -23
  132. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-extension.js +0 -10
  133. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.js +7 -17
  134. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.js +12 -16
  135. package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.js +31 -0
  136. package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.test.js +19 -0
  137. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/insert-image-controller.js +7 -4
  138. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +113 -12
  139. package/dist/collection/components/vega-rich-text-editor/test/extensions/extension-test-utils.js +41 -0
  140. package/dist/collection/components/vega-rich-text-editor/vega-rich-text-image-editor/slimmers/renderers/vega-rich-text-image-editor-renderer.js +1 -1
  141. package/dist/collection/components/vega-tooltip/vega-tooltip-content-box/vega-tooltip-content-box.css +5 -0
  142. package/dist/collection/helpers/calendar/test/utils.test.js +54 -1
  143. package/dist/collection/helpers/calendar/utils.js +35 -0
  144. package/dist/collection/helpers/chart/input-processors/format-time-positions-input-processor.js +2 -2
  145. package/dist/collection/helpers/chart/input-processors/pie-chart-arc-path-input-processor.js +1 -1
  146. package/dist/collection/helpers/chart/input-processors/x-axis-input-processor.js +5 -3
  147. package/dist/collection/helpers/chart/input-processors/x-axis-label-formatter-input-processor.js +2 -1
  148. package/dist/collection/helpers/chart/input-processors/y-axis-input-processor.js +7 -5
  149. package/dist/collection/helpers/chart/interacting-entry-generator/arc-path-hover-generator.js +1 -1
  150. package/dist/collection/helpers/chart/interacting-entry-generator/pie-legend-hover-generator.js +1 -1
  151. package/dist/collection/helpers/chart/renderers/canvas-renderer.js +1 -1
  152. package/dist/collection/helpers/chart/renderers/svg-renderer.js +1 -1
  153. package/dist/collection/helpers/chart/test/drawers/arc-path-drawer.test.js +1 -1
  154. package/dist/collection/helpers/chart/test/input-processors/format-time-positions-input-processor.test.js +1 -1
  155. package/dist/collection/helpers/chart/test/input-processors/sort-positions-input-processor.test.js +1 -1
  156. package/dist/collection/helpers/chart/test/input-processors/x-axis-input-processor.test.js +39 -0
  157. package/dist/collection/helpers/chart/test/input-processors/x-axis-label-formatter-input-processor.test.js +61 -14
  158. package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.js +39 -0
  159. package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.test.js +14 -0
  160. package/dist/collection/helpers/chart/test/renderers/svg-renderer.test.js +1 -1
  161. package/dist/collection/helpers/common/test/wait-for-component-did-render.test.js +67 -0
  162. package/dist/collection/helpers/slimmers/element-appender/element-appender-slimmer.js +27 -0
  163. package/dist/collection/helpers/slimmers/element-appender/test/element-appender-slimmer.test.js +50 -0
  164. package/dist/collection/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.js +14 -3
  165. package/dist/collection/helpers/slimmers/mutation-observer/data-tab-index-value-mapper.js +80 -0
  166. package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +55 -3
  167. package/dist/collection/helpers/slimmers/mutation-observer/test/data-tab-index-value-mapper.test.js +120 -0
  168. package/dist/collection/helpers/slimmers/position-calculation/base-position-calculation-strategy.js +123 -9
  169. package/dist/collection/helpers/slimmers/position-calculation/position-calculation-controller.js +14 -4
  170. package/dist/collection/helpers/slimmers/position-calculation/screen-position-calculation-strategy.js +13 -4
  171. package/dist/collection/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.js +7 -6
  172. package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +162 -7
  173. package/dist/collection/helpers/translation/locales/en.js +15 -0
  174. package/dist/collection/helpers/translation/tests/internal-translation-controller.test.js +15 -0
  175. package/dist/collection/helpers/ui/test/element-appender.test.js +7 -5
  176. package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +1 -1
  177. package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +10 -0
  178. package/dist/collection/polyfill/d3/d3-array-polyfill.js +89 -0
  179. package/dist/collection/polyfill/d3/d3-axis-polyfill.js +195 -0
  180. package/dist/collection/polyfill/d3/d3-scale-polyfill.js +582 -0
  181. package/dist/collection/polyfill/d3/d3-selection-polyfill.js +274 -0
  182. package/dist/collection/polyfill/d3/d3-shape-polyfill.js +252 -0
  183. package/dist/collection/polyfill/d3/d3-time-format-polyfill.js +207 -0
  184. package/dist/collection/polyfill/d3/d3-time-polyfill.js +99 -0
  185. package/dist/collection/polyfill/d3/index.js +31 -0
  186. package/dist/collection/polyfill/d3/test/d3-array-polyfill.test.js +72 -0
  187. package/dist/collection/polyfill/d3/test/d3-axis-polyfill.test.js +171 -0
  188. package/dist/collection/polyfill/d3/test/d3-integration.test.js +137 -0
  189. package/dist/collection/polyfill/d3/test/d3-scale-polyfill.test.js +382 -0
  190. package/dist/collection/polyfill/d3/test/d3-selection-polyfill.test.js +239 -0
  191. package/dist/collection/polyfill/d3/test/d3-shape-polyfill.test.js +225 -0
  192. package/dist/collection/polyfill/d3/test/d3-time-format-polyfill.test.js +162 -0
  193. package/dist/collection/polyfill/d3/test/d3-time-polyfill.test.js +76 -0
  194. package/dist/collection/polyfill/d3/test/index.test.js +78 -0
  195. package/dist/collection/polyfill/libphonenumber/as-you-type.js +405 -0
  196. package/dist/collection/polyfill/libphonenumber/format-helpers.js +186 -0
  197. package/dist/collection/polyfill/libphonenumber/index.js +22 -0
  198. package/dist/collection/polyfill/libphonenumber/metadata.js +150 -0
  199. package/dist/collection/polyfill/libphonenumber/metadata.json.js +3900 -0
  200. package/dist/collection/polyfill/libphonenumber/parse-phone-number.js +127 -0
  201. package/dist/collection/polyfill/libphonenumber/phone-number.js +38 -0
  202. package/dist/collection/polyfill/libphonenumber/test/as-you-type.test.js +309 -0
  203. package/dist/collection/polyfill/libphonenumber/test/format-helpers.test.js +192 -0
  204. package/dist/collection/polyfill/libphonenumber/test/index.test.js +16 -0
  205. package/dist/collection/polyfill/libphonenumber/test/metadata.test.js +196 -0
  206. package/dist/collection/polyfill/libphonenumber/test/parse-phone-number.test.js +218 -0
  207. package/dist/collection/polyfill/libphonenumber/test/phone-number.test.js +56 -0
  208. package/dist/collection/polyfill/libphonenumber/types.js +23 -0
  209. package/dist/collection/utils/e2e-utils.js +6 -0
  210. package/dist/esm/{app-globals-c0676920.js → app-globals-0b3b7111.js} +7 -7
  211. package/dist/esm/aria-attributes-value-mapper-2c632641.js +141 -0
  212. package/dist/esm/{child-nodes-event-prevent-slimmer-649b9d30.js → child-nodes-event-prevent-slimmer-331312b8.js} +1 -1
  213. package/dist/esm/{code-block-b6247a45.js → code-block-2408a812.js} +1 -1
  214. package/dist/esm/{component-value-history-controller-slimmer.abstract-2bb8533d.js → component-value-history-controller-slimmer.abstract-ac40820f.js} +3 -3
  215. package/dist/esm/{date-required-rule-e771e7d9.js → date-required-rule-09d5aa16.js} +1 -1
  216. package/dist/esm/{design-token-4aee1c56.js → design-token-7dec1eab.js} +2 -2
  217. package/dist/esm/{dto-renderer-manager-6fd22ab7.js → dto-renderer-manager-d413de1e.js} +2 -2
  218. package/dist/esm/{element-appender-slimmer-e4713a72.js → element-appender-slimmer-5d573612.js} +179 -20
  219. package/dist/esm/{form-field-controller-slimmer-5817d14d.js → form-field-controller-slimmer-e1a5a884.js} +1 -1
  220. package/dist/esm/{image-annotation-action-6701b4c9.js → image-annotation-action-54936eaa.js} +2 -2
  221. package/dist/esm/index.js +13 -13
  222. package/dist/esm/{inject-keyboard-manager-78730062.js → inject-keyboard-manager-9339bba8.js} +1 -1
  223. package/dist/esm/{internal-translation-controller-911515f9.js → internal-translation-controller-113a6288.js} +15 -0
  224. package/dist/esm/{keyboard-manager-38934f94.js → keyboard-manager-f9bfa678.js} +1 -1
  225. package/dist/esm/{keyboard-manager-slimmer-9984d922.js → keyboard-manager-slimmer-c8898843.js} +1 -1
  226. package/dist/esm/legend-input-processor-122008c5.js +2116 -0
  227. package/dist/esm/loader.js +9 -9
  228. package/dist/esm/{month-view-generator-eaf9029c.js → month-view-generator-160a9feb.js} +1 -1
  229. package/dist/esm/{public-rules-25cc3a39.js → public-rules-41561e6e.js} +7 -7
  230. package/dist/esm/{range-663f44dc.js → range-a5d78e69.js} +1 -1
  231. package/dist/esm/{responsive-format-facade-7a071174.js → responsive-format-facade-2a36c54a.js} +2 -2
  232. package/dist/esm/{rich-text-editor-required-rule-a238b862.js → rich-text-editor-required-rule-b09039da.js} +1 -1
  233. package/dist/esm/{string-format-strategy.abstract-713fba36.js → string-format-strategy.abstract-944f759b.js} +1 -1
  234. package/dist/esm/{string-input-formatter-slimmer-5b413ff9.js → string-input-formatter-slimmer-2508d88b.js} +1 -1
  235. package/dist/esm/{string-mask-strategy-6beaf664.js → string-mask-strategy-f9e252a2.js} +2 -2
  236. package/dist/esm/{style-formatter-3d06b72d.js → style-formatter-6db1e890.js} +2 -2
  237. package/dist/esm/{time-required-rule-e4138a76.js → time-required-rule-c7cfb257.js} +1 -1
  238. package/dist/esm/{token-extension-e33fd151.js → token-extension-25df8dbb.js} +102 -81
  239. package/dist/esm/{translation-slimmer-2394b173.js → translation-slimmer-9f0339aa.js} +1 -1
  240. package/dist/esm/{type-guard-f50e34d6.js → type-guard-af324dcd.js} +36 -2
  241. package/dist/esm/{valid-credit-card-number-rule-22ce81db.js → valid-credit-card-number-rule-099dba7d.js} +1 -1
  242. package/dist/esm/vega-accordion.entry.js +7 -7
  243. package/dist/esm/vega-app-header-button.entry.js +38 -145
  244. package/dist/esm/vega-banner.entry.js +1 -1
  245. package/dist/esm/vega-bar-chart.entry.js +2 -2
  246. package/dist/esm/vega-box.entry.js +6 -6
  247. package/dist/esm/vega-breadcrumb.entry.js +2 -2
  248. package/dist/esm/vega-button-circle.entry.js +23 -8
  249. package/dist/esm/vega-button-group_2.entry.js +2 -2
  250. package/dist/esm/vega-button-link.entry.js +18 -2
  251. package/dist/esm/vega-button.entry.js +5 -5
  252. package/dist/esm/vega-calendar_4.entry.js +7 -7
  253. package/dist/esm/vega-card.entry.js +5 -5
  254. package/dist/esm/vega-carousel.entry.js +4 -4
  255. package/dist/esm/vega-checkbox_2.entry.js +4 -4
  256. package/dist/esm/vega-chip.entry.js +6 -6
  257. package/dist/esm/vega-code-block.entry.js +10 -10
  258. package/dist/esm/vega-color-picker.entry.js +2 -2
  259. package/dist/esm/vega-combo-box.entry.js +7 -7
  260. package/dist/esm/vega-date-picker_2.entry.js +129 -26
  261. package/dist/esm/vega-dialog_2.entry.js +6 -6
  262. package/dist/esm/vega-divider.entry.js +5 -5
  263. package/dist/esm/vega-dropdown_5.entry.js +34 -10
  264. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  265. package/dist/esm/vega-file-uploader.entry.js +3 -3
  266. package/dist/esm/vega-flag-icon.entry.js +5 -5
  267. package/dist/esm/vega-flex.entry.js +6 -6
  268. package/dist/esm/vega-font.entry.js +5 -5
  269. package/dist/esm/vega-form.entry.js +5 -5
  270. package/dist/esm/vega-grid.entry.js +5 -5
  271. package/dist/esm/vega-icon.entry.js +5 -5
  272. package/dist/esm/vega-image-uploader.entry.js +7 -7
  273. package/dist/esm/vega-input-credit-card.entry.js +8 -8
  274. package/dist/esm/vega-input-numeric.entry.js +7 -7
  275. package/dist/esm/vega-input-passcode.entry.js +39 -9
  276. package/dist/esm/vega-input-phone-number.entry.js +4757 -5589
  277. package/dist/esm/vega-input-range.entry.js +5 -5
  278. package/dist/esm/vega-input-select.entry.js +7 -7
  279. package/dist/esm/vega-input.entry.js +220 -125
  280. package/dist/esm/vega-left-nav_5.entry.js +7 -8
  281. package/dist/esm/vega-line-chart.entry.js +311 -9
  282. package/dist/esm/vega-loader-wrapper_2.entry.js +4 -4
  283. package/dist/esm/vega-pagination-page-selector-mobile.entry.js +2 -2
  284. package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +2 -2
  285. package/dist/esm/vega-pagination.entry.js +6 -6
  286. package/dist/esm/vega-pie-chart.entry.js +5 -88
  287. package/dist/esm/vega-popover_2.entry.js +9 -9
  288. package/dist/esm/vega-progress-tracker_2.entry.js +4 -4
  289. package/dist/esm/vega-radio_2.entry.js +7 -7
  290. package/dist/esm/vega-rich-text-content.entry.js +26 -6
  291. package/dist/esm/vega-rich-text-editor_4.entry.js +130 -32
  292. package/dist/esm/vega-selection-chip_2.entry.js +6 -6
  293. package/dist/esm/vega-selection-tile_2.entry.js +4 -4
  294. package/dist/esm/vega-sidenav_3.entry.js +4 -4
  295. package/dist/esm/vega-signature-capture.entry.js +7 -7
  296. package/dist/esm/vega-stepper.entry.js +4 -4
  297. package/dist/esm/vega-tab-group_2.entry.js +2 -2
  298. package/dist/esm/vega-table_11.entry.js +6 -6
  299. package/dist/esm/vega-textarea.entry.js +4 -4
  300. package/dist/esm/vega-time-picker_2.entry.js +11 -11
  301. package/dist/esm/vega-toggle-switch.entry.js +2 -2
  302. package/dist/esm/vega-tooltip_2.entry.js +8 -8
  303. package/dist/esm/vega.js +9 -9
  304. package/dist/esm/y-axis-input-processor-c7e05353.js +826 -0
  305. package/dist/sri/vega-sri-manifest.json +317 -313
  306. package/dist/types/components/vega-app-header-button/types.d.ts +18 -0
  307. package/dist/types/components/vega-app-header-button/vega-app-header-button.d.ts +8 -1
  308. package/dist/types/components/vega-button-circle/vega-button-circle.d.ts +2 -0
  309. package/dist/types/components/vega-button-link/vega-button-link.d.ts +2 -0
  310. package/dist/types/components/vega-date-picker/slimmers/controllers/vega-date-picker-calendar-open-state-controller.d.ts +21 -0
  311. package/dist/types/components/vega-date-picker/types.d.ts +14 -0
  312. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-selection-controller.d.ts +1 -0
  313. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-renderer.d.ts +7 -0
  314. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.d.ts +3 -0
  315. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.d.ts +9 -1
  316. package/dist/types/components/vega-dropdown/slimmers/controllers/vega-dropdown-appender-controller.d.ts +11 -0
  317. package/dist/types/components/vega-input/slimmers/controllers/vega-input-render-mode-controller.d.ts +0 -1
  318. package/dist/types/components/vega-input/slimmers/renderers/vega-input-input-renderer.d.ts +0 -1
  319. package/dist/types/components/vega-input/vega-input.d.ts +4 -0
  320. package/dist/types/components/vega-input-passcode/slimmers/renderers/vega-input-passcode-renderer.d.ts +14 -0
  321. package/dist/types/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.d.ts +6 -0
  322. package/dist/types/components/vega-rich-text-editor/extensions/base-extension-renderer.d.ts +9 -1
  323. package/dist/types/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.d.ts +9 -1
  324. package/dist/types/components/vega-rich-text-editor/extensions/functions/function-extension.d.ts +0 -7
  325. package/dist/types/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.d.ts +5 -10
  326. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-extension.d.ts +1 -5
  327. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.d.ts +3 -8
  328. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.d.ts +5 -9
  329. package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.d.ts +26 -0
  330. package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.test.d.ts +1 -0
  331. package/dist/types/components/vega-rich-text-editor/interface.d.ts +4 -0
  332. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/insert-image-controller.d.ts +7 -1
  333. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.d.ts +30 -2
  334. package/dist/types/components/vega-rich-text-editor/test/extensions/extension-test-utils.d.ts +21 -0
  335. package/dist/types/components.d.ts +22 -2
  336. package/dist/types/helpers/calendar/utils.d.ts +17 -0
  337. package/dist/types/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.d.ts +1 -0
  338. package/dist/types/helpers/common/test/wait-for-component-did-render.test.d.ts +1 -0
  339. package/dist/types/helpers/slimmers/element-appender/element-appender-slimmer.d.ts +12 -0
  340. package/dist/types/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.d.ts +2 -1
  341. package/dist/types/helpers/slimmers/mutation-observer/data-tab-index-value-mapper.d.ts +35 -0
  342. package/dist/types/helpers/slimmers/mutation-observer/test/data-tab-index-value-mapper.test.d.ts +1 -0
  343. package/dist/types/helpers/slimmers/position-calculation/base-position-calculation-strategy.d.ts +60 -3
  344. package/dist/types/helpers/slimmers/position-calculation/screen-position-calculation-strategy.d.ts +3 -2
  345. package/dist/types/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.d.ts +1 -1
  346. package/dist/types/helpers/translation/interface.d.ts +15 -0
  347. package/dist/types/polyfill/d3/d3-array-polyfill.d.ts +48 -0
  348. package/dist/types/polyfill/d3/d3-axis-polyfill.d.ts +53 -0
  349. package/dist/types/polyfill/d3/d3-scale-polyfill.d.ts +42 -0
  350. package/dist/types/polyfill/d3/d3-selection-polyfill.d.ts +173 -0
  351. package/dist/types/polyfill/d3/d3-shape-polyfill.d.ts +129 -0
  352. package/dist/types/polyfill/d3/d3-time-format-polyfill.d.ts +28 -0
  353. package/dist/types/polyfill/d3/d3-time-polyfill.d.ts +68 -0
  354. package/dist/types/polyfill/d3/index.d.ts +27 -0
  355. package/dist/types/polyfill/d3/test/d3-array-polyfill.test.d.ts +1 -0
  356. package/dist/types/polyfill/d3/test/d3-axis-polyfill.test.d.ts +1 -0
  357. package/dist/types/polyfill/d3/test/d3-integration.test.d.ts +1 -0
  358. package/dist/types/polyfill/d3/test/d3-scale-polyfill.test.d.ts +1 -0
  359. package/dist/types/polyfill/d3/test/d3-selection-polyfill.test.d.ts +1 -0
  360. package/dist/types/polyfill/d3/test/d3-shape-polyfill.test.d.ts +1 -0
  361. package/dist/types/polyfill/d3/test/d3-time-format-polyfill.test.d.ts +1 -0
  362. package/dist/types/polyfill/d3/test/d3-time-polyfill.test.d.ts +1 -0
  363. package/dist/types/polyfill/d3/test/index.test.d.ts +1 -0
  364. package/dist/types/polyfill/libphonenumber/as-you-type.d.ts +154 -0
  365. package/dist/types/polyfill/libphonenumber/format-helpers.d.ts +64 -0
  366. package/dist/types/polyfill/libphonenumber/index.d.ts +22 -0
  367. package/dist/types/polyfill/libphonenumber/metadata.d.ts +45 -0
  368. package/dist/types/polyfill/libphonenumber/metadata.json.d.ts +470 -0
  369. package/dist/types/polyfill/libphonenumber/parse-phone-number.d.ts +26 -0
  370. package/dist/types/polyfill/libphonenumber/phone-number.d.ts +24 -0
  371. package/dist/types/polyfill/libphonenumber/test/as-you-type.test.d.ts +1 -0
  372. package/dist/types/polyfill/libphonenumber/test/format-helpers.test.d.ts +1 -0
  373. package/dist/types/polyfill/libphonenumber/test/index.test.d.ts +1 -0
  374. package/dist/types/polyfill/libphonenumber/test/metadata.test.d.ts +1 -0
  375. package/dist/types/polyfill/libphonenumber/test/parse-phone-number.test.d.ts +1 -0
  376. package/dist/types/polyfill/libphonenumber/test/phone-number.test.d.ts +1 -0
  377. package/dist/types/polyfill/libphonenumber/types.d.ts +77 -0
  378. package/dist/types/types/components.type.d.ts +2 -0
  379. package/dist/types/types/flag.type.d.ts +255 -4
  380. package/dist/types/types/ui.type.d.ts +3 -2
  381. package/dist/types/types/vega-chart.d.ts +10 -11
  382. package/dist/types/utils/e2e-utils.d.ts +2 -0
  383. package/dist/vega/index.esm.js +1 -1
  384. package/dist/vega/{p-d8fadcdc.entry.js → p-0037068c.entry.js} +1 -1
  385. package/dist/vega/{p-4bffdb28.js → p-051bbce6.js} +1 -1
  386. package/dist/vega/{p-02a7d60c.entry.js → p-0a3a285b.entry.js} +1 -1
  387. package/dist/vega/{p-1a3236e7.entry.js → p-0ac9a732.entry.js} +1 -1
  388. package/dist/vega/{p-2b49686d.entry.js → p-1033e4c4.entry.js} +1 -1
  389. package/dist/vega/{p-0e679d8c.js → p-10e51081.js} +1 -1
  390. package/dist/vega/p-15335b69.entry.js +1 -0
  391. package/dist/vega/{p-b366deff.entry.js → p-19270396.entry.js} +1 -1
  392. package/dist/vega/{p-10734a00.js → p-1a51bf6f.js} +1 -1
  393. package/dist/vega/{p-2d69632d.js → p-1a9b361b.js} +1 -1
  394. package/dist/vega/p-1ccba615.entry.js +1 -0
  395. package/dist/vega/{p-6dcdb580.entry.js → p-1deedff2.entry.js} +1 -1
  396. package/dist/vega/{p-6d60b66a.entry.js → p-22f3d35c.entry.js} +1 -1
  397. package/dist/vega/{p-3d8122ab.entry.js → p-23427f6a.entry.js} +1 -1
  398. package/dist/vega/p-2466316a.js +1 -0
  399. package/dist/vega/p-27b0af38.entry.js +1 -0
  400. package/dist/vega/{p-bb5e0192.entry.js → p-2c2193f2.entry.js} +1 -1
  401. package/dist/vega/{p-dd3a94f4.entry.js → p-3237be8b.entry.js} +1 -1
  402. package/dist/vega/{p-94a77fbe.entry.js → p-36a09524.entry.js} +1 -1
  403. package/dist/vega/{p-7181861a.js → p-38e850c3.js} +1 -1
  404. package/dist/vega/{p-e2af0e24.entry.js → p-3b9fc697.entry.js} +1 -1
  405. package/dist/vega/{p-3244c605.entry.js → p-41d14339.entry.js} +1 -1
  406. package/dist/vega/{p-a0b66c25.js → p-4c060ba9.js} +1 -1
  407. package/dist/vega/p-4d4bf82a.entry.js +1 -0
  408. package/dist/vega/{p-415ffa35.js → p-4d7d5583.js} +1 -1
  409. package/dist/vega/{p-2a10e2e5.js → p-4f146dae.js} +1 -1
  410. package/dist/vega/p-5f377954.js +1 -1
  411. package/dist/vega/{p-b256b7a4.js → p-600f7d6c.js} +1 -1
  412. package/dist/vega/{p-4ea30592.js → p-6188e783.js} +1 -1
  413. package/dist/vega/p-638d30a5.entry.js +1 -0
  414. package/dist/vega/{p-a7a8a4eb.entry.js → p-67b0ccdc.entry.js} +1 -1
  415. package/dist/vega/p-68846f0d.js +1 -0
  416. package/dist/vega/{p-d7a78c5e.entry.js → p-70444f6f.entry.js} +1 -1
  417. package/dist/vega/{p-e632475e.js → p-7127f966.js} +1 -1
  418. package/dist/vega/{p-49845a91.js → p-718c74ba.js} +1 -1
  419. package/dist/vega/p-77167587.entry.js +1 -0
  420. package/dist/vega/p-78ecfea0.entry.js +1 -0
  421. package/dist/vega/{p-b201f379.js → p-7cde8489.js} +1 -1
  422. package/dist/vega/p-8e34b266.js +1 -0
  423. package/dist/vega/p-9466619f.entry.js +1 -0
  424. package/dist/vega/p-9863e7a1.entry.js +1 -0
  425. package/dist/vega/p-999950d1.js +1 -0
  426. package/dist/vega/{p-9339c6c4.js → p-9a3a5b9e.js} +1 -1
  427. package/dist/vega/{p-b136ebba.entry.js → p-9adfcd47.entry.js} +1 -1
  428. package/dist/vega/{p-d555f677.entry.js → p-9e36f7ff.entry.js} +1 -1
  429. package/dist/vega/{p-8dbdd609.entry.js → p-9f9d9a53.entry.js} +1 -1
  430. package/dist/vega/{p-7958614a.entry.js → p-9feaac4b.entry.js} +1 -1
  431. package/dist/vega/{p-ca5898dc.entry.js → p-a0e69236.entry.js} +1 -1
  432. package/dist/vega/{p-95528b47.js → p-a17312a6.js} +1 -1
  433. package/dist/vega/p-a46e977b.entry.js +1 -0
  434. package/dist/vega/p-a79fdf2f.js +1 -0
  435. package/dist/vega/p-a800bf6d.js +1 -0
  436. package/dist/vega/{p-c29068fb.entry.js → p-aaf9b39f.entry.js} +1 -1
  437. package/dist/vega/{p-2e91295d.entry.js → p-acbb96b3.entry.js} +1 -1
  438. package/dist/vega/p-af2110fc.entry.js +1 -0
  439. package/dist/vega/{p-f14a5eae.entry.js → p-b35bb4a2.entry.js} +1 -1
  440. package/dist/vega/p-b8c10187.js +1 -0
  441. package/dist/vega/p-bdb5180c.js +1 -0
  442. package/dist/vega/{p-01d58eb8.entry.js → p-c086529c.entry.js} +1 -1
  443. package/dist/vega/{p-154f9cf7.entry.js → p-c61bcd92.entry.js} +1 -1
  444. package/dist/vega/{p-bebfbe95.entry.js → p-c7a9960f.entry.js} +1 -1
  445. package/dist/vega/{p-81b044b9.js → p-c7b9b7c2.js} +1 -1
  446. package/dist/vega/{p-f2b0b58a.js → p-c857e6e2.js} +1 -1
  447. package/dist/vega/{p-89f2e16d.entry.js → p-c871619c.entry.js} +1 -1
  448. package/dist/vega/{p-1f3cd061.entry.js → p-cbeb47be.entry.js} +1 -1
  449. package/dist/vega/{p-a786259a.js → p-cf6bfac7.js} +1 -1
  450. package/dist/vega/{p-57927b10.entry.js → p-d07f5d5a.entry.js} +1 -1
  451. package/dist/vega/{p-033c31d8.entry.js → p-d0975995.entry.js} +1 -1
  452. package/dist/vega/{p-d6dbbe61.entry.js → p-d2ee5711.entry.js} +1 -1
  453. package/dist/vega/{p-8950987b.entry.js → p-d2fc470e.entry.js} +1 -1
  454. package/dist/vega/{p-a560d8c5.entry.js → p-d70e1b75.entry.js} +1 -1
  455. package/dist/vega/p-d8180e42.entry.js +1 -0
  456. package/dist/vega/{p-3afc025e.entry.js → p-da0fd3dc.entry.js} +1 -1
  457. package/dist/vega/{p-087ea379.entry.js → p-da552ddf.entry.js} +1 -1
  458. package/dist/vega/{p-eda988d5.entry.js → p-ddce3e0e.entry.js} +1 -1
  459. package/dist/vega/{p-aa1174dc.js → p-dfb12762.js} +1 -1
  460. package/dist/vega/{p-8b153acd.entry.js → p-e0fb1f60.entry.js} +1 -1
  461. package/dist/vega/{p-249df6d2.entry.js → p-e1c017d1.entry.js} +1 -1
  462. package/dist/vega/p-e4917e76.js +1 -0
  463. package/dist/vega/{p-fd7ddd64.entry.js → p-e4c99b72.entry.js} +1 -1
  464. package/dist/vega/{p-9a137bab.entry.js → p-e841c1fe.entry.js} +1 -1
  465. package/dist/vega/{p-f05b8f76.entry.js → p-ea96b0f9.entry.js} +1 -1
  466. package/dist/vega/{p-76181a70.entry.js → p-eab9d999.entry.js} +1 -1
  467. package/dist/vega/{p-2cc9d126.entry.js → p-ed9ad4fd.entry.js} +1 -1
  468. package/dist/vega/{p-2ba78982.entry.js → p-ef603656.entry.js} +1 -1
  469. package/dist/vega/p-f5fcd13e.entry.js +1 -0
  470. package/dist/vega/{p-6d219c44.entry.js → p-f65cb0b6.entry.js} +1 -1
  471. package/dist/vega/p-faa9a3bd.js +1 -0
  472. package/dist/vega/{p-a8792e3d.js → p-fc049028.js} +1 -1
  473. package/dist/vega/p-ff287001.entry.js +1 -0
  474. package/dist/vega/{p-32183637.entry.js → p-ffb3e479.entry.js} +1 -1
  475. package/dist/vega/p-ffd080db.js +1 -0
  476. package/dist/vega/vega.esm.js +1 -1
  477. package/package.json +2 -6
  478. package/dist/cjs/legend-input-processor-27c65353.js +0 -4759
  479. package/dist/cjs/y-axis-input-processor-9fbfd5e7.js +0 -2302
  480. package/dist/esm/legend-input-processor-5ecae3a7.js +0 -4742
  481. package/dist/esm/y-axis-input-processor-bc54314a.js +0 -2290
  482. package/dist/vega/p-179aad4f.entry.js +0 -1
  483. package/dist/vega/p-1f5e35dc.entry.js +0 -1
  484. package/dist/vega/p-28ad1864.entry.js +0 -1
  485. package/dist/vega/p-32033e7a.js +0 -1
  486. package/dist/vega/p-32faa460.entry.js +0 -1
  487. package/dist/vega/p-464559e3.js +0 -1
  488. package/dist/vega/p-46b077d9.js +0 -1
  489. package/dist/vega/p-4e017458.entry.js +0 -1
  490. package/dist/vega/p-4e4a0228.entry.js +0 -1
  491. package/dist/vega/p-5831d6d3.entry.js +0 -1
  492. package/dist/vega/p-644f701a.js +0 -1
  493. package/dist/vega/p-6a62e476.entry.js +0 -1
  494. package/dist/vega/p-6b6f0fb4.js +0 -1
  495. package/dist/vega/p-a13a73fa.entry.js +0 -1
  496. package/dist/vega/p-b597393b.entry.js +0 -1
  497. package/dist/vega/p-be23bef2.js +0 -1
  498. package/dist/vega/p-c1d13eec.entry.js +0 -1
  499. package/dist/vega/p-c3d2f316.js +0 -1
  500. package/dist/vega/p-dad3ba5f.js +0 -1
  501. package/dist/vega/p-e1431c14.entry.js +0 -1
  502. package/dist/vega/p-e89e3ede.entry.js +0 -1
  503. package/dist/vega/p-f3d0f2dc.js +0 -1
  504. package/dist/vega/p-f5bafc45.entry.js +0 -1
  505. package/dist/vega/p-fc1fa345.js +0 -1
  506. /package/dist/cjs/{feature-flag-controller-04cb1e69.js → feature-flag-controller-9129ef52.js} +0 -0
  507. /package/dist/esm/{feature-flag-controller-09ea7e87.js → feature-flag-controller-30f7b625.js} +0 -0
  508. /package/dist/vega/{p-07cb0243.js → p-18e8d9b7.js} +0 -0
@@ -0,0 +1,2126 @@
1
+ 'use strict';
2
+
3
+ const array = require('./array-249289f2.js');
4
+ const typography = require('./typography-4560e7f1.js');
5
+ const pixel = require('./pixel-98f2a10c.js');
6
+
7
+ /** The GraphContextFactory class provides a method to create and return either a HTMLCanvasElement or SVGElement based on the specified mode and container element. */
8
+ class GraphContextFactory {
9
+ /**
10
+ * This function returns either a HTMLCanvasElement or an SVGElement based on the specified mode and container.
11
+ *
12
+ * @param {ChartGraphMode} mode - A string that specifies the mode of the chart graph. It can be either 'canvas' or 'svg'.
13
+ * @param {HTMLElement} container - HTMLElement - the HTML element that will contain the chart/graph.
14
+ * @returns {SVGElement | HTMLCanvasElement} either a HTMLCanvasElement or an SVGElement depending on the value of the `mode` parameter.
15
+ */
16
+ static get(mode, container) {
17
+ if (mode === 'canvas') {
18
+ const canvas = container.querySelector('canvas');
19
+ let context;
20
+ if (canvas) {
21
+ context = canvas;
22
+ }
23
+ else {
24
+ // eslint-disable-next-line no-restricted-globals
25
+ context = document.createElement('canvas');
26
+ context = container.appendChild(context);
27
+ }
28
+ return context;
29
+ }
30
+ else {
31
+ const svg = container.querySelector('svg');
32
+ let context;
33
+ if (svg) {
34
+ context = svg;
35
+ }
36
+ else {
37
+ // eslint-disable-next-line no-restricted-globals
38
+ context = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
39
+ context = container.appendChild(context);
40
+ }
41
+ return context;
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * defining an abstract class called `BaseRenderer` that takes a generic type `T` which
48
+ * can be either an `SVGElement` or a `HTMLCanvasElement`
49
+ */
50
+ class BaseRenderer {
51
+ /**
52
+ * This is a constructor function that takes a parameter of type T and sets it as a protected property called "context".
53
+ *
54
+ * @param {unknown} context - The "context" parameter is a protected property of a class constructor that is
55
+ * of type "T". It is used to store a reference to an object or data that is required by the class
56
+ * methods to perform their tasks
57
+ */
58
+ constructor(context) {
59
+ this.context = context;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * D3 Selection Polyfill - A lightweight DOM selection and manipulation utility.
65
+ *
66
+ * This is a drop-in replacement for d3-selection, implementing only the methods
67
+ * used in the Vega chart rendering system.
68
+ *
69
+ * Supported methods: select, selectAll, append, attr, property, text, datum,
70
+ * call, node, nodes, each, remove, clone, transition, duration.
71
+ *
72
+ * @see VD-5022 - [Zero Dependencies] remove d3 dependency
73
+ */
74
+ /**
75
+ * A lightweight selection class mimicking d3-selection's chainable API.
76
+ * Wraps an array of DOM elements and provides attribute/property/child manipulation.
77
+ */
78
+ class D3SelectionPolyfill {
79
+ /**
80
+ * @param {Element[]} elements - Array of DOM elements to wrap.
81
+ * @param {*} [datum] - Optional bound datum for the selection.
82
+ */
83
+ constructor(elements, datum) {
84
+ this._groups = elements;
85
+ this._datum = datum;
86
+ }
87
+ /**
88
+ * Selects the first descendant element matching the selector.
89
+ *
90
+ * @template DescElement
91
+ * @template Datum
92
+ * @template GElement
93
+ * @param {string} selector - CSS selector string.
94
+ * @returns {D3SelectionPolyfill<DescElement, Datum, GElement, Datum>} A new selection wrapping the matched element.
95
+ */
96
+ select(selector) {
97
+ const el = this._groups[0];
98
+ if (!el) {
99
+ return new D3SelectionPolyfill([]);
100
+ }
101
+ const found = el.querySelector(selector);
102
+ return new D3SelectionPolyfill(found ? [found] : []);
103
+ }
104
+ /**
105
+ * Selects all descendant elements matching the selector.
106
+ *
107
+ * @template DescElement
108
+ * @template NewDatum
109
+ * @template GElement
110
+ * @template Datum
111
+ * @param {string} selector - CSS selector string.
112
+ * @returns {D3SelectionPolyfill<DescElement, NewDatum, GElement, Datum>} A new selection wrapping all matched elements.
113
+ */
114
+ selectAll(selector) {
115
+ const el = this._groups[0];
116
+ if (!el) {
117
+ return new D3SelectionPolyfill([]);
118
+ }
119
+ const found = Array.from(el.querySelectorAll(selector));
120
+ return new D3SelectionPolyfill(found);
121
+ }
122
+ /**
123
+ * Appends a new child element to each element in the selection.
124
+ * Accepts either a tag name string or a factory function that returns a DOM element.
125
+ *
126
+ * @template ChildElement
127
+ * @template Datum
128
+ * @template GElement
129
+ * @param {string | Function} tagOrFactory - Tag name (e.g. 'g', 'path') or a factory function.
130
+ * @returns {D3SelectionPolyfill<ChildElement, Datum, GElement, Datum>} A new selection wrapping the appended elements.
131
+ */
132
+ append(tagOrFactory) {
133
+ const results = [];
134
+ for (const parent of this._groups) {
135
+ let child;
136
+ if (typeof tagOrFactory === 'function') {
137
+ child = tagOrFactory();
138
+ }
139
+ else {
140
+ child = parent.ownerDocument.createElementNS('http://www.w3.org/2000/svg', tagOrFactory);
141
+ }
142
+ parent.appendChild(child);
143
+ results.push(child);
144
+ }
145
+ return new D3SelectionPolyfill(results, this._datum);
146
+ }
147
+ /**
148
+ * Sets or gets an attribute on each element.
149
+ * If value is a function, it is called with the bound datum.
150
+ *
151
+ * @param {...*} args - Attribute name, and optionally a value or function returning a value.
152
+ * @returns {any} This selection for chaining, or the attribute value if getting.
153
+ */
154
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
+ attr(...args) {
156
+ const name = args[0];
157
+ if (args.length === 1) {
158
+ const el = this._groups[0];
159
+ return el ? el.getAttribute(name) : null;
160
+ }
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ const value = args[1];
163
+ for (let i = 0; i < this._groups.length; i++) {
164
+ const el = this._groups[i];
165
+ const resolvedValue = typeof value === 'function' ? value.call(el, this._datum, i, this._groups) : value;
166
+ if (resolvedValue === null || resolvedValue === undefined) {
167
+ el.removeAttribute(name);
168
+ }
169
+ else {
170
+ el.setAttribute(name, String(resolvedValue));
171
+ }
172
+ }
173
+ return this;
174
+ }
175
+ /**
176
+ * Sets a JavaScript property on each element.
177
+ *
178
+ * @param {string} name - Property name.
179
+ * @param {unknown} value - Property value.
180
+ * @returns {this} This selection for chaining.
181
+ */
182
+ property(name, value) {
183
+ for (const el of this._groups) {
184
+ el[name] = value;
185
+ }
186
+ return this;
187
+ }
188
+ /**
189
+ * Sets the text content of each element.
190
+ *
191
+ * @param {string} value - Text content string.
192
+ * @returns {this} This selection for chaining.
193
+ */
194
+ text(value) {
195
+ for (const el of this._groups) {
196
+ el.textContent = value;
197
+ }
198
+ return this;
199
+ }
200
+ /**
201
+ * Binds a datum to the selection.
202
+ *
203
+ * @template NewDatum
204
+ * @template GElement
205
+ * @template PElement
206
+ * @template PDatum
207
+ * @param {*} data - The datum to bind.
208
+ * @returns {D3SelectionPolyfill<GElement, NewDatum, PElement, PDatum>} A new selection with the bound datum.
209
+ */
210
+ datum(data) {
211
+ return new D3SelectionPolyfill(this._groups, data);
212
+ }
213
+ /**
214
+ * Calls a function with this selection as argument. Used for grouping operations.
215
+ *
216
+ * @param {Function} fn - Function to call.
217
+ * @param {...*} args - Additional arguments.
218
+ * @returns {this} This selection for chaining.
219
+ */
220
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
221
+ call(fn, ...args) {
222
+ fn(this, ...args);
223
+ return this;
224
+ }
225
+ /**
226
+ * Returns the first DOM node in the selection, or null.
227
+ *
228
+ * @template GElement
229
+ * @returns {GElement | null} The first element or null.
230
+ */
231
+ node() {
232
+ return this._groups[0] || null;
233
+ }
234
+ /**
235
+ * Returns all DOM nodes in the selection as an array.
236
+ *
237
+ * @template GElement
238
+ * @returns {GElement[]} Array of elements.
239
+ */
240
+ nodes() {
241
+ return [...this._groups];
242
+ }
243
+ /**
244
+ * Iterates over each element, calling the provided function.
245
+ * The function is called with `this` set to the current DOM element.
246
+ *
247
+ * @param {Function} fn - Callback function.
248
+ * @returns {this} This selection for chaining.
249
+ */
250
+ each(fn) {
251
+ for (let i = 0; i < this._groups.length; i++) {
252
+ fn.call(this._groups[i], this._datum, i, this._groups);
253
+ }
254
+ return this;
255
+ }
256
+ /**
257
+ * Removes all elements in the selection from the DOM.
258
+ *
259
+ * @returns {this} This selection for chaining.
260
+ */
261
+ remove() {
262
+ var _a;
263
+ for (const el of this._groups) {
264
+ (_a = el.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(el);
265
+ }
266
+ return this;
267
+ }
268
+ /**
269
+ * Clones each element in the selection (shallow clone) and inserts after the original.
270
+ *
271
+ * @template GElement
272
+ * @template Datum
273
+ * @template PElement
274
+ * @template PDatum
275
+ * @returns {D3SelectionPolyfill<GElement, Datum, PElement, PDatum>} A new selection wrapping the cloned elements.
276
+ */
277
+ clone() {
278
+ var _a;
279
+ const clones = [];
280
+ for (const el of this._groups) {
281
+ const cloned = el.cloneNode(false);
282
+ (_a = el.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(cloned, el.nextSibling);
283
+ clones.push(cloned);
284
+ }
285
+ return new D3SelectionPolyfill(clones, this._datum);
286
+ }
287
+ /**
288
+ * Creates a transition-like object. This is a simplified polyfill that
289
+ * applies attribute changes immediately (no actual animation), which is
290
+ * sufficient for Vega's usage of hover path swapping.
291
+ *
292
+ * @param {*} [_name] - Transition name (ignored in polyfill).
293
+ * @returns {this} This selection for chaining (acts as a no-op).
294
+ */
295
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
296
+ transition(_name) {
297
+ return this;
298
+ }
299
+ /**
300
+ * Sets the transition duration. No-op in this polyfill since
301
+ * transitions are applied immediately.
302
+ *
303
+ * @param {number} _ms - Duration in milliseconds (ignored).
304
+ * @returns {this} This selection for chaining.
305
+ */
306
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
307
+ duration(_ms) {
308
+ return this;
309
+ }
310
+ }
311
+ /**
312
+ * Selects a DOM element by wrapping it in a D3SelectionPolyfill.
313
+ * Mimics d3.select().
314
+ *
315
+ * @template GElement
316
+ * @param {Element | EventTarget} element - A DOM element or EventTarget to wrap.
317
+ * @returns {D3SelectionPolyfill<GElement>} A new D3SelectionPolyfill wrapping the element.
318
+ */
319
+ function select(element) {
320
+ return new D3SelectionPolyfill([element]);
321
+ }
322
+ /**
323
+ * Creates a detached SVG element (e.g., 'svg:text', 'svg:circle', 'svg:path').
324
+ * Mimics d3.create().
325
+ *
326
+ * @template GElement
327
+ * @param {string} qualifiedName - A qualified name like 'svg:text' or 'svg:circle'.
328
+ * @returns {D3SelectionPolyfill<GElement>} A new D3SelectionPolyfill wrapping the created element.
329
+ */
330
+ function create(qualifiedName) {
331
+ const parts = qualifiedName.split(':');
332
+ const tagName = parts.length > 1 ? parts[1] : parts[0];
333
+ // eslint-disable-next-line no-restricted-globals
334
+ const el = document.createElementNS('http://www.w3.org/2000/svg', tagName);
335
+ return new D3SelectionPolyfill([el]);
336
+ }
337
+
338
+ /* eslint-disable jsdoc/require-param-type, jsdoc/require-returns-type, jsdoc/require-param, jsdoc/require-returns */
339
+ /**
340
+ * D3 Shape Polyfill - Lightweight SVG shape generators.
341
+ *
342
+ * This is a drop-in replacement for d3-shape, implementing only the methods
343
+ * used in the Vega chart rendering system: line, arc, and pie.
344
+ *
345
+ * @see VD-5022 - [Zero Dependencies] remove d3 dependency
346
+ */
347
+ /**
348
+ * A line generator that creates SVG path data strings from data arrays.
349
+ * Mimics d3.line() with .x() and .y() value extractors.
350
+ */
351
+ class LineGenerator {
352
+ constructor() {
353
+ /** Default x value extractor: reads `.x` property or first array index. */
354
+ this.xAccessor = (d) => { var _a; return (_a = d.x) !== null && _a !== void 0 ? _a : d[0]; };
355
+ /** Default y value extractor: reads `.y` property or second array index. */
356
+ this.yAccessor = (d) => { var _a; return (_a = d.y) !== null && _a !== void 0 ? _a : d[1]; };
357
+ }
358
+ /**
359
+ * Sets the x accessor function.
360
+ *
361
+ * @param accessor - Function that returns the x value for a datum.
362
+ * @returns This generator for chaining.
363
+ */
364
+ x(accessor) {
365
+ this.xAccessor = accessor;
366
+ return this;
367
+ }
368
+ /**
369
+ * Sets the y accessor function.
370
+ *
371
+ * @param accessor - Function that returns the y value for a datum.
372
+ * @returns This generator for chaining.
373
+ */
374
+ y(accessor) {
375
+ this.yAccessor = accessor;
376
+ return this;
377
+ }
378
+ /**
379
+ * Generates an SVG path data string for the given data.
380
+ * Called as a function (used by d3's attr('d', lineGenerator)).
381
+ *
382
+ * @param data - Array of data points.
383
+ * @returns SVG path data string (M...L...L...).
384
+ */
385
+ generate(data) {
386
+ if (!data || data.length === 0) {
387
+ return '';
388
+ }
389
+ const parts = [];
390
+ for (let i = 0; i < data.length; i++) {
391
+ const xVal = this.xAccessor(data[i], i);
392
+ const yVal = this.yAccessor(data[i], i);
393
+ parts.push(i === 0 ? `M${xVal},${yVal}` : `L${xVal},${yVal}`);
394
+ }
395
+ return parts.join('');
396
+ }
397
+ }
398
+ /**
399
+ * Creates a line generator. Mimics d3.line<T>().
400
+ * The returned object is also callable as a function for d3 compatibility.
401
+ *
402
+ * @returns A new LineGenerator with callable function interface.
403
+ */
404
+ function line() {
405
+ const generator = new LineGenerator();
406
+ /* eslint-disable jsdoc/require-jsdoc */
407
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
408
+ const fn = (data) => generator.generate(data);
409
+ fn.x = (accessor) => {
410
+ generator.x(accessor);
411
+ return fn;
412
+ };
413
+ fn.y = (accessor) => {
414
+ generator.y(accessor);
415
+ return fn;
416
+ };
417
+ fn.generate = (data) => generator.generate(data);
418
+ /* eslint-enable jsdoc/require-jsdoc */
419
+ return fn;
420
+ }
421
+ // ─── Arc Generator ──────────────────────────────────────────────────
422
+ /**
423
+ * An arc generator that creates SVG path data strings for arc/pie slices.
424
+ * Mimics d3.arc<T>() with .innerRadius() and .outerRadius() value setters.
425
+ */
426
+ class ArcGenerator {
427
+ constructor() {
428
+ /** Inner radius value for the arc. */
429
+ this.innerRadiusValue = 0;
430
+ /** Outer radius value for the arc. */
431
+ this.outerRadiusValue = 0;
432
+ }
433
+ /**
434
+ * Sets the inner radius for the arc.
435
+ *
436
+ * @param radius - Inner radius value.
437
+ * @returns This generator for chaining.
438
+ */
439
+ innerRadius(radius) {
440
+ this.innerRadiusValue = radius;
441
+ return this;
442
+ }
443
+ /**
444
+ * Sets the outer radius for the arc.
445
+ *
446
+ * @param radius - Outer radius value.
447
+ * @returns This generator for chaining.
448
+ */
449
+ outerRadius(radius) {
450
+ this.outerRadiusValue = radius;
451
+ return this;
452
+ }
453
+ /**
454
+ * Generates an SVG path data string for an arc datum.
455
+ * The datum must have startAngle and endAngle properties (in angle units).
456
+ *
457
+ * @param d - Arc datum with startAngle and endAngle.
458
+ * @returns SVG path data string for the arc.
459
+ */
460
+ generate(d) {
461
+ const datum = d;
462
+ const startAngle = datum.startAngle - Math.PI / 2;
463
+ const endAngle = datum.endAngle - Math.PI / 2;
464
+ const innerR = this.innerRadiusValue;
465
+ const outerR = this.outerRadiusValue;
466
+ const angleDiff = endAngle - startAngle;
467
+ const largeArcFlag = Math.abs(angleDiff) >= Math.PI ? 1 : 0;
468
+ // Outer arc endpoints
469
+ const outerStartX = outerR * Math.cos(startAngle);
470
+ const outerStartY = outerR * Math.sin(startAngle);
471
+ const outerEndX = outerR * Math.cos(endAngle);
472
+ const outerEndY = outerR * Math.sin(endAngle);
473
+ if (innerR > 0) {
474
+ // Donut arc: outer arc clockwise + inner arc counter-clockwise
475
+ const innerEndX = innerR * Math.cos(endAngle);
476
+ const innerEndY = innerR * Math.sin(endAngle);
477
+ const innerStartX = innerR * Math.cos(startAngle);
478
+ const innerStartY = innerR * Math.sin(startAngle);
479
+ return [
480
+ `M${outerStartX},${outerStartY}`,
481
+ `A${outerR},${outerR},0,${largeArcFlag},1,${outerEndX},${outerEndY}`,
482
+ `L${innerEndX},${innerEndY}`,
483
+ `A${innerR},${innerR},0,${largeArcFlag},0,${innerStartX},${innerStartY}`,
484
+ 'Z',
485
+ ].join('');
486
+ }
487
+ else {
488
+ // Pie arc: start at outer edge, arc, line to center, close
489
+ return [
490
+ `M${outerStartX},${outerStartY}`,
491
+ `A${outerR},${outerR},0,${largeArcFlag},1,${outerEndX},${outerEndY}`,
492
+ 'L0,0',
493
+ 'Z',
494
+ ].join('');
495
+ }
496
+ }
497
+ }
498
+ /**
499
+ * Creates an arc generator. Mimics d3.arc<T>().
500
+ * The returned object is also callable as a function for d3 compatibility.
501
+ *
502
+ * @returns A new ArcGenerator with callable function interface.
503
+ */
504
+ function arc() {
505
+ const generator = new ArcGenerator();
506
+ /* eslint-disable jsdoc/require-jsdoc */
507
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
508
+ const fn = (d) => generator.generate(d);
509
+ fn.innerRadius = (radius) => {
510
+ generator.innerRadius(radius);
511
+ return fn;
512
+ };
513
+ fn.outerRadius = (radius) => {
514
+ generator.outerRadius(radius);
515
+ return fn;
516
+ };
517
+ fn.generate = (d) => generator.generate(d);
518
+ /* eslint-enable jsdoc/require-jsdoc */
519
+ return fn;
520
+ }
521
+ /**
522
+ * A pie layout generator that computes start/end angles for data items.
523
+ * Mimics d3.pie<T>() with .value() setter.
524
+ */
525
+ class PieGenerator {
526
+ constructor() {
527
+ /** Default value extractor: reads `.value` property or falls back to 0. */
528
+ this.valueAccessor = (d) => { var _a; return (_a = d.value) !== null && _a !== void 0 ? _a : 0; };
529
+ }
530
+ /**
531
+ * Sets the value accessor function.
532
+ *
533
+ * @param accessor - Function that returns the numeric value for each datum.
534
+ * @returns This generator for chaining.
535
+ */
536
+ value(accessor) {
537
+ this.valueAccessor = accessor;
538
+ return this;
539
+ }
540
+ /**
541
+ * Computes pie arc data from the input data array.
542
+ *
543
+ * @param data - Array of data items.
544
+ * @returns Array of PieArcDatum with computed angles.
545
+ */
546
+ generate(data) {
547
+ const values = data.map((d) => this.valueAccessor(d));
548
+ const total = values.reduce((sum, v) => sum + v, 0);
549
+ const n = data.length;
550
+ // Sort indices by descending value (d3.pie default sort)
551
+ const indices = Array.from({ length: n }, (_, i) => i);
552
+ indices.sort((a, b) => values[b] - values[a]);
553
+ // Assign angles in sorted order, place arcs at original indices
554
+ const arcs = new Array(n);
555
+ let currentAngle = 0;
556
+ for (const index of indices) {
557
+ const angle = total > 0 ? (values[index] / total) * 2 * Math.PI : 0;
558
+ arcs[index] = {
559
+ data: data[index],
560
+ index: index,
561
+ value: values[index],
562
+ startAngle: currentAngle,
563
+ endAngle: currentAngle + angle,
564
+ padAngle: 0,
565
+ };
566
+ currentAngle += angle;
567
+ }
568
+ return arcs;
569
+ }
570
+ }
571
+ /**
572
+ * Creates a pie layout generator. Mimics d3.pie<T>().
573
+ * The returned object is also callable as a function for d3 compatibility.
574
+ *
575
+ * @returns A new PieGenerator with callable function interface.
576
+ */
577
+ function pie() {
578
+ const generator = new PieGenerator();
579
+ /* eslint-disable jsdoc/require-jsdoc */
580
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
581
+ const fn = (data) => generator.generate(data);
582
+ fn.value = (accessor) => {
583
+ generator.value(accessor);
584
+ return fn;
585
+ };
586
+ fn.generate = (data) => generator.generate(data);
587
+ /* eslint-enable jsdoc/require-jsdoc */
588
+ return fn;
589
+ }
590
+
591
+ /**
592
+ * D3 Axis Polyfill - Lightweight SVG axis generators.
593
+ *
594
+ * This is a drop-in replacement for d3-axis, implementing only the methods
595
+ * used in the Vega chart rendering system: axisBottom and axisLeft.
596
+ *
597
+ * @see VD-5022 - [Zero Dependencies] remove d3 dependency
598
+ */
599
+ /**
600
+ * Internal axis generator class.
601
+ */
602
+ class AxisGenerator {
603
+ /**
604
+ * @param {AxisScale} scale - The scale to use for the axis.
605
+ * @param {string} orientation - 'bottom' for x-axis, 'left' for y-axis.
606
+ */
607
+ constructor(scale, orientation) {
608
+ this._tickCount = 10;
609
+ this._tickFormatter = null;
610
+ this._scale = scale;
611
+ this._orientation = orientation;
612
+ }
613
+ /**
614
+ * Sets the number of ticks.
615
+ *
616
+ * @param {number} count - Desired number of ticks.
617
+ */
618
+ setTickCount(count) {
619
+ this._tickCount = count;
620
+ }
621
+ /**
622
+ * Sets a custom tick format function.
623
+ *
624
+ * @param {Function} formatter - Function to format tick labels.
625
+ */
626
+ setTickFormatter(formatter) {
627
+ this._tickFormatter = formatter;
628
+ }
629
+ /**
630
+ * Renders the axis into the given SVG <g> selection.
631
+ * Creates a domain path, tick lines, and tick text labels.
632
+ *
633
+ * @param {D3SelectionPolyfill} selection - A D3SelectionPolyfill wrapping an SVG <g> element.
634
+ */
635
+ render(selection) {
636
+ const g = selection.node();
637
+ if (!g)
638
+ return;
639
+ const doc = g.ownerDocument;
640
+ const tickValues = this.getTickValues();
641
+ const formatter = this.getFormatter();
642
+ const offset = 0.5;
643
+ // Compute band centering offset (d3's center() function)
644
+ const bandOffset = typeof this._scale.bandwidth === 'function'
645
+ ? Math.max(0, this._scale.bandwidth() - offset * 2) / 2
646
+ : 0;
647
+ const range = this._scale.range();
648
+ const range0 = +range[0] + offset;
649
+ const range1 = +range[range.length - 1] + offset;
650
+ // Create domain path (with outer tick marks, matching d3's tickSizeOuter = 6)
651
+ const domain = doc.createElementNS('http://www.w3.org/2000/svg', 'path');
652
+ domain.setAttribute('class', 'domain');
653
+ domain.setAttribute('stroke', 'currentColor');
654
+ if (this._orientation === 'bottom') {
655
+ domain.setAttribute('d', `M${range0},6V${offset}H${range1}V6`);
656
+ }
657
+ else {
658
+ domain.setAttribute('d', `M-6,${range0}H${offset}V${range1}H-6`);
659
+ }
660
+ g.appendChild(domain);
661
+ // Create ticks
662
+ for (const tickValue of tickValues) {
663
+ const position = this._scale(tickValue);
664
+ if (position === undefined)
665
+ continue;
666
+ const finalPosition = position + bandOffset + offset;
667
+ const tickG = doc.createElementNS('http://www.w3.org/2000/svg', 'g');
668
+ tickG.setAttribute('class', 'tick');
669
+ tickG.setAttribute('opacity', '1');
670
+ const tickLine = doc.createElementNS('http://www.w3.org/2000/svg', 'line');
671
+ tickLine.setAttribute('stroke', 'currentColor');
672
+ const tickText = doc.createElementNS('http://www.w3.org/2000/svg', 'text');
673
+ tickText.setAttribute('fill', 'currentColor');
674
+ tickText.textContent = formatter(tickValue);
675
+ // eslint-disable-next-line spellcheck/spell-checker
676
+ const verticalOffset = this._orientation === 'bottom' ? '0.71em' : '0.32em';
677
+ if (this._orientation === 'bottom') {
678
+ tickG.setAttribute('transform', `translate(${finalPosition},0)`);
679
+ tickLine.setAttribute('y2', '6');
680
+ tickText.setAttribute('y', '9');
681
+ // eslint-disable-next-line spellcheck/spell-checker
682
+ tickText.setAttribute('dy', verticalOffset);
683
+ }
684
+ else {
685
+ tickG.setAttribute('transform', `translate(0,${finalPosition})`);
686
+ tickLine.setAttribute('x2', '-6');
687
+ tickText.setAttribute('x', '-9');
688
+ // eslint-disable-next-line spellcheck/spell-checker
689
+ tickText.setAttribute('dy', verticalOffset);
690
+ }
691
+ tickG.appendChild(tickLine);
692
+ tickG.appendChild(tickText);
693
+ g.appendChild(tickG);
694
+ }
695
+ // Set axis group attributes (matching d3)
696
+ g.setAttribute('fill', 'none');
697
+ g.setAttribute('font-size', '10');
698
+ g.setAttribute('font-family', 'sans-serif');
699
+ g.setAttribute('text-anchor', this._orientation === 'bottom' ? 'middle' : 'end');
700
+ }
701
+ /**
702
+ * Gets tick values from the scale.
703
+ *
704
+ * @template Domain
705
+ * @returns {Domain[]} Array of tick domain values.
706
+ */
707
+ getTickValues() {
708
+ if (this._scale.ticks) {
709
+ return this._scale.ticks(this._tickCount);
710
+ }
711
+ if (this._scale.domain) {
712
+ return this._scale.domain();
713
+ }
714
+ return [];
715
+ }
716
+ /**
717
+ * Gets the tick formatter function.
718
+ *
719
+ * @template Domain
720
+ * @returns {(d: Domain) => string} A function that converts tick values to strings.
721
+ */
722
+ getFormatter() {
723
+ if (this._tickFormatter) {
724
+ return this._tickFormatter;
725
+ }
726
+ if (this._scale.tickFormat) {
727
+ return this._scale.tickFormat(this._tickCount);
728
+ }
729
+ return (d) => String(d);
730
+ }
731
+ }
732
+ /**
733
+ * Creates a bottom-oriented axis generator. Mimics d3.axisBottom().
734
+ *
735
+ * @template Domain
736
+ * @param {AxisScale} scale - The scale to use.
737
+ * @returns {Axis<Domain>} An Axis callable that renders into a <g> element.
738
+ */
739
+ function axisBottom(scale) {
740
+ const generator = new AxisGenerator(scale, 'bottom');
741
+ /* eslint-disable jsdoc/require-jsdoc */
742
+ const axisFn = Object.assign(
743
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
744
+ (selection) => {
745
+ generator.render(selection);
746
+ }, {
747
+ ticks: (count) => {
748
+ generator.setTickCount(count);
749
+ return axisFn;
750
+ },
751
+ tickFormat: (formatter) => {
752
+ generator.setTickFormatter(formatter);
753
+ return axisFn;
754
+ },
755
+ });
756
+ /* eslint-enable jsdoc/require-jsdoc */
757
+ return axisFn;
758
+ }
759
+ /**
760
+ * Creates a left-oriented axis generator. Mimics d3.axisLeft().
761
+ *
762
+ * @template Domain
763
+ * @param {AxisScale} scale - The scale to use.
764
+ * @returns {Axis<Domain>} An Axis callable that renders into a <g> element.
765
+ */
766
+ function axisLeft(scale) {
767
+ const generator = new AxisGenerator(scale, 'left');
768
+ /* eslint-disable jsdoc/require-jsdoc */
769
+ const axisFn = Object.assign(
770
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
771
+ (selection) => {
772
+ generator.render(selection);
773
+ }, {
774
+ ticks: (count) => {
775
+ generator.setTickCount(count);
776
+ return axisFn;
777
+ },
778
+ tickFormat: (formatter) => {
779
+ generator.setTickFormatter(formatter);
780
+ return axisFn;
781
+ },
782
+ });
783
+ /* eslint-enable jsdoc/require-jsdoc */
784
+ return axisFn;
785
+ }
786
+
787
+ /** This class is used to render charts using SVG elements. */
788
+ class SVGRenderer extends BaseRenderer {
789
+ /**
790
+ * The function sets the layout of a chart using D3 and SVG.
791
+ *
792
+ * @param {number} width - chart width
793
+ * @param {number} height - chart height
794
+ * @param {number} top - chart margin top
795
+ * @param {number} left - chart margin left
796
+ */
797
+ setLayout(width, height, top, left) {
798
+ select(this.context)
799
+ .attr('width', width)
800
+ .attr('height', height)
801
+ .attr('viewBox', [0, 0, width, height])
802
+ .property('style', 'display:block;max-width:100%;height:auto;')
803
+ .call((g) => {
804
+ g.append('g')
805
+ .attr('class', 'vega-chart-draw-g')
806
+ .attr('transform', `translate(${left},${top})`);
807
+ })
808
+ .call((g) => {
809
+ g.append('g')
810
+ .attr('class', 'vega-chart-legend-g')
811
+ .attr('transform', `translate(${left / 3},${top / 4})`);
812
+ });
813
+ }
814
+ /**
815
+ * This function draws a line on a chart using D3.js library.
816
+ *
817
+ * @param {ChartPosition} from - The starting position of the line to be drawn on the chart. It is an
818
+ * object with two properties: x and y, representing the x and y coordinates of the starting point respectively.
819
+ * @param {ChartPosition} to - The "to" parameter is a ChartPosition object that represents the ending
820
+ * point of the line to be drawn. It contains the x and y coordinates of the point on the chart where the line should end.
821
+ * @param {string} color - The color of the line
822
+ */
823
+ drawLine(from, to, color) {
824
+ select(this.context)
825
+ .select('.vega-chart-draw-g')
826
+ .append('line')
827
+ .attr('x1', from.x)
828
+ .attr('y1', from.y)
829
+ .attr('x2', to.x)
830
+ .attr('y2', to.y)
831
+ .attr('stroke', color);
832
+ }
833
+ /**
834
+ * This function draws an x-axis on a chart using D3 and a given scale and end point.
835
+ *
836
+ * @param {ChartExtend<unknown>} extend - which is an object that contains information about the chart's scale and end position on the y-axis. The `scale` property
837
+ * is a D3 scale object that maps data values to pixel positions on the x-axis
838
+ * @param {string} color - The stroke color of axis
839
+ * @param {string} textStyle - The text style of the axis
840
+ */
841
+ drawXAxis(extend, color, textStyle) {
842
+ const { scale, end, labelFormatter, direction, height } = extend;
843
+ let axis = axisBottom(scale);
844
+ if (labelFormatter) {
845
+ axis = axis.tickFormat(labelFormatter);
846
+ }
847
+ select(this.context)
848
+ .select('.vega-chart-draw-g')
849
+ .append('g')
850
+ .attr('class', 'vega-chart-x-axis')
851
+ .attr('transform', `translate(0, ${end.y})`)
852
+ .call(axis)
853
+ .call((g) => {
854
+ g.select('.domain').attr('stroke-width', 2).attr('stroke', color);
855
+ })
856
+ .call((g) => {
857
+ g.selectAll('line').attr('stroke', color);
858
+ g.selectAll('text').property('style', textStyle);
859
+ })
860
+ .call((g) => {
861
+ if (direction === 'horizontal') {
862
+ g.selectAll('line').clone().attr('y2', `${-height}`);
863
+ g.select('.domain').attr('stroke-width', 0);
864
+ }
865
+ });
866
+ }
867
+ /**
868
+ * This function draws the Y-axis of a chart using D3 and a given scale.
869
+ *
870
+ * @param {ChartExtend<unknown>} extend - It likely contains additional information or settings related to the chart being drawn, but without more context it's
871
+ * difficult to say exactly what it contains.
872
+ * @param {string} color - The stroke color of the axis
873
+ * @param {string} textStyle - The text style of the axis
874
+ */
875
+ drawYAxis(extend, color, textStyle) {
876
+ const { scale, labelFormatter, width, tickSize, direction } = extend;
877
+ let axis = axisLeft(scale).ticks(tickSize);
878
+ if (labelFormatter) {
879
+ axis = axis.tickFormat(labelFormatter);
880
+ }
881
+ select(this.context)
882
+ .select('.vega-chart-draw-g')
883
+ .append('g')
884
+ .attr('class', 'vega-chart-y-axis')
885
+ .call(axis)
886
+ .call((g) => {
887
+ g.select('.domain').attr('stroke-width', 0).attr('stroke', color);
888
+ })
889
+ .call((g) => {
890
+ g.selectAll('line').attr('stroke-width', 2).attr('stroke', color);
891
+ g.selectAll('text').property('style', textStyle);
892
+ })
893
+ .call((g) => {
894
+ if (direction !== 'horizontal') {
895
+ g.selectAll('line').clone().attr('x2', `${width}`);
896
+ }
897
+ else {
898
+ g.select('.domain').attr('stroke-width', 2).attr('stroke', color);
899
+ }
900
+ });
901
+ }
902
+ /**
903
+ * This function draws a circle with a given center, radius, and color using D3.js.
904
+ *
905
+ * @param {ChartPosition} center - ChartPosition, which is an object containing the x and y coordinates of the center of the circle.
906
+ * @param {number} radius - The radius parameter is a number that specifies the radius of the circle to be drawn.
907
+ * @param {string} fillColor - The color parameter is a string that represents the color of the circle to be drawn
908
+ * @param {number} strokeWidth - the border width
909
+ * @param {string} strokeColor - the border color
910
+ */
911
+ drawCircle(center, radius, fillColor, strokeWidth, strokeColor) {
912
+ select(this.context)
913
+ .select('.vega-chart-draw-g')
914
+ .append(() => this.getCircleNode(center, radius, fillColor, strokeWidth, strokeColor));
915
+ }
916
+ /**
917
+ * This function draws text on a chart at a specified position using D3.js.
918
+ *
919
+ * @param {ChartPosition} position - ChartPosition is an object that contains the x and y coordinates where the text will be positioned on the chart.
920
+ * @param {string} text - The text parameter is a string that represents the text that will be
921
+ * displayed on the chart. It is the content that will be added to the text element created by this function.
922
+ * @param {string} textStyle - The text style of the axis
923
+ * @param {TextAnchorType} textAnchor - text anchor
924
+ * @param {number} rotate - rotate of the text
925
+ */
926
+ drawText(position, text, textStyle, textAnchor, rotate) {
927
+ select(this.context)
928
+ .select('.vega-chart-draw-g')
929
+ .append(() => this.getTextNode(position, text, textStyle, textAnchor, rotate));
930
+ }
931
+ /**
932
+ * This function draws a legend item with a colored circle and text at a specified position on a chart.
933
+ *
934
+ * @param {ChartPosition} position - The position parameter is an object that contains the x and y
935
+ * coordinates where the legend should be placed on the chart.
936
+ * @param {string} text - The text to be displayed in the legend.
937
+ * @param {string} color - Background color token type, which is a type of color
938
+ * used in the chart's background.
939
+ * @param {string} textStyle - The text style of the axis
940
+ * @returns {SVGGElement} svg g element
941
+ */
942
+ drawLegend(position, text, color, textStyle) {
943
+ return select(this.context)
944
+ .select('.vega-chart-legend-g')
945
+ .append('g')
946
+ .attr('class', 'vega-chart-legend-item')
947
+ .attr('data-legend', text)
948
+ .attr('transform', `translate(${position.x},${position.y})`)
949
+ .call((g) => {
950
+ g.append(() => this.getCircleNode({
951
+ x: -4,
952
+ y: -4,
953
+ }, 4, color));
954
+ g.append(() => this.getTextNode({ x: 8, y: 0 }, text, textStyle));
955
+ })
956
+ .node();
957
+ }
958
+ /**
959
+ * This function draws a rectangle with a specified position, width, height, and optional color using D3.js.
960
+ *
961
+ * @param {ChartPosition} position - The position parameter is an object that contains the x and y coordinates of the top-left corner of the rectangle.
962
+ * @param {number} width - The width of the rectangle to be drawn.
963
+ * @param {number} height - The height parameter is a number that represents the height of the rectangle to be drawn.
964
+ * @param {string} [color] - The color parameter is an optional string that represents the color of the rectangle to be drawn. If it is not provided, the rectangle will have no fill color.
965
+ */
966
+ drawRect(position, width, height, color) {
967
+ select(this.context)
968
+ .select('.vega-chart-draw-g')
969
+ .append('rect')
970
+ .attr('fill', color)
971
+ .attr('x', position.x)
972
+ .attr('y', position.y)
973
+ .attr('width', width)
974
+ .attr('height', height);
975
+ }
976
+ /**
977
+ * This function draws a path on a chart using D3 and SVG based on the provided positions and color.
978
+ *
979
+ * @param {ChartPosition[]} positions - An array of ChartPosition objects that represent the
980
+ * coordinates of the points on the path to be drawn. Each ChartPosition object contains an x and y
981
+ * value that represent the position of the point on the chart.
982
+ * @param {string} color - line color
983
+ * represents a color value. It is likely used to specify the color of the path that will be drawn on the chart.
984
+ */
985
+ drawLinePath(positions, color) {
986
+ select(this.context)
987
+ .select('.vega-chart-draw-g')
988
+ .append('path')
989
+ .attr('class', 'vega-chart-line-path')
990
+ .datum(positions)
991
+ .attr('fill', 'none')
992
+ .attr('stroke', color)
993
+ .attr('stroke-width', 3)
994
+ .attr('stroke-linecap', 'round')
995
+ .attr('stroke-linejoin', 'round')
996
+ .attr('d', line()
997
+ .x((position) => position.x)
998
+ .y((position) => position.y));
999
+ }
1000
+ /**
1001
+ * This function draws an arc path using D3 library and applies color and radius based on input parameters.
1002
+ *
1003
+ * @param {ChartPosition} center - the arc center position
1004
+ * @param {ArcPathItem} record - an object containing data for the arc path to be drawn
1005
+ * @param {string} color - The color parameter
1006
+ * and is used to set the fill color of the arc path.
1007
+ * @param {number} outerRadius - The outer radius parameter is a number that determines the outer
1008
+ * radius of the arc path being drawn.
1009
+ * @param {number} innerRadius - The inner radius of the arc path, specified as a number.
1010
+ * @returns {SVGPathElement} svg arc path element.
1011
+ */
1012
+ drawArcPath(center, record, color, outerRadius, innerRadius) {
1013
+ return select(this.context)
1014
+ .select('.vega-chart-draw-g')
1015
+ .append('path')
1016
+ .datum(record)
1017
+ .attr('class', 'vega-chart-arc-path')
1018
+ .attr('data-name', (item) => item.data.name)
1019
+ .attr('transform', `translate(${center.x},${center.y})`)
1020
+ .attr('fill', color)
1021
+ .attr('stroke-width', 0)
1022
+ .attr('d', arc().innerRadius(innerRadius).outerRadius(outerRadius))
1023
+ .attr('data-d', arc()
1024
+ .innerRadius(innerRadius)
1025
+ .outerRadius(outerRadius + 10))
1026
+ .node();
1027
+ }
1028
+ /**
1029
+ * This function clears all elements within two specific classes in a D3 selection.
1030
+ */
1031
+ clear() {
1032
+ select(this.context).selectAll('.vega-chart-draw-g').remove();
1033
+ select(this.context).selectAll('.vega-chart-legend-g').remove();
1034
+ }
1035
+ /**
1036
+ * This TypeScript function creates and returns an SVG text element with the given position and text.
1037
+ *
1038
+ * @param {ChartPosition} position - The position parameter is an object that contains the x and y
1039
+ * coordinates where the text element will be placed on the SVG canvas.
1040
+ * @param {string} text - The text parameter is a string that represents the text content that will be
1041
+ * displayed in the SVGTextElement.
1042
+ * @param {string} textStyle - The text style of the axis
1043
+ * @param {TextAnchorType} textAnchor - text anchor
1044
+ * @param {number} rotate - rotate of the text
1045
+ * @returns {SVGTextElement} an SVGTextElement node.
1046
+ */
1047
+ getTextNode(position, text, textStyle, textAnchor = 'start', rotate = 0) {
1048
+ const TextSelectionType = create('svg:text')
1049
+ .property('style', textStyle)
1050
+ .attr('x', position.x)
1051
+ .attr('y', position.y)
1052
+ .attr('text-anchor', textAnchor)
1053
+ .attr('rotate', rotate)
1054
+ .text(text);
1055
+ return TextSelectionType.node();
1056
+ }
1057
+ /**
1058
+ * This TypeScript function creates an SVG circle element with a specified center, radius, and color.
1059
+ *
1060
+ * @param {ChartPosition} center - The center position of the circle on the chart, specified as an
1061
+ * object with `x` and `y` properties.
1062
+ * @param {number} radius - The radius parameter is a number that represents the radius of the circle
1063
+ * to be created.
1064
+ * @param {string} fillColor - The color parameter
1065
+ * and is used to determine the fill color of the circle. It is likely an enum or string type that maps
1066
+ * to a specific color value.
1067
+ * @param {number} strokeWidth - the border width
1068
+ * @param {string} strokeColor - the border color
1069
+ * @returns {SVGCircleElement} an SVG circle element.
1070
+ */
1071
+ getCircleNode(center, radius, fillColor, strokeWidth, strokeColor) {
1072
+ const circleSelection = create('svg:circle')
1073
+ .attr('r', radius)
1074
+ .attr('cx', center.x)
1075
+ .attr('cy', center.y)
1076
+ .attr('fill', fillColor)
1077
+ .attr('stroke-width', strokeWidth || 0)
1078
+ .attr('stroke', strokeColor);
1079
+ return circleSelection.node();
1080
+ }
1081
+ }
1082
+
1083
+ /**
1084
+ * The CanvasRenderer class is a TypeScript class that extends the BaseRenderer class and provides
1085
+ * methods for drawing various shapes and elements on a canvas.
1086
+ */
1087
+ class CanvasRenderer extends BaseRenderer {
1088
+ /**
1089
+ * The function sets the layout of a chart.
1090
+ *
1091
+ * @param {number} width - chart width
1092
+ * @param {number} height - chart height
1093
+ */
1094
+ setLayout(width, height) {
1095
+ this.context.width = width;
1096
+ this.context.height = height;
1097
+ this.context.style.display = 'block';
1098
+ this.initCanvasContext2d();
1099
+ }
1100
+ /**
1101
+ * The function `drawLine` takes two `ChartPosition` parameters and draws a line between them.
1102
+ *
1103
+ * @param {ChartPosition} from - The starting position of the line on the chart. It is of type ChartPosition.
1104
+ * @param {ChartPosition} to - The "to" parameter in the "drawLine" function is a ChartPosition object
1105
+ * that represents the end point of the line to be drawn. It contains information about the x and y
1106
+ * coordinates of the point on the chart where the line should end.
1107
+ */
1108
+ drawLine(from, to) {
1109
+ const context2d = this.getContext2d();
1110
+ context2d.beginPath();
1111
+ context2d.moveTo(from.x, from.y);
1112
+ context2d.lineTo(to.x, to.y);
1113
+ context2d.closePath();
1114
+ }
1115
+ /**
1116
+ * This function draws the X-axis on a chart and takes in a parameter of type ChartExtend.
1117
+ *
1118
+ * @param {ChartExtend<unknown>} extend - The parameter "extend" is of type "ChartExtend" which is a generic type that can
1119
+ * take any data type as an argument. It is likely used to extend or modify the properties of the chart's X-axis
1120
+ */
1121
+ drawXAxis(extend) {
1122
+ this.drawLine(extend.start, extend.end);
1123
+ }
1124
+ /**
1125
+ * This function draws the Y-axis on a chart.
1126
+ *
1127
+ * @param {ChartExtend<unknown>} extend - The parameter "extend" is of type ChartExtend, which is a generic type that
1128
+ * represents the range of values for a chart axis. It contains information such as the minimum and
1129
+ * maximum values for the axis
1130
+ */
1131
+ drawYAxis(extend) {
1132
+ this.drawLine(extend.start, extend.end);
1133
+ }
1134
+ /**
1135
+ * The function `drawCircle` takes in a center position, radius, and color and draws a circle.
1136
+ *
1137
+ * @param {ChartPosition} center - The center of the circle, represented by a ChartPosition object
1138
+ * that contains the x and y coordinates of the center point.
1139
+ * @param {number} radius - The _radius parameter is a number that represents the radius of the
1140
+ * circle to be drawn. The radius is the distance from the center of the circle to any point on its circumference.
1141
+ * @param {string} fillColor - The _color,
1142
+ * which is a type that represents a color value that can be used as a background color for a chart element
1143
+ * @param {number} strokeWidth - the border width
1144
+ * @param {string} strokeColor - the border color
1145
+ */
1146
+ drawCircle(center, radius, fillColor, strokeWidth, strokeColor) {
1147
+ const context2d = this.getContext2d();
1148
+ if (strokeWidth && strokeColor) {
1149
+ context2d.fillStyle = strokeColor;
1150
+ context2d.beginPath();
1151
+ context2d.arc(center.x, center.y, radius, 0, Math.PI * 2);
1152
+ context2d.fill();
1153
+ }
1154
+ context2d.fillStyle = fillColor;
1155
+ context2d.beginPath();
1156
+ context2d.arc(center.x, center.y, radius - (strokeWidth || 0), 0, Math.PI * 2);
1157
+ context2d.fill();
1158
+ }
1159
+ /**
1160
+ * The function draws a legend on a chart with a circle and text at a specified position and color.
1161
+ *
1162
+ * @param {ChartPosition} position - ChartPosition is a type that represents the position of an
1163
+ * element on a chart. It could be an object with properties like x and y coordinates or a string that
1164
+ * represents a predefined position.
1165
+ * @param {string} text - The text parameter is a string that represents the label or name of the
1166
+ * legend that will be displayed on the chart.
1167
+ * @param {string} color - color string
1168
+ * represents a color for the legend. It could be a string or a number that corresponds to a specific
1169
+ * color value.
1170
+ * @returns {HTMLCanvasElement} chart canvas element
1171
+ */
1172
+ drawLegend(position, text, color) {
1173
+ this.drawCircle(position, 4, color);
1174
+ this.drawText(position, text);
1175
+ return this.context;
1176
+ }
1177
+ /**
1178
+ * The function `drawText` takes a position and a string of text as parameters and does not return anything.
1179
+ *
1180
+ * @param {ChartPosition} position - ChartPosition is a data type that represents the position of the
1181
+ * text on a chart. It could be an object with properties such as x and y coordinates, or it could be
1182
+ * a string that represents a pre-defined position on the chart (e.g. "top-left", "bottom-right",
1183
+ * etc.).
1184
+ * @param {string} text - The text parameter is a string that represents the text that needs to be drawn on the chart.
1185
+ */
1186
+ drawText(position, text) {
1187
+ this.getContext2d().fillText(text, position.x, position.y);
1188
+ }
1189
+ /**
1190
+ * The function `drawRect` takes in a position, width, height, and optional color parameter to draw a rectangle.
1191
+ *
1192
+ * @param {ChartPosition} position - The position parameter is of type ChartPosition and represents
1193
+ * the position of the rectangle on the chart. It could be an object with x and y properties
1194
+ * representing the coordinates of the top-left corner of the rectangle.
1195
+ * @param {number} width - The width parameter is a number that represents the width of the rectangle
1196
+ * to be drawn. It determines how wide the rectangle will be on the chart.
1197
+ * @param {number} height - The `height` parameter in the `drawRect` function specifies the height of
1198
+ * the rectangle to be drawn. It is a required parameter and must be a number value.
1199
+ * @param {string} [color] - The color parameter is an optional parameter that
1200
+ * specifies the background color of the rectangle. It is of type string, which is
1201
+ * a custom type that represents a color token
1202
+ */
1203
+ drawRect(position, width, height, color) {
1204
+ const context2d = this.getContext2d();
1205
+ context2d.fillStyle = color;
1206
+ context2d.fillRect(position.x, position.y, width, height);
1207
+ }
1208
+ /**
1209
+ * The function `drawLinePath` takes in an array of `ChartPosition` objects and a `string` color and draws a path.
1210
+ *
1211
+ * @param {ChartPosition[]} positions - An array of ChartPosition objects that represent the
1212
+ * coordinates of points on a chart. Each ChartPosition object has an x and y property that represent
1213
+ * the horizontal and vertical position of the point on the chart.
1214
+ * @param {string} color - The `color` parameter is of type
1215
+ * `string` and represents the color of the path to be drawn. This parameter is
1216
+ * used to set the background color of the chart.
1217
+ */
1218
+ drawLinePath(positions, color) {
1219
+ const pathNode = create('svg:path')
1220
+ .datum(positions)
1221
+ .attr('d', line()
1222
+ .x((position) => position.x)
1223
+ .y((position) => position.y))
1224
+ .node();
1225
+ const path = new Path2D(pathNode.getAttribute('d'));
1226
+ const context2d = this.getContext2d();
1227
+ context2d.lineWidth = 3;
1228
+ context2d.strokeStyle = color;
1229
+ context2d.stroke(path);
1230
+ }
1231
+ /**
1232
+ * This function draws an arc path using D3 library and applies color and radius based on input parameters.
1233
+ *
1234
+ * @param {ChartPosition} center - arc center position
1235
+ * @param {ArcPathItem} record - an object containing data for the arc path to be drawn
1236
+ * @param {string} color - The color parameter
1237
+ * and is used to set the fill color of the arc path.
1238
+ * @param {number} outerRadius - The outer radius parameter is a number that determines the outer
1239
+ * radius of the arc path being drawn.
1240
+ * @param {number} innerRadius - The inner radius of the arc path, specified as a number.
1241
+ * @returns {HTMLCanvasElement} chart canvas element.
1242
+ */
1243
+ drawArcPath(center, record, color, outerRadius, innerRadius) {
1244
+ const context2d = this.getContext2d();
1245
+ context2d.beginPath();
1246
+ context2d.moveTo(center.x, center.y);
1247
+ context2d.arc(center.x, center.y, outerRadius, record.startAngle, record.endAngle);
1248
+ context2d.fillStyle = color;
1249
+ context2d.fill();
1250
+ if (innerRadius) {
1251
+ this.drawCircle(center, innerRadius, '#F0F3F7');
1252
+ }
1253
+ return this.context;
1254
+ }
1255
+ /**
1256
+ * The function "clear"
1257
+ */
1258
+ clear() {
1259
+ this.getContext2d().clearRect(0, 0, this.context.width, this.context.height);
1260
+ }
1261
+ /**
1262
+ * This function initializes a 2D canvas context.
1263
+ */
1264
+ initCanvasContext2d() {
1265
+ this.canvasContext2d = this.context.getContext('2d');
1266
+ }
1267
+ /**
1268
+ * This function returns the canvas 2D rendering context and initializes it if it doesn't exist.
1269
+ *
1270
+ * @returns {CanvasRenderingContext2D} The function `getContext2d()` returns the `CanvasRenderingContext2D` object.
1271
+ */
1272
+ getContext2d() {
1273
+ if (!this.canvasContext2d) {
1274
+ this.initCanvasContext2d();
1275
+ }
1276
+ return this.canvasContext2d;
1277
+ }
1278
+ }
1279
+
1280
+ /** The RendererFactory class provides a static method to create a renderer based on the type of context provided. */
1281
+ class RendererFactory {
1282
+ /**
1283
+ * This function returns a renderer based on the type of context provided (SVG or Canvas).
1284
+ *
1285
+ * @param {SVGElement | HTMLCanvasElement} context - The `context` parameter is either an
1286
+ * SVGElement or a HTMLCanvasElement. It is used to determine which renderer to instantiate and
1287
+ * return
1288
+ * @returns {BaseRenderer<SVGElement | HTMLCanvasElement> } based on the type of the `context` parameter. If
1289
+ * the `context` is an instance of `SVGElement`, an `SVGRenderer` object is returned
1290
+ */
1291
+ static get(context) {
1292
+ if (context instanceof SVGElement) {
1293
+ return new SVGRenderer(context);
1294
+ }
1295
+ else if (context instanceof HTMLCanvasElement) {
1296
+ return new CanvasRenderer(context);
1297
+ }
1298
+ else {
1299
+ throw new Error('Invalid context');
1300
+ }
1301
+ }
1302
+ }
1303
+
1304
+ const DEFAULT_LAYOUT = {
1305
+ width: undefined,
1306
+ height: undefined,
1307
+ margin: {
1308
+ top: 30,
1309
+ right: 30,
1310
+ bottom: 30,
1311
+ left: 30,
1312
+ },
1313
+ };
1314
+ const DEFAULT_MARGIN_TOP_WITH_LEGENDS = 60;
1315
+ const DEFAULT_MARGIN_LEFT_WITH_AXIS = 60;
1316
+ /** The ChartDimensionController class contains methods for setting and retrieving the width and height of a chart container element. */
1317
+ class ChartDimensionController {
1318
+ /**
1319
+ * This is a constructor function that takes an HTMLElement as a parameter and assigns it to a private property called "container".
1320
+ *
1321
+ * @param {HTMLElement} container - The "container" parameter is a reference to an HTML element that
1322
+ * will be used as a container for the component or module being constructed. This parameter is
1323
+ * typically passed in during the instantiation of the component or module and is used to specify
1324
+ * where the component or module should be rendered in the DOM.
1325
+ */
1326
+ constructor(container) {
1327
+ this.container = container;
1328
+ }
1329
+ /**
1330
+ * This function sets the width and height of a container element based on a given layout object. if the layout is null, then will not update,
1331
+ * prevent the original style is changed
1332
+ *
1333
+ * @param {ChartLayout} layout - ChartLayout object that contains the width and height values for the chart container.
1334
+ */
1335
+ setContainerWidthAndHeight(layout) {
1336
+ const { width, height } = layout;
1337
+ if (width !== undefined) {
1338
+ this.container.style.width = pixel.parseNumberToPixelString(width);
1339
+ }
1340
+ if (height !== undefined) {
1341
+ this.container.style.height = pixel.parseNumberToPixelString(height);
1342
+ }
1343
+ }
1344
+ /**
1345
+ * This function returns the client width of a container or parses the width from a layout object.
1346
+ *
1347
+ * @param {ChartLayout} layout - In this function, the layout parameter is used to determine the width of the chart container. If the container's
1348
+ * clientWidth property is not available,
1349
+ * @returns {number} returning a number. The number is either the client width of the container element or the parsed width value from the `ChartLayout` object.
1350
+ */
1351
+ getContainerClientWidth(layout) {
1352
+ return (this.container.clientWidth ||
1353
+ pixel.parsePixelStringToNumber((layout === null || layout === void 0 ? void 0 : layout.width) || this.container.style.width));
1354
+ }
1355
+ /**
1356
+ * This function returns the height of a container element in pixels, either by accessing its clientHeight property or by parsing a string value from the layout object.
1357
+ *
1358
+ * @param {ChartLayout} layout - the layout parameter is used to determine the height of the chart container if it is not already set.
1359
+ * @returns {number} The function `getContainerClientHeight` returns a number which represents the height of
1360
+ * the container client or the parsed height value from the `ChartLayout` object.
1361
+ */
1362
+ getContainerClientHeight(layout) {
1363
+ return (this.container.clientHeight ||
1364
+ pixel.parsePixelStringToNumber((layout === null || layout === void 0 ? void 0 : layout.height) || this.container.style.height));
1365
+ }
1366
+ /**
1367
+ * This function calculates the inner width of a chart container by subtracting the left and right margins from the client width.
1368
+ *
1369
+ * @param {ChartLayout} layout - ChartLayout object that contains information about the chart layout,
1370
+ * including the container width and margin.
1371
+ * @returns {number} the inner width of a container element, which is calculated by subtracting the left and
1372
+ * right margins from the client width of the container.
1373
+ */
1374
+ getContainerInnerWidth(layout) {
1375
+ const width = this.getContainerClientWidth(layout);
1376
+ const { left, right } = ((layout === null || layout === void 0 ? void 0 : layout.margin) || DEFAULT_LAYOUT.margin);
1377
+ return width ? width - right - left : 0;
1378
+ }
1379
+ /**
1380
+ * This function calculates the inner height of a chart container by subtracting the top and bottom margins from the client height.
1381
+ *
1382
+ * @param {ChartLayout} layout - The `layout` parameter is an object of type `ChartLayout` which
1383
+ * contains information about the layout of a chart, including its dimensions and margins.
1384
+ * @returns {number} the inner height of a container element, which is calculated by subtracting the top and
1385
+ * bottom margins from the client height of the container. The returned value is a number.
1386
+ */
1387
+ getContainerInnerHeight(layout) {
1388
+ const height = this.getContainerClientHeight(layout);
1389
+ const { top, bottom } = ((layout === null || layout === void 0 ? void 0 : layout.margin) || DEFAULT_LAYOUT.margin);
1390
+ return height ? height - top - bottom : 0;
1391
+ }
1392
+ /**
1393
+ * This function merges a given chart layout with default values and returns the updated layout.
1394
+ *
1395
+ * @param {string} chartName - A string representing the name of the chart.
1396
+ * @param {ChartLayout} layout - The `layout` parameter is an optional object that contains properties
1397
+ * for the width, height, and margin of a chart. If provided, it will be merged with the default
1398
+ * layout settings to create a new layout object. If not provided, the default layout settings will be
1399
+ * used.
1400
+ * @param {boolean} hasLegends - A boolean value indicating whether the chart has legends or not.
1401
+ * @returns {ChartLayout} a ChartLayout object.
1402
+ */
1403
+ mergeLayout(chartName, layout, hasLegends) {
1404
+ const defaultTop = hasLegends ? DEFAULT_MARGIN_TOP_WITH_LEGENDS : DEFAULT_LAYOUT.margin.top;
1405
+ const defaultLeft = chartName === 'VEGA-LINE-CHART' || chartName === 'VEGA-BAR-CHART'
1406
+ ? DEFAULT_MARGIN_LEFT_WITH_AXIS
1407
+ : DEFAULT_LAYOUT.margin.left;
1408
+ const newLayout = {
1409
+ width: layout && layout.width ? layout.width : DEFAULT_LAYOUT.width,
1410
+ height: layout && layout.height ? layout.height : DEFAULT_LAYOUT.height,
1411
+ margin: Object.assign({}, DEFAULT_LAYOUT.margin, { top: defaultTop, left: defaultLeft }, layout && layout.margin ? layout.margin : {}),
1412
+ };
1413
+ return newLayout;
1414
+ }
1415
+ }
1416
+
1417
+ /**
1418
+ * This is a TypeScript code that defines an abstract class `BaseInteractor` with a generic type `T` that extends either `SVGElement` or `HTMLCanvasElement`.
1419
+ */
1420
+ class BaseInteractor {
1421
+ /**
1422
+ * This is a constructor function that takes a parameter of type T and sets it as a protected property called "context".
1423
+ *
1424
+ * @param {SVGElement | HTMLCanvasElement} context - The "context" parameter is a protected property of a class constructor that is
1425
+ * of type "T". It is used to store a reference to an object or data that is required by the class
1426
+ * methods to perform their tasks. The "protected" keyword means that the property can only be
1427
+ * accessed within the class
1428
+ */
1429
+ constructor(context) {
1430
+ this.context = context;
1431
+ this.interactingEntryForEventRegistry = new Map();
1432
+ this.interactingEntryForDrawerRegistry = new WeakMap();
1433
+ }
1434
+ /**
1435
+ * This function registers an interacting entry with a drawer, draw piece, and event type in an interactor registry.
1436
+ *
1437
+ * @param {BaseDrawer<unknown>} drawer - The drawer parameter is an instance of a class that extends the BaseDrawer class,
1438
+ * which is used for drawing on a canvas or other graphical surface.
1439
+ * @param {DrawPiece} drawPiece - DrawPiece is a type that represents a specific piece that can be
1440
+ * drawn on a canvas or other graphical surface. It could include information such as the shape,
1441
+ * color, size, and position of the piece.
1442
+ * @param {InteractingEntry} interactingEntry - InteractingEntry is a data structure that represents
1443
+ * an interaction between a user and a graphical element on the screen. It contains information such
1444
+ * as the type of event that triggered the interaction (e.g. mouse click, touch)
1445
+ */
1446
+ register(drawer, drawPiece, interactingEntry) {
1447
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
1448
+ const eventType = interactingEntry.eventType;
1449
+ if (!this.interactingEntryForEventRegistry.get(eventType)) {
1450
+ this.interactingEntryForEventRegistry.set(eventType, []);
1451
+ }
1452
+ this.interactingEntryForEventRegistry.get(eventType).push(interactingEntry);
1453
+ if (!this.interactingEntryForDrawerRegistry.get(drawer)) {
1454
+ this.interactingEntryForDrawerRegistry.set(drawer, new WeakMap());
1455
+ }
1456
+ if (!this.interactingEntryForDrawerRegistry.get(drawer).get(drawPiece)) {
1457
+ this.interactingEntryForDrawerRegistry.get(drawer).set(drawPiece, []);
1458
+ }
1459
+ this.interactingEntryForDrawerRegistry.get(drawer).get(drawPiece).push(interactingEntry);
1460
+ /* eslint-enable @typescript-eslint/no-non-null-assertion */
1461
+ }
1462
+ /**
1463
+ * This function unregisters a drawer from the interactor registry.
1464
+ *
1465
+ * @param {BaseDrawer<unknown>} drawer - The parameter `drawer` is of type `BaseDrawer<unknown>`. It is an object that
1466
+ * represents a drawer and is used to unregister the drawer from the `interactorRegistry`. The
1467
+ * `interactorRegistry` is a `WeakMap` that stores a mapping between an `Interactor` and
1468
+ */
1469
+ unregisterByDrawer(drawer) {
1470
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
1471
+ const drawPiece = drawer.drawPiece;
1472
+ if (drawPiece &&
1473
+ this.interactingEntryForDrawerRegistry.has(drawer) &&
1474
+ this.interactingEntryForDrawerRegistry.get(drawer) &&
1475
+ this.interactingEntryForDrawerRegistry.get(drawer).has(drawPiece) &&
1476
+ this.interactingEntryForDrawerRegistry.get(drawer).get(drawPiece)) {
1477
+ this.interactingEntryForEventRegistry.forEach((value, key) => {
1478
+ this.interactingEntryForEventRegistry.set(key, value.filter((interactingEntry) => {
1479
+ return (this.interactingEntryForDrawerRegistry
1480
+ .get(drawer)
1481
+ .get(drawPiece)
1482
+ .indexOf(interactingEntry) < 0);
1483
+ }));
1484
+ });
1485
+ /* eslint-enable @typescript-eslint/no-non-null-assertion */
1486
+ }
1487
+ this.interactingEntryForDrawerRegistry.delete(drawer);
1488
+ }
1489
+ /**
1490
+ * This function handles mouse events for registered interactor and drawers.
1491
+ *
1492
+ * @param {EventType} eventType - The type of event being registered in the registry, such as "click" or "mousemove".
1493
+ * @param {MouseEvent} event - The `event` parameter is of type `MouseEvent`, which represents a
1494
+ * mouse-related event (such as a click, double-click, or mouse movement) that occurred on the web
1495
+ * page. It contains information about the event, such as the type of event, the target element that
1496
+ * triggered the event
1497
+ */
1498
+ callRegistry(eventType, event) {
1499
+ const interactingEntryArray = this.interactingEntryForEventRegistry.get(eventType);
1500
+ if (interactingEntryArray) {
1501
+ interactingEntryArray.forEach((interactingEntry) => {
1502
+ if (interactingEntry.shouldHandle(event)) {
1503
+ interactingEntry.handle(event);
1504
+ }
1505
+ });
1506
+ }
1507
+ }
1508
+ }
1509
+
1510
+ /**
1511
+ * The CanvasInteractor class extends the BaseInteractor class and provides empty methods for handling mouse move, click, and hover events on a HTML canvas element.
1512
+ */
1513
+ class CanvasInteractor extends BaseInteractor {
1514
+ }
1515
+
1516
+ /**
1517
+ * The SVGInteractor class extends the BaseInteractor class and provides methods for handling mouse events on SVG elements.
1518
+ */
1519
+ class SVGInteractor extends BaseInteractor {
1520
+ /**
1521
+ * This is a constructor function that adds event listeners for click and mouseover events to an SVG element.
1522
+ *
1523
+ * @param {SVGElement} context - The context parameter is an SVGElement, which is the element that the
1524
+ * constructor is being called on. It is used to add event listeners to the element for mouseover and
1525
+ * click events.
1526
+ */
1527
+ constructor(context) {
1528
+ super(context);
1529
+ this.addContextListener();
1530
+ }
1531
+ /**
1532
+ * This function adds event listeners for click and mouseover events to the context element and calls
1533
+ * a registry function with the corresponding event type and event object.
1534
+ */
1535
+ addContextListener() {
1536
+ this.context.addEventListener('click', (event) => {
1537
+ this.callRegistry('click', event);
1538
+ });
1539
+ this.context.addEventListener('mouseover', (event) => {
1540
+ this.callRegistry('mouseover', event);
1541
+ });
1542
+ }
1543
+ }
1544
+
1545
+ /** The InteractorFactory class provides a static method to create and return an appropriate interactor based on the type of context provided. */
1546
+ class InteractorFactory {
1547
+ /**
1548
+ * This function returns a BaseInteractor object based on the type of context passed in (SVGElement or HTMLCanvasElement).
1549
+ *
1550
+ * @param {SVGElement | HTMLCanvasElement} context - The `context` parameter is either an SVGElement
1551
+ * or an HTMLCanvasElement. It is used to determine which type of interactor to create and return. If
1552
+ * the context is an SVGElement, an instance of SVGInteractor is returned. If the context is an
1553
+ * HTMLCanvasElement, an instance of
1554
+ * @returns {BaseInteractor<SVGElement | HTMLCanvasElement>} A `BaseInteractor` object that is either an instance of `SVGInteractor` or
1555
+ * `CanvasInteractor`, depending on the type of the `context` parameter passed to the `get` method.
1556
+ */
1557
+ static get(context) {
1558
+ if (context instanceof SVGElement) {
1559
+ return new SVGInteractor(context);
1560
+ }
1561
+ else if (context instanceof HTMLCanvasElement) {
1562
+ return new CanvasInteractor(context);
1563
+ }
1564
+ else {
1565
+ throw new Error('Invalid context');
1566
+ }
1567
+ }
1568
+ }
1569
+
1570
+ /** This is a TypeScript class called `BaseChart` that serves as a base class for creating charts */
1571
+ class BaseChart {
1572
+ /**
1573
+ * This is a constructor function that initializes a chart with options and creates a chain of drawers for rendering.
1574
+ *
1575
+ * @param {ChartOptions<unknown>} options - generic type that represents the configuration options for the chart
1576
+ */
1577
+ constructor(options) {
1578
+ this.options = options;
1579
+ this.isLayoutSet = false;
1580
+ this.drawers = [];
1581
+ const context = GraphContextFactory.get(options.mode, options.container.shadowRoot ? options.container.shadowRoot : options.container);
1582
+ this.dimensionController = new ChartDimensionController(options.container);
1583
+ this.renderer = RendererFactory.get(context);
1584
+ this.interactor = InteractorFactory.get(context);
1585
+ this.initLayoutOptions(options);
1586
+ }
1587
+ /**
1588
+ * The function clears the renderer.
1589
+ */
1590
+ clear() {
1591
+ this.renderer.clear();
1592
+ }
1593
+ /**
1594
+ * This function updates the chart options, creates a new drawer chain, resets the layout, and renders the chart.
1595
+ *
1596
+ * @param {ChartOptions<unknown>} options - ChartOptions<T> is a generic type that represents the configuration options for a
1597
+ * chart. It can include properties such as the chart type, data, labels, colors, and other stylingoptions
1598
+ */
1599
+ updateOptions(options) {
1600
+ this.initLayoutOptions(options);
1601
+ this.isLayoutSet = false;
1602
+ this.render();
1603
+ }
1604
+ /**
1605
+ * re render the chart using existing options
1606
+ */
1607
+ reRender() {
1608
+ this.updateOptions(this.options);
1609
+ }
1610
+ /**
1611
+ * sets the layout if it hasn't been set yet, and executes all the drawers. unregister the interactor by drawer
1612
+ */
1613
+ render() {
1614
+ this.unregisterByDrawer();
1615
+ this.drawers = this.createDrawerChain(this.renderer, this.interactor);
1616
+ this.clear();
1617
+ if (!this.isLayoutSet) {
1618
+ this.setLayout();
1619
+ this.isLayoutSet = true;
1620
+ }
1621
+ this.drawers.forEach((drawer) => drawer.execute());
1622
+ }
1623
+ /**
1624
+ * sets the layout of a renderer using the options provided.
1625
+ */
1626
+ setLayout() {
1627
+ const layout = this.options.layout;
1628
+ const width = this.dimensionController.getContainerClientWidth(layout), height = this.dimensionController.getContainerClientHeight(layout), margin = (layout === null || layout === void 0 ? void 0 : layout.margin) || DEFAULT_LAYOUT.margin;
1629
+ this.renderer.setLayout(width, height, margin.top, margin.left);
1630
+ }
1631
+ /**
1632
+ * This function initializes layout options for a chart.
1633
+ *
1634
+ * @param {ChartOptions} options - ChartOptions<T> is a generic type that represents the configuration options for a
1635
+ * chart. It includes properties such as data, layout, and style.
1636
+ */
1637
+ initLayoutOptions(options) {
1638
+ const newLayout = this.dimensionController.mergeLayout(options.container.tagName, options.layout, options.legends && options.legends.length ? true : false);
1639
+ this.options = Object.assign(options, { layout: newLayout });
1640
+ this.dimensionController.setContainerWidthAndHeight(newLayout);
1641
+ this.options.container.style.display = 'block';
1642
+ }
1643
+ /**
1644
+ * This function un-registers drawers from the interactor.
1645
+ */
1646
+ unregisterByDrawer() {
1647
+ if (this.drawers) {
1648
+ this.drawers.forEach((drawer) => {
1649
+ this.interactor.unregisterByDrawer(drawer);
1650
+ });
1651
+ }
1652
+ }
1653
+ }
1654
+
1655
+ /* This file is generated by vega-design 2.0.77 */
1656
+ /* eslint-disable */
1657
+ /* tslint:disable */
1658
+ // prettier-ignore
1659
+ const BackgroundColorsMappingLight = {
1660
+ "bg-brand": "#33393D",
1661
+ "bg-page": "#F0F3F7",
1662
+ "bg-primary": "#FCFCFC",
1663
+ "bg-secondary": "#F5F7F7",
1664
+ "bg-tertiary": "#F0F3F7",
1665
+ "bg-quaternary": "#F1F8FB",
1666
+ "bg-inverted-primary": "#04041C",
1667
+ "bg-inverted-secondary": "#121227",
1668
+ "bg-inverted-tertiary": "#181830",
1669
+ "bg-inverted-quaternary": "#464765",
1670
+ "bg-action": "#1362E2",
1671
+ "bg-action-hover": "#0470EC",
1672
+ "bg-action-focus": "#1362E2",
1673
+ "bg-action-active": "#1D41C3",
1674
+ "bg-action-quaternary": "#DEE1E3",
1675
+ "bg-action-quaternary-hover": "#EFEFEF",
1676
+ "bg-action-quaternary-active": "#CDD1D3",
1677
+ "bg-action-secondary": "#FCFCFC",
1678
+ "bg-action-secondary-hover": "#0470EC",
1679
+ "bg-action-secondary-active": "#1D41C3",
1680
+ "bg-action-tertiary": "#000000",
1681
+ "bg-action-tertiary-hover": "#04041C",
1682
+ "bg-action-tertiary-active": "#04041C",
1683
+ "bg-app-header": "#F0F3F7",
1684
+ "bg-backdrop-modal": "#121227",
1685
+ "bg-backdrop-popover": "#203645",
1686
+ "bg-backdrop-sidebar": "#121227",
1687
+ "bg-chip": "#203645",
1688
+ "bg-chip-hover": "#203645",
1689
+ "bg-chip-active": "#203645",
1690
+ "bg-danger": "#BD2947",
1691
+ "bg-danger-hover": "#E94768",
1692
+ "bg-danger-focus": "#BD2947",
1693
+ "bg-danger-active": "#E63257",
1694
+ "bg-danger-tertiary": "#000000",
1695
+ "bg-danger-tertiary-hover": "#FF5772",
1696
+ "bg-danger-tertiary-active": "#BD2947",
1697
+ "bg-disabled": "#B0B4B5",
1698
+ "bg-divider": "#ABC6D8",
1699
+ "bg-divider-secondary": "#C7D9E5",
1700
+ "bg-keypad-btn-active": "#E5EFFF",
1701
+ "bg-loading-progress": "#99C0FF",
1702
+ "bg-loading-track": "#E5EFFF",
1703
+ "bg-segment-hover": "#CDD1D3",
1704
+ "bg-segment-control": "#596063",
1705
+ "bg-selected": "#0097FF",
1706
+ "bg-sidebar": "#121227",
1707
+ "bg-sidebar-icon": "#BCBAD5",
1708
+ "bg-sidebar-icon-hover": "#121227",
1709
+ "bg-sidebar-icon-selected": "#FCFCFC",
1710
+ "bg-sidebar-item-hover": "#FCFCFC",
1711
+ "bg-sidebar-item-selected": "#1362E2",
1712
+ "bg-site-footer": "#33393D",
1713
+ "bg-site-footer-action": "#ABC6D8",
1714
+ "bg-site-footer-action-hover": "#C7D9E5",
1715
+ "bg-site-footer-action-active": "#8FB3CB",
1716
+ "bg-site-footer-field": "#596063",
1717
+ "bg-slider-handle": "#FCFCFC",
1718
+ "bg-status-error": "#FF6E8B",
1719
+ "bg-status-info": "#CDD1D3",
1720
+ "bg-status-success": "#A0E9A7",
1721
+ "bg-status-warning": "#FFDC83",
1722
+ "bg-tab": "#F0F3F7",
1723
+ "bg-tab-hover": "#F5F7F7",
1724
+ "bg-tab-selected": "#203645",
1725
+ "bg-table-alt-row": "#F5F7F7",
1726
+ "bg-table-header": "#F0F3F7",
1727
+ "bg-table-row-hover": "#F1F8FB",
1728
+ "bg-table-row-selected-expanded": "#E5EFFF",
1729
+ "bg-table-selected-row": "#CCDFFF",
1730
+ "bg-textarea-count": "#04041C",
1731
+ "bg-tile": "#FCFCFC",
1732
+ "bg-tile-hover": "#F5F7F7",
1733
+ "bg-tile-selected": "#F2F7FF",
1734
+ "bg-tile-selected-hover": "#E5EFFF",
1735
+ "bg-toggle-switch": "#6B747D",
1736
+ "bg-toggle-switch-hover": "#6B747D",
1737
+ "bg-toggle-switch-selected-disabled": "#99C0FF",
1738
+ "bg-transparent": "#000000",
1739
+ "bg-accent1-primary": "#73E6DC",
1740
+ "bg-accent1-secondary": "#C1F4EF",
1741
+ "bg-accent1-tertiary": "#E0F9F7",
1742
+ "bg-accent2-primary": "#806BFF",
1743
+ "bg-accent2-secondary": "#C7BDFF",
1744
+ "bg-accent2-tertiary": "#E3DEFF",
1745
+ "bg-accent3-primary": "#FFDC83",
1746
+ "bg-accent3-secondary": "#FFEFC8",
1747
+ "bg-accent3-tertiary": "#FFF7E3",
1748
+ "bg-accent4-primary": "#FF9571",
1749
+ "bg-accent4-secondary": "#FFD0C0",
1750
+ "bg-accent4-tertiary": "#FFE7DF",
1751
+ "bg-accent5-primary": "#00BBFF",
1752
+ "bg-accent5-secondary": "#8EDFF9",
1753
+ "bg-accent5-tertiary": "#E3F7FD",
1754
+ "bg-accent6-primary": "#FF82C9",
1755
+ "bg-accent6-secondary": "#FFC7E7",
1756
+ "bg-accent6-tertiary": "#FFE3F3",
1757
+ "bg-accent7-primary": "#259F9F",
1758
+ "bg-accent7-secondary": "#9BD4D6",
1759
+ "bg-accent7-tertiary": "#D0EFEF",
1760
+ "bg-accent8-primary": "#563D82",
1761
+ "bg-accent8-secondary": "#C7A2CC",
1762
+ "bg-accent8-tertiary": "#E6D6EA",
1763
+ "bg-accent9-primary": "#FFBF3F",
1764
+ "bg-accent9-secondary": "#FED78E",
1765
+ "bg-accent9-tertiary": "#FBE2B9",
1766
+ "bg-accent10-primary": "#ED7A23",
1767
+ "bg-accent10-secondary": "#F19255",
1768
+ "bg-accent10-tertiary": "#F5BB94",
1769
+ "bg-date-picker-range": "#E5EFFF"
1770
+ };
1771
+
1772
+ const CHART_DEFAULT_COLORS = [
1773
+ 'bg-accent1-primary',
1774
+ 'bg-accent2-primary',
1775
+ 'bg-accent3-primary',
1776
+ 'bg-accent4-primary',
1777
+ 'bg-accent5-primary',
1778
+ 'bg-accent6-primary',
1779
+ 'bg-accent7-primary',
1780
+ 'bg-accent8-primary',
1781
+ 'bg-accent9-primary',
1782
+ 'bg-accent10-primary',
1783
+ ];
1784
+ const DEFAULT_FONT_FAMILY = 'font-family:"Inter", sans-serif;';
1785
+ const FONTSTYLEMAPPING = Object.keys(typography.Typography).reduce((result, key) => {
1786
+ result[key] =
1787
+ DEFAULT_FONT_FAMILY +
1788
+ typography.Typography[key].filter((str) => str.indexOf('@apply') < 0).join(';');
1789
+ return result;
1790
+ }, { 'v-text-secondary': `color:rgba(107, 116, 125, 1);` });
1791
+ /**
1792
+ * base drawer that provides a common structure for drawing charts using a renderer and options.
1793
+ */
1794
+ class BaseDrawer {
1795
+ /**
1796
+ * This is a constructor function that takes in a renderer and options for a chart drawer.
1797
+ *
1798
+ * @param {BaseRenderer<SVGElement | HTMLCanvasElement>} renderer - `renderer` parameter is an instance of a `BaseRenderer` class that can render either SVG elements or a 2D canvas context
1799
+ * @param {BaseInteractor<SVGElement | HTMLCanvasElement>} interactor - `renderer` parameter is an instance of a `BaseInteractor` class
1800
+ * @param {ChartDrawerOptions<unknown>} options - where `T` is a generic type parameter. This parameter contains various options that can be used to customize the chart being drawn
1801
+ */
1802
+ constructor(renderer, interactor, options) {
1803
+ this.renderer = renderer;
1804
+ this.interactor = interactor;
1805
+ this.options = options;
1806
+ }
1807
+ /**
1808
+ * The function executes a draw method.
1809
+ */
1810
+ execute() {
1811
+ const drawPiece = this.draw();
1812
+ this.drawPiece = drawPiece;
1813
+ this.addInteractionSupport(drawPiece);
1814
+ }
1815
+ /**
1816
+ * returns a color token based on an index and an optional array of colors.
1817
+ *
1818
+ * @param {number} index - The index parameter is a number that represents the index of the color to be returned from the colors array.
1819
+ * @param {BackgroundColorsTokenType[]} [colors] - `colors` is an optional parameter of type `BackgroundColorsTokenType[]`
1820
+ * @returns {BackgroundColorsTokenType} color token
1821
+ */
1822
+ getColorByIndex(index, colors) {
1823
+ colors = colors && colors.length ? colors : CHART_DEFAULT_COLORS;
1824
+ index = index % colors.length;
1825
+ return colors[index];
1826
+ }
1827
+ /**
1828
+ * This function takes a token representing a background color and returns the corresponding color value from a predefined mapping.
1829
+ *
1830
+ * @param {BackgroundColorsTokenType} token - a string representing the token for a background color
1831
+ * @returns {string} The string value returned is the color code
1832
+ */
1833
+ getColorFromToken(token) {
1834
+ return BackgroundColorsMappingLight[token];
1835
+ }
1836
+ /**
1837
+ * The function takes a token as input and returns the corresponding CSS style text from a predefined mapping.
1838
+ *
1839
+ * @param {string} token - The `token` parameter is a string that represents a specific style mapping
1840
+ * in the `FONTSTYLEMAPPING` object. The function returns the CSS style text associated with the given `token`.
1841
+ * @returns {string} a string that represents the CSS style associated with the input token. If the input token
1842
+ * matches a key in the `FONTSTYLEMAPPING` object, the corresponding CSS style string is returned.
1843
+ */
1844
+ getStyleTextFromToken(token) {
1845
+ return token
1846
+ .split(' ')
1847
+ .map((item) => FONTSTYLEMAPPING[item])
1848
+ .join(';');
1849
+ }
1850
+ }
1851
+
1852
+ /** The code is defining an abstract class called `InteractingEntryGenerator` with a generic type `T`. This class is responsible for generating an `InteractingEntry` object based on the provided options. */
1853
+ class InteractingEntryGenerator {
1854
+ /**
1855
+ * The function generates an InteractingEntry object based on the provided options.
1856
+ *
1857
+ * @param {unknown} options - The `options` parameter is a generic type `T` that represents the options or configuration for the `generate` function. It can be any type that you define when calling the `generate` function.
1858
+ * @returns {InteractingEntry} An object of type InteractingEntry is being returned.
1859
+ */
1860
+ generate(options) {
1861
+ return {
1862
+ eventType: this.eventType,
1863
+ shouldHandle: this.createShouldHandle(options),
1864
+ handle: this.createHandle(options),
1865
+ };
1866
+ }
1867
+ }
1868
+
1869
+ /** The PieLegendHoverGenerator class generates an InteractingEntry object that handles mouseover events on a legend of a D3 pie chart and triggers a mouseover event on the corresponding path element. */
1870
+ class PieLegendHoverGenerator extends InteractingEntryGenerator {
1871
+ constructor() {
1872
+ super(...arguments);
1873
+ this.eventType = 'mouseover';
1874
+ }
1875
+ /**
1876
+ * The function "createShouldHandle" returns a function that takes an event as a parameter and returns a boolean value.
1877
+ *
1878
+ * @returns {InteractingEntry['shouldHandle']} A function that takes an event as an argument and returns a boolean value.
1879
+ */
1880
+ createShouldHandle() {
1881
+ return this.shouldHandle;
1882
+ }
1883
+ /**
1884
+ * The function "createHandle" returns the handle property of an InteractingEntry object.
1885
+ *
1886
+ * @param {LegendInputType} options the legend render options
1887
+ * @returns {InteractingEntry['handle']} The `handle` property of the `InteractingEntry` object is being returned.
1888
+ */
1889
+ createHandle(options) {
1890
+ // eslint-disable-next-line jsdoc/require-jsdoc
1891
+ return (event) => {
1892
+ this.handle(event, options);
1893
+ };
1894
+ }
1895
+ /**
1896
+ * This function checks if a mouse event should be handled based on whether the target or its parent element has a specific class.
1897
+ *
1898
+ * @param {MouseEvent} event - MouseEvent is a type of event that is triggered by a mouse action, such
1899
+ * as clicking, hovering, or scrolling. It contains information about the event, such as the target
1900
+ * element and the position of the mouse.
1901
+ * @returns {boolean} A boolean value is being returned. The method `shouldHandle` checks if the target element
1902
+ * or its parent element has a class of `vega-chart-legend-item` and returns `true` if it does, and
1903
+ * `false` otherwise.
1904
+ */
1905
+ shouldHandle(event) {
1906
+ var _a;
1907
+ const target = event.target;
1908
+ const currentTarget = event.currentTarget;
1909
+ const container = currentTarget.parentElement && currentTarget.parentElement.nodeType !== 11
1910
+ ? currentTarget.parentElement
1911
+ : currentTarget.parentNode['host'];
1912
+ return (container.tagName === 'VEGA-PIE-CHART' &&
1913
+ (target.classList.contains('vega-chart-legend-item') ||
1914
+ !!((_a = target.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('vega-chart-legend-item'))));
1915
+ }
1916
+ /**
1917
+ * The function handles a mouse event on a legend and triggers a mouseover event on the corresponding path element in a D3 chart.
1918
+ *
1919
+ * @param {MouseEvent} event - The event parameter is a MouseEvent, which represents a user action
1920
+ * (such as a click or hover) on a specific element in the DOM.
1921
+ * @param {LegendInputType} options - LegendInputType is a custom type that likely contains
1922
+ * information about the data being displayed in the chart, such as the names of the categories or
1923
+ * series being plotted. It may also include information about the chart's appearance or behavior,
1924
+ * such as the colors or labels used in the legend. Without more information about
1925
+ */
1926
+ handle(event, options) {
1927
+ var _a;
1928
+ const svgSelection = select(event.currentTarget);
1929
+ const target = event.target;
1930
+ const targetTextNode = target.tagName === 'text'
1931
+ ? target
1932
+ : target.tagName === 'circle'
1933
+ ? target.nextElementSibling
1934
+ : target.querySelector('text');
1935
+ const name = targetTextNode ? targetTextNode.textContent : '';
1936
+ const index = name ? options.data.indexOf(name) : 0;
1937
+ const paths = svgSelection
1938
+ .selectAll(`path.vega-chart-arc-path`)
1939
+ .nodes();
1940
+ (_a = paths[index]) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
1941
+ }
1942
+ }
1943
+
1944
+ /** The LegendDrawer class draws circles and text for each legend in a chart. */
1945
+ class LegendDrawer extends BaseDrawer {
1946
+ constructor() {
1947
+ super(...arguments);
1948
+ this.pieLegendHoverGenerator = new PieLegendHoverGenerator();
1949
+ }
1950
+ /**
1951
+ * This function adds interaction support to a chart by registering it with an interactor and providing a hover generator.
1952
+ *
1953
+ * @param {(SVGGElement | HTMLCanvasElement)[]} drawPiece - `drawPiece` is a parameter of type array
1954
+ * that contains either `SVGGElement` or `HTMLCanvasElement` elements. It is used as a callback
1955
+ * function to draw the legend items on the chart.
1956
+ */
1957
+ addInteractionSupport(drawPiece) {
1958
+ var _a;
1959
+ if ((_a = this.options.renderOptions.data) === null || _a === void 0 ? void 0 : _a.length) {
1960
+ this.interactor.register(this, drawPiece, this.pieLegendHoverGenerator.generate(this.options.renderOptions));
1961
+ }
1962
+ }
1963
+ /**
1964
+ * This function draws a legend on a chart using input options.
1965
+ *
1966
+ * @returns {(SVGGElement | HTMLCanvasElement)[] | undefined} draw piece
1967
+ */
1968
+ draw() {
1969
+ const { data = [], colors, position, width } = this.options.renderOptions;
1970
+ const options = this.getChartLegendOptions(data, colors, position);
1971
+ if (options) {
1972
+ const longestLegendLength = array.getLongestTextLengthFromArray(data);
1973
+ return options.legends.map((legend, index) => {
1974
+ const position = this.getLegendPosition(options.position, index, longestLegendLength, width);
1975
+ return this.renderer.drawLegend(position, legend.field, legend.color, this.getStyleTextFromToken('v-font-footnote2-short'));
1976
+ });
1977
+ }
1978
+ }
1979
+ /**
1980
+ * This function takes in an array of strings and an optional position parameter, and returns an object containing legend options for a chart.
1981
+ *
1982
+ * @param {string[]} data - an array of strings representing the legend labels
1983
+ * @param {BackgroundColorsTokenType[]} [colors] - bg color token array
1984
+ * @param {ChartPosition} [position] - The `position` parameter is an optional parameter of type
1985
+ * `ChartPosition` which specifies the x and y coordinates of the chart legend on the chart. If it is
1986
+ * not provided, the default position is `{x: 10, y: 0}`.
1987
+ * @returns {ChartLegendOptions | undefined} an object of type `ChartLegendOptions`.
1988
+ */
1989
+ getChartLegendOptions(data, colors, position) {
1990
+ if (data && data.length) {
1991
+ position = position ? Object.assign({ x: 10, y: 0 }, position) : { x: 10, y: 0 };
1992
+ const legendsMap = {
1993
+ position,
1994
+ legends: data.map((text, index) => {
1995
+ return {
1996
+ field: text,
1997
+ color: this.getColorFromToken(this.getColorByIndex(index, colors)),
1998
+ icon: '',
1999
+ };
2000
+ }),
2001
+ };
2002
+ return legendsMap;
2003
+ }
2004
+ }
2005
+ /**
2006
+ * This function calculates the position of a legend on a chart based on its index and the chart layout.
2007
+ *
2008
+ * @param {ChartPosition} position - The initial position of the legend on the chart, with x and y coordinates.
2009
+ * @param {number} index - The index parameter is a number that represents the index of the legend item in the array of legends. It is used to calculate the position of the legend item on the chart.
2010
+ * @param {number} longestTextLength - text length
2011
+ * @param {number} width - chart width
2012
+ * @returns {ChartPosition} an object of type `ChartPosition` with `x` and `y` properties.
2013
+ */
2014
+ getLegendPosition(position, index, longestTextLength, width) {
2015
+ const maxWidth = width;
2016
+ if (maxWidth) {
2017
+ const restWidth = maxWidth - position.x;
2018
+ const singleWidth = longestTextLength * 7 + 24;
2019
+ const singleHeight = 18;
2020
+ const column = Math.max(Number((restWidth / singleWidth).toFixed(0)), 1);
2021
+ const row = parseInt((index / column).toString());
2022
+ const x = position.x + singleWidth * (index % column);
2023
+ const y = position.y + row * singleHeight;
2024
+ return { x, y };
2025
+ }
2026
+ return { x: 0, y: 0 };
2027
+ }
2028
+ }
2029
+
2030
+ /** The LayoutInputProcessor class processes input chart options to calculate layout dimensions and margins. */
2031
+ class LayoutInputProcessor {
2032
+ /**
2033
+ * This function processes chart options and returns layout dimensions and margins.
2034
+ *
2035
+ * @param {ChartOptions<unknown>} input - A ChartOptions object containing the container and layout properties.
2036
+ * @returns {LayoutProcessResultType} An object with properties `width`, `height`, `innerWidth`, `innerHeight`, `top`, `right`,
2037
+ * `bottom`, and `left`.
2038
+ */
2039
+ process(input) {
2040
+ const { container, layout } = input;
2041
+ const { top, right, bottom, left } = ((layout === null || layout === void 0 ? void 0 : layout.margin) ||
2042
+ DEFAULT_LAYOUT.margin);
2043
+ const dimensionController = new ChartDimensionController(container);
2044
+ return {
2045
+ width: dimensionController.getContainerClientWidth(layout),
2046
+ height: dimensionController.getContainerClientHeight(layout),
2047
+ innerWidth: dimensionController.getContainerInnerWidth(layout),
2048
+ innerHeight: dimensionController.getContainerInnerHeight(layout),
2049
+ top,
2050
+ right,
2051
+ bottom,
2052
+ left,
2053
+ };
2054
+ }
2055
+ }
2056
+
2057
+ /** The `ProcessorChain` class takes an array of input processors, processes input through them, and returns the final output. */
2058
+ class ProcessorChain {
2059
+ /**
2060
+ * This is a constructor function that takes an array of input processors as a parameter.
2061
+ *
2062
+ * @param {InputProcessor<unknown, unknown, unknown>[]} processors - The `processors` parameter is a
2063
+ * private property of the class that is of type `InputProcessor` which is an interface that takes
2064
+ * three type parameters - `Input`, `Output`, and `Context`. It is an array of instances of classes
2065
+ * that implement the `InputProcessor` interface. These processors are
2066
+ */
2067
+ constructor(processors) {
2068
+ this.processors = processors;
2069
+ }
2070
+ /**
2071
+ * This function processes input through a series of processors and returns the final output.
2072
+ *
2073
+ * @typedef T generic type
2074
+ * @param {unknown} input - The input parameter is of type unknown, which means it can be any type of
2075
+ * value. It is the data that will be processed by the processors.
2076
+ * @returns {T} the output of the last processor in the `this.processors` array.
2077
+ */
2078
+ process(input) {
2079
+ let previousOutput;
2080
+ for (const processor of this.processors) {
2081
+ previousOutput = processor.process(input, previousOutput);
2082
+ }
2083
+ return previousOutput;
2084
+ }
2085
+ }
2086
+
2087
+ /** The `LegendInputProcessor` class processes chart options and previous layout results to generate a legend input object for a line chart. */
2088
+ class LegendInputProcessor {
2089
+ /**
2090
+ * This function takes in chart options and previous layout results, and returns a legend input object with data, colors, position, width, and height properties.
2091
+ *
2092
+ * @param {ChartOptions<LineChartDataType>} input - The input parameter is an object of type ChartOptions that contains the data and
2093
+ * configuration options for a line chart.
2094
+ * @param {LayoutProcessResultType} previousOutput - `previousOutput` is an optional parameter of
2095
+ * type `LayoutProcessResultType` that represents the output of the previous layout process. It is
2096
+ * used to retrieve the width and height of the chart, which are needed to properly position the
2097
+ * legend. If no previous output is provided, the width and height will
2098
+ * @returns {LegendInputType} an object of type `LegendInputType`. The object contains the following properties:
2099
+ * - `data`: an array of legend items
2100
+ * - `colors`: an array of colors used in the chart
2101
+ * - `position`: an object with `x` and `y` properties representing the position of the legend
2102
+ * - `width`: the width of the chart
2103
+ * - `height`: the
2104
+ */
2105
+ process(input, previousOutput) {
2106
+ const { colors, legends = [] } = input;
2107
+ const { width, height } = previousOutput;
2108
+ return {
2109
+ data: legends,
2110
+ colors,
2111
+ position: { x: 10, y: 10 },
2112
+ width,
2113
+ height,
2114
+ };
2115
+ }
2116
+ }
2117
+
2118
+ exports.BaseChart = BaseChart;
2119
+ exports.BaseDrawer = BaseDrawer;
2120
+ exports.InteractingEntryGenerator = InteractingEntryGenerator;
2121
+ exports.LayoutInputProcessor = LayoutInputProcessor;
2122
+ exports.LegendDrawer = LegendDrawer;
2123
+ exports.LegendInputProcessor = LegendInputProcessor;
2124
+ exports.ProcessorChain = ProcessorChain;
2125
+ exports.pie = pie;
2126
+ exports.select = select;