@helpdice/ui 1.7.5 → 1.7.7

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 (304) hide show
  1. package/dist/CurrencyInput/index.js +2981 -0
  2. package/dist/LinearProgress/index.d.ts +2 -0
  3. package/dist/{css-baseline → LinearProgress}/index.js +25 -317
  4. package/dist/LinearProgress/linear-progress.d.ts +9 -0
  5. package/dist/Loadable/index.js +570 -0
  6. package/dist/PhoneInput/index.js +2136 -314
  7. package/dist/Placeholder/index.js +2116 -254
  8. package/dist/auto-complete/index.js +2145 -652
  9. package/dist/avatar/index.js +2119 -333
  10. package/dist/badge/index.js +2117 -331
  11. package/dist/breadcrumbs/index.js +2126 -340
  12. package/dist/button/button.compact.d.ts +2 -0
  13. package/dist/button/index.js +2214 -342
  14. package/dist/button-dropdown/index.js +2120 -291
  15. package/dist/button-group/index.js +2117 -331
  16. package/dist/capacity/index.js +2117 -331
  17. package/dist/card/index.js +2127 -298
  18. package/dist/checkbox/index.js +2119 -290
  19. package/dist/code/index.js +2116 -297
  20. package/dist/collapse/index.js +2117 -475
  21. package/dist/description/index.js +2117 -331
  22. package/dist/display/index.js +2117 -331
  23. package/dist/divider/index.js +2118 -332
  24. package/dist/dot/index.js +2117 -331
  25. package/dist/drawer/index.js +2129 -439
  26. package/dist/fieldset/index.js +2121 -354
  27. package/dist/grid/index.js +2119 -333
  28. package/dist/image/index.js +2122 -336
  29. package/dist/index.d.ts +2 -14
  30. package/dist/index.js +3175 -1879
  31. package/dist/input/index.js +2125 -296
  32. package/dist/keyboard/index.js +2116 -297
  33. package/dist/link/index.js +2117 -331
  34. package/dist/list/index.js +2119 -333
  35. package/dist/loading/index.js +2117 -331
  36. package/dist/menu/index.js +77 -45
  37. package/dist/modal/index.js +2145 -452
  38. package/dist/note/index.js +2117 -331
  39. package/dist/page/index.js +2117 -331
  40. package/dist/pagination/index.js +2118 -351
  41. package/dist/popover/index.js +2123 -354
  42. package/dist/progress/index.js +2117 -331
  43. package/dist/radio/index.js +2120 -334
  44. package/dist/rating/index.js +2118 -332
  45. package/dist/row/index.js +2115 -296
  46. package/dist/select/index.js +2151 -688
  47. package/dist/slider/index.js +2123 -356
  48. package/dist/snippet/index.js +2118 -421
  49. package/dist/spacer/index.js +2115 -296
  50. package/dist/spinner/index.js +2117 -331
  51. package/dist/table/index.js +2341 -754
  52. package/dist/tabs/index.js +2123 -344
  53. package/dist/tag/index.js +2116 -254
  54. package/dist/text/index.js +2116 -297
  55. package/dist/textarea/index.js +2117 -288
  56. package/dist/toggle/index.js +2117 -331
  57. package/dist/tooltip/index.js +2120 -351
  58. package/dist/tree/index.js +2123 -459
  59. package/dist/use-input/index.js +2122 -24
  60. package/dist/use-modal/index.js +2122 -24
  61. package/dist/use-network-status/index.d.ts +2 -0
  62. package/dist/{use-current-state → use-network-status}/index.js +22 -15
  63. package/dist/use-network-status/use-netowork-status.d.ts +4 -0
  64. package/dist/use-scale/index.js +2115 -296
  65. package/dist/use-tabs/index.js +2122 -24
  66. package/dist/user/index.js +2123 -337
  67. package/esm/CurrencyInput/components/CurrencyInput.js +342 -0
  68. package/esm/CurrencyInput/components/CurrencyInputProps.js +1 -0
  69. package/esm/CurrencyInput/components/utils/addSeparators.js +7 -0
  70. package/esm/CurrencyInput/components/utils/cleanValue.js +69 -0
  71. package/esm/CurrencyInput/components/utils/escapeRegExp.js +8 -0
  72. package/esm/CurrencyInput/components/utils/fixedDecimalValue.js +29 -0
  73. package/esm/CurrencyInput/components/utils/formatValue.js +124 -0
  74. package/esm/CurrencyInput/components/utils/getLocaleConfig.js +47 -0
  75. package/esm/CurrencyInput/components/utils/getSuffix.js +10 -0
  76. package/esm/CurrencyInput/components/utils/index.js +8 -0
  77. package/esm/CurrencyInput/components/utils/isNumber.js +3 -0
  78. package/esm/CurrencyInput/components/utils/padTrimValue.js +27 -0
  79. package/esm/CurrencyInput/components/utils/parseAbbrValue.js +43 -0
  80. package/esm/CurrencyInput/components/utils/removeInvalidChars.js +10 -0
  81. package/esm/CurrencyInput/components/utils/removeSeparators.js +10 -0
  82. package/esm/CurrencyInput/components/utils/repositionCursor.js +35 -0
  83. package/esm/CurrencyInput/index.js +4 -0
  84. package/esm/LinearProgress/index.d.ts +2 -0
  85. package/esm/LinearProgress/index.js +2 -0
  86. package/esm/LinearProgress/linear-progress.d.ts +9 -0
  87. package/esm/LinearProgress/linear-progress.js +28 -0
  88. package/esm/Loadable/index.js +2 -0
  89. package/esm/PhoneInput/phone.js +22 -19
  90. package/esm/auto-complete/auto-complete-dropdown.js +1 -3
  91. package/esm/auto-complete/auto-complete-item.js +1 -3
  92. package/esm/auto-complete/auto-complete-searching.js +1 -1
  93. package/esm/auto-complete/auto-complete.js +1 -1
  94. package/esm/avatar/avatar-group.js +1 -2
  95. package/esm/avatar/avatar.js +1 -2
  96. package/esm/badge/badge.js +1 -2
  97. package/esm/breadcrumbs/breadcrumbs-item.js +1 -1
  98. package/esm/breadcrumbs/breadcrumbs-separator.js +1 -1
  99. package/esm/breadcrumbs/breadcrumbs.js +1 -1
  100. package/esm/button/button-icon.js +1 -1
  101. package/esm/button/button.compact.d.ts +2 -0
  102. package/esm/button/button.compact.js +94 -50
  103. package/esm/button/button.js +1 -2
  104. package/esm/button/utils.js +1 -1
  105. package/esm/button-dropdown/button-dropdown-item.js +1 -1
  106. package/esm/button-dropdown/button-dropdown.js +1 -2
  107. package/esm/button-group/button-group.js +1 -2
  108. package/esm/capacity/capacity.js +1 -2
  109. package/esm/card/card-content.js +1 -1
  110. package/esm/card/card-footer.js +1 -2
  111. package/esm/card/card.js +1 -2
  112. package/esm/carousal/Arrow.js +18 -0
  113. package/esm/carousal/Indicator.js +20 -0
  114. package/esm/carousal/Thumbs.js +302 -0
  115. package/esm/carousal/animations.js +162 -0
  116. package/esm/carousal/index.js +683 -0
  117. package/esm/carousal/types.js +1 -0
  118. package/esm/carousal/utils.js +49 -0
  119. package/esm/checkbox/checkbox-group.js +1 -1
  120. package/esm/checkbox/checkbox.icon.js +1 -1
  121. package/esm/checkbox/checkbox.js +1 -2
  122. package/esm/code/code.js +1 -1
  123. package/esm/collapse/collapse-group.js +1 -2
  124. package/esm/collapse/collapse.js +1 -4
  125. package/esm/description/description.js +1 -2
  126. package/esm/display/display.js +1 -2
  127. package/esm/divider/divider.js +1 -2
  128. package/esm/dot/dot.js +1 -2
  129. package/esm/drawer/drawer-wrapper.js +1 -3
  130. package/esm/drawer/drawer.js +1 -1
  131. package/esm/fieldset/fieldset-content.js +1 -1
  132. package/esm/fieldset/fieldset-footer.js +1 -1
  133. package/esm/fieldset/fieldset-group.js +1 -3
  134. package/esm/fieldset/fieldset-title.js +1 -1
  135. package/esm/fieldset/fieldset.js +1 -2
  136. package/esm/grid/basic-item.js +1 -2
  137. package/esm/grid/grid-container.js +1 -1
  138. package/esm/grid/grid.js +1 -1
  139. package/esm/image/image-browser.js +1 -2
  140. package/esm/image/image.js +1 -2
  141. package/esm/image/image.skeleton.js +1 -1
  142. package/esm/index.d.ts +2 -14
  143. package/esm/index.js +5 -9
  144. package/esm/input/input-block-label.js +1 -1
  145. package/esm/input/input-icon-clear.js +1 -2
  146. package/esm/input/input-label.js +1 -1
  147. package/esm/input/input.js +1 -2
  148. package/esm/keyboard/keyboard.js +1 -1
  149. package/esm/link/link.js +1 -2
  150. package/esm/list/list-item.js +1 -2
  151. package/esm/loading/loading.js +1 -2
  152. package/esm/modal/modal-action.js +1 -2
  153. package/esm/modal/modal-actions.js +1 -1
  154. package/esm/modal/modal-content.js +1 -1
  155. package/esm/modal/modal-subtitle.js +1 -1
  156. package/esm/modal/modal-title.js +1 -1
  157. package/esm/modal/modal-wrapper.js +1 -3
  158. package/esm/modal/modal.js +1 -1
  159. package/esm/note/note.js +1 -2
  160. package/esm/page/page-header.js +1 -1
  161. package/esm/page/page.js +1 -1
  162. package/esm/pagination/pagination-item.js +1 -2
  163. package/esm/pagination/pagination.js +1 -1
  164. package/esm/popover/popover-item.js +1 -2
  165. package/esm/popover/popover.js +1 -1
  166. package/esm/progress/progress.js +1 -2
  167. package/esm/radio/radio-description.js +1 -1
  168. package/esm/radio/radio-group.js +1 -1
  169. package/esm/radio/radio.js +1 -2
  170. package/esm/rating/rating.js +1 -2
  171. package/esm/row/row.js +1 -1
  172. package/esm/select/select-dropdown.js +1 -3
  173. package/esm/select/select-icon-clear.js +1 -1
  174. package/esm/select/select-multiple-value.js +1 -1
  175. package/esm/select/select-option.js +1 -3
  176. package/esm/select/select.js +9 -12
  177. package/esm/slider/slider-dot.js +1 -2
  178. package/esm/slider/slider-mark.js +1 -1
  179. package/esm/slider/slider.js +1 -3
  180. package/esm/snippet/snippet.js +1 -3
  181. package/esm/spinner/spinner.js +1 -2
  182. package/esm/table/table-body.js +1 -2
  183. package/esm/table/table-head.js +3 -2
  184. package/esm/tabs/tabs-item.js +1 -2
  185. package/esm/tabs/tabs.js +1 -3
  186. package/esm/tag/tag.js +1 -1
  187. package/esm/text/child.js +1 -1
  188. package/esm/textarea/textarea.js +1 -2
  189. package/esm/toggle/toggle.js +1 -2
  190. package/esm/tooltip/tooltip-content.js +1 -3
  191. package/esm/tooltip/tooltip-icon.js +1 -1
  192. package/esm/tooltip/tooltip.js +1 -1
  193. package/esm/tree/tree-file-icon.js +1 -1
  194. package/esm/tree/tree-file.js +1 -2
  195. package/esm/tree/tree-folder-icon.js +1 -1
  196. package/esm/tree/tree-folder.js +1 -3
  197. package/esm/tree/tree-status-icon.js +1 -1
  198. package/esm/tree/tree.js +1 -1
  199. package/esm/use-input/use-input.js +1 -1
  200. package/esm/use-modal/use-modal.js +1 -1
  201. package/esm/use-network-status/index.d.ts +2 -0
  202. package/esm/use-network-status/index.js +2 -0
  203. package/esm/use-network-status/use-netowork-status.d.ts +4 -0
  204. package/esm/use-network-status/use-netowork-status.js +29 -0
  205. package/esm/use-scale/with-scale.js +1 -1
  206. package/esm/use-tabs/use-tabs.js +1 -1
  207. package/esm/user/user.js +1 -2
  208. package/esm/utils/use-context-state/use-context-state.js +1 -1
  209. package/esm/utils/use-drag.js +1 -1
  210. package/package.json +12 -4
  211. package/dist/css-baseline/css-baseline.d.ts +0 -9
  212. package/dist/css-baseline/index.d.ts +0 -1
  213. package/dist/shared/backdrop.d.ts +0 -14
  214. package/dist/shared/css-transition.d.ts +0 -13
  215. package/dist/shared/dropdown.d.ts +0 -9
  216. package/dist/shared/ellipsis.d.ts +0 -6
  217. package/dist/shared/expand.d.ts +0 -7
  218. package/dist/shared/highlight.d.ts +0 -13
  219. package/dist/ui-provider/index.d.ts +0 -3
  220. package/dist/ui-provider/index.js +0 -2186
  221. package/dist/ui-provider/theme-provider.d.ts +0 -8
  222. package/dist/ui-provider/ui-provider.d.ts +0 -8
  223. package/dist/use-all-themes/all-themes-context.d.ts +0 -7
  224. package/dist/use-all-themes/index.d.ts +0 -3
  225. package/dist/use-all-themes/index.js +0 -311
  226. package/dist/use-classes/index.d.ts +0 -2
  227. package/dist/use-classes/index.js +0 -48
  228. package/dist/use-classes/use-classes.d.ts +0 -4
  229. package/dist/use-current-state/index.d.ts +0 -2
  230. package/dist/use-current-state/use-current-state.d.ts +0 -4
  231. package/dist/use-media-query/index.d.ts +0 -3
  232. package/dist/use-media-query/index.js +0 -444
  233. package/dist/use-media-query/use-media-query.d.ts +0 -12
  234. package/dist/use-theme/index.d.ts +0 -2
  235. package/dist/use-theme/index.js +0 -309
  236. package/dist/use-theme/theme-context.d.ts +0 -4
  237. package/dist/use-toasts/helpers.d.ts +0 -18
  238. package/dist/use-toasts/index.d.ts +0 -3
  239. package/dist/use-toasts/index.js +0 -204
  240. package/dist/use-toasts/toast-container.d.ts +0 -3
  241. package/dist/use-toasts/toast-item.d.ts +0 -8
  242. package/dist/use-toasts/use-toast.d.ts +0 -40
  243. package/dist/utils/use-current-state.d.ts +0 -2
  244. package/dist/utils/use-dom-observer.d.ts +0 -3
  245. package/dist/utils/use-hd-ui-context.d.ts +0 -16
  246. package/dist/utils/use-previous.d.ts +0 -2
  247. package/esm/captcha/index.js +0 -128
  248. package/esm/css-baseline/css-baseline.d.ts +0 -9
  249. package/esm/css-baseline/css-baseline.js +0 -23
  250. package/esm/css-baseline/index.d.ts +0 -1
  251. package/esm/css-baseline/index.js +0 -2
  252. package/esm/shared/backdrop.d.ts +0 -14
  253. package/esm/shared/backdrop.js +0 -66
  254. package/esm/shared/css-transition.d.ts +0 -13
  255. package/esm/shared/css-transition.js +0 -65
  256. package/esm/shared/dropdown.d.ts +0 -9
  257. package/esm/shared/dropdown.js +0 -99
  258. package/esm/shared/ellipsis.d.ts +0 -6
  259. package/esm/shared/ellipsis.js +0 -13
  260. package/esm/shared/expand.d.ts +0 -7
  261. package/esm/shared/expand.js +0 -86
  262. package/esm/shared/highlight.d.ts +0 -13
  263. package/esm/shared/highlight.js +0 -46
  264. package/esm/ui-provider/index.d.ts +0 -3
  265. package/esm/ui-provider/index.js +0 -4
  266. package/esm/ui-provider/theme-provider.d.ts +0 -8
  267. package/esm/ui-provider/theme-provider.js +0 -45
  268. package/esm/ui-provider/ui-provider.d.ts +0 -8
  269. package/esm/ui-provider/ui-provider.js +0 -55
  270. package/esm/use-all-themes/all-themes-context.d.ts +0 -7
  271. package/esm/use-all-themes/all-themes-context.js +0 -11
  272. package/esm/use-all-themes/index.d.ts +0 -3
  273. package/esm/use-all-themes/index.js +0 -2
  274. package/esm/use-classes/index.d.ts +0 -2
  275. package/esm/use-classes/index.js +0 -2
  276. package/esm/use-classes/use-classes.d.ts +0 -4
  277. package/esm/use-classes/use-classes.js +0 -34
  278. package/esm/use-current-state/index.d.ts +0 -2
  279. package/esm/use-current-state/index.js +0 -2
  280. package/esm/use-current-state/use-current-state.d.ts +0 -4
  281. package/esm/use-current-state/use-current-state.js +0 -23
  282. package/esm/use-media-query/index.d.ts +0 -3
  283. package/esm/use-media-query/index.js +0 -2
  284. package/esm/use-media-query/use-media-query.d.ts +0 -12
  285. package/esm/use-media-query/use-media-query.js +0 -81
  286. package/esm/use-theme/index.d.ts +0 -2
  287. package/esm/use-theme/index.js +0 -2
  288. package/esm/use-theme/theme-context.d.ts +0 -4
  289. package/esm/use-theme/theme-context.js +0 -9
  290. package/esm/use-toasts/helpers.d.ts +0 -18
  291. package/esm/use-toasts/helpers.js +0 -68
  292. package/esm/use-toasts/index.d.ts +0 -3
  293. package/esm/use-toasts/index.js +0 -2
  294. package/esm/use-toasts/toast-container.d.ts +0 -3
  295. package/esm/use-toasts/toast-container.js +0 -120
  296. package/esm/use-toasts/toast-item.d.ts +0 -8
  297. package/esm/use-toasts/toast-item.js +0 -45
  298. package/esm/use-toasts/use-toast.d.ts +0 -40
  299. package/esm/use-toasts/use-toast.js +0 -103
  300. package/esm/utils/use-current-state.d.ts +0 -2
  301. package/esm/utils/use-current-state.js +0 -2
  302. package/esm/utils/use-dom-observer.d.ts +0 -3
  303. package/esm/utils/use-hd-ui-context.d.ts +0 -16
  304. package/esm/utils/use-previous.d.ts +0 -2
@@ -0,0 +1,2981 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var require$$1 = require('react-dom');
7
+
8
+ function _arrayLikeToArray(r, a) {
9
+ (null == a || a > r.length) && (a = r.length);
10
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
11
+ return n;
12
+ }
13
+ function _arrayWithHoles(r) {
14
+ if (Array.isArray(r)) return r;
15
+ }
16
+ function _arrayWithoutHoles(r) {
17
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
18
+ }
19
+ function _defineProperty(e, r, t) {
20
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
21
+ value: t,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ }) : e[r] = t, e;
26
+ }
27
+ function _extends() {
28
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
29
+ for (var e = 1; e < arguments.length; e++) {
30
+ var t = arguments[e];
31
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
32
+ }
33
+ return n;
34
+ }, _extends.apply(null, arguments);
35
+ }
36
+ function _iterableToArray(r) {
37
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
38
+ }
39
+ function _iterableToArrayLimit(r, l) {
40
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
41
+ if (null != t) {
42
+ var e,
43
+ n,
44
+ i,
45
+ u,
46
+ a = [],
47
+ f = true,
48
+ o = false;
49
+ try {
50
+ if (i = (t = t.call(r)).next, 0 === l) {
51
+ if (Object(t) !== t) return;
52
+ f = !1;
53
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
54
+ } catch (r) {
55
+ o = true, n = r;
56
+ } finally {
57
+ try {
58
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
59
+ } finally {
60
+ if (o) throw n;
61
+ }
62
+ }
63
+ return a;
64
+ }
65
+ }
66
+ function _nonIterableRest() {
67
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
68
+ }
69
+ function _nonIterableSpread() {
70
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
+ }
72
+ function ownKeys(e, r) {
73
+ var t = Object.keys(e);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var o = Object.getOwnPropertySymbols(e);
76
+ r && (o = o.filter(function (r) {
77
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
78
+ })), t.push.apply(t, o);
79
+ }
80
+ return t;
81
+ }
82
+ function _objectSpread2(e) {
83
+ for (var r = 1; r < arguments.length; r++) {
84
+ var t = null != arguments[r] ? arguments[r] : {};
85
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
86
+ _defineProperty(e, r, t[r]);
87
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
88
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
89
+ });
90
+ }
91
+ return e;
92
+ }
93
+ function _objectWithoutProperties(e, t) {
94
+ if (null == e) return {};
95
+ var o,
96
+ r,
97
+ i = _objectWithoutPropertiesLoose(e, t);
98
+ if (Object.getOwnPropertySymbols) {
99
+ var n = Object.getOwnPropertySymbols(e);
100
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
101
+ }
102
+ return i;
103
+ }
104
+ function _objectWithoutPropertiesLoose(r, e) {
105
+ if (null == r) return {};
106
+ var t = {};
107
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
108
+ if (-1 !== e.indexOf(n)) continue;
109
+ t[n] = r[n];
110
+ }
111
+ return t;
112
+ }
113
+ function _slicedToArray(r, e) {
114
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
115
+ }
116
+ function _toConsumableArray(r) {
117
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
118
+ }
119
+ function _toPrimitive(t, r) {
120
+ if ("object" != typeof t || !t) return t;
121
+ var e = t[Symbol.toPrimitive];
122
+ if (void 0 !== e) {
123
+ var i = e.call(t, r);
124
+ if ("object" != typeof i) return i;
125
+ throw new TypeError("@@toPrimitive must return a primitive value.");
126
+ }
127
+ return ("string" === r ? String : Number)(t);
128
+ }
129
+ function _toPropertyKey(t) {
130
+ var i = _toPrimitive(t, "string");
131
+ return "symbol" == typeof i ? i : i + "";
132
+ }
133
+ function _unsupportedIterableToArray(r, a) {
134
+ if (r) {
135
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
136
+ var t = {}.toString.call(r).slice(8, -1);
137
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Escape regex char
143
+ *
144
+ * See: https://stackoverflow.com/questions/17885855/use-dynamic-variable-string-as-regex-pattern-in-javascript
145
+ */
146
+ var escapeRegExp = function escapeRegExp(stringToGoIntoTheRegex) {
147
+ return stringToGoIntoTheRegex.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
148
+ };
149
+
150
+ var abbrMap = {
151
+ k: 1000,
152
+ m: 1000000,
153
+ b: 1000000000
154
+ };
155
+
156
+ /**
157
+ * Parse a value with abbreviation e.g 1k = 1000
158
+ */
159
+ var parseAbbrValue = function parseAbbrValue(value) {
160
+ var decimalSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
161
+ var reg = new RegExp("(\\d+(".concat(escapeRegExp(decimalSeparator), "\\d*)?)([kmb])$"), 'i');
162
+ var match = value.match(reg);
163
+ if (match) {
164
+ var _match = _slicedToArray(match, 4),
165
+ digits = _match[1],
166
+ abbr = _match[3];
167
+ var multiplier = abbrMap[abbr.toLowerCase()];
168
+ return Number(digits.replace(decimalSeparator, '.')) * multiplier;
169
+ }
170
+ return undefined;
171
+ };
172
+
173
+ /**
174
+ * Remove group separator from value eg. 1,000 > 1000
175
+ */
176
+ var removeSeparators = function removeSeparators(value) {
177
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
178
+ var reg = new RegExp(escapeRegExp(separator), 'g');
179
+ return value.replace(reg, '');
180
+ };
181
+
182
+ /**
183
+ * Remove invalid characters
184
+ */
185
+ var removeInvalidChars = function removeInvalidChars(value, validChars) {
186
+ var chars = escapeRegExp(validChars.join(''));
187
+ var reg = new RegExp("[^\\d".concat(chars, "]"), 'gi');
188
+ return value.replace(reg, '');
189
+ };
190
+
191
+ /**
192
+ * Remove prefix, separators and extra decimals from value
193
+ */
194
+ var cleanValue = function cleanValue(_ref) {
195
+ var value = _ref.value,
196
+ _ref$groupSeparator = _ref.groupSeparator,
197
+ groupSeparator = _ref$groupSeparator === void 0 ? ',' : _ref$groupSeparator,
198
+ _ref$decimalSeparator = _ref.decimalSeparator,
199
+ decimalSeparator = _ref$decimalSeparator === void 0 ? '.' : _ref$decimalSeparator,
200
+ _ref$allowDecimals = _ref.allowDecimals,
201
+ allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
202
+ _ref$decimalsLimit = _ref.decimalsLimit,
203
+ decimalsLimit = _ref$decimalsLimit === void 0 ? 2 : _ref$decimalsLimit,
204
+ _ref$allowNegativeVal = _ref.allowNegativeValue,
205
+ allowNegativeValue = _ref$allowNegativeVal === void 0 ? true : _ref$allowNegativeVal,
206
+ _ref$disableAbbreviat = _ref.disableAbbreviations,
207
+ disableAbbreviations = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
208
+ _ref$prefix = _ref.prefix,
209
+ prefix = _ref$prefix === void 0 ? '' : _ref$prefix,
210
+ _ref$transformRawValu = _ref.transformRawValue,
211
+ transformRawValue = _ref$transformRawValu === void 0 ? function (rawValue) {
212
+ return rawValue;
213
+ } : _ref$transformRawValu;
214
+ var transformedValue = transformRawValue(value);
215
+ if (transformedValue === '-') {
216
+ return transformedValue;
217
+ }
218
+ var abbreviations = disableAbbreviations ? [] : ['k', 'm', 'b'];
219
+ var reg = new RegExp("((^|\\D)-\\d)|(-".concat(escapeRegExp(prefix), ")"));
220
+ var isNegative = reg.test(transformedValue);
221
+
222
+ // Is there a digit before the prefix? eg. 1$
223
+ var _ref2 = RegExp("(\\d+)-?".concat(escapeRegExp(prefix))).exec(value) || [],
224
+ _ref3 = _slicedToArray(_ref2, 2),
225
+ prefixWithValue = _ref3[0],
226
+ preValue = _ref3[1];
227
+ var withoutPrefix = prefix ? prefixWithValue ? transformedValue.replace(prefixWithValue, '').concat(preValue) : transformedValue.replace(prefix, '') : transformedValue;
228
+ var withoutSeparators = removeSeparators(withoutPrefix, groupSeparator);
229
+ var withoutInvalidChars = removeInvalidChars(withoutSeparators, [groupSeparator, decimalSeparator].concat(abbreviations));
230
+ var valueOnly = withoutInvalidChars;
231
+ if (!disableAbbreviations) {
232
+ // disallow letter without number
233
+ if (abbreviations.some(function (letter) {
234
+ return letter === withoutInvalidChars.toLowerCase().replace(decimalSeparator, '');
235
+ })) {
236
+ return '';
237
+ }
238
+ var parsed = parseAbbrValue(withoutInvalidChars, decimalSeparator);
239
+ if (parsed) {
240
+ valueOnly = String(parsed);
241
+ }
242
+ }
243
+ var includeNegative = isNegative && allowNegativeValue ? '-' : '';
244
+ if (decimalSeparator && valueOnly.includes(decimalSeparator)) {
245
+ var _withoutInvalidChars$ = withoutInvalidChars.split(decimalSeparator),
246
+ _withoutInvalidChars$2 = _slicedToArray(_withoutInvalidChars$, 2),
247
+ _int = _withoutInvalidChars$2[0],
248
+ decimals = _withoutInvalidChars$2[1];
249
+ var trimmedDecimals = decimalsLimit && decimals ? decimals.slice(0, decimalsLimit) : decimals;
250
+ var includeDecimals = allowDecimals ? "".concat(decimalSeparator).concat(trimmedDecimals) : '';
251
+ return "".concat(includeNegative).concat(_int).concat(includeDecimals);
252
+ }
253
+ return "".concat(includeNegative).concat(valueOnly);
254
+ };
255
+
256
+ var fixedDecimalValue = function fixedDecimalValue(value, decimalSeparator, fixedDecimalLength) {
257
+ if (fixedDecimalLength !== undefined && value.length > 1) {
258
+ if (fixedDecimalLength === 0) {
259
+ return value.replace(decimalSeparator, '');
260
+ }
261
+ if (value.includes(decimalSeparator)) {
262
+ var _value$split = value.split(decimalSeparator),
263
+ _value$split2 = _slicedToArray(_value$split, 2),
264
+ _int = _value$split2[0],
265
+ decimals = _value$split2[1];
266
+ if (decimals.length === fixedDecimalLength) {
267
+ return value;
268
+ }
269
+ if (decimals.length > fixedDecimalLength) {
270
+ return "".concat(_int).concat(decimalSeparator).concat(decimals.slice(0, fixedDecimalLength));
271
+ }
272
+ }
273
+ var reg = value.length > fixedDecimalLength ? new RegExp("(\\d+)(\\d{".concat(fixedDecimalLength, "})")) : new RegExp("(\\d)(\\d+)");
274
+ var match = value.match(reg);
275
+ if (match) {
276
+ var _match = _slicedToArray(match, 3),
277
+ _int2 = _match[1],
278
+ _decimals = _match[2];
279
+ return "".concat(_int2).concat(decimalSeparator).concat(_decimals);
280
+ }
281
+ }
282
+ return value;
283
+ };
284
+
285
+ var getSuffix = function getSuffix(value, _ref) {
286
+ var _ref$groupSeparator = _ref.groupSeparator,
287
+ groupSeparator = _ref$groupSeparator === void 0 ? ',' : _ref$groupSeparator,
288
+ _ref$decimalSeparator = _ref.decimalSeparator,
289
+ decimalSeparator = _ref$decimalSeparator === void 0 ? '.' : _ref$decimalSeparator;
290
+ var suffixReg = new RegExp("\\d([^".concat(escapeRegExp(groupSeparator)).concat(escapeRegExp(decimalSeparator), "0-9]+)"));
291
+ var suffixMatch = value.match(suffixReg);
292
+ return suffixMatch ? suffixMatch[1] : undefined;
293
+ };
294
+
295
+ /**
296
+ * Format value with decimal separator, group separator and prefix
297
+ */
298
+ var formatValue = function formatValue(options) {
299
+ var _value = options.value,
300
+ decimalSeparator = options.decimalSeparator,
301
+ intlConfig = options.intlConfig,
302
+ decimalScale = options.decimalScale,
303
+ _options$prefix = options.prefix,
304
+ prefix = _options$prefix === void 0 ? '' : _options$prefix,
305
+ _options$suffix = options.suffix,
306
+ suffix = _options$suffix === void 0 ? '' : _options$suffix;
307
+ if (_value === '' || _value === undefined) {
308
+ return '';
309
+ }
310
+ if (_value === '-') {
311
+ return '-';
312
+ }
313
+ var isNegative = new RegExp("^\\d?-".concat(prefix ? "".concat(escapeRegExp(prefix), "?") : '', "\\d")).test(_value);
314
+ var value = decimalSeparator !== '.' ? replaceDecimalSeparator(_value, decimalSeparator, isNegative) : _value;
315
+ if (decimalSeparator && decimalSeparator !== '-' && value.startsWith(decimalSeparator)) {
316
+ value = '0' + value;
317
+ }
318
+ var defaultNumberFormatOptions = {
319
+ minimumFractionDigits: decimalScale || 0,
320
+ maximumFractionDigits: 20
321
+ };
322
+ var numberFormatter = intlConfig ? new Intl.NumberFormat(intlConfig.locale, intlConfig.currency ? _objectSpread2(_objectSpread2({}, defaultNumberFormatOptions), {}, {
323
+ style: 'currency',
324
+ currency: intlConfig.currency
325
+ }) : defaultNumberFormatOptions) : new Intl.NumberFormat(undefined, defaultNumberFormatOptions);
326
+ var parts = numberFormatter.formatToParts(Number(value));
327
+ var formatted = replaceParts(parts, options);
328
+
329
+ // Does intl formatting add a suffix?
330
+ var intlSuffix = getSuffix(formatted, _objectSpread2({}, options));
331
+
332
+ // Include decimal separator if user input ends with decimal separator
333
+ var includeDecimalSeparator = _value.slice(-1) === decimalSeparator ? decimalSeparator : '';
334
+ var _ref = value.match(RegExp('\\d+\\.(\\d+)')) || [],
335
+ _ref2 = _slicedToArray(_ref, 2),
336
+ decimals = _ref2[1];
337
+
338
+ // Keep original decimal padding if no decimalScale
339
+ if (decimalScale === undefined && decimals && decimalSeparator) {
340
+ if (formatted.includes(decimalSeparator)) {
341
+ formatted = formatted.replace(RegExp("(\\d+)(".concat(escapeRegExp(decimalSeparator), ")(\\d+)"), 'g'), "$1$2".concat(decimals));
342
+ } else {
343
+ if (intlSuffix && !suffix) {
344
+ formatted = formatted.replace(intlSuffix, "".concat(decimalSeparator).concat(decimals).concat(intlSuffix));
345
+ } else {
346
+ formatted = "".concat(formatted).concat(decimalSeparator).concat(decimals);
347
+ }
348
+ }
349
+ }
350
+ if (suffix && includeDecimalSeparator) {
351
+ return "".concat(formatted).concat(includeDecimalSeparator).concat(suffix);
352
+ }
353
+ if (intlSuffix && includeDecimalSeparator) {
354
+ return formatted.replace(intlSuffix, "".concat(includeDecimalSeparator).concat(intlSuffix));
355
+ }
356
+ if (intlSuffix && suffix) {
357
+ return formatted.replace(intlSuffix, "".concat(includeDecimalSeparator).concat(suffix));
358
+ }
359
+ return [formatted, includeDecimalSeparator, suffix].join('');
360
+ };
361
+
362
+ /**
363
+ * Before converting to Number, decimal separator has to be .
364
+ */
365
+ var replaceDecimalSeparator = function replaceDecimalSeparator(value, decimalSeparator, isNegative) {
366
+ var newValue = value;
367
+ if (decimalSeparator && decimalSeparator !== '.') {
368
+ newValue = newValue.replace(RegExp(escapeRegExp(decimalSeparator), 'g'), '.');
369
+ if (isNegative && decimalSeparator === '-') {
370
+ newValue = "-".concat(newValue.slice(1));
371
+ }
372
+ }
373
+ return newValue;
374
+ };
375
+ var replaceParts = function replaceParts(parts, _ref3) {
376
+ var prefix = _ref3.prefix,
377
+ groupSeparator = _ref3.groupSeparator,
378
+ decimalSeparator = _ref3.decimalSeparator,
379
+ decimalScale = _ref3.decimalScale,
380
+ _ref3$disableGroupSep = _ref3.disableGroupSeparators,
381
+ disableGroupSeparators = _ref3$disableGroupSep === void 0 ? false : _ref3$disableGroupSep;
382
+ return parts.reduce(function (prev, _ref4, i) {
383
+ var type = _ref4.type,
384
+ value = _ref4.value;
385
+ if (i === 0 && prefix) {
386
+ if (type === 'minusSign') {
387
+ return [value, prefix];
388
+ }
389
+ if (type === 'currency') {
390
+ return [].concat(_toConsumableArray(prev), [prefix]);
391
+ }
392
+ return [prefix, value];
393
+ }
394
+ if (type === 'currency') {
395
+ return prefix ? prev : [].concat(_toConsumableArray(prev), [value]);
396
+ }
397
+ if (type === 'group') {
398
+ return !disableGroupSeparators ? [].concat(_toConsumableArray(prev), [groupSeparator !== undefined ? groupSeparator : value]) : prev;
399
+ }
400
+ if (type === 'decimal') {
401
+ if (decimalScale !== undefined && decimalScale === 0) {
402
+ return prev;
403
+ }
404
+ return [].concat(_toConsumableArray(prev), [decimalSeparator !== undefined ? decimalSeparator : value]);
405
+ }
406
+ if (type === 'fraction') {
407
+ return [].concat(_toConsumableArray(prev), [decimalScale !== undefined ? value.slice(0, decimalScale) : value]);
408
+ }
409
+ return [].concat(_toConsumableArray(prev), [value]);
410
+ }, ['']).join('');
411
+ };
412
+
413
+ var defaultConfig = {
414
+ currencySymbol: '',
415
+ groupSeparator: '',
416
+ decimalSeparator: '',
417
+ prefix: '',
418
+ suffix: ''
419
+ };
420
+
421
+ /**
422
+ * Get locale config from input or default
423
+ */
424
+ var getLocaleConfig = function getLocaleConfig(intlConfig) {
425
+ var _ref = intlConfig || {},
426
+ locale = _ref.locale,
427
+ currency = _ref.currency;
428
+ var numberFormatter = locale ? new Intl.NumberFormat(locale, currency ? {
429
+ currency: currency,
430
+ style: 'currency'
431
+ } : undefined) : new Intl.NumberFormat();
432
+ return numberFormatter.formatToParts(1000.1).reduce(function (prev, curr, i) {
433
+ if (curr.type === 'currency') {
434
+ if (i === 0) {
435
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
436
+ currencySymbol: curr.value,
437
+ prefix: curr.value
438
+ });
439
+ } else {
440
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
441
+ currencySymbol: curr.value,
442
+ suffix: curr.value
443
+ });
444
+ }
445
+ }
446
+ if (curr.type === 'group') {
447
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
448
+ groupSeparator: curr.value
449
+ });
450
+ }
451
+ if (curr.type === 'decimal') {
452
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
453
+ decimalSeparator: curr.value
454
+ });
455
+ }
456
+ return prev;
457
+ }, defaultConfig);
458
+ };
459
+
460
+ var isNumber = function isNumber(input) {
461
+ return RegExp(/\d/, 'gi').test(input);
462
+ };
463
+
464
+ var padTrimValue = function padTrimValue(value) {
465
+ var decimalSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
466
+ var decimalScale = arguments.length > 2 ? arguments[2] : undefined;
467
+ if (decimalScale === undefined || value === '' || value === undefined) {
468
+ return value;
469
+ }
470
+ if (!value.match(/\d/g)) {
471
+ return '';
472
+ }
473
+ var _value$split = value.split(decimalSeparator),
474
+ _value$split2 = _slicedToArray(_value$split, 2),
475
+ _int = _value$split2[0],
476
+ decimals = _value$split2[1];
477
+ if (decimalScale === 0) {
478
+ return _int;
479
+ }
480
+ var newValue = decimals || '';
481
+ if (newValue.length < decimalScale) {
482
+ while (newValue.length < decimalScale) {
483
+ newValue += '0';
484
+ }
485
+ } else {
486
+ newValue = newValue.slice(0, decimalScale);
487
+ }
488
+ return "".concat(_int).concat(decimalSeparator).concat(newValue);
489
+ };
490
+
491
+ /**
492
+ * Based on the last key stroke and the cursor position, update the value
493
+ * and reposition the cursor to the right place
494
+ */
495
+ var repositionCursor = function repositionCursor(_ref) {
496
+ var selectionStart = _ref.selectionStart,
497
+ value = _ref.value,
498
+ lastKeyStroke = _ref.lastKeyStroke,
499
+ stateValue = _ref.stateValue,
500
+ groupSeparator = _ref.groupSeparator;
501
+ var cursorPosition = selectionStart;
502
+ var modifiedValue = value;
503
+ if (stateValue && cursorPosition) {
504
+ var splitValue = value.split('');
505
+ // if cursor is to right of groupSeparator and backspace pressed, delete the character to the left of the separator and reposition the cursor
506
+ if (lastKeyStroke === 'Backspace' && stateValue[cursorPosition] === groupSeparator) {
507
+ splitValue.splice(cursorPosition - 1, 1);
508
+ cursorPosition -= 1;
509
+ }
510
+ // if cursor is to left of groupSeparator and delete pressed, delete the character to the right of the separator and reposition the cursor
511
+ if (lastKeyStroke === 'Delete' && stateValue[cursorPosition] === groupSeparator) {
512
+ splitValue.splice(cursorPosition, 1);
513
+ cursorPosition += 1;
514
+ }
515
+ modifiedValue = splitValue.join('');
516
+ return {
517
+ modifiedValue: modifiedValue,
518
+ cursorPosition: cursorPosition
519
+ };
520
+ }
521
+ return {
522
+ modifiedValue: modifiedValue,
523
+ cursorPosition: selectionStart
524
+ };
525
+ };
526
+
527
+ var dist = {};
528
+
529
+ var hasRequiredDist;
530
+
531
+ function requireDist () {
532
+ if (hasRequiredDist) return dist;
533
+ hasRequiredDist = 1;
534
+
535
+ var React$1 = React;
536
+ var reactDom = require$$1;
537
+
538
+ function _arrayLikeToArray(r, a) {
539
+ (null == a || a > r.length) && (a = r.length);
540
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
541
+ return n;
542
+ }
543
+ function _arrayWithHoles(r) {
544
+ if (Array.isArray(r)) return r;
545
+ }
546
+ function _arrayWithoutHoles(r) {
547
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
548
+ }
549
+ function _defineProperty(e, r, t) {
550
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
551
+ value: t,
552
+ enumerable: true,
553
+ configurable: true,
554
+ writable: true
555
+ }) : e[r] = t, e;
556
+ }
557
+ function _extends() {
558
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
559
+ for (var e = 1; e < arguments.length; e++) {
560
+ var t = arguments[e];
561
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
562
+ }
563
+ return n;
564
+ }, _extends.apply(null, arguments);
565
+ }
566
+ function _iterableToArray(r) {
567
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
568
+ }
569
+ function _iterableToArrayLimit(r, l) {
570
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
571
+ if (null != t) {
572
+ var e,
573
+ n,
574
+ i,
575
+ u,
576
+ a = [],
577
+ f = true,
578
+ o = false;
579
+ try {
580
+ if (i = (t = t.call(r)).next, 0 === l) {
581
+ if (Object(t) !== t) return;
582
+ f = !1;
583
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
584
+ } catch (r) {
585
+ o = true, n = r;
586
+ } finally {
587
+ try {
588
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
589
+ } finally {
590
+ if (o) throw n;
591
+ }
592
+ }
593
+ return a;
594
+ }
595
+ }
596
+ function _nonIterableRest() {
597
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
598
+ }
599
+ function _nonIterableSpread() {
600
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
601
+ }
602
+ function ownKeys(e, r) {
603
+ var t = Object.keys(e);
604
+ if (Object.getOwnPropertySymbols) {
605
+ var o = Object.getOwnPropertySymbols(e);
606
+ r && (o = o.filter(function (r) {
607
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
608
+ })), t.push.apply(t, o);
609
+ }
610
+ return t;
611
+ }
612
+ function _objectSpread2(e) {
613
+ for (var r = 1; r < arguments.length; r++) {
614
+ var t = null != arguments[r] ? arguments[r] : {};
615
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
616
+ _defineProperty(e, r, t[r]);
617
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
618
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
619
+ });
620
+ }
621
+ return e;
622
+ }
623
+ function _objectWithoutProperties(e, t) {
624
+ if (null == e) return {};
625
+ var o,
626
+ r,
627
+ i = _objectWithoutPropertiesLoose(e, t);
628
+ if (Object.getOwnPropertySymbols) {
629
+ var n = Object.getOwnPropertySymbols(e);
630
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
631
+ }
632
+ return i;
633
+ }
634
+ function _objectWithoutPropertiesLoose(r, e) {
635
+ if (null == r) return {};
636
+ var t = {};
637
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
638
+ if (-1 !== e.indexOf(n)) continue;
639
+ t[n] = r[n];
640
+ }
641
+ return t;
642
+ }
643
+ function _slicedToArray(r, e) {
644
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
645
+ }
646
+ function _toConsumableArray(r) {
647
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
648
+ }
649
+ function _toPrimitive(t, r) {
650
+ if ("object" != typeof t || !t) return t;
651
+ var e = t[Symbol.toPrimitive];
652
+ if (void 0 !== e) {
653
+ var i = e.call(t, r);
654
+ if ("object" != typeof i) return i;
655
+ throw new TypeError("@@toPrimitive must return a primitive value.");
656
+ }
657
+ return ("string" === r ? String : Number)(t);
658
+ }
659
+ function _toPropertyKey(t) {
660
+ var i = _toPrimitive(t, "string");
661
+ return "symbol" == typeof i ? i : i + "";
662
+ }
663
+ function _typeof(o) {
664
+ "@babel/helpers - typeof";
665
+
666
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
667
+ return typeof o;
668
+ } : function (o) {
669
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
670
+ }, _typeof(o);
671
+ }
672
+ function _unsupportedIterableToArray(r, a) {
673
+ if (r) {
674
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
675
+ var t = {}.toString.call(r).slice(8, -1);
676
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
677
+ }
678
+ }
679
+
680
+ var defaultToastLayout = {
681
+ padding: '12px 16px',
682
+ margin: '8px 0',
683
+ width: '420px',
684
+ maxWidth: '90vw',
685
+ maxHeight: '75px',
686
+ placement: 'bottomRight'
687
+ };
688
+ var defaultParams = {
689
+ toasts: [],
690
+ toastLayout: defaultToastLayout,
691
+ updateToastLayout: function updateToastLayout(t) {
692
+ return t;
693
+ },
694
+ updateToasts: function updateToasts(t) {
695
+ return t;
696
+ },
697
+ lastUpdateToastId: null,
698
+ updateLastToastId: function updateLastToastId() {
699
+ return null;
700
+ }
701
+ };
702
+ var HUIContent = /*#__PURE__*/React$1.createContext(defaultParams);
703
+ var useHUIContext = function useHUIContext() {
704
+ return React$1.useContext(HUIContent);
705
+ };
706
+
707
+ var defaultFont = {
708
+ sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
709
+ mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
710
+ prism: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,"Liberation Mono", "Courier New", monospace'
711
+ };
712
+ var defaultBreakpoints = {
713
+ xs: {
714
+ min: '0',
715
+ max: '650px'
716
+ },
717
+ sm: {
718
+ min: '650px',
719
+ max: '900px'
720
+ },
721
+ md: {
722
+ min: '900px',
723
+ max: '1280px'
724
+ },
725
+ lg: {
726
+ min: '1280px',
727
+ max: '1920px'
728
+ },
729
+ xl: {
730
+ min: '1920px',
731
+ max: '10000px'
732
+ }
733
+ };
734
+ var defaultLayout = {
735
+ gap: '16pt',
736
+ gapNegative: '-16pt',
737
+ gapHalf: '8pt',
738
+ gapHalfNegative: '-8pt',
739
+ gapQuarter: '4pt',
740
+ gapQuarterNegative: '-4pt',
741
+ pageMargin: '16pt',
742
+ pageWidth: '750pt',
743
+ pageWidthWithMargin: '782pt',
744
+ breakpointMobile: defaultBreakpoints.xs.max,
745
+ breakpointTablet: defaultBreakpoints.sm.max,
746
+ radius: '6px',
747
+ unit: '16px'
748
+ };
749
+
750
+ var palette$1 = {
751
+ accents_1: '#fafafa',
752
+ accents_2: '#eaeaea',
753
+ accents_3: '#999',
754
+ accents_4: '#888',
755
+ accents_5: '#666',
756
+ accents_6: '#444',
757
+ accents_7: '#333',
758
+ accents_8: '#111',
759
+ background: '#fff',
760
+ foreground: '#000',
761
+ selection: '#79ffe1',
762
+ secondary: '#666',
763
+ code: '#f81ce5',
764
+ border: '#eaeaea',
765
+ error: '#e00',
766
+ errorLight: '#ff1a1a',
767
+ errorLighter: '#f7d4d6',
768
+ errorDark: '#c50000',
769
+ success: '#0070f3',
770
+ successLight: '#3291ff',
771
+ successLighter: '#d3e5ff',
772
+ successDark: '#0761d1',
773
+ warning: '#f5a623',
774
+ warningLight: '#f7b955',
775
+ warningLighter: '#ffefcf',
776
+ warningDark: '#ab570a',
777
+ cyan: '#50e3c2',
778
+ cyanLighter: '#aaffec',
779
+ cyanLight: '#79ffe1',
780
+ cyanDark: '#29bc9b',
781
+ violet: '#7928ca',
782
+ violetLighter: '#e3d7fc',
783
+ violetLight: '#8a63d2',
784
+ violetDark: '#4c2889',
785
+ purple: '#f81ce5',
786
+ alert: '#ff0080',
787
+ magenta: '#eb367f',
788
+ link: '#0070f3'
789
+ };
790
+ var expressiveness$1 = {
791
+ linkStyle: 'none',
792
+ linkHoverStyle: 'none',
793
+ dropdownBoxShadow: '0 4px 4px 0 rgba(0, 0, 0, 0.02)',
794
+ scrollerStart: 'rgba(255, 255, 255, 1)',
795
+ scrollerEnd: 'rgba(255, 255, 255, 0)',
796
+ shadowSmall: '0 5px 10px rgba(0, 0, 0, 0.12)',
797
+ shadowMedium: '0 8px 30px rgba(0, 0, 0, 0.12)',
798
+ shadowLarge: '0 30px 60px rgba(0, 0, 0, 0.12)',
799
+ portalOpacity: 0.25
800
+ };
801
+ var font$1 = defaultFont;
802
+ var breakpoints$1 = defaultBreakpoints;
803
+ var layout$1 = defaultLayout;
804
+ var themes$1 = {
805
+ type: 'light',
806
+ font: font$1,
807
+ layout: layout$1,
808
+ palette: palette$1,
809
+ breakpoints: breakpoints$1,
810
+ expressiveness: expressiveness$1
811
+ };
812
+
813
+ var palette = {
814
+ accents_1: '#111',
815
+ accents_2: '#333',
816
+ accents_3: '#444',
817
+ accents_4: '#666',
818
+ accents_5: '#888',
819
+ accents_6: '#999',
820
+ accents_7: '#eaeaea',
821
+ accents_8: '#fafafa',
822
+ background: '#000',
823
+ foreground: '#fff',
824
+ selection: '#f81ce5',
825
+ secondary: '#888',
826
+ code: '#79ffe1',
827
+ border: '#333',
828
+ error: '#e00',
829
+ errorLighter: '#f7d4d6',
830
+ errorLight: '#ff1a1a',
831
+ errorDark: '#c50000',
832
+ success: '#0070f3',
833
+ successLighter: '#d3e5ff',
834
+ successLight: '#3291ff',
835
+ successDark: '#0761d1',
836
+ warning: '#f5a623',
837
+ warningLighter: '#ffefcf',
838
+ warningLight: '#f7b955',
839
+ warningDark: '#ab570a',
840
+ cyan: '#50e3c2',
841
+ cyanLighter: '#aaffec',
842
+ cyanLight: '#79ffe1',
843
+ cyanDark: '#29bc9b',
844
+ violet: '#7928ca',
845
+ violetLighter: '#e3d7fc',
846
+ violetLight: '#8a63d2',
847
+ violetDark: '#4c2889',
848
+ purple: '#f81ce5',
849
+ alert: '#ff0080',
850
+ magenta: '#eb367f',
851
+ link: '#3291ff'
852
+ };
853
+ var expressiveness = {
854
+ linkStyle: 'none',
855
+ linkHoverStyle: 'none',
856
+ dropdownBoxShadow: '0 0 0 1px #333',
857
+ scrollerStart: 'rgba(255, 255, 255, 1)',
858
+ scrollerEnd: 'rgba(255, 255, 255, 0)',
859
+ shadowSmall: '0 0 0 1px #333',
860
+ shadowMedium: '0 0 0 1px #333',
861
+ shadowLarge: '0 0 0 1px #333',
862
+ portalOpacity: 0.75
863
+ };
864
+ var font = defaultFont;
865
+ var breakpoints = defaultBreakpoints;
866
+ var layout = defaultLayout;
867
+ var themes = {
868
+ type: 'dark',
869
+ font: font,
870
+ layout: layout,
871
+ palette: palette,
872
+ breakpoints: breakpoints,
873
+ expressiveness: expressiveness
874
+ };
875
+
876
+ var isObject = function isObject(target) {
877
+ return target && _typeof(target) === 'object';
878
+ };
879
+ var _deepDuplicable = function deepDuplicable(source, target) {
880
+ if (!isObject(target) || !isObject(source)) return source;
881
+ var sourceKeys = Object.keys(source);
882
+ var result = {};
883
+ for (var _i = 0, _sourceKeys = sourceKeys; _i < _sourceKeys.length; _i++) {
884
+ var key = _sourceKeys[_i];
885
+ var sourceValue = source[key];
886
+ var targetValue = target[key];
887
+ if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
888
+ result[key] = targetValue.concat(sourceValue);
889
+ } else if (isObject(sourceValue) && isObject(targetValue)) {
890
+ result[key] = _deepDuplicable(sourceValue, _objectSpread2({}, targetValue));
891
+ } else if (targetValue) {
892
+ result[key] = targetValue;
893
+ } else {
894
+ result[key] = sourceValue;
895
+ }
896
+ }
897
+ return result;
898
+ };
899
+ var getPresets = function getPresets() {
900
+ return [themes$1, themes];
901
+ };
902
+ var getPresetStaticTheme = function getPresetStaticTheme() {
903
+ return themes$1;
904
+ };
905
+ var isAvailableThemeType = function isAvailableThemeType(type) {
906
+ if (!type) return false;
907
+ var presetThemes = getPresets();
908
+ var hasType = presetThemes.find(function (theme) {
909
+ return theme.type === type;
910
+ });
911
+ return !hasType;
912
+ };
913
+ var isPresetTheme = function isPresetTheme(themeOrType) {
914
+ if (!themeOrType) return false;
915
+ var isType = typeof themeOrType === 'string';
916
+ var type = isType ? themeOrType : themeOrType.type;
917
+ return !isAvailableThemeType(type);
918
+ };
919
+ var hasUserCustomTheme = function hasUserCustomTheme() {
920
+ var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
921
+ return !!themes.find(function (item) {
922
+ return isAvailableThemeType(item.type);
923
+ });
924
+ };
925
+ var create = function create(base, custom) {
926
+ if (!isAvailableThemeType(custom.type)) {
927
+ throw new Error('Duplicate or unavailable theme type');
928
+ }
929
+ return _deepDuplicable(base, custom);
930
+ };
931
+ var createFromDark = function createFromDark(custom) {
932
+ return create(themes, custom);
933
+ };
934
+ var createFromLight = function createFromLight(custom) {
935
+ return create(themes$1, custom);
936
+ };
937
+ var Themes = {
938
+ isPresetTheme: isPresetTheme,
939
+ isAvailableThemeType: isAvailableThemeType,
940
+ hasUserCustomTheme: hasUserCustomTheme,
941
+ getPresets: getPresets,
942
+ getPresetStaticTheme: getPresetStaticTheme,
943
+ create: create,
944
+ createFromDark: createFromDark,
945
+ createFromLight: createFromLight
946
+ };
947
+
948
+ /* "use client" */
949
+
950
+ var defaultTheme = Themes.getPresetStaticTheme();
951
+ var ThemeContext = /*#__PURE__*/React$1.createContext(defaultTheme);
952
+ var useTheme = function useTheme() {
953
+ return React$1.useContext(ThemeContext);
954
+ };
955
+
956
+ /* "use client" */
957
+
958
+ var defaultAllThemesConfig = {
959
+ themes: Themes.getPresets()
960
+ };
961
+ var AllThemesContext = /*#__PURE__*/React$1.createContext(defaultAllThemesConfig);
962
+ var useAllThemes = function useAllThemes() {
963
+ return React$1.useContext(AllThemesContext);
964
+ };
965
+
966
+ var ThemeProvider = function ThemeProvider(_ref) {
967
+ var children = _ref.children,
968
+ themeType = _ref.themeType,
969
+ _ref$themes = _ref.themes,
970
+ themes = _ref$themes === void 0 ? [] : _ref$themes;
971
+ var _React$useState = React$1.useState({
972
+ themes: Themes.getPresets()
973
+ }),
974
+ _React$useState2 = _slicedToArray(_React$useState, 2),
975
+ allThemes = _React$useState2[0],
976
+ setAllThemes = _React$useState2[1];
977
+ var currentTheme = React$1.useMemo(function () {
978
+ var theme = allThemes.themes.find(function (item) {
979
+ return item.type === themeType;
980
+ });
981
+ if (theme) return theme;
982
+ return Themes.getPresetStaticTheme();
983
+ }, [allThemes, themeType]);
984
+ React$1.useEffect(function () {
985
+ if (!(themes !== null && themes !== void 0 && themes.length)) return;
986
+ setAllThemes(function (last) {
987
+ var safeThemes = themes.filter(function (item) {
988
+ return Themes.isAvailableThemeType(item.type);
989
+ });
990
+ var nextThemes = Themes.getPresets().concat(safeThemes);
991
+ return _objectSpread2(_objectSpread2({}, last), {}, {
992
+ themes: nextThemes
993
+ });
994
+ });
995
+ }, [themes]);
996
+ return /*#__PURE__*/React$1.createElement(AllThemesContext.Provider, {
997
+ value: allThemes
998
+ }, /*#__PURE__*/React$1.createElement(ThemeContext.Provider, {
999
+ value: currentTheme
1000
+ }, children));
1001
+ };
1002
+
1003
+ var useCurrentState = function useCurrentState(initialState) {
1004
+ var _useState = React$1.useState(function () {
1005
+ return typeof initialState === 'function' ? initialState() : initialState;
1006
+ }),
1007
+ _useState2 = _slicedToArray(_useState, 2),
1008
+ state = _useState2[0],
1009
+ setState = _useState2[1];
1010
+ var ref = React$1.useRef(initialState);
1011
+ React$1.useEffect(function () {
1012
+ ref.current = state;
1013
+ }, [state]);
1014
+ var setValue = function setValue(val) {
1015
+ var result = typeof val === 'function' ? val(ref.current) : val;
1016
+ ref.current = result;
1017
+ setState(result);
1018
+ };
1019
+ return [state, setValue, ref];
1020
+ };
1021
+
1022
+ function getDefaultExportFromCjs (x) {
1023
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1024
+ }
1025
+
1026
+ var index = {};
1027
+
1028
+ var hasRequiredIndex;
1029
+
1030
+ function requireIndex () {
1031
+ if (hasRequiredIndex) return index;
1032
+ hasRequiredIndex = 1;
1033
+ var React$1$1 = React$1;
1034
+
1035
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
1036
+
1037
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1$1);
1038
+
1039
+ /*
1040
+ Based on Glamor's sheet
1041
+ https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
1042
+ */ function _defineProperties(target, props) {
1043
+ for(var i = 0; i < props.length; i++){
1044
+ var descriptor = props[i];
1045
+ descriptor.enumerable = descriptor.enumerable || false;
1046
+ descriptor.configurable = true;
1047
+ if ("value" in descriptor) descriptor.writable = true;
1048
+ Object.defineProperty(target, descriptor.key, descriptor);
1049
+ }
1050
+ }
1051
+ function _createClass(Constructor, protoProps, staticProps) {
1052
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1053
+ return Constructor;
1054
+ }
1055
+ var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
1056
+ var isString = function(o) {
1057
+ return Object.prototype.toString.call(o) === "[object String]";
1058
+ };
1059
+ var StyleSheet = /*#__PURE__*/ function() {
1060
+ function StyleSheet(param) {
1061
+ var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
1062
+ invariant$1(isString(name), "`name` must be a string");
1063
+ this._name = name;
1064
+ this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
1065
+ invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
1066
+ this._optimizeForSpeed = optimizeForSpeed;
1067
+ this._serverSheet = undefined;
1068
+ this._tags = [];
1069
+ this._injected = false;
1070
+ this._rulesCount = 0;
1071
+ var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
1072
+ this._nonce = node ? node.getAttribute("content") : null;
1073
+ }
1074
+ var _proto = StyleSheet.prototype;
1075
+ _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
1076
+ invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
1077
+ invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
1078
+ this.flush();
1079
+ this._optimizeForSpeed = bool;
1080
+ this.inject();
1081
+ };
1082
+ _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
1083
+ return this._optimizeForSpeed;
1084
+ };
1085
+ _proto.inject = function inject() {
1086
+ var _this = this;
1087
+ invariant$1(!this._injected, "sheet already injected");
1088
+ this._injected = true;
1089
+ if (typeof window !== "undefined" && this._optimizeForSpeed) {
1090
+ this._tags[0] = this.makeStyleTag(this._name);
1091
+ this._optimizeForSpeed = "insertRule" in this.getSheet();
1092
+ if (!this._optimizeForSpeed) {
1093
+ if (!isProd) {
1094
+ console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
1095
+ }
1096
+ this.flush();
1097
+ this._injected = true;
1098
+ }
1099
+ return;
1100
+ }
1101
+ this._serverSheet = {
1102
+ cssRules: [],
1103
+ insertRule: function(rule, index) {
1104
+ if (typeof index === "number") {
1105
+ _this._serverSheet.cssRules[index] = {
1106
+ cssText: rule
1107
+ };
1108
+ } else {
1109
+ _this._serverSheet.cssRules.push({
1110
+ cssText: rule
1111
+ });
1112
+ }
1113
+ return index;
1114
+ },
1115
+ deleteRule: function(index) {
1116
+ _this._serverSheet.cssRules[index] = null;
1117
+ }
1118
+ };
1119
+ };
1120
+ _proto.getSheetForTag = function getSheetForTag(tag) {
1121
+ if (tag.sheet) {
1122
+ return tag.sheet;
1123
+ }
1124
+ // this weirdness brought to you by firefox
1125
+ for(var i = 0; i < document.styleSheets.length; i++){
1126
+ if (document.styleSheets[i].ownerNode === tag) {
1127
+ return document.styleSheets[i];
1128
+ }
1129
+ }
1130
+ };
1131
+ _proto.getSheet = function getSheet() {
1132
+ return this.getSheetForTag(this._tags[this._tags.length - 1]);
1133
+ };
1134
+ _proto.insertRule = function insertRule(rule, index) {
1135
+ invariant$1(isString(rule), "`insertRule` accepts only strings");
1136
+ if (typeof window === "undefined") {
1137
+ if (typeof index !== "number") {
1138
+ index = this._serverSheet.cssRules.length;
1139
+ }
1140
+ this._serverSheet.insertRule(rule, index);
1141
+ return this._rulesCount++;
1142
+ }
1143
+ if (this._optimizeForSpeed) {
1144
+ var sheet = this.getSheet();
1145
+ if (typeof index !== "number") {
1146
+ index = sheet.cssRules.length;
1147
+ }
1148
+ // this weirdness for perf, and chrome's weird bug
1149
+ // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
1150
+ try {
1151
+ sheet.insertRule(rule, index);
1152
+ } catch (error) {
1153
+ if (!isProd) {
1154
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
1155
+ }
1156
+ return -1;
1157
+ }
1158
+ } else {
1159
+ var insertionPoint = this._tags[index];
1160
+ this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
1161
+ }
1162
+ return this._rulesCount++;
1163
+ };
1164
+ _proto.replaceRule = function replaceRule(index, rule) {
1165
+ if (this._optimizeForSpeed || typeof window === "undefined") {
1166
+ var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
1167
+ if (!rule.trim()) {
1168
+ rule = this._deletedRulePlaceholder;
1169
+ }
1170
+ if (!sheet.cssRules[index]) {
1171
+ // @TBD Should we throw an error?
1172
+ return index;
1173
+ }
1174
+ sheet.deleteRule(index);
1175
+ try {
1176
+ sheet.insertRule(rule, index);
1177
+ } catch (error) {
1178
+ if (!isProd) {
1179
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
1180
+ }
1181
+ // In order to preserve the indices we insert a deleteRulePlaceholder
1182
+ sheet.insertRule(this._deletedRulePlaceholder, index);
1183
+ }
1184
+ } else {
1185
+ var tag = this._tags[index];
1186
+ invariant$1(tag, "old rule at index `" + index + "` not found");
1187
+ tag.textContent = rule;
1188
+ }
1189
+ return index;
1190
+ };
1191
+ _proto.deleteRule = function deleteRule(index) {
1192
+ if (typeof window === "undefined") {
1193
+ this._serverSheet.deleteRule(index);
1194
+ return;
1195
+ }
1196
+ if (this._optimizeForSpeed) {
1197
+ this.replaceRule(index, "");
1198
+ } else {
1199
+ var tag = this._tags[index];
1200
+ invariant$1(tag, "rule at index `" + index + "` not found");
1201
+ tag.parentNode.removeChild(tag);
1202
+ this._tags[index] = null;
1203
+ }
1204
+ };
1205
+ _proto.flush = function flush() {
1206
+ this._injected = false;
1207
+ this._rulesCount = 0;
1208
+ if (typeof window !== "undefined") {
1209
+ this._tags.forEach(function(tag) {
1210
+ return tag && tag.parentNode.removeChild(tag);
1211
+ });
1212
+ this._tags = [];
1213
+ } else {
1214
+ // simpler on server
1215
+ this._serverSheet.cssRules = [];
1216
+ }
1217
+ };
1218
+ _proto.cssRules = function cssRules() {
1219
+ var _this = this;
1220
+ if (typeof window === "undefined") {
1221
+ return this._serverSheet.cssRules;
1222
+ }
1223
+ return this._tags.reduce(function(rules, tag) {
1224
+ if (tag) {
1225
+ rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
1226
+ return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
1227
+ }));
1228
+ } else {
1229
+ rules.push(null);
1230
+ }
1231
+ return rules;
1232
+ }, []);
1233
+ };
1234
+ _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
1235
+ if (cssString) {
1236
+ invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
1237
+ }
1238
+ var tag = document.createElement("style");
1239
+ if (this._nonce) tag.setAttribute("nonce", this._nonce);
1240
+ tag.type = "text/css";
1241
+ tag.setAttribute("data-" + name, "");
1242
+ if (cssString) {
1243
+ tag.appendChild(document.createTextNode(cssString));
1244
+ }
1245
+ var head = document.head || document.getElementsByTagName("head")[0];
1246
+ if (relativeToTag) {
1247
+ head.insertBefore(tag, relativeToTag);
1248
+ } else {
1249
+ head.appendChild(tag);
1250
+ }
1251
+ return tag;
1252
+ };
1253
+ _createClass(StyleSheet, [
1254
+ {
1255
+ key: "length",
1256
+ get: function get() {
1257
+ return this._rulesCount;
1258
+ }
1259
+ }
1260
+ ]);
1261
+ return StyleSheet;
1262
+ }();
1263
+ function invariant$1(condition, message) {
1264
+ if (!condition) {
1265
+ throw new Error("StyleSheet: " + message + ".");
1266
+ }
1267
+ }
1268
+
1269
+ function hash(str) {
1270
+ var _$hash = 5381, i = str.length;
1271
+ while(i){
1272
+ _$hash = _$hash * 33 ^ str.charCodeAt(--i);
1273
+ }
1274
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
1275
+ * integers. Since we want the results to be always positive, convert the
1276
+ * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
1277
+ }
1278
+ var stringHash = hash;
1279
+
1280
+ var sanitize = function(rule) {
1281
+ return rule.replace(/\/style/gi, "\\/style");
1282
+ };
1283
+ var cache = {};
1284
+ /**
1285
+ * computeId
1286
+ *
1287
+ * Compute and memoize a jsx id from a basedId and optionally props.
1288
+ */ function computeId(baseId, props) {
1289
+ if (!props) {
1290
+ return "jsx-" + baseId;
1291
+ }
1292
+ var propsToString = String(props);
1293
+ var key = baseId + propsToString;
1294
+ if (!cache[key]) {
1295
+ cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
1296
+ }
1297
+ return cache[key];
1298
+ }
1299
+ /**
1300
+ * computeSelector
1301
+ *
1302
+ * Compute and memoize dynamic selectors.
1303
+ */ function computeSelector(id, css) {
1304
+ var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
1305
+ // Sanitize SSR-ed CSS.
1306
+ // Client side code doesn't need to be sanitized since we use
1307
+ // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
1308
+ if (typeof window === "undefined") {
1309
+ css = sanitize(css);
1310
+ }
1311
+ var idcss = id + css;
1312
+ if (!cache[idcss]) {
1313
+ cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
1314
+ }
1315
+ return cache[idcss];
1316
+ }
1317
+
1318
+ function mapRulesToStyle(cssRules, options) {
1319
+ if (options === void 0) options = {};
1320
+ return cssRules.map(function(args) {
1321
+ var id = args[0];
1322
+ var css = args[1];
1323
+ return /*#__PURE__*/ React__default["default"].createElement("style", {
1324
+ id: "__" + id,
1325
+ // Avoid warnings upon render with a key
1326
+ key: "__" + id,
1327
+ nonce: options.nonce ? options.nonce : undefined,
1328
+ dangerouslySetInnerHTML: {
1329
+ __html: css
1330
+ }
1331
+ });
1332
+ });
1333
+ }
1334
+ var StyleSheetRegistry = /*#__PURE__*/ function() {
1335
+ function StyleSheetRegistry(param) {
1336
+ var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
1337
+ this._sheet = styleSheet || new StyleSheet({
1338
+ name: "styled-jsx",
1339
+ optimizeForSpeed: optimizeForSpeed
1340
+ });
1341
+ this._sheet.inject();
1342
+ if (styleSheet && typeof optimizeForSpeed === "boolean") {
1343
+ this._sheet.setOptimizeForSpeed(optimizeForSpeed);
1344
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
1345
+ }
1346
+ this._fromServer = undefined;
1347
+ this._indices = {};
1348
+ this._instancesCounts = {};
1349
+ }
1350
+ var _proto = StyleSheetRegistry.prototype;
1351
+ _proto.add = function add(props) {
1352
+ var _this = this;
1353
+ if (undefined === this._optimizeForSpeed) {
1354
+ this._optimizeForSpeed = Array.isArray(props.children);
1355
+ this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
1356
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
1357
+ }
1358
+ if (typeof window !== "undefined" && !this._fromServer) {
1359
+ this._fromServer = this.selectFromServer();
1360
+ this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
1361
+ acc[tagName] = 0;
1362
+ return acc;
1363
+ }, {});
1364
+ }
1365
+ var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
1366
+ // Deduping: just increase the instances count.
1367
+ if (styleId in this._instancesCounts) {
1368
+ this._instancesCounts[styleId] += 1;
1369
+ return;
1370
+ }
1371
+ var indices = rules.map(function(rule) {
1372
+ return _this._sheet.insertRule(rule);
1373
+ })// Filter out invalid rules
1374
+ .filter(function(index) {
1375
+ return index !== -1;
1376
+ });
1377
+ this._indices[styleId] = indices;
1378
+ this._instancesCounts[styleId] = 1;
1379
+ };
1380
+ _proto.remove = function remove(props) {
1381
+ var _this = this;
1382
+ var styleId = this.getIdAndRules(props).styleId;
1383
+ invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
1384
+ this._instancesCounts[styleId] -= 1;
1385
+ if (this._instancesCounts[styleId] < 1) {
1386
+ var tagFromServer = this._fromServer && this._fromServer[styleId];
1387
+ if (tagFromServer) {
1388
+ tagFromServer.parentNode.removeChild(tagFromServer);
1389
+ delete this._fromServer[styleId];
1390
+ } else {
1391
+ this._indices[styleId].forEach(function(index) {
1392
+ return _this._sheet.deleteRule(index);
1393
+ });
1394
+ delete this._indices[styleId];
1395
+ }
1396
+ delete this._instancesCounts[styleId];
1397
+ }
1398
+ };
1399
+ _proto.update = function update(props, nextProps) {
1400
+ this.add(nextProps);
1401
+ this.remove(props);
1402
+ };
1403
+ _proto.flush = function flush() {
1404
+ this._sheet.flush();
1405
+ this._sheet.inject();
1406
+ this._fromServer = undefined;
1407
+ this._indices = {};
1408
+ this._instancesCounts = {};
1409
+ };
1410
+ _proto.cssRules = function cssRules() {
1411
+ var _this = this;
1412
+ var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
1413
+ return [
1414
+ styleId,
1415
+ _this._fromServer[styleId]
1416
+ ];
1417
+ }) : [];
1418
+ var cssRules = this._sheet.cssRules();
1419
+ return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
1420
+ return [
1421
+ styleId,
1422
+ _this._indices[styleId].map(function(index) {
1423
+ return cssRules[index].cssText;
1424
+ }).join(_this._optimizeForSpeed ? "" : "\n")
1425
+ ];
1426
+ })// filter out empty rules
1427
+ .filter(function(rule) {
1428
+ return Boolean(rule[1]);
1429
+ }));
1430
+ };
1431
+ _proto.styles = function styles(options) {
1432
+ return mapRulesToStyle(this.cssRules(), options);
1433
+ };
1434
+ _proto.getIdAndRules = function getIdAndRules(props) {
1435
+ var css = props.children, dynamic = props.dynamic, id = props.id;
1436
+ if (dynamic) {
1437
+ var styleId = computeId(id, dynamic);
1438
+ return {
1439
+ styleId: styleId,
1440
+ rules: Array.isArray(css) ? css.map(function(rule) {
1441
+ return computeSelector(styleId, rule);
1442
+ }) : [
1443
+ computeSelector(styleId, css)
1444
+ ]
1445
+ };
1446
+ }
1447
+ return {
1448
+ styleId: computeId(id),
1449
+ rules: Array.isArray(css) ? css : [
1450
+ css
1451
+ ]
1452
+ };
1453
+ };
1454
+ /**
1455
+ * selectFromServer
1456
+ *
1457
+ * Collects style tags from the document with id __jsx-XXX
1458
+ */ _proto.selectFromServer = function selectFromServer() {
1459
+ var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
1460
+ return elements.reduce(function(acc, element) {
1461
+ var id = element.id.slice(2);
1462
+ acc[id] = element;
1463
+ return acc;
1464
+ }, {});
1465
+ };
1466
+ return StyleSheetRegistry;
1467
+ }();
1468
+ function invariant(condition, message) {
1469
+ if (!condition) {
1470
+ throw new Error("StyleSheetRegistry: " + message + ".");
1471
+ }
1472
+ }
1473
+ var StyleSheetContext = /*#__PURE__*/ React$1$1.createContext(null);
1474
+ StyleSheetContext.displayName = "StyleSheetContext";
1475
+ function createStyleRegistry() {
1476
+ return new StyleSheetRegistry();
1477
+ }
1478
+ function StyleRegistry(param) {
1479
+ var configuredRegistry = param.registry, children = param.children;
1480
+ var rootRegistry = React$1$1.useContext(StyleSheetContext);
1481
+ var ref = React$1$1.useState(function() {
1482
+ return rootRegistry || configuredRegistry || createStyleRegistry();
1483
+ }), registry = ref[0];
1484
+ return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
1485
+ value: registry
1486
+ }, children);
1487
+ }
1488
+ function useStyleRegistry() {
1489
+ return React$1$1.useContext(StyleSheetContext);
1490
+ }
1491
+
1492
+ // Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
1493
+ // https://github.com/reactwg/react-18/discussions/110
1494
+ var useInsertionEffect = React__default["default"].useInsertionEffect || React$1$1.useLayoutEffect;
1495
+ var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
1496
+ function JSXStyle(props) {
1497
+ var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
1498
+ var insertionEffectCalled = React$1$1.useRef(false);
1499
+ // `registry` might not exist while server-side rendering
1500
+ if (!registry) {
1501
+ return null;
1502
+ }
1503
+ if (typeof window === "undefined") {
1504
+ registry.add(props);
1505
+ return null;
1506
+ }
1507
+ useInsertionEffect(function() {
1508
+ // ReactDOM removes all DOM during hydration in certain cases
1509
+ if (!document.head) {
1510
+ return;
1511
+ }
1512
+ registry.add(props);
1513
+ insertionEffectCalled.current = true;
1514
+ return function() {
1515
+ insertionEffectCalled.current = false;
1516
+ registry.remove(props);
1517
+ };
1518
+ }, [
1519
+ props.id,
1520
+ String(props.dynamic)
1521
+ ]);
1522
+ React$1$1.useLayoutEffect(function() {
1523
+ if (!document.head || insertionEffectCalled.current) {
1524
+ return;
1525
+ }
1526
+ registry.add(props);
1527
+ return function() {
1528
+ registry.remove(props);
1529
+ };
1530
+ // props.children can be string[], will be striped since id is identical
1531
+ }, [
1532
+ props.id,
1533
+ String(props.dynamic)
1534
+ ]);
1535
+ return null;
1536
+ }
1537
+ JSXStyle.dynamic = function(info) {
1538
+ return info.map(function(tagInfo) {
1539
+ var baseId = tagInfo[0];
1540
+ var props = tagInfo[1];
1541
+ return computeId(baseId, props);
1542
+ }).join(" ");
1543
+ };
1544
+
1545
+ index.StyleRegistry = StyleRegistry;
1546
+ index.createStyleRegistry = createStyleRegistry;
1547
+ index.style = JSXStyle;
1548
+ index.useStyleRegistry = useStyleRegistry;
1549
+ return index;
1550
+ }
1551
+
1552
+ var style;
1553
+ var hasRequiredStyle;
1554
+
1555
+ function requireStyle () {
1556
+ if (hasRequiredStyle) return style;
1557
+ hasRequiredStyle = 1;
1558
+ style = requireIndex().style;
1559
+ return style;
1560
+ }
1561
+
1562
+ var styleExports = requireStyle();
1563
+ var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
1564
+
1565
+ /* "use client" */
1566
+
1567
+ var getId = function getId() {
1568
+ return Math.random().toString(32).slice(2, 10);
1569
+ };
1570
+ var isBrowser = function isBrowser() {
1571
+ return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
1572
+ };
1573
+
1574
+ var useSSR = function useSSR() {
1575
+ var _useState = React$1.useState(false),
1576
+ _useState2 = _slicedToArray(_useState, 2),
1577
+ browser = _useState2[0],
1578
+ setBrowser = _useState2[1];
1579
+ React$1.useEffect(function () {
1580
+ setBrowser(isBrowser());
1581
+ }, []);
1582
+ return {
1583
+ isBrowser: browser,
1584
+ isServer: !browser
1585
+ };
1586
+ };
1587
+
1588
+ var createElement = function createElement(id) {
1589
+ var el = document.createElement('div');
1590
+ el.setAttribute('id', id);
1591
+ return el;
1592
+ };
1593
+ var usePortal = function usePortal() {
1594
+ var selectId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getId();
1595
+ var getContainer = arguments.length > 1 ? arguments[1] : undefined;
1596
+ var id = "helpdice-ui-".concat(selectId);
1597
+ var _useSSR = useSSR(),
1598
+ isBrowser = _useSSR.isBrowser;
1599
+ var _useState = React$1.useState(isBrowser ? createElement(id) : null),
1600
+ _useState2 = _slicedToArray(_useState, 2),
1601
+ elSnapshot = _useState2[0],
1602
+ setElSnapshot = _useState2[1];
1603
+ React$1.useEffect(function () {
1604
+ var customContainer = getContainer ? getContainer() : null;
1605
+ var parentElement = customContainer || document.body;
1606
+ var hasElement = parentElement.querySelector("#".concat(id));
1607
+ var el = hasElement || createElement(id);
1608
+ if (!hasElement) {
1609
+ parentElement.appendChild(el);
1610
+ }
1611
+ setElSnapshot(el);
1612
+ }, []);
1613
+ return elSnapshot;
1614
+ };
1615
+
1616
+ var _excluded$2 = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
1617
+ var CssTransition = function CssTransition(_ref) {
1618
+ var children = _ref.children,
1619
+ _ref$className = _ref.className,
1620
+ className = _ref$className === void 0 ? '' : _ref$className,
1621
+ _ref$visible = _ref.visible,
1622
+ visible = _ref$visible === void 0 ? false : _ref$visible,
1623
+ _ref$enterTime = _ref.enterTime,
1624
+ enterTime = _ref$enterTime === void 0 ? 60 : _ref$enterTime,
1625
+ _ref$leaveTime = _ref.leaveTime,
1626
+ leaveTime = _ref$leaveTime === void 0 ? 60 : _ref$leaveTime,
1627
+ _ref$clearTime = _ref.clearTime,
1628
+ clearTime = _ref$clearTime === void 0 ? 60 : _ref$clearTime,
1629
+ _ref$name = _ref.name,
1630
+ name = _ref$name === void 0 ? 'transition' : _ref$name,
1631
+ props = _objectWithoutProperties(_ref, _excluded$2);
1632
+ var _useState = React$1.useState(''),
1633
+ _useState2 = _slicedToArray(_useState, 2),
1634
+ classes = _useState2[0],
1635
+ setClasses = _useState2[1];
1636
+ var _useState3 = React$1.useState(visible),
1637
+ _useState4 = _slicedToArray(_useState3, 2),
1638
+ renderable = _useState4[0],
1639
+ setRenderable = _useState4[1];
1640
+ React$1.useEffect(function () {
1641
+ var statusClassName = visible ? 'enter' : 'leave';
1642
+ var time = visible ? enterTime : leaveTime;
1643
+ if (visible && !renderable) {
1644
+ setRenderable(true);
1645
+ }
1646
+ setClasses("".concat(name, "-").concat(statusClassName));
1647
+
1648
+ // set class to active
1649
+ var timer = setTimeout(function () {
1650
+ setClasses("".concat(name, "-").concat(statusClassName, " ").concat(name, "-").concat(statusClassName, "-active"));
1651
+ clearTimeout(timer);
1652
+ }, time);
1653
+
1654
+ // remove classess when animation over
1655
+ var clearClassesTimer = setTimeout(function () {
1656
+ if (!visible) {
1657
+ setClasses('');
1658
+ setRenderable(false);
1659
+ }
1660
+ clearTimeout(clearClassesTimer);
1661
+ }, time + clearTime);
1662
+ return function () {
1663
+ clearTimeout(timer);
1664
+ clearTimeout(clearClassesTimer);
1665
+ };
1666
+ }, [visible, renderable]);
1667
+ if (! /*#__PURE__*/React$1.isValidElement(children) || !renderable) return null;
1668
+ var propsTransition = _objectSpread2(_objectSpread2({}, props), {}, {
1669
+ className: "".concat(children.props.className, " ").concat(className, " ").concat(classes)
1670
+ });
1671
+ return /*#__PURE__*/React$1.cloneElement(children, propsTransition);
1672
+ };
1673
+ CssTransition.displayName = 'CssTransition';
1674
+
1675
+ var tuple = function tuple() {
1676
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1677
+ args[_key] = arguments[_key];
1678
+ }
1679
+ return args;
1680
+ };
1681
+ tuple('default', 'secondary', 'success', 'warning', 'error', 'abort', 'secondary-light', 'success-light', 'warning-light', 'error-light');
1682
+ tuple('default', 'secondary', 'success', 'warning', 'error');
1683
+ tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite');
1684
+ tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite', 'alert', 'purple', 'violet', 'cyan');
1685
+ tuple('default', 'silent', 'prevent');
1686
+ tuple('hover', 'click');
1687
+ tuple('top', 'topStart', 'topEnd', 'left', 'leftStart', 'leftEnd', 'bottom', 'bottomStart', 'bottomEnd', 'right', 'rightStart', 'rightEnd');
1688
+ tuple('start', 'center', 'end', 'left', 'right');
1689
+
1690
+ var makeToastActions = function makeToastActions(actions, cancelHandle) {
1691
+ var handler = function handler(event, userHandler) {
1692
+ userHandler && userHandler(event, cancelHandle);
1693
+ };
1694
+ if (!actions || !actions.length) return null;
1695
+ return actions.map(function (action, index) {
1696
+ return /*#__PURE__*/React$1.createElement("button", {
1697
+ color: action.passive ? 'default' : 'secondary',
1698
+ key: "action-".concat(index),
1699
+ onClick: function onClick(event) {
1700
+ return handler(event, action.handler);
1701
+ }
1702
+ }, action.name);
1703
+ });
1704
+ };
1705
+ var getColors = function getColors(palette, type) {
1706
+ var colors = {
1707
+ "default": palette.background,
1708
+ secondary: palette.secondary,
1709
+ success: palette.success,
1710
+ warning: palette.warning,
1711
+ error: palette.error
1712
+ };
1713
+ var isDefault = !type || type === 'default';
1714
+ if (isDefault) return {
1715
+ bgColor: colors["default"],
1716
+ color: palette.foreground
1717
+ };
1718
+ /**
1719
+ * Prevent main color change in special types.
1720
+ * The color will only follow the theme when it is in the default type.
1721
+ */
1722
+ return {
1723
+ bgColor: colors[type],
1724
+ color: 'white'
1725
+ };
1726
+ };
1727
+ tuple('topLeft', 'topRight', 'bottomLeft', 'bottomRight');
1728
+ var isTopPlacement = function isTopPlacement(placement) {
1729
+ return "".concat(placement).toLowerCase().startsWith('top');
1730
+ };
1731
+ var isLeftPlacement = function isLeftPlacement(placement) {
1732
+ return "".concat(placement).toLowerCase().endsWith('left');
1733
+ };
1734
+ var getTranslateByPlacement = function getTranslateByPlacement(placement) {
1735
+ var translateInByPlacement = {
1736
+ topLeft: 'translate(-60px, -60px)',
1737
+ topRight: 'translate(60px, -60px)',
1738
+ bottomLeft: 'translate(-60px, 60px)',
1739
+ bottomRight: 'translate(60px, 60px)'
1740
+ };
1741
+ var translateOutByPlacement = {
1742
+ topLeft: 'translate(-50px, 15px) scale(0.85)',
1743
+ topRight: 'translate(50px, 15px) scale(0.85)',
1744
+ bottomLeft: 'translate(-50px, -15px) scale(0.85)',
1745
+ bottomRight: 'translate(50px, -15px) scale(0.85)'
1746
+ };
1747
+ return {
1748
+ enter: translateInByPlacement[placement],
1749
+ leave: translateOutByPlacement[placement]
1750
+ };
1751
+ };
1752
+
1753
+ var ToastItem = /*#__PURE__*/React$1.memo(function (_ref) {
1754
+ var toast = _ref.toast,
1755
+ layout = _ref.layout;
1756
+ var theme = useTheme();
1757
+ var _useMemo = React$1.useMemo(function () {
1758
+ return getColors(theme.palette, toast.type);
1759
+ }, [theme.palette, toast.type]),
1760
+ color = _useMemo.color,
1761
+ bgColor = _useMemo.bgColor;
1762
+ var isReactNode = typeof toast.text !== 'string';
1763
+ var padding = layout.padding,
1764
+ margin = layout.margin,
1765
+ maxHeight = layout.maxHeight,
1766
+ maxWidth = layout.maxWidth,
1767
+ width = layout.width,
1768
+ placement = layout.placement;
1769
+ var _useMemo2 = React$1.useMemo(function () {
1770
+ return getTranslateByPlacement(placement);
1771
+ }, [placement]),
1772
+ enter = _useMemo2.enter,
1773
+ leave = _useMemo2.leave;
1774
+ return /*#__PURE__*/React$1.createElement(CssTransition, {
1775
+ name: "toast",
1776
+ visible: toast.visible,
1777
+ clearTime: 350
1778
+ }, /*#__PURE__*/React$1.createElement("div", {
1779
+ key: toast.id,
1780
+ className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "toast"
1781
+ }, isReactNode ? toast.text : /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("div", {
1782
+ className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "message"
1783
+ }, toast.text), /*#__PURE__*/React$1.createElement("div", {
1784
+ className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "action"
1785
+ }, makeToastActions(toast.actions, toast.cancel))), /*#__PURE__*/React$1.createElement(_JSXStyle, {
1786
+ id: "1407001838",
1787
+ dynamic: [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]
1788
+ }, ".toast.__jsx-style-dynamic-selector{width:".concat(width, ";max-width:").concat(maxWidth, ";max-height:").concat(maxHeight, ";display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(theme.palette.foreground, ";background-color:").concat(bgColor, ";color:").concat(color, ";border:0;border-radius:").concat(theme.layout.radius, ";opacity:1;box-shadow:").concat(theme.expressiveness.shadowSmall, ";-webkit-transition:all 350ms cubic-bezier(0.1,0.2,0.1,1);transition:all 350ms cubic-bezier(0.1,0.2,0.1,1);overflow:hidden;}.message.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;font-size:0.875em;display:-webkit-box;word-break:break-all;padding-right:").concat(theme.layout.gapHalf, ";overflow:hidden;max-height:100%;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-height:1.1rem;}.toast-enter.__jsx-style-dynamic-selector{opacity:0;height:0;padding:0;margin:0;-webkit-transform:").concat(enter, ";-ms-transform:").concat(enter, ";transform:").concat(enter, ";}.toast-enter-active.__jsx-style-dynamic-selector{opacity:1;height:auto;margin:").concat(margin, ";padding:").concat(padding, ";-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);}.toast-leave.__jsx-style-dynamic-selector{opacity:1;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);height:auto;margin:").concat(margin, ";padding:").concat(padding, ";}.toast-leave-active.__jsx-style-dynamic-selector{opacity:0;-webkit-transform:").concat(leave, ";-ms-transform:").concat(leave, ";transform:").concat(leave, ";}"))));
1789
+ });
1790
+
1791
+ /* "use client" */
1792
+
1793
+ var classObjectToString = function classObjectToString(className) {
1794
+ var keys = Object.keys(className);
1795
+ var len = keys.length;
1796
+ var str = '';
1797
+ for (var index = 0; index < len; index++) {
1798
+ var key = keys[index];
1799
+ var val = className[keys[index]];
1800
+ if (!val) continue;
1801
+ str = str ? "".concat(str, " ").concat(String(key)) : String(key);
1802
+ }
1803
+ return str;
1804
+ };
1805
+ var isObjectClassName = function isObjectClassName(value) {
1806
+ return _typeof(value) === 'object' && !Array.isArray(value);
1807
+ };
1808
+ var useClasses = function useClasses() {
1809
+ var len = arguments.length;
1810
+ var classes = '';
1811
+ if (len === 0) return classes;
1812
+ for (var index = 0; index < len; index++) {
1813
+ var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
1814
+ if (!val) continue;
1815
+ if (isObjectClassName(val)) {
1816
+ classes += " ".concat(classObjectToString(val));
1817
+ } else {
1818
+ classes += " ".concat(String(val).trim());
1819
+ }
1820
+ }
1821
+ return classes.trim();
1822
+ };
1823
+
1824
+ var ToastContainer = function ToastContainer() {
1825
+ var theme = useTheme();
1826
+ var portal = usePortal('toast');
1827
+ var _useCurrentState = useCurrentState(false),
1828
+ _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
1829
+ setHovering = _useCurrentState2[1],
1830
+ hoveringRef = _useCurrentState2[2];
1831
+ var _useHUIContext = useHUIContext(),
1832
+ toasts = _useHUIContext.toasts,
1833
+ updateToasts = _useHUIContext.updateToasts,
1834
+ toastLayout = _useHUIContext.toastLayout,
1835
+ lastUpdateToastId = _useHUIContext.lastUpdateToastId;
1836
+ var memoizedLayout = React$1.useMemo(function () {
1837
+ return toastLayout;
1838
+ }, [toastLayout]);
1839
+ var toastElements = React$1.useMemo(function () {
1840
+ return toasts.map(function (toast) {
1841
+ return /*#__PURE__*/React$1.createElement(ToastItem, {
1842
+ toast: toast,
1843
+ layout: memoizedLayout,
1844
+ key: toast._internalIdent
1845
+ });
1846
+ });
1847
+ }, [toasts, memoizedLayout]);
1848
+ var classNames = React$1.useMemo(function () {
1849
+ return useClasses('toasts', {
1850
+ top: isTopPlacement(toastLayout.placement),
1851
+ left: isLeftPlacement(toastLayout.placement)
1852
+ });
1853
+ }, [memoizedLayout]);
1854
+ var hoverHandler = function hoverHandler(isHovering) {
1855
+ setHovering(isHovering);
1856
+ if (isHovering) {
1857
+ return updateToasts(function (last) {
1858
+ return last.map(function (toast) {
1859
+ if (!toast.visible) return toast;
1860
+ toast._timeout && window.clearTimeout(toast._timeout);
1861
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
1862
+ timeout: null
1863
+ });
1864
+ });
1865
+ });
1866
+ }
1867
+ updateToasts(function (last) {
1868
+ return last.map(function (toast, index) {
1869
+ if (!toast.visible) return toast;
1870
+ toast._timeout && window.clearTimeout(toast._timeout);
1871
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
1872
+ _timeout: function () {
1873
+ var timer = window.setTimeout(function () {
1874
+ toast.cancel();
1875
+ window.clearTimeout(timer);
1876
+ }, toast.delay + index * 100);
1877
+ return timer;
1878
+ }()
1879
+ });
1880
+ });
1881
+ });
1882
+ };
1883
+ React$1.useEffect(function () {
1884
+ var index = toasts.findIndex(function (r) {
1885
+ return r._internalIdent === lastUpdateToastId;
1886
+ });
1887
+ var toast = toasts[index];
1888
+ if (!toast || toast.visible || !hoveringRef.current) return;
1889
+ var hasVisible = toasts.find(function (r, i) {
1890
+ return i < index && r.visible;
1891
+ });
1892
+ if (hasVisible || !hoveringRef.current) return;
1893
+ hoverHandler(false);
1894
+ }, [toasts, lastUpdateToastId]);
1895
+ React$1.useEffect(function () {
1896
+ var timeout = null;
1897
+ var timer = window.setInterval(function () {
1898
+ if (toasts.length === 0) return;
1899
+ timeout = window.setTimeout(function () {
1900
+ var allInvisible = !toasts.find(function (r) {
1901
+ return r.visible;
1902
+ });
1903
+ allInvisible && updateToasts(function () {
1904
+ return [];
1905
+ });
1906
+ timeout && clearTimeout(timeout);
1907
+ }, 350);
1908
+ }, 5000);
1909
+ return function () {
1910
+ timer && clearInterval(timer);
1911
+ timeout && clearTimeout(timeout);
1912
+ };
1913
+ }, [toasts]);
1914
+ if (!portal) return null;
1915
+ if (!toasts || toasts.length === 0) return null;
1916
+ return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React$1.createElement("div", {
1917
+ onMouseEnter: function onMouseEnter() {
1918
+ return hoverHandler(true);
1919
+ },
1920
+ onMouseLeave: function onMouseLeave() {
1921
+ return hoverHandler(false);
1922
+ },
1923
+ className: _JSXStyle.dynamic([["622610754", [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]]]) + " " + (classNames || "")
1924
+ }, toastElements, /*#__PURE__*/React$1.createElement(_JSXStyle, {
1925
+ id: "622610754",
1926
+ dynamic: [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]
1927
+ }, ".toasts.__jsx-style-dynamic-selector{position:fixed;width:auto;max-width:100%;right:".concat(theme.layout.gap, ";bottom:").concat(theme.layout.gap, ";z-index:2000;-webkit-transition:all 400ms ease;transition:all 400ms ease;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}.top.__jsx-style-dynamic-selector{bottom:unset;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;top:").concat(theme.layout.gap, ";}.left.__jsx-style-dynamic-selector{right:unset;left:").concat(theme.layout.gap, ";}"))), portal);
1928
+ };
1929
+
1930
+ var HuiProvider = function HuiProvider(_ref) {
1931
+ var themes = _ref.themes,
1932
+ themeType = _ref.themeType,
1933
+ children = _ref.children;
1934
+ var _React$useState = React$1.useState(''),
1935
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1936
+ lastUpdateToastId = _React$useState2[0],
1937
+ setLastUpdateToastId = _React$useState2[1];
1938
+ var _useCurrentState = useCurrentState([]),
1939
+ _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
1940
+ toasts = _useCurrentState2[0],
1941
+ setToasts = _useCurrentState2[1],
1942
+ toastsRef = _useCurrentState2[2];
1943
+ var _useCurrentState3 = useCurrentState(defaultToastLayout),
1944
+ _useCurrentState4 = _slicedToArray(_useCurrentState3, 3),
1945
+ toastLayout = _useCurrentState4[0],
1946
+ setToastLayout = _useCurrentState4[1],
1947
+ toastLayoutRef = _useCurrentState4[2];
1948
+ var updateToasts = function updateToasts(fn) {
1949
+ var nextToasts = fn(toastsRef.current);
1950
+ setToasts(nextToasts);
1951
+ };
1952
+ var updateToastLayout = function updateToastLayout(fn) {
1953
+ var nextLayout = fn(toastLayoutRef.current);
1954
+ setToastLayout(nextLayout);
1955
+ };
1956
+ var updateLastToastId = function updateLastToastId(fn) {
1957
+ setLastUpdateToastId(fn());
1958
+ };
1959
+ var initialValue = React$1.useMemo(function () {
1960
+ return {
1961
+ toasts: toasts,
1962
+ toastLayout: toastLayout,
1963
+ updateToasts: updateToasts,
1964
+ lastUpdateToastId: lastUpdateToastId,
1965
+ updateToastLayout: updateToastLayout,
1966
+ updateLastToastId: updateLastToastId
1967
+ };
1968
+ }, [toasts, toastLayout, lastUpdateToastId]);
1969
+ return /*#__PURE__*/React$1.createElement(HUIContent.Provider, {
1970
+ value: initialValue
1971
+ }, /*#__PURE__*/React$1.createElement(ThemeProvider, {
1972
+ themes: themes,
1973
+ themeType: themeType
1974
+ }, children, /*#__PURE__*/React$1.createElement(ToastContainer, null)));
1975
+ };
1976
+
1977
+ // import flush from 'styled-jsx'
1978
+
1979
+ // export type FlushToReact = <T>(opts?: { nonce?: string }) => Array<ReactElement<T>>
1980
+
1981
+ // export type FlushToHTML = (opts?: { nonce?: string }) => string
1982
+
1983
+ var CssBaseline = function CssBaseline(_ref) {
1984
+ var children = _ref.children;
1985
+ var theme = useTheme();
1986
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, children, /*#__PURE__*/React$1.createElement(_JSXStyle, {
1987
+ id: "3647548829",
1988
+ dynamic: [theme.palette.background, theme.palette.foreground, theme.palette.background, theme.font.sans, theme.font.sans, theme.palette.link, theme.expressiveness.linkStyle, theme.expressiveness.linkHoverStyle, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gap, theme.palette.foreground, theme.palette.code, theme.font.mono, theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.palette.accents_2, theme.layout.radius, theme.font.mono, theme.palette.foreground, theme.palette.accents_2, theme.palette.accents_1, theme.layout.gap, theme.layout.gap, theme.palette.accents_5, theme.palette.accents_1, theme.layout.radius, theme.palette.border, theme.palette.selection, theme.palette.foreground]
1989
+ }, "html,body{background-color:".concat(theme.palette.background, ";color:").concat(theme.palette.foreground, ";}html{font-size:16px;--helpdice-icons-background:").concat(theme.palette.background, ";}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;font-size:1rem;line-height:1.5;margin:0;padding:0;min-height:100%;position:relative;overflow-x:hidden;font-family:").concat(theme.font.sans, ";}#__next{overflow-x:hidden;}*,*:before,*:after{box-sizing:inherit;text-rendering:geometricPrecision;-webkit-tap-highlight-color:transparent;}p,small{font-weight:400;color:inherit;-webkit-letter-spacing:-0.005625em;-moz-letter-spacing:-0.005625em;-ms-letter-spacing:-0.005625em;letter-spacing:-0.005625em;font-family:").concat(theme.font.sans, ";}p{margin:1em 0;font-size:1em;line-height:1.625em;}small{margin:0;line-height:1.5;font-size:0.875em;}b{font-weight:600;}span{font-size:inherit;color:inherit;font-weight:inherit;}img{max-width:100%;}a{cursor:pointer;font-size:inherit;-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(theme.palette.link, ";-webkit-text-decoration:").concat(theme.expressiveness.linkStyle, ";text-decoration:").concat(theme.expressiveness.linkStyle, ";}a:hover{-webkit-text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";}ul,ol{padding:0;list-style-type:none;margin:").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gap, ";color:").concat(theme.palette.foreground, ";}ol{list-style-type:decimal;}li{margin-bottom:0.625em;font-size:1em;line-height:1.625em;}h1,h2,h3,h4,h5,h6{color:inherit;margin:0 0 0.7rem 0;}h1{font-size:3rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;line-height:1.5;font-weight:700;}h2{font-size:2.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h3{font-size:1.5rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h4{font-size:1.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h5{font-size:1rem;-webkit-letter-spacing:-0.01em;-moz-letter-spacing:-0.01em;-ms-letter-spacing:-0.01em;letter-spacing:-0.01em;font-weight:600;}h6{font-size:0.875rem;-webkit-letter-spacing:-0.005em;-moz-letter-spacing:-0.005em;-ms-letter-spacing:-0.005em;letter-spacing:-0.005em;font-weight:600;}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit;color:inherit;margin:0;}button:focus,input:focus,select:focus,textarea:focus{outline:none;}code{color:").concat(theme.palette.code, ";font-family:").concat(theme.font.mono, ";font-size:0.9em;white-space:pre-wrap;}code:before,code:after{content:'\\`';}pre{padding:calc(").concat(theme.layout.gap, " * 0.9) ").concat(theme.layout.gap, ";margin:").concat(theme.layout.gap, " 0;border:1px solid ").concat(theme.palette.accents_2, ";border-radius:").concat(theme.layout.radius, ";font-family:").concat(theme.font.mono, ";white-space:pre;overflow:auto;line-height:1.5;text-align:left;font-size:14px;-webkit-overflow-scrolling:touch;}pre code{color:").concat(theme.palette.foreground, ";font-size:1em;line-height:1.25em;white-space:pre;}pre code:before,pre code:after{display:none;}pre p{margin:0;}pre::-webkit-scrollbar{display:none;width:0;height:0;background:transparent;}hr{border-color:").concat(theme.palette.accents_2, ";}details{background-color:").concat(theme.palette.accents_1, ";border:none;}details:focus,details:hover,details:active{outline:none;}summary{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;list-style:none;outline:none;}summary::marker,summary::before,summary::-webkit-details-marker{display:none;}summary::-moz-list-bullet{font-size:0;}summary:focus,summary:hover,summary:active{outline:none;list-style:none;}blockquote{padding:calc(0.667 * ").concat(theme.layout.gap, ") ").concat(theme.layout.gap, ";color:").concat(theme.palette.accents_5, ";background-color:").concat(theme.palette.accents_1, ";border-radius:").concat(theme.layout.radius, ";margin:1.5em 0;border:1px solid ").concat(theme.palette.border, ";}blockquote *:first-child{margin-top:0;}blockquote *:last-child{margin-bottom:0;}::selection{background-color:").concat(theme.palette.selection, ";color:").concat(theme.palette.foreground, ";}")));
1990
+ };
1991
+ var MemoCssBaseline = /*#__PURE__*/React$1.memo(CssBaseline);
1992
+
1993
+ var getElementOffset = function getElementOffset(el) {
1994
+ if (!el) return {
1995
+ top: 0,
1996
+ left: 0
1997
+ };
1998
+ var _el$getBoundingClient = el.getBoundingClientRect(),
1999
+ top = _el$getBoundingClient.top,
2000
+ left = _el$getBoundingClient.left;
2001
+ return {
2002
+ top: top,
2003
+ left: left
2004
+ };
2005
+ };
2006
+ var defaultRect$1 = {
2007
+ top: -1e3,
2008
+ left: -1e3,
2009
+ right: -1e3,
2010
+ width: 0,
2011
+ height: 0,
2012
+ elementTop: -1e3
2013
+ };
2014
+ var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect, getContainer) {
2015
+ if (!domRect) return defaultRect$1;
2016
+ var container = getContainer ? getContainer() : null;
2017
+ var scrollElement = container || document.documentElement;
2018
+ var _getElementOffset = getElementOffset(container),
2019
+ offsetTop = _getElementOffset.top,
2020
+ offsetLeft = _getElementOffset.left;
2021
+ return _objectSpread2(_objectSpread2({}, domRect), {}, {
2022
+ width: domRect.width || domRect.right - domRect.left,
2023
+ height: domRect.height || domRect.top - domRect.bottom,
2024
+ top: domRect.bottom + scrollElement.scrollTop - offsetTop,
2025
+ left: domRect.left + scrollElement.scrollLeft - offsetLeft,
2026
+ elementTop: domRect.top + scrollElement.scrollTop - offsetTop
2027
+ });
2028
+ };
2029
+ var isUnplacedRect = function isUnplacedRect(rect) {
2030
+ if (!rect) return true;
2031
+ return rect.top === defaultRect$1.top && rect.left === defaultRect$1.left;
2032
+ };
2033
+ var getRefRect = function getRefRect(ref, getContainer) {
2034
+ if (!ref || !ref.current) return defaultRect$1;
2035
+ var rect = ref.current.getBoundingClientRect();
2036
+ return getRectFromDOMWithContainer(rect, getContainer);
2037
+ };
2038
+ var getEventRect = function getEventRect(event, getContainer) {
2039
+ var _event$target;
2040
+ var rect = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getBoundingClientRect();
2041
+ if (!rect) return defaultRect$1;
2042
+ return getRectFromDOMWithContainer(rect, getContainer);
2043
+ };
2044
+ var isRefTarget = function isRefTarget(eventOrRef) {
2045
+ return typeof (eventOrRef === null || eventOrRef === void 0 ? void 0 : eventOrRef.target) === 'undefined';
2046
+ };
2047
+ var useRect = function useRect(initialState) {
2048
+ var _useState = React$1.useState(initialState || defaultRect$1),
2049
+ _useState2 = _slicedToArray(_useState, 2),
2050
+ rect = _useState2[0],
2051
+ setRect = _useState2[1];
2052
+ var updateRect = function updateRect(eventOrRef, getContainer) {
2053
+ if (isRefTarget(eventOrRef)) return setRect(getRefRect(eventOrRef, getContainer));
2054
+ setRect(getEventRect(eventOrRef, getContainer));
2055
+ };
2056
+ return {
2057
+ rect: rect,
2058
+ setRect: updateRect
2059
+ };
2060
+ };
2061
+
2062
+ var defaultToast = {
2063
+ delay: 2000,
2064
+ type: 'default'
2065
+ };
2066
+ var useToasts = function useToasts(layout) {
2067
+ var _useHUIContext = useHUIContext(),
2068
+ updateToasts = _useHUIContext.updateToasts,
2069
+ toasts = _useHUIContext.toasts,
2070
+ updateToastLayout = _useHUIContext.updateToastLayout,
2071
+ updateLastToastId = _useHUIContext.updateLastToastId;
2072
+ React$1.useEffect(function () {
2073
+ if (!layout) return;
2074
+ updateToastLayout(function () {
2075
+ return layout ? _objectSpread2(_objectSpread2({}, defaultToastLayout), layout) : defaultToastLayout;
2076
+ });
2077
+ }, []);
2078
+ var _cancel = function cancel(internalId) {
2079
+ updateToasts(function (currentToasts) {
2080
+ return currentToasts.map(function (item) {
2081
+ if (item._internalIdent !== internalId) return item;
2082
+ return _objectSpread2(_objectSpread2({}, item), {}, {
2083
+ visible: false
2084
+ });
2085
+ });
2086
+ });
2087
+ updateLastToastId(function () {
2088
+ return internalId;
2089
+ });
2090
+ };
2091
+ var removeAll = function removeAll() {
2092
+ updateToasts(function (last) {
2093
+ return last.map(function (toast) {
2094
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
2095
+ visible: false
2096
+ });
2097
+ });
2098
+ });
2099
+ };
2100
+ var findToastOneByID = function findToastOneByID(id) {
2101
+ return toasts.find(function (t) {
2102
+ return t.id === id;
2103
+ });
2104
+ };
2105
+ var removeToastOneByID = function removeToastOneByID(id) {
2106
+ updateToasts(function (last) {
2107
+ return last.map(function (toast) {
2108
+ if (toast.id !== id) return toast;
2109
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
2110
+ visible: false
2111
+ });
2112
+ });
2113
+ });
2114
+ };
2115
+ var setToast = function setToast(toast) {
2116
+ var internalIdent = "toast-".concat(getId());
2117
+ var delay = toast.delay || defaultToast.delay;
2118
+ if (toast.id) {
2119
+ var hasIdent = toasts.find(function (t) {
2120
+ return t.id === toast.id;
2121
+ });
2122
+ if (hasIdent) {
2123
+ throw new Error('Toast: Already have the same key: "ident"');
2124
+ }
2125
+ }
2126
+ updateToasts(function (last) {
2127
+ var newToast = {
2128
+ delay: delay,
2129
+ text: toast.text,
2130
+ visible: true,
2131
+ type: toast.type || defaultToast.type,
2132
+ id: toast.id || internalIdent,
2133
+ actions: toast.actions || [],
2134
+ _internalIdent: internalIdent,
2135
+ _timeout: window.setTimeout(function () {
2136
+ _cancel(internalIdent);
2137
+ if (newToast._timeout) {
2138
+ window.clearTimeout(newToast._timeout);
2139
+ newToast._timeout = null;
2140
+ }
2141
+ }, delay),
2142
+ cancel: function cancel() {
2143
+ return _cancel(internalIdent);
2144
+ }
2145
+ };
2146
+ return [].concat(_toConsumableArray(last), [newToast]);
2147
+ });
2148
+ };
2149
+ return {
2150
+ toasts: toasts,
2151
+ setToast: setToast,
2152
+ removeAll: removeAll,
2153
+ findToastOneByID: findToastOneByID,
2154
+ removeToastOneByID: removeToastOneByID
2155
+ };
2156
+ };
2157
+
2158
+ tuple('xs', 'sm', 'md', 'lg', 'xl', 'mobile');
2159
+ tuple('up', 'down', 'default');
2160
+ var defaultResponsiveOptions = {
2161
+ match: 'default'
2162
+ };
2163
+ var makeQueries = function makeQueries(bp, up, down) {
2164
+ var queryString = function queryString(item) {
2165
+ var upQuery = "(min-width: ".concat(item.min, ")");
2166
+ var downQuery = "(max-width: ".concat(item.max, ")");
2167
+ return up ? upQuery : down ? downQuery : "".concat(upQuery, " and ").concat(downQuery);
2168
+ };
2169
+ var xs = queryString(bp.xs);
2170
+ return {
2171
+ xs: xs,
2172
+ mobile: xs,
2173
+ sm: queryString(bp.sm),
2174
+ md: queryString(bp.md),
2175
+ lg: queryString(bp.lg),
2176
+ xl: queryString(bp.xl)
2177
+ };
2178
+ };
2179
+ var useMediaQuery = function useMediaQuery(breakpoint) {
2180
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultResponsiveOptions;
2181
+ var _options$match = options.match,
2182
+ matchType = _options$match === void 0 ? 'default' : _options$match,
2183
+ _options$ssrMatchMedi = options.ssrMatchMedia,
2184
+ ssrMatchMedia = _options$ssrMatchMedi === void 0 ? null : _options$ssrMatchMedi;
2185
+ var supportMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
2186
+ var theme = useTheme();
2187
+ var mediaQueries = React$1.useMemo(function () {
2188
+ var up = matchType === 'up';
2189
+ var down = matchType === 'down';
2190
+ return makeQueries(theme.breakpoints, up, down);
2191
+ }, [theme.breakpoints, options]);
2192
+ var query = React$1.useMemo(function () {
2193
+ return mediaQueries[breakpoint];
2194
+ }, [mediaQueries, breakpoint]);
2195
+ var matchQuery = function matchQuery(q) {
2196
+ return window.matchMedia(q);
2197
+ };
2198
+
2199
+ /**
2200
+ * Do nothing in the server-side rendering.
2201
+ * If server match query fucntion is simulated, return user-defined value first.
2202
+ */
2203
+ var _useState = React$1.useState(function () {
2204
+ if (supportMedia) return matchQuery(query).matches;
2205
+ if (ssrMatchMedia && typeof ssrMatchMedia === 'function') {
2206
+ return ssrMatchMedia(query).matches;
2207
+ }
2208
+ return false;
2209
+ }),
2210
+ _useState2 = _slicedToArray(_useState, 2),
2211
+ state = _useState2[0],
2212
+ setState = _useState2[1];
2213
+ React$1.useEffect(function () {
2214
+ if (!supportMedia) return;
2215
+ var queryList = matchQuery(query);
2216
+ var update = function update() {
2217
+ return setState(matchQuery(query).matches);
2218
+ };
2219
+ update();
2220
+
2221
+ /**
2222
+ * addListener is deprecated. EventTarget.addEventListener is recommended.
2223
+ * But in some old browsers, MediaQueryList does not inherit from EventTarget.
2224
+ */
2225
+ queryList.addListener(update);
2226
+ return function () {
2227
+ queryList.removeListener(update);
2228
+ };
2229
+ }, [supportMedia]);
2230
+ return state;
2231
+ };
2232
+
2233
+ /* "use client" */
2234
+
2235
+ var usePrevious = function usePrevious(state) {
2236
+ var ref = React$1.useRef(null);
2237
+ React$1.useEffect(function () {
2238
+ ref.current = state;
2239
+ });
2240
+ return ref ? ref.current : null;
2241
+ };
2242
+
2243
+ var _excluded$1 = ["rect", "visible", "hoverHeightRatio", "hoverWidthRatio", "activeOpacity", "className"];
2244
+ var Highlight = function Highlight(_ref) {
2245
+ var rect = _ref.rect,
2246
+ visible = _ref.visible,
2247
+ _ref$hoverHeightRatio = _ref.hoverHeightRatio,
2248
+ hoverHeightRatio = _ref$hoverHeightRatio === void 0 ? 1 : _ref$hoverHeightRatio,
2249
+ _ref$hoverWidthRatio = _ref.hoverWidthRatio,
2250
+ hoverWidthRatio = _ref$hoverWidthRatio === void 0 ? 1 : _ref$hoverWidthRatio,
2251
+ _ref$activeOpacity = _ref.activeOpacity,
2252
+ activeOpacity = _ref$activeOpacity === void 0 ? 0.8 : _ref$activeOpacity,
2253
+ className = _ref.className,
2254
+ props = _objectWithoutProperties(_ref, _excluded$1);
2255
+ var theme = useTheme();
2256
+ var ref = React$1.useRef(null);
2257
+ var isFirstVisible = usePrevious(isUnplacedRect(rect));
2258
+ var position = React$1.useMemo(function () {
2259
+ var width = rect.width * hoverWidthRatio;
2260
+ var height = rect.height * hoverHeightRatio;
2261
+ return {
2262
+ width: "".concat(width, "px"),
2263
+ left: "".concat(rect.left + (rect.width - width) / 2, "px"),
2264
+ height: "".concat(height, "px"),
2265
+ top: "".concat(rect.elementTop + (rect.height - height) / 2, "px"),
2266
+ transition: isFirstVisible ? 'opacity' : 'opacity, width, left, top'
2267
+ };
2268
+ }, [rect, hoverWidthRatio, hoverHeightRatio]);
2269
+ return /*#__PURE__*/React$1.createElement("div", _extends({
2270
+ ref: ref
2271
+ }, props, {
2272
+ className: _JSXStyle.dynamic([["603024321", [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]]]) + " " + (props && props.className != null && props.className || useClasses('highlight', className) || "")
2273
+ }), /*#__PURE__*/React$1.createElement(_JSXStyle, {
2274
+ id: "603024321",
2275
+ dynamic: [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]
2276
+ }, ".highlight.__jsx-style-dynamic-selector{background:".concat(theme.palette.accents_2, ";position:absolute;border-radius:5px;width:").concat(position.width, ";left:").concat(position.left, ";height:").concat(position.height, ";top:").concat(position.top, ";opacity:").concat(visible ? activeOpacity : 0, ";-webkit-transition:0.15s ease;transition:0.15s ease;-webkit-transition-property:").concat(position.transition, ";transition-property:").concat(position.transition, ";}")));
2277
+ };
2278
+
2279
+ var Ellipsis = function Ellipsis(_ref) {
2280
+ var children = _ref.children,
2281
+ height = _ref.height;
2282
+ return /*#__PURE__*/React$1.createElement("span", {
2283
+ className: _JSXStyle.dynamic([["822089635", [height]]])
2284
+ }, children, /*#__PURE__*/React$1.createElement(_JSXStyle, {
2285
+ id: "822089635",
2286
+ dynamic: [height]
2287
+ }, "span.__jsx-style-dynamic-selector{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:".concat(height, ";min-width:0;}")));
2288
+ };
2289
+ var ellipsis = /*#__PURE__*/React$1.memo(Ellipsis);
2290
+
2291
+ var getRealShape = function getRealShape(el) {
2292
+ var defaultShape = {
2293
+ width: 0,
2294
+ height: 0
2295
+ };
2296
+ if (!el || typeof window === 'undefined') return defaultShape;
2297
+ var rect = el.getBoundingClientRect();
2298
+ var _window$getComputedSt = window.getComputedStyle(el),
2299
+ width = _window$getComputedSt.width,
2300
+ height = _window$getComputedSt.height;
2301
+ var getCSSStyleVal = function getCSSStyleVal(str, parentNum) {
2302
+ if (!str) return 0;
2303
+ var strVal = str.includes('px') ? +str.split('px')[0] : str.includes('%') ? +str.split('%')[0] * parentNum * 0.01 : str;
2304
+ return Number.isNaN(+strVal) ? 0 : +strVal;
2305
+ };
2306
+ return {
2307
+ width: getCSSStyleVal("".concat(width), rect.width),
2308
+ height: getCSSStyleVal("".concat(height), rect.height)
2309
+ };
2310
+ };
2311
+ var useRealShape = function useRealShape(ref) {
2312
+ var _useState = React$1.useState({
2313
+ width: 0,
2314
+ height: 0
2315
+ }),
2316
+ _useState2 = _slicedToArray(_useState, 2),
2317
+ state = _useState2[0],
2318
+ setState = _useState2[1];
2319
+ var update = function update() {
2320
+ var _getRealShape = getRealShape(ref.current),
2321
+ width = _getRealShape.width,
2322
+ height = _getRealShape.height;
2323
+ setState({
2324
+ width: width,
2325
+ height: height
2326
+ });
2327
+ };
2328
+ React$1.useEffect(function () {
2329
+ return update();
2330
+ }, [ref.current]);
2331
+ return [state, update];
2332
+ };
2333
+
2334
+ var Expand = function Expand(_ref) {
2335
+ var _ref$isExpanded = _ref.isExpanded,
2336
+ isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
2337
+ _ref$delay = _ref.delay,
2338
+ delay = _ref$delay === void 0 ? 200 : _ref$delay,
2339
+ children = _ref.children;
2340
+ var _useState = React$1.useState(isExpanded ? 'auto' : '0'),
2341
+ _useState2 = _slicedToArray(_useState, 2),
2342
+ height = _useState2[0],
2343
+ setHeight = _useState2[1];
2344
+ var _useState3 = React$1.useState(isExpanded),
2345
+ _useState4 = _slicedToArray(_useState3, 2),
2346
+ selfExpanded = _useState4[0],
2347
+ setSelfExpanded = _useState4[1];
2348
+ var _useState5 = React$1.useState(isExpanded),
2349
+ _useState6 = _slicedToArray(_useState5, 2),
2350
+ visible = _useState6[0],
2351
+ setVisible = _useState6[1];
2352
+ var contentRef = React$1.useRef(null);
2353
+ var entryTimer = React$1.useRef();
2354
+ var leaveTimer = React$1.useRef();
2355
+ var resetTimer = React$1.useRef();
2356
+ var _useRealShape = useRealShape(contentRef),
2357
+ _useRealShape2 = _slicedToArray(_useRealShape, 2),
2358
+ state = _useRealShape2[0],
2359
+ updateShape = _useRealShape2[1];
2360
+ var classes = useClasses('container', {
2361
+ expanded: selfExpanded
2362
+ });
2363
+ React$1.useEffect(function () {
2364
+ return setHeight("".concat(state.height, "px"));
2365
+ }, [state.height]);
2366
+ React$1.useEffect(function () {
2367
+ // show element or reset height.
2368
+ // force an update once manually, even if the element does not change.
2369
+ // (the height of the element might be "auto")
2370
+ if (isExpanded) {
2371
+ setVisible(isExpanded);
2372
+ } else {
2373
+ updateShape();
2374
+ setHeight("".concat(state.height, "px"));
2375
+ }
2376
+
2377
+ // show expand animation
2378
+ entryTimer.current = window.setTimeout(function () {
2379
+ setSelfExpanded(isExpanded);
2380
+ clearTimeout(entryTimer.current);
2381
+ }, 30);
2382
+
2383
+ // Reset height after animation
2384
+ if (isExpanded) {
2385
+ resetTimer.current = window.setTimeout(function () {
2386
+ setHeight('auto');
2387
+ clearTimeout(resetTimer.current);
2388
+ }, delay);
2389
+ } else {
2390
+ leaveTimer.current = window.setTimeout(function () {
2391
+ setVisible(isExpanded);
2392
+ clearTimeout(leaveTimer.current);
2393
+ }, delay / 2);
2394
+ }
2395
+ return function () {
2396
+ clearTimeout(entryTimer.current);
2397
+ clearTimeout(leaveTimer.current);
2398
+ clearTimeout(resetTimer.current);
2399
+ };
2400
+ }, [isExpanded]);
2401
+ return /*#__PURE__*/React$1.createElement("div", {
2402
+ className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + (classes || "")
2403
+ }, /*#__PURE__*/React$1.createElement("div", {
2404
+ ref: contentRef,
2405
+ className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + "content"
2406
+ }, children), /*#__PURE__*/React$1.createElement(_JSXStyle, {
2407
+ id: "1918690829",
2408
+ dynamic: [visible ? 'visible' : 'hidden', delay, height]
2409
+ }, ".container.__jsx-style-dynamic-selector{padding:0;margin:0;height:0;overflow:hidden;visibility:".concat(visible ? 'visible' : 'hidden', ";-webkit-transition:height ").concat(delay, "ms ease;transition:height ").concat(delay, "ms ease;}.expanded.__jsx-style-dynamic-selector{height:").concat(height, ";visibility:visible;}")));
2410
+ };
2411
+ Expand.displayName = 'Expand';
2412
+
2413
+ /* "use client" */
2414
+
2415
+ var useResize = function useResize(callback) {
2416
+ var immediatelyInvoke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2417
+ React$1.useEffect(function () {
2418
+ var fn = function fn() {
2419
+ return callback();
2420
+ };
2421
+ if (immediatelyInvoke) {
2422
+ fn();
2423
+ }
2424
+ window.addEventListener('resize', fn);
2425
+ return function () {
2426
+ return window.removeEventListener('resize', fn);
2427
+ };
2428
+ }, []);
2429
+ };
2430
+
2431
+ /* "use client" */
2432
+
2433
+ var useClickAnyWhere = function useClickAnyWhere(handler) {
2434
+ React$1.useEffect(function () {
2435
+ var callback = function callback(event) {
2436
+ return handler(event);
2437
+ };
2438
+ document.addEventListener('click', callback);
2439
+ return function () {
2440
+ return document.removeEventListener('click', callback);
2441
+ };
2442
+ }, [handler]);
2443
+ };
2444
+
2445
+ /* "use client" */
2446
+
2447
+ var useDOMObserver = function useDOMObserver(ref) {
2448
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
2449
+ var config = {
2450
+ attributes: false,
2451
+ childList: true,
2452
+ subtree: true
2453
+ };
2454
+ React$1.useEffect(function () {
2455
+ if (!ref || !ref.current) return;
2456
+ var unmount = false;
2457
+ var done = function done() {
2458
+ if (unmount) return;
2459
+ callback.apply(void 0, arguments);
2460
+ };
2461
+ var observer = new MutationObserver(done);
2462
+ observer.observe(ref.current, config);
2463
+ return function () {
2464
+ unmount = true;
2465
+ observer.disconnect();
2466
+ };
2467
+ }, [ref]);
2468
+ };
2469
+
2470
+ var warningStack = {};
2471
+ var useWarning = function useWarning(message, component) {
2472
+ var tag = ' ';
2473
+ var log = "[Helpdice UI]".concat(tag, ": ").concat(message);
2474
+ if (typeof console === 'undefined') return;
2475
+ if (warningStack[log]) return;
2476
+ warningStack[log] = true;
2477
+ if (process.env.NODE_ENV !== 'production') {
2478
+ return console.error(log);
2479
+ }
2480
+ console.warn(log);
2481
+ };
2482
+
2483
+ var defaultRect = {
2484
+ top: -1e3,
2485
+ left: -1e3,
2486
+ right: -1e3,
2487
+ width: 0
2488
+ };
2489
+ var Dropdown = /*#__PURE__*/React$1.memo(function (_ref) {
2490
+ var children = _ref.children,
2491
+ parent = _ref.parent,
2492
+ visible = _ref.visible,
2493
+ disableMatchWidth = _ref.disableMatchWidth,
2494
+ getPopupContainer = _ref.getPopupContainer;
2495
+ var el = usePortal('dropdown', getPopupContainer);
2496
+ var _useState = React$1.useState(defaultRect),
2497
+ _useState2 = _slicedToArray(_useState, 2),
2498
+ rect = _useState2[0],
2499
+ setRect = _useState2[1];
2500
+ var classes = useClasses('dropdown', disableMatchWidth ? 'disable-match' : 'width-match');
2501
+ if (!parent) return null;
2502
+
2503
+ /* istanbul ignore next */
2504
+ if (process.env.NODE_ENV !== 'production') {
2505
+ if (getPopupContainer && getPopupContainer()) {
2506
+ var _el = getPopupContainer();
2507
+ var style = window.getComputedStyle(_el);
2508
+ if (style.position === 'static') {
2509
+ useWarning('The element specified by "getPopupContainer" must have "position" set.');
2510
+ }
2511
+ }
2512
+ }
2513
+ var updateRect = function updateRect() {
2514
+ var _getRefRect = getRefRect(parent, getPopupContainer),
2515
+ top = _getRefRect.top,
2516
+ left = _getRefRect.left,
2517
+ right = _getRefRect.right,
2518
+ nativeWidth = _getRefRect.width;
2519
+ setRect({
2520
+ top: top,
2521
+ left: left,
2522
+ right: right,
2523
+ width: nativeWidth
2524
+ });
2525
+ };
2526
+ useResize(updateRect);
2527
+ useClickAnyWhere(function () {
2528
+ var _getRefRect2 = getRefRect(parent, getPopupContainer),
2529
+ top = _getRefRect2.top,
2530
+ left = _getRefRect2.left;
2531
+ var shouldUpdatePosition = top !== rect.top || left !== rect.left;
2532
+ if (!shouldUpdatePosition) return;
2533
+ updateRect();
2534
+ });
2535
+ useDOMObserver(parent, function () {
2536
+ updateRect();
2537
+ });
2538
+ React$1.useEffect(function () {
2539
+ if (!parent || !parent.current) return;
2540
+ parent.current.addEventListener('mouseenter', updateRect);
2541
+ /* istanbul ignore next */
2542
+ return function () {
2543
+ if (!parent || !parent.current) return;
2544
+ parent.current.removeEventListener('mouseenter', updateRect);
2545
+ };
2546
+ }, [parent]);
2547
+ var clickHandler = function clickHandler(event) {
2548
+ event.stopPropagation();
2549
+ event.nativeEvent.stopImmediatePropagation();
2550
+ event.preventDefault();
2551
+ };
2552
+ var mouseDownHandler = function mouseDownHandler(event) {
2553
+ event.preventDefault();
2554
+ };
2555
+ if (!el) return null;
2556
+ return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React$1.createElement(CssTransition, {
2557
+ visible: visible
2558
+ }, /*#__PURE__*/React$1.createElement("div", {
2559
+ onClick: clickHandler,
2560
+ onMouseDown: mouseDownHandler,
2561
+ className: _JSXStyle.dynamic([["1644673105", [rect.top + 2, rect.left, rect.width, rect.width]]]) + " " + (classes || "")
2562
+ }, children, /*#__PURE__*/React$1.createElement(_JSXStyle, {
2563
+ id: "1644673105",
2564
+ dynamic: [rect.top + 2, rect.left, rect.width, rect.width]
2565
+ }, ".dropdown.__jsx-style-dynamic-selector{position:absolute;top:".concat(rect.top + 2, "px;left:").concat(rect.left, "px;z-index:1100;}.width-match.__jsx-style-dynamic-selector{width:").concat(rect.width, "px;}.disable-match.__jsx-style-dynamic-selector{min-width:").concat(rect.width, "px;}")))), el);
2566
+ });
2567
+
2568
+ var _excluded = ["children", "onClick", "visible", "width", "onContentClick", "backdropClassName", "positionClassName", "layerClassName"];
2569
+ var Backdrop = /*#__PURE__*/React$1.memo(function (_ref) {
2570
+ var children = _ref.children,
2571
+ _ref$onClick = _ref.onClick,
2572
+ onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
2573
+ _ref$visible = _ref.visible,
2574
+ visible = _ref$visible === void 0 ? false : _ref$visible,
2575
+ width = _ref.width,
2576
+ _ref$onContentClick = _ref.onContentClick,
2577
+ onContentClick = _ref$onContentClick === void 0 ? function () {} : _ref$onContentClick,
2578
+ _ref$backdropClassNam = _ref.backdropClassName,
2579
+ backdropClassName = _ref$backdropClassNam === void 0 ? '' : _ref$backdropClassNam,
2580
+ _ref$positionClassNam = _ref.positionClassName,
2581
+ positionClassName = _ref$positionClassNam === void 0 ? '' : _ref$positionClassNam,
2582
+ _ref$layerClassName = _ref.layerClassName,
2583
+ layerClassName = _ref$layerClassName === void 0 ? '' : _ref$layerClassName,
2584
+ props = _objectWithoutProperties(_ref, _excluded);
2585
+ var theme = useTheme();
2586
+ var _useCurrentState = useCurrentState(false),
2587
+ _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
2588
+ setIsContentMouseDown = _useCurrentState2[1],
2589
+ IsContentMouseDownRef = _useCurrentState2[2];
2590
+ var clickHandler = function clickHandler(event) {
2591
+ if (IsContentMouseDownRef.current) return;
2592
+ onClick && onClick(event);
2593
+ };
2594
+ var mouseUpHandler = function mouseUpHandler() {
2595
+ if (!IsContentMouseDownRef.current) return;
2596
+ var timer = setTimeout(function () {
2597
+ setIsContentMouseDown(false);
2598
+ clearTimeout(timer);
2599
+ }, 0);
2600
+ };
2601
+ return /*#__PURE__*/React$1.createElement(CssTransition, {
2602
+ name: "backdrop-wrapper",
2603
+ visible: visible,
2604
+ clearTime: 300
2605
+ }, /*#__PURE__*/React$1.createElement("div", _extends({
2606
+ onClick: clickHandler,
2607
+ onMouseUp: mouseUpHandler
2608
+ }, props, {
2609
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (props && props.className != null && props.className || useClasses('backdrop', backdropClassName) || "")
2610
+ }), /*#__PURE__*/React$1.createElement("div", {
2611
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('layer', layerClassName) || "")
2612
+ }), /*#__PURE__*/React$1.createElement("div", {
2613
+ onClick: onContentClick,
2614
+ onMouseDown: function onMouseDown() {
2615
+ return setIsContentMouseDown(true);
2616
+ },
2617
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('position', positionClassName) || "")
2618
+ }, children), /*#__PURE__*/React$1.createElement(_JSXStyle, {
2619
+ id: "2021762493",
2620
+ dynamic: [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]
2621
+ }, ".backdrop.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;overflow:auto;z-index:1000;-webkit-overflow-scrolling:touch;box-sizing:border-box;text-align:center;}.position.__jsx-style-dynamic-selector{position:relative;z-index:1001;outline:none;max-width:90%;width:".concat(width, ";margin:20px auto;vertical-align:middle;display:inline-block;}.backdrop.__jsx-style-dynamic-selector:before{display:inline-block;width:0;height:100%;vertical-align:middle;content:'';}.layer.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;width:100%;height:100%;opacity:").concat(theme.expressiveness.portalOpacity, ";background-color:black;-webkit-transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);pointer-events:none;z-index:1000;}.backdrop-wrapper-enter.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}.backdrop-wrapper-enter-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}"))));
2622
+ });
2623
+ Backdrop.displayName = 'Backdrop';
2624
+
2625
+ dist.Backdrop = Backdrop;
2626
+ dist.CssBaseline = MemoCssBaseline;
2627
+ dist.CssTransition = CssTransition;
2628
+ dist.Dropdown = Dropdown;
2629
+ dist.Ellipsis = ellipsis;
2630
+ dist.Expand = Expand;
2631
+ dist.Highlight = Highlight;
2632
+ dist.Themes = Themes;
2633
+ dist.UiProvider = HuiProvider;
2634
+ dist.useAllThemes = useAllThemes;
2635
+ dist.useClasses = useClasses;
2636
+ dist.useCurrentState = useCurrentState;
2637
+ dist.useMediaQuery = useMediaQuery;
2638
+ dist.useRect = useRect;
2639
+ dist.useTheme = useTheme;
2640
+ dist.useToasts = useToasts;
2641
+ return dist;
2642
+ }
2643
+
2644
+ var distExports = /*@__PURE__*/ requireDist();
2645
+
2646
+ var _excluded = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
2647
+ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
2648
+ var _ref$allowDecimals = _ref.allowDecimals,
2649
+ allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
2650
+ _ref$allowNegativeVal = _ref.allowNegativeValue,
2651
+ allowNegativeValue = _ref$allowNegativeVal === void 0 ? true : _ref$allowNegativeVal,
2652
+ id = _ref.id,
2653
+ name = _ref.name,
2654
+ className = _ref.className,
2655
+ customInput = _ref.customInput,
2656
+ decimalsLimit = _ref.decimalsLimit,
2657
+ defaultValue = _ref.defaultValue,
2658
+ _ref$disabled = _ref.disabled,
2659
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
2660
+ userMaxLength = _ref.maxLength,
2661
+ userValue = _ref.value,
2662
+ onValueChange = _ref.onValueChange,
2663
+ fixedDecimalLength = _ref.fixedDecimalLength,
2664
+ placeholder = _ref.placeholder,
2665
+ decimalScale = _ref.decimalScale,
2666
+ prefix = _ref.prefix,
2667
+ suffix = _ref.suffix,
2668
+ intlConfig = _ref.intlConfig,
2669
+ step = _ref.step,
2670
+ min = _ref.min,
2671
+ max = _ref.max,
2672
+ _ref$disableGroupSepa = _ref.disableGroupSeparators,
2673
+ disableGroupSeparators = _ref$disableGroupSepa === void 0 ? false : _ref$disableGroupSepa,
2674
+ _ref$disableAbbreviat = _ref.disableAbbreviations,
2675
+ disableAbbreviations = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
2676
+ _decimalSeparator = _ref.decimalSeparator,
2677
+ _groupSeparator = _ref.groupSeparator,
2678
+ onChange = _ref.onChange,
2679
+ onFocus = _ref.onFocus,
2680
+ onBlur = _ref.onBlur,
2681
+ onKeyDown = _ref.onKeyDown,
2682
+ onKeyUp = _ref.onKeyUp,
2683
+ transformRawValue = _ref.transformRawValue,
2684
+ _ref$formatValueOnBlu = _ref.formatValueOnBlur,
2685
+ formatValueOnBlur = _ref$formatValueOnBlu === void 0 ? true : _ref$formatValueOnBlu,
2686
+ children = _ref.children,
2687
+ props = _objectWithoutProperties(_ref, _excluded);
2688
+ var theme = distExports.useTheme();
2689
+ if (_decimalSeparator && isNumber(_decimalSeparator)) {
2690
+ throw new Error('decimalSeparator cannot be a number');
2691
+ }
2692
+ if (_groupSeparator && isNumber(_groupSeparator)) {
2693
+ throw new Error('groupSeparator cannot be a number');
2694
+ }
2695
+ var localeConfig = React.useMemo(function () {
2696
+ return getLocaleConfig(intlConfig);
2697
+ }, [intlConfig]);
2698
+ var decimalSeparator = _decimalSeparator || localeConfig.decimalSeparator || '';
2699
+ var groupSeparator = _groupSeparator || localeConfig.groupSeparator || '';
2700
+ if (decimalSeparator && groupSeparator && decimalSeparator === groupSeparator && disableGroupSeparators === false) {
2701
+ throw new Error('decimalSeparator cannot be the same as groupSeparator');
2702
+ }
2703
+ var formatValueOptions = {
2704
+ decimalSeparator: decimalSeparator,
2705
+ groupSeparator: groupSeparator,
2706
+ disableGroupSeparators: disableGroupSeparators,
2707
+ intlConfig: intlConfig,
2708
+ prefix: prefix || localeConfig.prefix,
2709
+ suffix: suffix
2710
+ };
2711
+ var cleanValueOptions = {
2712
+ decimalSeparator: decimalSeparator,
2713
+ groupSeparator: groupSeparator,
2714
+ allowDecimals: allowDecimals,
2715
+ decimalsLimit: decimalsLimit || fixedDecimalLength || 2,
2716
+ allowNegativeValue: allowNegativeValue,
2717
+ disableAbbreviations: disableAbbreviations,
2718
+ prefix: prefix || localeConfig.prefix,
2719
+ transformRawValue: transformRawValue
2720
+ };
2721
+ var _useState = React.useState(function () {
2722
+ return defaultValue != null ? formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
2723
+ decimalScale: decimalScale,
2724
+ value: String(defaultValue)
2725
+ })) : userValue != null ? formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
2726
+ decimalScale: decimalScale,
2727
+ value: String(userValue)
2728
+ })) : '';
2729
+ }),
2730
+ _useState2 = _slicedToArray(_useState, 2),
2731
+ stateValue = _useState2[0],
2732
+ setStateValue = _useState2[1];
2733
+ var _useState3 = React.useState(false),
2734
+ _useState4 = _slicedToArray(_useState3, 2),
2735
+ dirty = _useState4[0],
2736
+ setDirty = _useState4[1];
2737
+ var _useState5 = React.useState(0),
2738
+ _useState6 = _slicedToArray(_useState5, 2),
2739
+ cursor = _useState6[0],
2740
+ setCursor = _useState6[1];
2741
+ var _useState7 = React.useState(0),
2742
+ _useState8 = _slicedToArray(_useState7, 2),
2743
+ changeCount = _useState8[0],
2744
+ setChangeCount = _useState8[1];
2745
+ var _useState9 = React.useState(null),
2746
+ _useState0 = _slicedToArray(_useState9, 2),
2747
+ lastKeyStroke = _useState0[0],
2748
+ setLastKeyStroke = _useState0[1];
2749
+ var inputRef = React.useRef(null);
2750
+ React.useImperativeHandle(ref, function () {
2751
+ return inputRef.current;
2752
+ });
2753
+
2754
+ /**
2755
+ * Process change in value
2756
+ */
2757
+ var processChange = function processChange(value, selectionStart) {
2758
+ setDirty(true);
2759
+ var _repositionCursor = repositionCursor({
2760
+ selectionStart: selectionStart,
2761
+ value: value,
2762
+ lastKeyStroke: lastKeyStroke,
2763
+ stateValue: stateValue,
2764
+ groupSeparator: groupSeparator
2765
+ }),
2766
+ modifiedValue = _repositionCursor.modifiedValue,
2767
+ cursorPosition = _repositionCursor.cursorPosition;
2768
+ var stringValue = cleanValue(_objectSpread2({
2769
+ value: modifiedValue
2770
+ }, cleanValueOptions));
2771
+ if (userMaxLength && stringValue.replace(/-/g, '').length > userMaxLength) {
2772
+ return;
2773
+ }
2774
+ if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
2775
+ onValueChange && onValueChange(undefined, name, {
2776
+ "float": null,
2777
+ formatted: '',
2778
+ value: ''
2779
+ });
2780
+ setStateValue(stringValue);
2781
+ // Always sets cursor after '-' or decimalSeparator input
2782
+ setCursor(1);
2783
+ return;
2784
+ }
2785
+ var stringValueWithoutSeparator = decimalSeparator ? stringValue.replace(decimalSeparator, '.') : stringValue;
2786
+ var numberValue = parseFloat(stringValueWithoutSeparator);
2787
+ var formattedValue = formatValue(_objectSpread2({
2788
+ value: stringValue
2789
+ }, formatValueOptions));
2790
+ if (cursorPosition != null) {
2791
+ // Prevent cursor jumping
2792
+ var newCursor = cursorPosition + (formattedValue.length - value.length);
2793
+ newCursor = newCursor <= 0 ? prefix ? prefix.length : 0 : newCursor;
2794
+ setCursor(newCursor);
2795
+ setChangeCount(changeCount + 1);
2796
+ }
2797
+ setStateValue(formattedValue);
2798
+ if (onValueChange) {
2799
+ var values = {
2800
+ "float": numberValue,
2801
+ formatted: formattedValue,
2802
+ value: stringValue
2803
+ };
2804
+ onValueChange(stringValue, name, values);
2805
+ }
2806
+ };
2807
+
2808
+ /**
2809
+ * Handle change event
2810
+ */
2811
+ var handleOnChange = function handleOnChange(event) {
2812
+ var _event$target = event.target,
2813
+ value = _event$target.value,
2814
+ selectionStart = _event$target.selectionStart;
2815
+ processChange(value, selectionStart);
2816
+ onChange && onChange(event);
2817
+ };
2818
+
2819
+ /**
2820
+ * Handle focus event
2821
+ */
2822
+ var handleOnFocus = function handleOnFocus(event) {
2823
+ onFocus && onFocus(event);
2824
+ return stateValue ? stateValue.length : 0;
2825
+ };
2826
+
2827
+ /**
2828
+ * Handle blur event
2829
+ *
2830
+ * Format value by padding/trimming decimals if required by
2831
+ */
2832
+ var handleOnBlur = function handleOnBlur(event) {
2833
+ var value = event.target.value;
2834
+ var valueOnly = cleanValue(_objectSpread2({
2835
+ value: value
2836
+ }, cleanValueOptions));
2837
+ if (valueOnly === '-' || valueOnly === decimalSeparator || !valueOnly) {
2838
+ setStateValue('');
2839
+ onBlur && onBlur(event);
2840
+ return;
2841
+ }
2842
+ var fixedDecimals = fixedDecimalValue(valueOnly, decimalSeparator, fixedDecimalLength);
2843
+ var newValue = padTrimValue(fixedDecimals, decimalSeparator, decimalScale !== undefined ? decimalScale : fixedDecimalLength);
2844
+ var numberValue = parseFloat(newValue.replace(decimalSeparator, '.'));
2845
+ var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
2846
+ value: newValue
2847
+ }));
2848
+ if (onValueChange && formatValueOnBlur) {
2849
+ onValueChange(newValue, name, {
2850
+ "float": numberValue,
2851
+ formatted: formattedValue,
2852
+ value: newValue
2853
+ });
2854
+ }
2855
+ setStateValue(formattedValue);
2856
+ onBlur && onBlur(event);
2857
+ };
2858
+
2859
+ /**
2860
+ * Handle key down event
2861
+ *
2862
+ * Increase or decrease value by step
2863
+ */
2864
+ var handleOnKeyDown = function handleOnKeyDown(event) {
2865
+ var key = event.key;
2866
+ setLastKeyStroke(key);
2867
+ if (step && (key === 'ArrowUp' || key === 'ArrowDown')) {
2868
+ event.preventDefault();
2869
+ setCursor(stateValue.length);
2870
+ var currentValue = parseFloat(userValue != null ? String(userValue).replace(decimalSeparator, '.') : cleanValue(_objectSpread2({
2871
+ value: stateValue
2872
+ }, cleanValueOptions))) || 0;
2873
+ var newValue = key === 'ArrowUp' ? currentValue + step : currentValue - step;
2874
+ if (min !== undefined && newValue < Number(min)) {
2875
+ return;
2876
+ }
2877
+ if (max !== undefined && newValue > Number(max)) {
2878
+ return;
2879
+ }
2880
+ var fixedLength = String(step).includes('.') ? Number(String(step).split('.')[1].length) : undefined;
2881
+ processChange(String(fixedLength ? newValue.toFixed(fixedLength) : newValue).replace('.', decimalSeparator));
2882
+ }
2883
+ onKeyDown && onKeyDown(event);
2884
+ };
2885
+
2886
+ /**
2887
+ * Handle key up event
2888
+ *
2889
+ * Move cursor if there is a suffix to prevent user typing past suffix
2890
+ */
2891
+ var handleOnKeyUp = function handleOnKeyUp(event) {
2892
+ var key = event.key,
2893
+ selectionStart = event.currentTarget.selectionStart;
2894
+ if (key !== 'ArrowUp' && key !== 'ArrowDown' && stateValue !== '-') {
2895
+ var _suffix = getSuffix(stateValue, {
2896
+ groupSeparator: groupSeparator,
2897
+ decimalSeparator: decimalSeparator
2898
+ });
2899
+ if (_suffix && selectionStart && selectionStart > stateValue.length - _suffix.length) {
2900
+ /* istanbul ignore else */
2901
+ if (inputRef.current) {
2902
+ var newCursor = stateValue.length - _suffix.length;
2903
+ inputRef.current.setSelectionRange(newCursor, newCursor);
2904
+ }
2905
+ }
2906
+ }
2907
+ onKeyUp && onKeyUp(event);
2908
+ };
2909
+
2910
+ // Update state if userValue changes to undefined
2911
+ React.useEffect(function () {
2912
+ if (userValue == null && defaultValue == null) {
2913
+ setStateValue('');
2914
+ }
2915
+ }, [defaultValue, userValue]);
2916
+ React.useEffect(function () {
2917
+ // prevent cursor jumping if editing value
2918
+ if (dirty && stateValue !== '-' && inputRef.current && document.activeElement === inputRef.current) {
2919
+ inputRef.current.setSelectionRange(cursor, cursor);
2920
+ }
2921
+ }, [stateValue, cursor, inputRef, dirty, changeCount]);
2922
+
2923
+ /**
2924
+ * If user has only entered "-" or decimal separator,
2925
+ * keep the char to allow them to enter next value
2926
+ */
2927
+ var getRenderValue = function getRenderValue() {
2928
+ if (userValue != null && stateValue !== '-' && (!decimalSeparator || stateValue !== decimalSeparator)) {
2929
+ return formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
2930
+ decimalScale: dirty ? undefined : decimalScale,
2931
+ value: String(userValue)
2932
+ }));
2933
+ }
2934
+ return stateValue;
2935
+ };
2936
+ var inputProps = _objectSpread2({
2937
+ type: 'text',
2938
+ inputMode: 'decimal',
2939
+ id: id,
2940
+ name: name,
2941
+ className: className,
2942
+ onChange: handleOnChange,
2943
+ onBlur: handleOnBlur,
2944
+ onFocus: handleOnFocus,
2945
+ onKeyDown: handleOnKeyDown,
2946
+ onKeyUp: handleOnKeyUp,
2947
+ placeholder: placeholder,
2948
+ disabled: disabled,
2949
+ value: getRenderValue(),
2950
+ ref: inputRef
2951
+ }, props);
2952
+ if (customInput) {
2953
+ var CustomInput = customInput;
2954
+ return /*#__PURE__*/React.createElement(CustomInput, inputProps);
2955
+ }
2956
+ return /*#__PURE__*/React.createElement("div", null, children && /*#__PURE__*/React.createElement("label", {
2957
+ style: {
2958
+ display: 'block',
2959
+ marginBottom: '0.7rem',
2960
+ fontSize: '14px',
2961
+ fontWeight: 'light'
2962
+ }
2963
+ }, children), /*#__PURE__*/React.createElement("input", _extends({}, inputProps, {
2964
+ style: {
2965
+ textAlign: 'right',
2966
+ border: "1px solid ".concat(theme.palette.border),
2967
+ fontSize: '14px',
2968
+ borderRadius: '5px',
2969
+ height: '35px',
2970
+ padding: '5px 10px',
2971
+ fontWeight: 'light',
2972
+ width: 'auto',
2973
+ background: 'transparent',
2974
+ minWidth: '200px'
2975
+ }
2976
+ })));
2977
+ });
2978
+
2979
+ exports.cleanValue = cleanValue;
2980
+ exports.default = InputCurrency;
2981
+ exports.formatValue = formatValue;