@helpdice/ui 2.1.5 → 2.1.9

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 (124) hide show
  1. package/dist/auto-complete/index.js +2158 -17
  2. package/dist/button/button.d.ts +1 -1
  3. package/dist/button/index.js +73 -16
  4. package/dist/button/styles.d.ts +1 -0
  5. package/dist/carousal/index.js +73 -16
  6. package/dist/container/box.d.ts +42 -0
  7. package/dist/container/index.d.ts +2 -0
  8. package/dist/container/index.js +948 -0
  9. package/dist/copy-to-clipboard/clipboard.d.ts +14 -0
  10. package/dist/copy-to-clipboard/copy.d.ts +2 -0
  11. package/dist/copy-to-clipboard/index.d.ts +2 -0
  12. package/dist/copy-to-clipboard/index.js +1702 -0
  13. package/dist/copy-to-clipboard/toggle-selection.d.ts +1 -0
  14. package/dist/grid/index.d.ts +2 -3
  15. package/dist/grid/index.js +0 -1
  16. package/dist/html-renderer/index.js +35 -12
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +15776 -15418
  19. package/dist/input/index.d.ts +4 -0
  20. package/dist/input/index.js +2162 -18
  21. package/dist/input/input-props.d.ts +1 -0
  22. package/dist/input/phone-input/phone.d.ts +13 -0
  23. package/dist/modal/index.js +73 -16
  24. package/dist/notetip/index.js +690 -0
  25. package/{esm/notetip/index.d.ts → dist/notetip/note-tip.d.ts} +2 -2
  26. package/dist/placeholder/index.js +643 -8
  27. package/dist/table/index.js +4370 -2163
  28. package/dist/text/child.d.ts +1 -0
  29. package/dist/text/index.js +686 -8
  30. package/dist/text/text.d.ts +1 -0
  31. package/esm/button/button.d.ts +1 -1
  32. package/esm/button/button.js +51 -5
  33. package/esm/button/styles.d.ts +1 -0
  34. package/esm/button/styles.js +22 -11
  35. package/esm/container/box.d.ts +42 -0
  36. package/esm/container/box.js +39 -0
  37. package/esm/container/index.d.ts +2 -0
  38. package/esm/container/index.js +2 -0
  39. package/esm/copy-to-clipboard/clipboard.d.ts +14 -0
  40. package/esm/copy-to-clipboard/clipboard.js +91 -0
  41. package/esm/copy-to-clipboard/copy.d.ts +2 -0
  42. package/esm/copy-to-clipboard/copy.js +105 -0
  43. package/esm/copy-to-clipboard/index.d.ts +2 -0
  44. package/esm/copy-to-clipboard/index.js +2 -0
  45. package/esm/copy-to-clipboard/toggle-selection.d.ts +1 -0
  46. package/esm/copy-to-clipboard/toggle-selection.js +31 -0
  47. package/esm/grid/index.d.ts +2 -3
  48. package/esm/grid/index.js +5 -3
  49. package/esm/index.d.ts +6 -6
  50. package/esm/index.js +7 -5
  51. package/esm/input/index.d.ts +4 -0
  52. package/esm/input/index.js +4 -0
  53. package/esm/input/input-field.js +12 -10
  54. package/esm/input/input-props.d.ts +1 -0
  55. package/esm/input/phone-input/phone.d.ts +13 -0
  56. package/esm/input/phone-input/phone.js +166 -0
  57. package/esm/notetip/index.js +2 -97
  58. package/{dist/notetip/index.d.ts → esm/notetip/note-tip.d.ts} +2 -2
  59. package/esm/notetip/note-tip.js +97 -0
  60. package/esm/table/table-body.js +2 -2
  61. package/esm/table/table-cell.js +1 -1
  62. package/esm/table/table-head.js +4 -2
  63. package/esm/table/table.js +0 -1
  64. package/esm/text/child.d.ts +1 -0
  65. package/esm/text/text.d.ts +1 -0
  66. package/esm/text/text.js +25 -3
  67. package/package.json +19 -19
  68. package/dist/currency-input/index.js +0 -862
  69. package/dist/phone-input/index.js +0 -2033
  70. package/dist/phone-input/phone.d.ts +0 -11
  71. package/esm/phone-input/phone.d.ts +0 -11
  72. package/esm/phone-input/phone.js +0 -161
  73. /package/dist/{currency-input → input/currency-input}/components/CurrencyInput.d.ts +0 -0
  74. /package/dist/{currency-input → input/currency-input}/components/CurrencyInputProps.d.ts +0 -0
  75. /package/dist/{currency-input → input/currency-input}/components/utils/cleanValue.d.ts +0 -0
  76. /package/dist/{currency-input → input/currency-input}/components/utils/escapeRegExp.d.ts +0 -0
  77. /package/dist/{currency-input → input/currency-input}/components/utils/fixedDecimalValue.d.ts +0 -0
  78. /package/dist/{currency-input → input/currency-input}/components/utils/formatValue.d.ts +0 -0
  79. /package/dist/{currency-input → input/currency-input}/components/utils/getLocaleConfig.d.ts +0 -0
  80. /package/dist/{currency-input → input/currency-input}/components/utils/getSuffix.d.ts +0 -0
  81. /package/dist/{currency-input → input/currency-input}/components/utils/index.d.ts +0 -0
  82. /package/dist/{currency-input → input/currency-input}/components/utils/isNumber.d.ts +0 -0
  83. /package/dist/{currency-input → input/currency-input}/components/utils/padTrimValue.d.ts +0 -0
  84. /package/dist/{currency-input → input/currency-input}/components/utils/parseAbbrValue.d.ts +0 -0
  85. /package/dist/{currency-input → input/currency-input}/components/utils/removeInvalidChars.d.ts +0 -0
  86. /package/dist/{currency-input → input/currency-input}/components/utils/removeSeparators.d.ts +0 -0
  87. /package/dist/{currency-input → input/currency-input}/components/utils/repositionCursor.d.ts +0 -0
  88. /package/dist/{currency-input → input/currency-input}/index.d.ts +0 -0
  89. /package/dist/{phone-input → input/phone-input}/index.d.ts +0 -0
  90. /package/esm/{currency-input → input/currency-input}/components/CurrencyInput.d.ts +0 -0
  91. /package/esm/{currency-input → input/currency-input}/components/CurrencyInput.js +0 -0
  92. /package/esm/{currency-input → input/currency-input}/components/CurrencyInputProps.d.ts +0 -0
  93. /package/esm/{currency-input → input/currency-input}/components/CurrencyInputProps.js +0 -0
  94. /package/esm/{currency-input → input/currency-input}/components/utils/addSeparators.js +0 -0
  95. /package/esm/{currency-input → input/currency-input}/components/utils/cleanValue.d.ts +0 -0
  96. /package/esm/{currency-input → input/currency-input}/components/utils/cleanValue.js +0 -0
  97. /package/esm/{currency-input → input/currency-input}/components/utils/escapeRegExp.d.ts +0 -0
  98. /package/esm/{currency-input → input/currency-input}/components/utils/escapeRegExp.js +0 -0
  99. /package/esm/{currency-input → input/currency-input}/components/utils/fixedDecimalValue.d.ts +0 -0
  100. /package/esm/{currency-input → input/currency-input}/components/utils/fixedDecimalValue.js +0 -0
  101. /package/esm/{currency-input → input/currency-input}/components/utils/formatValue.d.ts +0 -0
  102. /package/esm/{currency-input → input/currency-input}/components/utils/formatValue.js +0 -0
  103. /package/esm/{currency-input → input/currency-input}/components/utils/getLocaleConfig.d.ts +0 -0
  104. /package/esm/{currency-input → input/currency-input}/components/utils/getLocaleConfig.js +0 -0
  105. /package/esm/{currency-input → input/currency-input}/components/utils/getSuffix.d.ts +0 -0
  106. /package/esm/{currency-input → input/currency-input}/components/utils/getSuffix.js +0 -0
  107. /package/esm/{currency-input → input/currency-input}/components/utils/index.d.ts +0 -0
  108. /package/esm/{currency-input → input/currency-input}/components/utils/index.js +0 -0
  109. /package/esm/{currency-input → input/currency-input}/components/utils/isNumber.d.ts +0 -0
  110. /package/esm/{currency-input → input/currency-input}/components/utils/isNumber.js +0 -0
  111. /package/esm/{currency-input → input/currency-input}/components/utils/padTrimValue.d.ts +0 -0
  112. /package/esm/{currency-input → input/currency-input}/components/utils/padTrimValue.js +0 -0
  113. /package/esm/{currency-input → input/currency-input}/components/utils/parseAbbrValue.d.ts +0 -0
  114. /package/esm/{currency-input → input/currency-input}/components/utils/parseAbbrValue.js +0 -0
  115. /package/esm/{currency-input → input/currency-input}/components/utils/removeInvalidChars.d.ts +0 -0
  116. /package/esm/{currency-input → input/currency-input}/components/utils/removeInvalidChars.js +0 -0
  117. /package/esm/{currency-input → input/currency-input}/components/utils/removeSeparators.d.ts +0 -0
  118. /package/esm/{currency-input → input/currency-input}/components/utils/removeSeparators.js +0 -0
  119. /package/esm/{currency-input → input/currency-input}/components/utils/repositionCursor.d.ts +0 -0
  120. /package/esm/{currency-input → input/currency-input}/components/utils/repositionCursor.js +0 -0
  121. /package/esm/{currency-input → input/currency-input}/index.d.ts +0 -0
  122. /package/esm/{currency-input → input/currency-input}/index.js +0 -0
  123. /package/esm/{phone-input → input/phone-input}/index.d.ts +0 -0
  124. /package/esm/{phone-input → input/phone-input}/index.js +0 -0
@@ -0,0 +1,1702 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var icons = require('@helpdice/icons');
7
+ var theme = require('@helpdice/theme');
8
+
9
+ function _arrayLikeToArray(r, a) {
10
+ (null == a || a > r.length) && (a = r.length);
11
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12
+ return n;
13
+ }
14
+ function _arrayWithHoles(r) {
15
+ if (Array.isArray(r)) return r;
16
+ }
17
+ function _createForOfIteratorHelper(r, e) {
18
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
19
+ if (!t) {
20
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
21
+ t && (r = t);
22
+ var n = 0,
23
+ F = function () {};
24
+ return {
25
+ s: F,
26
+ n: function () {
27
+ return n >= r.length ? {
28
+ done: true
29
+ } : {
30
+ done: false,
31
+ value: r[n++]
32
+ };
33
+ },
34
+ e: function (r) {
35
+ throw r;
36
+ },
37
+ f: F
38
+ };
39
+ }
40
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ var o,
43
+ a = true,
44
+ u = false;
45
+ return {
46
+ s: function () {
47
+ t = t.call(r);
48
+ },
49
+ n: function () {
50
+ var r = t.next();
51
+ return a = r.done, r;
52
+ },
53
+ e: function (r) {
54
+ u = true, o = r;
55
+ },
56
+ f: function () {
57
+ try {
58
+ a || null == t.return || t.return();
59
+ } finally {
60
+ if (u) throw o;
61
+ }
62
+ }
63
+ };
64
+ }
65
+ function _defineProperty(e, r, t) {
66
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
67
+ value: t,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ }) : e[r] = t, e;
72
+ }
73
+ function _extends() {
74
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
75
+ for (var e = 1; e < arguments.length; e++) {
76
+ var t = arguments[e];
77
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
78
+ }
79
+ return n;
80
+ }, _extends.apply(null, arguments);
81
+ }
82
+ function _iterableToArrayLimit(r, l) {
83
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
84
+ if (null != t) {
85
+ var e,
86
+ n,
87
+ i,
88
+ u,
89
+ a = [],
90
+ f = true,
91
+ o = false;
92
+ try {
93
+ if (i = (t = t.call(r)).next, 0 === l) {
94
+ if (Object(t) !== t) return;
95
+ f = !1;
96
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
97
+ } catch (r) {
98
+ o = true, n = r;
99
+ } finally {
100
+ try {
101
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
102
+ } finally {
103
+ if (o) throw n;
104
+ }
105
+ }
106
+ return a;
107
+ }
108
+ }
109
+ function _nonIterableRest() {
110
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
+ }
112
+ function ownKeys(e, r) {
113
+ var t = Object.keys(e);
114
+ if (Object.getOwnPropertySymbols) {
115
+ var o = Object.getOwnPropertySymbols(e);
116
+ r && (o = o.filter(function (r) {
117
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
118
+ })), t.push.apply(t, o);
119
+ }
120
+ return t;
121
+ }
122
+ function _objectSpread2(e) {
123
+ for (var r = 1; r < arguments.length; r++) {
124
+ var t = null != arguments[r] ? arguments[r] : {};
125
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
126
+ _defineProperty(e, r, t[r]);
127
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
128
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
129
+ });
130
+ }
131
+ return e;
132
+ }
133
+ function _objectWithoutProperties(e, t) {
134
+ if (null == e) return {};
135
+ var o,
136
+ r,
137
+ i = _objectWithoutPropertiesLoose(e, t);
138
+ if (Object.getOwnPropertySymbols) {
139
+ var n = Object.getOwnPropertySymbols(e);
140
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
141
+ }
142
+ return i;
143
+ }
144
+ function _objectWithoutPropertiesLoose(r, e) {
145
+ if (null == r) return {};
146
+ var t = {};
147
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
148
+ if (-1 !== e.indexOf(n)) continue;
149
+ t[n] = r[n];
150
+ }
151
+ return t;
152
+ }
153
+ function _slicedToArray(r, e) {
154
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
155
+ }
156
+ function _toPrimitive(t, r) {
157
+ if ("object" != typeof t || !t) return t;
158
+ var e = t[Symbol.toPrimitive];
159
+ if (void 0 !== e) {
160
+ var i = e.call(t, r);
161
+ if ("object" != typeof i) return i;
162
+ throw new TypeError("@@toPrimitive must return a primitive value.");
163
+ }
164
+ return ("string" === r ? String : Number)(t);
165
+ }
166
+ function _toPropertyKey(t) {
167
+ var i = _toPrimitive(t, "string");
168
+ return "symbol" == typeof i ? i : i + "";
169
+ }
170
+ function _unsupportedIterableToArray(r, a) {
171
+ if (r) {
172
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
173
+ var t = {}.toString.call(r).slice(8, -1);
174
+ 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;
175
+ }
176
+ }
177
+
178
+ function deselectCurrent () {
179
+ var selection = document.getSelection();
180
+ if (!selection.rangeCount) {
181
+ return function () {};
182
+ }
183
+ var active = document.activeElement;
184
+ var ranges = [];
185
+ for (var i = 0; i < selection.rangeCount; i++) {
186
+ ranges.push(selection.getRangeAt(i));
187
+ }
188
+ switch (active.tagName.toUpperCase() // .toUpperCase handles XHTML
189
+ ) {
190
+ case 'INPUT':
191
+ case 'TEXTAREA':
192
+ active.blur();
193
+ break;
194
+ default:
195
+ active = null;
196
+ break;
197
+ }
198
+ selection.removeAllRanges();
199
+ return function () {
200
+ selection.type === 'Caret' && selection.removeAllRanges();
201
+ if (!selection.rangeCount) {
202
+ ranges.forEach(function (range) {
203
+ selection.addRange(range);
204
+ });
205
+ }
206
+ active && active.focus();
207
+ };
208
+ }
209
+
210
+ var clipboardToIE11Formatting = {
211
+ 'text/plain': 'Text',
212
+ 'text/html': 'Url',
213
+ "default": 'Text'
214
+ };
215
+ var defaultMessage = 'Copy to clipboard: #{key}, Enter';
216
+ function format(message) {
217
+ var copyKey = (/mac os x/i.test(navigator.userAgent) ? '⌘' : 'Ctrl') + '+C';
218
+ return message.replace(/#{\s*key\s*}/g, copyKey);
219
+ }
220
+ function copy(text, options) {
221
+ var debug,
222
+ message,
223
+ reselectPrevious,
224
+ range,
225
+ selection,
226
+ mark,
227
+ success = false;
228
+ if (!options) {
229
+ options = {};
230
+ }
231
+ debug = options.debug || false;
232
+ try {
233
+ reselectPrevious = deselectCurrent();
234
+ range = document.createRange();
235
+ selection = document.getSelection();
236
+ mark = document.createElement('span');
237
+ mark.textContent = text;
238
+ // avoid screen readers from reading out loud the text
239
+ mark.ariaHidden = 'true';
240
+ // reset user styles for span element
241
+ mark.style.all = 'unset';
242
+ // prevents scrolling to the end of the page
243
+ mark.style.position = 'fixed';
244
+ mark.style.top = 0;
245
+ mark.style.clip = 'rect(0, 0, 0, 0)';
246
+ // used to preserve spaces and line breaks
247
+ mark.style.whiteSpace = 'pre';
248
+ // do not inherit user-select (it may be `none`)
249
+ mark.style.webkitUserSelect = 'text';
250
+ mark.style.MozUserSelect = 'text';
251
+ mark.style.msUserSelect = 'text';
252
+ mark.style.userSelect = 'text';
253
+ mark.addEventListener('copy', function (e) {
254
+ e.stopPropagation();
255
+ if (options.format) {
256
+ e.preventDefault();
257
+ if (typeof e.clipboardData === 'undefined') {
258
+ // IE 11
259
+ debug && console.warn('unable to use e.clipboardData');
260
+ debug && console.warn('trying IE specific stuff');
261
+ window.clipboardData.clearData();
262
+ var format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting['default'];
263
+ window.clipboardData.setData(format, text);
264
+ } else {
265
+ // all other browsers
266
+ e.clipboardData.clearData();
267
+ e.clipboardData.setData(options.format, text);
268
+ }
269
+ }
270
+ if (options.onCopy) {
271
+ e.preventDefault();
272
+ options.onCopy(e.clipboardData);
273
+ }
274
+ });
275
+ document.body.appendChild(mark);
276
+ range.selectNodeContents(mark);
277
+ selection.addRange(range);
278
+ var successful = document.execCommand('copy');
279
+ if (!successful) {
280
+ throw new Error('copy command was unsuccessful');
281
+ }
282
+ success = true;
283
+ } catch (err) {
284
+ debug && console.error('unable to copy using execCommand: ', err);
285
+ debug && console.warn('trying IE specific stuff');
286
+ try {
287
+ window.clipboardData.setData(options.format || 'text', text);
288
+ options.onCopy && options.onCopy(window.clipboardData);
289
+ success = true;
290
+ } catch (err) {
291
+ debug && console.error('unable to copy using clipboardData: ', err);
292
+ debug && console.error('falling back to prompt');
293
+ message = format('message' in options ? options.message : defaultMessage);
294
+ window.prompt(message, text);
295
+ }
296
+ } finally {
297
+ if (selection) {
298
+ if (typeof selection.removeRange == 'function') {
299
+ selection.removeRange(range);
300
+ } else {
301
+ selection.removeAllRanges();
302
+ }
303
+ }
304
+ if (mark) {
305
+ document.body.removeChild(mark);
306
+ }
307
+ reselectPrevious();
308
+ }
309
+ return success;
310
+ }
311
+
312
+ function getDefaultExportFromCjs (x) {
313
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
314
+ }
315
+
316
+ var index = {};
317
+
318
+ var hasRequiredIndex;
319
+
320
+ function requireIndex () {
321
+ if (hasRequiredIndex) return index;
322
+ hasRequiredIndex = 1;
323
+ var React$1 = React;
324
+
325
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
326
+
327
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
328
+
329
+ /*
330
+ Based on Glamor's sheet
331
+ https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
332
+ */ function _defineProperties(target, props) {
333
+ for(var i = 0; i < props.length; i++){
334
+ var descriptor = props[i];
335
+ descriptor.enumerable = descriptor.enumerable || false;
336
+ descriptor.configurable = true;
337
+ if ("value" in descriptor) descriptor.writable = true;
338
+ Object.defineProperty(target, descriptor.key, descriptor);
339
+ }
340
+ }
341
+ function _createClass(Constructor, protoProps, staticProps) {
342
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
343
+ return Constructor;
344
+ }
345
+ var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
346
+ var isString = function(o) {
347
+ return Object.prototype.toString.call(o) === "[object String]";
348
+ };
349
+ var StyleSheet = /*#__PURE__*/ function() {
350
+ function StyleSheet(param) {
351
+ var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
352
+ invariant$1(isString(name), "`name` must be a string");
353
+ this._name = name;
354
+ this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
355
+ invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
356
+ this._optimizeForSpeed = optimizeForSpeed;
357
+ this._serverSheet = undefined;
358
+ this._tags = [];
359
+ this._injected = false;
360
+ this._rulesCount = 0;
361
+ var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
362
+ this._nonce = node ? node.getAttribute("content") : null;
363
+ }
364
+ var _proto = StyleSheet.prototype;
365
+ _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
366
+ invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
367
+ invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
368
+ this.flush();
369
+ this._optimizeForSpeed = bool;
370
+ this.inject();
371
+ };
372
+ _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
373
+ return this._optimizeForSpeed;
374
+ };
375
+ _proto.inject = function inject() {
376
+ var _this = this;
377
+ invariant$1(!this._injected, "sheet already injected");
378
+ this._injected = true;
379
+ if (typeof window !== "undefined" && this._optimizeForSpeed) {
380
+ this._tags[0] = this.makeStyleTag(this._name);
381
+ this._optimizeForSpeed = "insertRule" in this.getSheet();
382
+ if (!this._optimizeForSpeed) {
383
+ if (!isProd) {
384
+ console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
385
+ }
386
+ this.flush();
387
+ this._injected = true;
388
+ }
389
+ return;
390
+ }
391
+ this._serverSheet = {
392
+ cssRules: [],
393
+ insertRule: function(rule, index) {
394
+ if (typeof index === "number") {
395
+ _this._serverSheet.cssRules[index] = {
396
+ cssText: rule
397
+ };
398
+ } else {
399
+ _this._serverSheet.cssRules.push({
400
+ cssText: rule
401
+ });
402
+ }
403
+ return index;
404
+ },
405
+ deleteRule: function(index) {
406
+ _this._serverSheet.cssRules[index] = null;
407
+ }
408
+ };
409
+ };
410
+ _proto.getSheetForTag = function getSheetForTag(tag) {
411
+ if (tag.sheet) {
412
+ return tag.sheet;
413
+ }
414
+ // this weirdness brought to you by firefox
415
+ for(var i = 0; i < document.styleSheets.length; i++){
416
+ if (document.styleSheets[i].ownerNode === tag) {
417
+ return document.styleSheets[i];
418
+ }
419
+ }
420
+ };
421
+ _proto.getSheet = function getSheet() {
422
+ return this.getSheetForTag(this._tags[this._tags.length - 1]);
423
+ };
424
+ _proto.insertRule = function insertRule(rule, index) {
425
+ invariant$1(isString(rule), "`insertRule` accepts only strings");
426
+ if (typeof window === "undefined") {
427
+ if (typeof index !== "number") {
428
+ index = this._serverSheet.cssRules.length;
429
+ }
430
+ this._serverSheet.insertRule(rule, index);
431
+ return this._rulesCount++;
432
+ }
433
+ if (this._optimizeForSpeed) {
434
+ var sheet = this.getSheet();
435
+ if (typeof index !== "number") {
436
+ index = sheet.cssRules.length;
437
+ }
438
+ // this weirdness for perf, and chrome's weird bug
439
+ // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
440
+ try {
441
+ sheet.insertRule(rule, index);
442
+ } catch (error) {
443
+ if (!isProd) {
444
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
445
+ }
446
+ return -1;
447
+ }
448
+ } else {
449
+ var insertionPoint = this._tags[index];
450
+ this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
451
+ }
452
+ return this._rulesCount++;
453
+ };
454
+ _proto.replaceRule = function replaceRule(index, rule) {
455
+ if (this._optimizeForSpeed || typeof window === "undefined") {
456
+ var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
457
+ if (!rule.trim()) {
458
+ rule = this._deletedRulePlaceholder;
459
+ }
460
+ if (!sheet.cssRules[index]) {
461
+ // @TBD Should we throw an error?
462
+ return index;
463
+ }
464
+ sheet.deleteRule(index);
465
+ try {
466
+ sheet.insertRule(rule, index);
467
+ } catch (error) {
468
+ if (!isProd) {
469
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
470
+ }
471
+ // In order to preserve the indices we insert a deleteRulePlaceholder
472
+ sheet.insertRule(this._deletedRulePlaceholder, index);
473
+ }
474
+ } else {
475
+ var tag = this._tags[index];
476
+ invariant$1(tag, "old rule at index `" + index + "` not found");
477
+ tag.textContent = rule;
478
+ }
479
+ return index;
480
+ };
481
+ _proto.deleteRule = function deleteRule(index) {
482
+ if (typeof window === "undefined") {
483
+ this._serverSheet.deleteRule(index);
484
+ return;
485
+ }
486
+ if (this._optimizeForSpeed) {
487
+ this.replaceRule(index, "");
488
+ } else {
489
+ var tag = this._tags[index];
490
+ invariant$1(tag, "rule at index `" + index + "` not found");
491
+ tag.parentNode.removeChild(tag);
492
+ this._tags[index] = null;
493
+ }
494
+ };
495
+ _proto.flush = function flush() {
496
+ this._injected = false;
497
+ this._rulesCount = 0;
498
+ if (typeof window !== "undefined") {
499
+ this._tags.forEach(function(tag) {
500
+ return tag && tag.parentNode.removeChild(tag);
501
+ });
502
+ this._tags = [];
503
+ } else {
504
+ // simpler on server
505
+ this._serverSheet.cssRules = [];
506
+ }
507
+ };
508
+ _proto.cssRules = function cssRules() {
509
+ var _this = this;
510
+ if (typeof window === "undefined") {
511
+ return this._serverSheet.cssRules;
512
+ }
513
+ return this._tags.reduce(function(rules, tag) {
514
+ if (tag) {
515
+ rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
516
+ return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
517
+ }));
518
+ } else {
519
+ rules.push(null);
520
+ }
521
+ return rules;
522
+ }, []);
523
+ };
524
+ _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
525
+ if (cssString) {
526
+ invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
527
+ }
528
+ var tag = document.createElement("style");
529
+ if (this._nonce) tag.setAttribute("nonce", this._nonce);
530
+ tag.type = "text/css";
531
+ tag.setAttribute("data-" + name, "");
532
+ if (cssString) {
533
+ tag.appendChild(document.createTextNode(cssString));
534
+ }
535
+ var head = document.head || document.getElementsByTagName("head")[0];
536
+ if (relativeToTag) {
537
+ head.insertBefore(tag, relativeToTag);
538
+ } else {
539
+ head.appendChild(tag);
540
+ }
541
+ return tag;
542
+ };
543
+ _createClass(StyleSheet, [
544
+ {
545
+ key: "length",
546
+ get: function get() {
547
+ return this._rulesCount;
548
+ }
549
+ }
550
+ ]);
551
+ return StyleSheet;
552
+ }();
553
+ function invariant$1(condition, message) {
554
+ if (!condition) {
555
+ throw new Error("StyleSheet: " + message + ".");
556
+ }
557
+ }
558
+
559
+ function hash(str) {
560
+ var _$hash = 5381, i = str.length;
561
+ while(i){
562
+ _$hash = _$hash * 33 ^ str.charCodeAt(--i);
563
+ }
564
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
565
+ * integers. Since we want the results to be always positive, convert the
566
+ * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
567
+ }
568
+ var stringHash = hash;
569
+
570
+ var sanitize = function(rule) {
571
+ return rule.replace(/\/style/gi, "\\/style");
572
+ };
573
+ var cache = {};
574
+ /**
575
+ * computeId
576
+ *
577
+ * Compute and memoize a jsx id from a basedId and optionally props.
578
+ */ function computeId(baseId, props) {
579
+ if (!props) {
580
+ return "jsx-" + baseId;
581
+ }
582
+ var propsToString = String(props);
583
+ var key = baseId + propsToString;
584
+ if (!cache[key]) {
585
+ cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
586
+ }
587
+ return cache[key];
588
+ }
589
+ /**
590
+ * computeSelector
591
+ *
592
+ * Compute and memoize dynamic selectors.
593
+ */ function computeSelector(id, css) {
594
+ var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
595
+ // Sanitize SSR-ed CSS.
596
+ // Client side code doesn't need to be sanitized since we use
597
+ // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
598
+ if (typeof window === "undefined") {
599
+ css = sanitize(css);
600
+ }
601
+ var idcss = id + css;
602
+ if (!cache[idcss]) {
603
+ cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
604
+ }
605
+ return cache[idcss];
606
+ }
607
+
608
+ function mapRulesToStyle(cssRules, options) {
609
+ if (options === void 0) options = {};
610
+ return cssRules.map(function(args) {
611
+ var id = args[0];
612
+ var css = args[1];
613
+ return /*#__PURE__*/ React__default["default"].createElement("style", {
614
+ id: "__" + id,
615
+ // Avoid warnings upon render with a key
616
+ key: "__" + id,
617
+ nonce: options.nonce ? options.nonce : undefined,
618
+ dangerouslySetInnerHTML: {
619
+ __html: css
620
+ }
621
+ });
622
+ });
623
+ }
624
+ var StyleSheetRegistry = /*#__PURE__*/ function() {
625
+ function StyleSheetRegistry(param) {
626
+ var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
627
+ this._sheet = styleSheet || new StyleSheet({
628
+ name: "styled-jsx",
629
+ optimizeForSpeed: optimizeForSpeed
630
+ });
631
+ this._sheet.inject();
632
+ if (styleSheet && typeof optimizeForSpeed === "boolean") {
633
+ this._sheet.setOptimizeForSpeed(optimizeForSpeed);
634
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
635
+ }
636
+ this._fromServer = undefined;
637
+ this._indices = {};
638
+ this._instancesCounts = {};
639
+ }
640
+ var _proto = StyleSheetRegistry.prototype;
641
+ _proto.add = function add(props) {
642
+ var _this = this;
643
+ if (undefined === this._optimizeForSpeed) {
644
+ this._optimizeForSpeed = Array.isArray(props.children);
645
+ this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
646
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
647
+ }
648
+ if (typeof window !== "undefined" && !this._fromServer) {
649
+ this._fromServer = this.selectFromServer();
650
+ this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
651
+ acc[tagName] = 0;
652
+ return acc;
653
+ }, {});
654
+ }
655
+ var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
656
+ // Deduping: just increase the instances count.
657
+ if (styleId in this._instancesCounts) {
658
+ this._instancesCounts[styleId] += 1;
659
+ return;
660
+ }
661
+ var indices = rules.map(function(rule) {
662
+ return _this._sheet.insertRule(rule);
663
+ })// Filter out invalid rules
664
+ .filter(function(index) {
665
+ return index !== -1;
666
+ });
667
+ this._indices[styleId] = indices;
668
+ this._instancesCounts[styleId] = 1;
669
+ };
670
+ _proto.remove = function remove(props) {
671
+ var _this = this;
672
+ var styleId = this.getIdAndRules(props).styleId;
673
+ invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
674
+ this._instancesCounts[styleId] -= 1;
675
+ if (this._instancesCounts[styleId] < 1) {
676
+ var tagFromServer = this._fromServer && this._fromServer[styleId];
677
+ if (tagFromServer) {
678
+ tagFromServer.parentNode.removeChild(tagFromServer);
679
+ delete this._fromServer[styleId];
680
+ } else {
681
+ this._indices[styleId].forEach(function(index) {
682
+ return _this._sheet.deleteRule(index);
683
+ });
684
+ delete this._indices[styleId];
685
+ }
686
+ delete this._instancesCounts[styleId];
687
+ }
688
+ };
689
+ _proto.update = function update(props, nextProps) {
690
+ this.add(nextProps);
691
+ this.remove(props);
692
+ };
693
+ _proto.flush = function flush() {
694
+ this._sheet.flush();
695
+ this._sheet.inject();
696
+ this._fromServer = undefined;
697
+ this._indices = {};
698
+ this._instancesCounts = {};
699
+ };
700
+ _proto.cssRules = function cssRules() {
701
+ var _this = this;
702
+ var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
703
+ return [
704
+ styleId,
705
+ _this._fromServer[styleId]
706
+ ];
707
+ }) : [];
708
+ var cssRules = this._sheet.cssRules();
709
+ return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
710
+ return [
711
+ styleId,
712
+ _this._indices[styleId].map(function(index) {
713
+ return cssRules[index].cssText;
714
+ }).join(_this._optimizeForSpeed ? "" : "\n")
715
+ ];
716
+ })// filter out empty rules
717
+ .filter(function(rule) {
718
+ return Boolean(rule[1]);
719
+ }));
720
+ };
721
+ _proto.styles = function styles(options) {
722
+ return mapRulesToStyle(this.cssRules(), options);
723
+ };
724
+ _proto.getIdAndRules = function getIdAndRules(props) {
725
+ var css = props.children, dynamic = props.dynamic, id = props.id;
726
+ if (dynamic) {
727
+ var styleId = computeId(id, dynamic);
728
+ return {
729
+ styleId: styleId,
730
+ rules: Array.isArray(css) ? css.map(function(rule) {
731
+ return computeSelector(styleId, rule);
732
+ }) : [
733
+ computeSelector(styleId, css)
734
+ ]
735
+ };
736
+ }
737
+ return {
738
+ styleId: computeId(id),
739
+ rules: Array.isArray(css) ? css : [
740
+ css
741
+ ]
742
+ };
743
+ };
744
+ /**
745
+ * selectFromServer
746
+ *
747
+ * Collects style tags from the document with id __jsx-XXX
748
+ */ _proto.selectFromServer = function selectFromServer() {
749
+ var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
750
+ return elements.reduce(function(acc, element) {
751
+ var id = element.id.slice(2);
752
+ acc[id] = element;
753
+ return acc;
754
+ }, {});
755
+ };
756
+ return StyleSheetRegistry;
757
+ }();
758
+ function invariant(condition, message) {
759
+ if (!condition) {
760
+ throw new Error("StyleSheetRegistry: " + message + ".");
761
+ }
762
+ }
763
+ var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
764
+ StyleSheetContext.displayName = "StyleSheetContext";
765
+ function createStyleRegistry() {
766
+ return new StyleSheetRegistry();
767
+ }
768
+ function StyleRegistry(param) {
769
+ var configuredRegistry = param.registry, children = param.children;
770
+ var rootRegistry = React$1.useContext(StyleSheetContext);
771
+ var ref = React$1.useState(function() {
772
+ return rootRegistry || configuredRegistry || createStyleRegistry();
773
+ }), registry = ref[0];
774
+ return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
775
+ value: registry
776
+ }, children);
777
+ }
778
+ function useStyleRegistry() {
779
+ return React$1.useContext(StyleSheetContext);
780
+ }
781
+
782
+ // Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
783
+ // https://github.com/reactwg/react-18/discussions/110
784
+ var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
785
+ var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
786
+ function JSXStyle(props) {
787
+ var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
788
+ var insertionEffectCalled = React$1.useRef(false);
789
+ // `registry` might not exist while server-side rendering
790
+ if (!registry) {
791
+ return null;
792
+ }
793
+ if (typeof window === "undefined") {
794
+ registry.add(props);
795
+ return null;
796
+ }
797
+ useInsertionEffect(function() {
798
+ // ReactDOM removes all DOM during hydration in certain cases
799
+ if (!document.head) {
800
+ return;
801
+ }
802
+ registry.add(props);
803
+ insertionEffectCalled.current = true;
804
+ return function() {
805
+ insertionEffectCalled.current = false;
806
+ registry.remove(props);
807
+ };
808
+ }, [
809
+ props.id,
810
+ String(props.dynamic)
811
+ ]);
812
+ React$1.useLayoutEffect(function() {
813
+ if (!document.head || insertionEffectCalled.current) {
814
+ return;
815
+ }
816
+ registry.add(props);
817
+ return function() {
818
+ registry.remove(props);
819
+ };
820
+ // props.children can be string[], will be striped since id is identical
821
+ }, [
822
+ props.id,
823
+ String(props.dynamic)
824
+ ]);
825
+ return null;
826
+ }
827
+ JSXStyle.dynamic = function(info) {
828
+ return info.map(function(tagInfo) {
829
+ var baseId = tagInfo[0];
830
+ var props = tagInfo[1];
831
+ return computeId(baseId, props);
832
+ }).join(" ");
833
+ };
834
+
835
+ index.StyleRegistry = StyleRegistry;
836
+ index.createStyleRegistry = createStyleRegistry;
837
+ index.style = JSXStyle;
838
+ index.useStyleRegistry = useStyleRegistry;
839
+ return index;
840
+ }
841
+
842
+ var style;
843
+ var hasRequiredStyle;
844
+
845
+ function requireStyle () {
846
+ if (hasRequiredStyle) return style;
847
+ hasRequiredStyle = 1;
848
+ style = requireIndex().style;
849
+ return style;
850
+ }
851
+
852
+ var styleExports = requireStyle();
853
+ var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
854
+
855
+ /* "use client" */
856
+
857
+ var ScalePropKeys = ['width', 'height', 'padding', 'margin', 'w', 'h', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'pl', 'pr', 'pt', 'pb', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'ml', 'mr', 'mt', 'mb', 'px', 'py', 'mx', 'my', 'font', 'unit', 'scale'];
858
+ var defaultDynamicLayoutPipe = function defaultDynamicLayoutPipe(scale1x) {
859
+ return "".concat(scale1x);
860
+ };
861
+ var defaultContext$1 = {
862
+ getScaleProps: function getScaleProps() {
863
+ return undefined;
864
+ },
865
+ getAllScaleProps: function getAllScaleProps() {
866
+ return {};
867
+ },
868
+ SCALES: {
869
+ pl: defaultDynamicLayoutPipe,
870
+ pr: defaultDynamicLayoutPipe,
871
+ pb: defaultDynamicLayoutPipe,
872
+ pt: defaultDynamicLayoutPipe,
873
+ px: defaultDynamicLayoutPipe,
874
+ py: defaultDynamicLayoutPipe,
875
+ mb: defaultDynamicLayoutPipe,
876
+ ml: defaultDynamicLayoutPipe,
877
+ mr: defaultDynamicLayoutPipe,
878
+ mt: defaultDynamicLayoutPipe,
879
+ mx: defaultDynamicLayoutPipe,
880
+ my: defaultDynamicLayoutPipe,
881
+ width: defaultDynamicLayoutPipe,
882
+ height: defaultDynamicLayoutPipe,
883
+ font: defaultDynamicLayoutPipe
884
+ },
885
+ unit: '16px'
886
+ };
887
+ var ScaleContext = /*#__PURE__*/React.createContext(defaultContext$1);
888
+ var useScale = function useScale() {
889
+ return React.useContext(ScaleContext);
890
+ };
891
+
892
+ /* "use client" */
893
+
894
+ var isCSSNumberValue = function isCSSNumberValue(value) {
895
+ return value !== undefined && !Number.isNaN(+value);
896
+ };
897
+
898
+ var generateGetScaleProps = function generateGetScaleProps(props) {
899
+ var getScaleProps = function getScaleProps(keyOrKeys) {
900
+ if (!Array.isArray(keyOrKeys)) return props[keyOrKeys];
901
+ var value = undefined;
902
+ var _iterator = _createForOfIteratorHelper(keyOrKeys),
903
+ _step;
904
+ try {
905
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
906
+ var key = _step.value;
907
+ var currentValue = props[key];
908
+ if (typeof currentValue !== 'undefined') {
909
+ value = currentValue;
910
+ }
911
+ }
912
+ } catch (err) {
913
+ _iterator.e(err);
914
+ } finally {
915
+ _iterator.f();
916
+ }
917
+ return value;
918
+ };
919
+ return getScaleProps;
920
+ };
921
+ var generateGetAllScaleProps = function generateGetAllScaleProps(props) {
922
+ var getAllScaleProps = function getAllScaleProps() {
923
+ var scaleProps = {};
924
+ var _iterator2 = _createForOfIteratorHelper(ScalePropKeys),
925
+ _step2;
926
+ try {
927
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
928
+ var key = _step2.value;
929
+ var value = props[key];
930
+ if (typeof value !== 'undefined') {
931
+ scaleProps[key] = value;
932
+ }
933
+ }
934
+ } catch (err) {
935
+ _iterator2.e(err);
936
+ } finally {
937
+ _iterator2.f();
938
+ }
939
+ return scaleProps;
940
+ };
941
+ return getAllScaleProps;
942
+ };
943
+
944
+ var _excluded$3 = ["children"];
945
+ var reduceScaleCoefficient = function reduceScaleCoefficient(scale) {
946
+ if (scale === 1) return scale;
947
+ var diff = Math.abs((scale - 1) / 2);
948
+ return scale > 1 ? 1 + diff : 1 - diff;
949
+ };
950
+ var withScale = function withScale(Render) {
951
+ var ScaleFC = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
952
+ var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _ref28, _ref29, _ref30, _ref31;
953
+ var children = _ref.children,
954
+ props = _objectWithoutProperties(_ref, _excluded$3);
955
+ var _useTheme = theme.useTheme(),
956
+ layout = _useTheme.layout;
957
+ var paddingLeft = props.paddingLeft,
958
+ pl = props.pl,
959
+ paddingRight = props.paddingRight,
960
+ pr = props.pr,
961
+ paddingTop = props.paddingTop,
962
+ pt = props.pt,
963
+ paddingBottom = props.paddingBottom,
964
+ pb = props.pb,
965
+ marginTop = props.marginTop,
966
+ mt = props.mt,
967
+ marginRight = props.marginRight,
968
+ mr = props.mr,
969
+ marginBottom = props.marginBottom,
970
+ mb = props.mb,
971
+ marginLeft = props.marginLeft,
972
+ ml = props.ml,
973
+ px = props.px,
974
+ py = props.py,
975
+ mx = props.mx,
976
+ my = props.my,
977
+ width = props.width,
978
+ height = props.height,
979
+ font = props.font,
980
+ w = props.w,
981
+ h = props.h,
982
+ margin = props.margin,
983
+ padding = props.padding,
984
+ _props$unit = props.unit,
985
+ unit = _props$unit === void 0 ? layout.unit : _props$unit,
986
+ _props$scale = props.scale,
987
+ scale = _props$scale === void 0 ? 1 : _props$scale;
988
+ var makeScaleHandler = function makeScaleHandler(attrValue) {
989
+ return function (scale1x, defaultValue) {
990
+ // 0 means disable scale and the default value is 0
991
+ if (scale1x === 0) {
992
+ scale1x = 1;
993
+ defaultValue = defaultValue || 0;
994
+ }
995
+ var factor = reduceScaleCoefficient(scale) * scale1x;
996
+ if (typeof attrValue === 'undefined') {
997
+ if (typeof defaultValue !== 'undefined') return "".concat(defaultValue);
998
+ return "calc(".concat(factor, " * ").concat(unit, ")");
999
+ }
1000
+ if (!isCSSNumberValue(attrValue)) return "".concat(attrValue);
1001
+ var customFactor = factor * Number(attrValue);
1002
+ return "calc(".concat(customFactor, " * ").concat(unit, ")");
1003
+ };
1004
+ };
1005
+ var value = {
1006
+ unit: unit,
1007
+ SCALES: {
1008
+ pt: makeScaleHandler((_ref2 = (_ref3 = paddingTop !== null && paddingTop !== void 0 ? paddingTop : pt) !== null && _ref3 !== void 0 ? _ref3 : py) !== null && _ref2 !== void 0 ? _ref2 : padding),
1009
+ pr: makeScaleHandler((_ref4 = (_ref5 = paddingRight !== null && paddingRight !== void 0 ? paddingRight : pr) !== null && _ref5 !== void 0 ? _ref5 : px) !== null && _ref4 !== void 0 ? _ref4 : padding),
1010
+ pb: makeScaleHandler((_ref6 = (_ref7 = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : pb) !== null && _ref7 !== void 0 ? _ref7 : py) !== null && _ref6 !== void 0 ? _ref6 : padding),
1011
+ pl: makeScaleHandler((_ref8 = (_ref9 = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : pl) !== null && _ref9 !== void 0 ? _ref9 : px) !== null && _ref8 !== void 0 ? _ref8 : padding),
1012
+ px: makeScaleHandler((_ref0 = (_ref1 = (_ref10 = (_ref11 = px !== null && px !== void 0 ? px : paddingLeft) !== null && _ref11 !== void 0 ? _ref11 : paddingRight) !== null && _ref10 !== void 0 ? _ref10 : pl) !== null && _ref1 !== void 0 ? _ref1 : pr) !== null && _ref0 !== void 0 ? _ref0 : padding),
1013
+ py: makeScaleHandler((_ref12 = (_ref13 = (_ref14 = (_ref15 = py !== null && py !== void 0 ? py : paddingTop) !== null && _ref15 !== void 0 ? _ref15 : paddingBottom) !== null && _ref14 !== void 0 ? _ref14 : pt) !== null && _ref13 !== void 0 ? _ref13 : pb) !== null && _ref12 !== void 0 ? _ref12 : padding),
1014
+ mt: makeScaleHandler((_ref16 = (_ref17 = marginTop !== null && marginTop !== void 0 ? marginTop : mt) !== null && _ref17 !== void 0 ? _ref17 : my) !== null && _ref16 !== void 0 ? _ref16 : margin),
1015
+ mr: makeScaleHandler((_ref18 = (_ref19 = marginRight !== null && marginRight !== void 0 ? marginRight : mr) !== null && _ref19 !== void 0 ? _ref19 : mx) !== null && _ref18 !== void 0 ? _ref18 : margin),
1016
+ mb: makeScaleHandler((_ref20 = (_ref21 = marginBottom !== null && marginBottom !== void 0 ? marginBottom : mb) !== null && _ref21 !== void 0 ? _ref21 : my) !== null && _ref20 !== void 0 ? _ref20 : margin),
1017
+ ml: makeScaleHandler((_ref22 = (_ref23 = marginLeft !== null && marginLeft !== void 0 ? marginLeft : ml) !== null && _ref23 !== void 0 ? _ref23 : mx) !== null && _ref22 !== void 0 ? _ref22 : margin),
1018
+ mx: makeScaleHandler((_ref24 = (_ref25 = (_ref26 = (_ref27 = mx !== null && mx !== void 0 ? mx : marginLeft) !== null && _ref27 !== void 0 ? _ref27 : marginRight) !== null && _ref26 !== void 0 ? _ref26 : ml) !== null && _ref25 !== void 0 ? _ref25 : mr) !== null && _ref24 !== void 0 ? _ref24 : margin),
1019
+ my: makeScaleHandler((_ref28 = (_ref29 = (_ref30 = (_ref31 = my !== null && my !== void 0 ? my : marginTop) !== null && _ref31 !== void 0 ? _ref31 : marginBottom) !== null && _ref30 !== void 0 ? _ref30 : mt) !== null && _ref29 !== void 0 ? _ref29 : mb) !== null && _ref28 !== void 0 ? _ref28 : margin),
1020
+ width: makeScaleHandler(width !== null && width !== void 0 ? width : w),
1021
+ height: makeScaleHandler(height !== null && height !== void 0 ? height : h),
1022
+ font: makeScaleHandler(font)
1023
+ },
1024
+ getScaleProps: generateGetScaleProps(props),
1025
+ getAllScaleProps: generateGetAllScaleProps(props)
1026
+ };
1027
+ return /*#__PURE__*/React.createElement(ScaleContext.Provider, {
1028
+ value: value
1029
+ }, /*#__PURE__*/React.createElement(Render, _extends({}, props, {
1030
+ ref: ref
1031
+ }), children));
1032
+ });
1033
+ ScaleFC.displayName = "Scale".concat(Render.displayName || 'Wrapper');
1034
+ return ScaleFC;
1035
+ };
1036
+
1037
+ var ButtonDrip = function ButtonDrip(_ref) {
1038
+ var _ref$x = _ref.x,
1039
+ x = _ref$x === void 0 ? 0 : _ref$x,
1040
+ _ref$y = _ref.y,
1041
+ y = _ref$y === void 0 ? 0 : _ref$y,
1042
+ color = _ref.color,
1043
+ onCompleted = _ref.onCompleted;
1044
+ var dripRef = React.useRef(null);
1045
+ /* istanbul ignore next */
1046
+ var top = Number.isNaN(+y) ? 0 : y - 10;
1047
+ /* istanbul ignore next */
1048
+ var left = Number.isNaN(+x) ? 0 : x - 10;
1049
+ React.useEffect(function () {
1050
+ /* istanbul ignore next */
1051
+ if (!dripRef.current) return;
1052
+ dripRef.current.addEventListener('animationend', onCompleted);
1053
+ return function () {
1054
+ /* istanbul ignore next */
1055
+ if (!dripRef.current) return;
1056
+ dripRef.current.removeEventListener('animationend', onCompleted);
1057
+ };
1058
+ });
1059
+ return /*#__PURE__*/React.createElement("div", {
1060
+ ref: dripRef,
1061
+ className: "jsx-3424889537" + " " + "drip"
1062
+ }, /*#__PURE__*/React.createElement("svg", {
1063
+ width: "20",
1064
+ height: "20",
1065
+ viewBox: "0 0 20 20",
1066
+ style: {
1067
+ top: top,
1068
+ left: left
1069
+ },
1070
+ className: "jsx-3424889537"
1071
+ }, /*#__PURE__*/React.createElement("g", {
1072
+ stroke: "none",
1073
+ strokeWidth: "1",
1074
+ fill: "none",
1075
+ fillRule: "evenodd",
1076
+ className: "jsx-3424889537"
1077
+ }, /*#__PURE__*/React.createElement("g", {
1078
+ fill: color,
1079
+ className: "jsx-3424889537"
1080
+ }, /*#__PURE__*/React.createElement("rect", {
1081
+ width: "100%",
1082
+ height: "100%",
1083
+ rx: "10",
1084
+ className: "jsx-3424889537"
1085
+ })))), /*#__PURE__*/React.createElement(_JSXStyle, {
1086
+ id: "3424889537"
1087
+ }, ".drip.jsx-3424889537{position:absolute;left:0;right:0;top:0;bottom:0;}svg.jsx-3424889537{position:absolute;-webkit-animation:350ms ease-in expand-jsx-3424889537;animation:350ms ease-in expand-jsx-3424889537;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;width:1rem;height:1rem;}@-webkit-keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}@keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}"));
1088
+ };
1089
+ ButtonDrip.displayName = 'ButtonDrip';
1090
+
1091
+ var _excluded$2 = ["children", "type", "color", "className", "spaceRatio"];
1092
+ var getIconBgColor = function getIconBgColor(type, palette, color) {
1093
+ var colors = {
1094
+ "default": palette.accents_6,
1095
+ secondary: palette.secondary,
1096
+ success: palette.success,
1097
+ warning: palette.warning,
1098
+ error: palette.error
1099
+ };
1100
+ return color ? color : colors[type];
1101
+ };
1102
+ var LoadingComponent = function LoadingComponent(_ref) {
1103
+ var children = _ref.children,
1104
+ _ref$type = _ref.type,
1105
+ type = _ref$type === void 0 ? 'default' : _ref$type,
1106
+ color = _ref.color,
1107
+ _ref$className = _ref.className,
1108
+ className = _ref$className === void 0 ? '' : _ref$className,
1109
+ _ref$spaceRatio = _ref.spaceRatio,
1110
+ spaceRatio = _ref$spaceRatio === void 0 ? 1 : _ref$spaceRatio,
1111
+ props = _objectWithoutProperties(_ref, _excluded$2);
1112
+ var theme$1 = theme.useTheme();
1113
+ var _useScale = useScale(),
1114
+ SCALES = _useScale.SCALES;
1115
+ var classes = theme.useClasses('loading-container', className);
1116
+ var bgColor = React.useMemo(function () {
1117
+ return getIconBgColor(type, theme$1.palette, color);
1118
+ }, [type, theme$1.palette, color]);
1119
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
1120
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + (props && props.className != null && props.className || classes || "")
1121
+ }), /*#__PURE__*/React.createElement("span", {
1122
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + "loading"
1123
+ }, children && /*#__PURE__*/React.createElement("label", {
1124
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
1125
+ }, children), /*#__PURE__*/React.createElement("i", {
1126
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
1127
+ }), /*#__PURE__*/React.createElement("i", {
1128
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
1129
+ }), /*#__PURE__*/React.createElement("i", {
1130
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
1131
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
1132
+ id: "2201634259",
1133
+ dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]
1134
+ }, ".loading-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;font-size:".concat(SCALES.font(1), ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, '100%'), ";min-height:1em;padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}label.__jsx-style-dynamic-selector{margin-right:0.5em;color:").concat(theme$1.palette.accents_5, ";line-height:1;}label.__jsx-style-dynamic-selector *{margin:0;}.loading.__jsx-style-dynamic-selector{position:absolute;top:50%;left:50%;width:100%;height:100%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}i.__jsx-style-dynamic-selector{width:0.25em;height:0.25em;border-radius:50%;background-color:").concat(bgColor, ";margin:0 calc(0.25em / 2 * ").concat(spaceRatio, ");display:inline-block;-webkit-animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;}i.__jsx-style-dynamic-selector:nth-child(2){-webkit-animation-delay:0.2s;animation-delay:0.2s;}i.__jsx-style-dynamic-selector:nth-child(3){-webkit-animation-delay:0.4s;animation-delay:0.4s;}@-webkit-keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}@keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}")));
1135
+ };
1136
+ LoadingComponent.displayName = 'Loading';
1137
+ var Loading = withScale(LoadingComponent);
1138
+
1139
+ var ButtonLoading = function ButtonLoading(_ref) {
1140
+ var color = _ref.color;
1141
+ return /*#__PURE__*/React.createElement("div", {
1142
+ className: "jsx-212623367" + " " + "btn-loading"
1143
+ }, /*#__PURE__*/React.createElement(Loading, {
1144
+ color: color
1145
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
1146
+ id: "212623367"
1147
+ }, ".btn-loading.jsx-212623367{position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;background-color:var(--helpdice-ui-button-bg);}"));
1148
+ };
1149
+ ButtonLoading.displayName = 'ButtonLoading';
1150
+
1151
+ var _excluded$1 = ["isRight", "isSingle", "children", "className"];
1152
+ var ButtonIcon = function ButtonIcon(_ref) {
1153
+ var _ref$isRight = _ref.isRight,
1154
+ isRight = _ref$isRight === void 0 ? false : _ref$isRight,
1155
+ isSingle = _ref.isSingle,
1156
+ children = _ref.children,
1157
+ _ref$className = _ref.className,
1158
+ className = _ref$className === void 0 ? '' : _ref$className,
1159
+ props = _objectWithoutProperties(_ref, _excluded$1);
1160
+ var classes = theme.useClasses('icon', {
1161
+ right: isRight,
1162
+ single: isSingle
1163
+ }, className);
1164
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
1165
+ className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || "")
1166
+ }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
1167
+ id: "2467502931"
1168
+ }, ".icon.jsx-2467502931{position:absolute;left:var(--helpdice-ui-button-icon-padding);right:auto;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--helpdice-ui-button-color);z-index:1;}.right.jsx-2467502931{right:var(--helpdice-ui-button-icon-padding);left:auto;}.icon.jsx-2467502931 svg{background:transparent;height:calc(var(--helpdice-ui-button-height) / 2.35);width:calc(var(--helpdice-ui-button-height) / 2.35);}.single.jsx-2467502931{position:static;-webkit-transform:none;-ms-transform:none;transform:none;}"));
1169
+ };
1170
+ ButtonIcon.displayName = 'ButtonIcon';
1171
+
1172
+ var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
1173
+ var icon = icons.icon,
1174
+ iconRight = icons.iconRight;
1175
+ var hasIcon = icon || iconRight;
1176
+ var isRight = Boolean(iconRight);
1177
+ var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
1178
+ var classes = theme.useClasses('text', isRight ? 'right' : 'left');
1179
+ if (!hasIcon) return /*#__PURE__*/React.createElement("div", {
1180
+ className: "text"
1181
+ }, children);
1182
+ if (React.Children.count(children) === 0) {
1183
+ return /*#__PURE__*/React.createElement(ButtonIcon, {
1184
+ isRight: isRight,
1185
+ isSingle: true
1186
+ }, hasIcon);
1187
+ }
1188
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonIcon, {
1189
+ isRight: isRight
1190
+ }, hasIcon), /*#__PURE__*/React.createElement("div", {
1191
+ className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || "")
1192
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
1193
+ id: "3568181479",
1194
+ dynamic: [paddingForAutoMode, paddingForAutoMode]
1195
+ }, ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}"))));
1196
+ };
1197
+ var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
1198
+ if (!config.isButtonGroup) return props;
1199
+ return _objectSpread2(_objectSpread2({}, props), {}, {
1200
+ auto: true,
1201
+ shadow: false,
1202
+ ghost: config.ghost || props.ghost,
1203
+ type: config.type || props.type,
1204
+ disabled: config.disabled || props.disabled
1205
+ });
1206
+ };
1207
+
1208
+ /* "use client" */
1209
+
1210
+ var defaultContext = {
1211
+ isButtonGroup: false,
1212
+ disabled: false
1213
+ };
1214
+ var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext);
1215
+ var useButtonGroupContext = function useButtonGroupContext() {
1216
+ return React.useContext(ButtonGroupContext);
1217
+ };
1218
+
1219
+ var hexToRgb = function hexToRgb(color) {
1220
+ var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1221
+ var full = color.replace(fullReg, function (_, r, g, b) {
1222
+ return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
1223
+ });
1224
+ var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
1225
+ if (!values) {
1226
+ throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
1227
+ }
1228
+ return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
1229
+ };
1230
+ var colorToRgbValues = function colorToRgbValues(color) {
1231
+ if (color.charAt(0) === '#') return hexToRgb(color);
1232
+ var safeColor = color.replace(/ /g, '');
1233
+ var colorType = color.substr(0, 4);
1234
+ var regArray = safeColor.match(/\((.+)\)/);
1235
+ if (!colorType.startsWith('rgb') || !regArray) {
1236
+ console.log(color);
1237
+ throw new Error("Helpdice UI: Only support [\"RGB\", \"RGBA\", \"HEX\"] color.");
1238
+ }
1239
+ return regArray[1].split(',').map(function (str) {
1240
+ return Number.parseFloat(str);
1241
+ });
1242
+ };
1243
+ var addColorAlpha = function addColorAlpha(color, alpha) {
1244
+ if (!/^#|rgb|RGB/.test(color)) return color;
1245
+ var _colorToRgbValues = colorToRgbValues(color),
1246
+ _colorToRgbValues2 = _slicedToArray(_colorToRgbValues, 3),
1247
+ r = _colorToRgbValues2[0],
1248
+ g = _colorToRgbValues2[1],
1249
+ b = _colorToRgbValues2[2];
1250
+ var safeAlpha = alpha > 1 ? 1 : alpha < 0 ? 0 : alpha;
1251
+ return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(safeAlpha, ")");
1252
+ };
1253
+
1254
+ var getButtonGhostColors = function getButtonGhostColors(palette, _color) {
1255
+ var colors = {
1256
+ secondary: {
1257
+ bg: palette.background,
1258
+ border: palette.foreground,
1259
+ color: palette.foreground,
1260
+ ripple: ''
1261
+ },
1262
+ success: {
1263
+ bg: palette.background,
1264
+ border: palette.success,
1265
+ color: palette.success,
1266
+ ripple: ''
1267
+ },
1268
+ warning: {
1269
+ bg: palette.background,
1270
+ border: palette.warning,
1271
+ color: palette.warning,
1272
+ ripple: ''
1273
+ },
1274
+ error: {
1275
+ bg: palette.background,
1276
+ border: palette.error,
1277
+ color: palette.error,
1278
+ ripple: ''
1279
+ }
1280
+ };
1281
+ return colors[_color] || null;
1282
+ };
1283
+ var getButtonColors = function getButtonColors(palette, props) {
1284
+ var color = props.color,
1285
+ disabled = props.disabled,
1286
+ ghost = props.ghost;
1287
+ var colors = {
1288
+ "default": {
1289
+ bg: palette.background,
1290
+ border: palette.border,
1291
+ color: palette.accents_5,
1292
+ ripple: palette.accents_1
1293
+ },
1294
+ secondary: {
1295
+ bg: palette.foreground,
1296
+ border: palette.foreground,
1297
+ color: palette.background,
1298
+ ripple: palette.accents_1
1299
+ },
1300
+ success: {
1301
+ bg: palette.success,
1302
+ border: palette.success,
1303
+ color: '#fff',
1304
+ ripple: '#1f93ffff'
1305
+ },
1306
+ warning: {
1307
+ bg: palette.warning,
1308
+ border: palette.warning,
1309
+ color: '#fff',
1310
+ ripple: '#ffca29ff'
1311
+ },
1312
+ error: {
1313
+ bg: palette.error,
1314
+ border: palette.error,
1315
+ color: '#fff',
1316
+ ripple: '#ff5a55ff'
1317
+ },
1318
+ abort: {
1319
+ bg: 'transparent',
1320
+ border: 'transparent',
1321
+ color: palette.accents_5,
1322
+ ripple: palette.accents_1
1323
+ }
1324
+ };
1325
+ if (disabled) return {
1326
+ bg: palette.accents_1,
1327
+ border: palette.accents_2,
1328
+ color: '#ccc',
1329
+ ripple: ''
1330
+ };
1331
+
1332
+ /**
1333
+ * The '-light' type is the same color as the common type,
1334
+ * only hover's color is different.
1335
+ * e.g.
1336
+ * Color['success'] === Color['success-light']
1337
+ * Color['warning'] === Color['warning-light']
1338
+ */
1339
+ var withoutLightType = color === null || color === void 0 ? void 0 : color.replace('-light', '');
1340
+ var defaultColor = colors["default"];
1341
+ if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
1342
+ return colors[withoutLightType] || defaultColor;
1343
+ };
1344
+ var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, _color) {
1345
+ var colors = {
1346
+ secondary: {
1347
+ bg: palette.foreground,
1348
+ border: palette.background,
1349
+ color: palette.background
1350
+ },
1351
+ success: {
1352
+ bg: palette.success,
1353
+ border: palette.background,
1354
+ color: 'white'
1355
+ },
1356
+ warning: {
1357
+ bg: palette.warning,
1358
+ border: palette.background,
1359
+ color: 'white'
1360
+ },
1361
+ error: {
1362
+ bg: palette.error,
1363
+ border: palette.background,
1364
+ color: 'white'
1365
+ }
1366
+ };
1367
+ var withoutLightType = _color === null || _color === void 0 ? void 0 : _color.replace('-light', '');
1368
+ return colors[withoutLightType] || null;
1369
+ };
1370
+ var getButtonHoverColors = function getButtonHoverColors(palette, props) {
1371
+ var color = props.color,
1372
+ disabled = props.disabled,
1373
+ loading = props.loading,
1374
+ shadow = props.shadow,
1375
+ ghost = props.ghost;
1376
+ var defaultColor = getButtonColors(palette, props);
1377
+ var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
1378
+ var colors = {
1379
+ "default": {
1380
+ bg: palette.background,
1381
+ border: palette.foreground
1382
+ },
1383
+ secondary: {
1384
+ bg: palette.background,
1385
+ border: palette.foreground
1386
+ },
1387
+ success: {
1388
+ bg: palette.background,
1389
+ border: palette.success
1390
+ },
1391
+ warning: {
1392
+ bg: palette.background,
1393
+ border: palette.warning
1394
+ },
1395
+ error: {
1396
+ bg: palette.background,
1397
+ border: palette.error
1398
+ },
1399
+ abort: {
1400
+ bg: 'transparent',
1401
+ border: 'transparent',
1402
+ color: palette.accents_5
1403
+ },
1404
+ 'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1405
+ bg: alphaBackground
1406
+ }),
1407
+ 'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1408
+ bg: alphaBackground
1409
+ }),
1410
+ 'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1411
+ bg: alphaBackground
1412
+ }),
1413
+ 'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1414
+ bg: alphaBackground
1415
+ })
1416
+ };
1417
+ if (disabled) return {
1418
+ bg: palette.accents_1,
1419
+ border: palette.accents_2,
1420
+ color: '#ccc'
1421
+ };
1422
+ if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1423
+ color: 'transparent'
1424
+ });
1425
+ if (shadow) return defaultColor;
1426
+ var hoverColor = (ghost ? getButtonGhostHoverColors(palette, color) : colors[color]) || colors["default"];
1427
+ return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
1428
+ color: hoverColor.color || hoverColor.border
1429
+ });
1430
+ };
1431
+ var getButtonCursor = function getButtonCursor(disabled, loading) {
1432
+ if (disabled) return {
1433
+ cursor: 'not-allowed',
1434
+ events: 'auto'
1435
+ };
1436
+ if (loading) return {
1437
+ cursor: 'default',
1438
+ events: 'none'
1439
+ };
1440
+ return {
1441
+ cursor: 'pointer',
1442
+ events: 'auto'
1443
+ };
1444
+ };
1445
+ var getButtonDripColor = function getButtonDripColor(palette, props) {
1446
+ var type = props.type;
1447
+ var isLightHover = type ? type.endsWith('light') : false;
1448
+ var hoverColors = getButtonHoverColors(palette, props);
1449
+ return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
1450
+ };
1451
+
1452
+ var _excluded = ["children", "disabled", "color", "loading", "shadow", "ghost", "effect", "round", "onClick", "auto", "icon", "type", "iconRight", "className", "crossOrigin"];
1453
+ var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
1454
+ var theme$1 = theme.useTheme();
1455
+ var _useScale = useScale(),
1456
+ SCALES = _useScale.SCALES;
1457
+ var buttonRef = React.useRef(null);
1458
+ React.useImperativeHandle(ref, function () {
1459
+ return buttonRef.current;
1460
+ }); // Changed with !
1461
+
1462
+ var _useState = React.useState(false),
1463
+ _useState2 = _slicedToArray(_useState, 2),
1464
+ dripShow = _useState2[0],
1465
+ setDripShow = _useState2[1];
1466
+ var _useState3 = React.useState(0),
1467
+ _useState4 = _slicedToArray(_useState3, 2),
1468
+ dripX = _useState4[0],
1469
+ setDripX = _useState4[1];
1470
+ var _useState5 = React.useState(0),
1471
+ _useState6 = _slicedToArray(_useState5, 2),
1472
+ dripY = _useState6[0],
1473
+ setDripY = _useState6[1];
1474
+ var groupConfig = useButtonGroupContext();
1475
+ var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
1476
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1477
+ var children = filteredProps.children,
1478
+ _filteredProps$disabl = filteredProps.disabled,
1479
+ disabled = _filteredProps$disabl === void 0 ? false : _filteredProps$disabl;
1480
+ filteredProps.color;
1481
+ var _filteredProps$loadin = filteredProps.loading,
1482
+ loading = _filteredProps$loadin === void 0 ? false : _filteredProps$loadin,
1483
+ _filteredProps$shadow = filteredProps.shadow,
1484
+ shadow = _filteredProps$shadow === void 0 ? false : _filteredProps$shadow,
1485
+ _filteredProps$ghost = filteredProps.ghost,
1486
+ ghost = _filteredProps$ghost === void 0 ? false : _filteredProps$ghost,
1487
+ _filteredProps$effect = filteredProps.effect,
1488
+ effect = _filteredProps$effect === void 0 ? true : _filteredProps$effect,
1489
+ _filteredProps$round = filteredProps.round,
1490
+ round = _filteredProps$round === void 0 ? false : _filteredProps$round,
1491
+ onClick = filteredProps.onClick,
1492
+ _filteredProps$auto = filteredProps.auto,
1493
+ auto = _filteredProps$auto === void 0 ? false : _filteredProps$auto,
1494
+ icon = filteredProps.icon,
1495
+ _filteredProps$type = filteredProps.type,
1496
+ type = _filteredProps$type === void 0 ? 'button' : _filteredProps$type,
1497
+ iconRight = filteredProps.iconRight,
1498
+ _filteredProps$classN = filteredProps.className,
1499
+ className = _filteredProps$classN === void 0 ? '' : _filteredProps$classN;
1500
+ filteredProps.crossOrigin;
1501
+ var props = _objectWithoutProperties(filteredProps, _excluded);
1502
+ /* eslint-enable @typescript-eslint/no-unused-vars */
1503
+
1504
+ var _useMemo = React.useMemo(function () {
1505
+ return getButtonColors(theme$1.palette, filteredProps);
1506
+ }, [theme$1.palette, filteredProps]),
1507
+ bg = _useMemo.bg,
1508
+ border = _useMemo.border,
1509
+ color = _useMemo.color,
1510
+ rippleColor = _useMemo.ripple;
1511
+ var hover = React.useMemo(function () {
1512
+ return getButtonHoverColors(theme$1.palette, filteredProps);
1513
+ }, [theme$1.palette, filteredProps]);
1514
+ var _useMemo2 = React.useMemo(function () {
1515
+ return getButtonCursor(disabled, loading);
1516
+ }, [disabled, loading]),
1517
+ cursor = _useMemo2.cursor,
1518
+ events = _useMemo2.events;
1519
+ var dripColor = React.useMemo(function () {
1520
+ return getButtonDripColor(theme$1.palette, filteredProps);
1521
+ }, [theme$1.palette, filteredProps]);
1522
+
1523
+ /* istanbul ignore next */
1524
+ var dripCompletedHandle = function dripCompletedHandle() {
1525
+ setDripShow(false);
1526
+ setDripX(0);
1527
+ setDripY(0);
1528
+ };
1529
+ var createRipple = function createRipple(event) {
1530
+ var button = buttonRef.current;
1531
+ if (!button) return;
1532
+ var rect = button.getBoundingClientRect();
1533
+ var size = Math.max(rect.width, rect.height);
1534
+ var x = event.clientX - rect.left - size / 2;
1535
+ var y = event.clientY - rect.top - size / 2;
1536
+ var rippleCount = 1; // number of rings
1537
+ var rippleDelay = 500; // ms between each ripple
1538
+ var _loop = function _loop() {
1539
+ var ripple = document.createElement('span');
1540
+ Object.assign(ripple.style, {
1541
+ position: 'absolute',
1542
+ borderRadius: '50%',
1543
+ backgroundColor: rippleColor,
1544
+ width: "".concat(size, "px"),
1545
+ height: "".concat(size, "px"),
1546
+ left: "".concat(x, "px"),
1547
+ top: "".concat(y, "px"),
1548
+ pointerEvents: 'none',
1549
+ transform: 'scale(0)',
1550
+ opacity: '1',
1551
+ transition: "transform 600ms ease-out ".concat(i * rippleDelay, "ms, opacity 600ms ease-out ").concat(i * rippleDelay, "ms"),
1552
+ zIndex: 1
1553
+ });
1554
+ button.appendChild(ripple);
1555
+
1556
+ // Force reflow to start transition
1557
+ window.getComputedStyle(ripple).opacity;
1558
+ ripple.style.transform = 'scale(2.5)';
1559
+ ripple.style.opacity = '0';
1560
+ ripple.addEventListener('transitionend', function () {
1561
+ ripple.remove();
1562
+ });
1563
+ };
1564
+ for (var i = 0; i < rippleCount; i++) {
1565
+ _loop();
1566
+ }
1567
+ };
1568
+ var clickHandler = function clickHandler(event) {
1569
+ if (disabled || loading) return;
1570
+ var showDrip = !shadow && !ghost && effect;
1571
+ /* istanbul ignore next */
1572
+ if (showDrip && buttonRef.current) {
1573
+ var rect = buttonRef.current.getBoundingClientRect();
1574
+ setDripShow(true);
1575
+ setDripX(event.clientX - rect.left);
1576
+ setDripY(event.clientY - rect.top);
1577
+ }
1578
+ if (shadow) {
1579
+ createRipple(event);
1580
+ }
1581
+ onClick && onClick(event);
1582
+ };
1583
+ var childrenWithIcon = React.useMemo(function () {
1584
+ return getButtonChildrenWithIcon(auto, children, {
1585
+ icon: icon,
1586
+ iconRight: iconRight
1587
+ });
1588
+ }, [auto, children, icon, iconRight]);
1589
+ var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
1590
+ paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
1591
+
1592
+ // If shadow provided is string then value other default
1593
+ var btnShadow = typeof shadow === 'string' ? shadow : shadow ? theme$1.shadows.level.z2 : 'none';
1594
+ return /*#__PURE__*/React.createElement("button", _extends({
1595
+ ref: buttonRef,
1596
+ type: type,
1597
+ disabled: disabled,
1598
+ onClick: clickHandler
1599
+ }, props, {
1600
+ className: _JSXStyle.dynamic([["905110486", [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor, events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || theme.useClasses('btn', className) || "")
1601
+ }), loading && /*#__PURE__*/React.createElement(ButtonLoading, {
1602
+ color: color
1603
+ }), childrenWithIcon, dripShow && /*#__PURE__*/React.createElement(ButtonDrip, {
1604
+ x: dripX,
1605
+ y: dripY,
1606
+ color: dripColor,
1607
+ onCompleted: dripCompletedHandle
1608
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
1609
+ id: "905110486",
1610
+ dynamic: [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor, events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']
1611
+ }, ".btn.__jsx-style-dynamic-selector{box-sizing:border-box;display:inline-block;line-height:".concat(SCALES.height(2.5), ";border-radius:").concat(round ? '50%' : theme$1.layout.radius, ";font-weight:400;font-size:").concat(SCALES.font(0.875), ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:none;text-transform:capitalize;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;white-space:nowrap;-webkit-transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;position:relative;overflow:hidden;color:").concat(color, ";background-color:").concat(bg, ";border:1px solid ").concat(shadow ? 'transparent' : border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? btnShadow : 'none', ";--helpdice-ui-button-icon-padding:").concat(SCALES.pl(0.727), ";--helpdice-ui-button-height:").concat(SCALES.height(2.5), ";--helpdice-ui-button-color:").concat(color, ";--helpdice-ui-button-bg:").concat(bg, ";min-width:").concat(auto ? 'min-content' : SCALES.width(10.5), ";width:").concat(auto ? 'auto' : 'initial', ";height:").concat(SCALES.height(2.5), ";padding:").concat(SCALES.pt(0), " ").concat(paddingRight, " ").concat(SCALES.pb(0), " ").concat(paddingLeft, ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.btn.__jsx-style-dynamic-selector:hover,.btn.__jsx-style-dynamic-selector:focus{color:").concat(hover.color, ";--helpdice-ui-button-color:").concat(hover.color, ";background-color:").concat(hover.bg, ";border-color:").concat(hover.border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(btnShadow, ";}.btn.__jsx-style-dynamic-selector .text{position:relative;z-index:1;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-align:center;line-height:inherit;top:-1px;}.btn.__jsx-style-dynamic-selector .text p,.btn.__jsx-style-dynamic-selector .text pre,.btn.__jsx-style-dynamic-selector .text div{margin:0;}.ripple.__jsx-style-dynamic-selector{position:absolute;border-radius:50%;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;background-color:rgba(0,0,0,0.3);pointer-events:none;z-index:1;}@-webkit-keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}@keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}")));
1612
+ });
1613
+ ButtonComponent.displayName = 'Button';
1614
+ var Button = withScale(ButtonComponent);
1615
+
1616
+ // export function Clipboard(props: ClipboardProps) {
1617
+ // const { setToast } = useToasts();
1618
+ // const { showIcon, text, onCopy, options: options, children, } = props;
1619
+ // const elem: ReactNode = React.Children.only(children) as ReactNode;
1620
+ // const onClick = (event: MouseEventHandler<HTMLButtonElement | MouseEvent>) => {
1621
+ // const result = copy(text, options);
1622
+
1623
+ // if (result) {
1624
+ // setToast({
1625
+ // text: 'Text Copied'
1626
+ // });
1627
+ // }
1628
+
1629
+ // if (onCopy) {
1630
+ // onCopy(text, result);
1631
+ // }
1632
+
1633
+ // // Bypass onClick if it was present
1634
+ // if (elem && elem.props && typeof elem.props.onClick === 'function') {
1635
+ // elem.props.onClick(event);
1636
+ // }
1637
+ // };
1638
+
1639
+ // if (showIcon) {
1640
+ // return React.cloneElement(
1641
+ // <div>
1642
+ // {elem}
1643
+ // <Button auto scale={0.1} px={0.6} onClick={onClick} icon={<Copy />} />
1644
+ // </div>,
1645
+ // { ...props }
1646
+ // );
1647
+ // }
1648
+
1649
+ // return React.cloneElement(
1650
+ // <div onClick={onClick}>
1651
+ // {elem}
1652
+ // </div>,
1653
+ // { ...props }
1654
+ // );
1655
+ // }
1656
+
1657
+ function Clipboard(props) {
1658
+ var _useToasts = theme.useToasts(),
1659
+ setToast = _useToasts.setToast;
1660
+ var showIcon = props.showIcon,
1661
+ text = props.text,
1662
+ onCopy = props.onCopy,
1663
+ options = props.options,
1664
+ children = props.children;
1665
+ var elem = React.Children.only(children);
1666
+ var _onClick = function onClick() {
1667
+ var result = copy(text, options);
1668
+ if (result) {
1669
+ setToast({
1670
+ text: 'Text Copied'
1671
+ });
1672
+ }
1673
+ if (onCopy) {
1674
+ onCopy(text, result);
1675
+ }
1676
+
1677
+ // ✅ Safely invoke child's onClick if it exists
1678
+ // if (isValidElement(elem) && typeof elem?.props?.onClick === 'function') {
1679
+ // elem.props.onClick();
1680
+ // }
1681
+ };
1682
+
1683
+ // If showIcon is true, render the child + a copy icon button
1684
+ if (showIcon) {
1685
+ return /*#__PURE__*/React.createElement("div", null, elem, /*#__PURE__*/React.createElement(Button, {
1686
+ auto: true,
1687
+ scale: 0.1,
1688
+ px: 0.6,
1689
+ onClick: function onClick() {
1690
+ return _onClick;
1691
+ },
1692
+ icon: /*#__PURE__*/React.createElement(icons.Copy, null)
1693
+ }));
1694
+ }
1695
+
1696
+ // Otherwise, make the entire div clickable for copy
1697
+ return /*#__PURE__*/React.cloneElement(/*#__PURE__*/React.createElement("div", {
1698
+ onClick: _onClick
1699
+ }, elem), _objectSpread2({}, props));
1700
+ }
1701
+
1702
+ exports.default = Clipboard;