@yamada-ui/utils 1.5.0-dev-20240912004633 → 1.5.1-dev-20240917033401

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 (111) hide show
  1. package/dist/array.d.mts +1 -1
  2. package/dist/array.d.ts +1 -1
  3. package/dist/array.js +3 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/array.mjs +1 -1
  6. package/dist/assertion.d.mts +14 -14
  7. package/dist/assertion.d.ts +14 -14
  8. package/dist/assertion.js +44 -16
  9. package/dist/assertion.js.map +1 -1
  10. package/dist/assertion.mjs +1 -1
  11. package/dist/calc.d.mts +12 -7
  12. package/dist/calc.d.ts +12 -7
  13. package/dist/calc.js +17 -7
  14. package/dist/calc.js.map +1 -1
  15. package/dist/calc.mjs +1 -1
  16. package/dist/{chunk-ZFE4ZWCP.mjs → chunk-2AWPBKLQ.mjs} +68 -47
  17. package/dist/chunk-2AWPBKLQ.mjs.map +1 -0
  18. package/dist/chunk-5EG6NSMV.mjs +9 -0
  19. package/dist/chunk-5EG6NSMV.mjs.map +1 -0
  20. package/dist/{chunk-I5E5UXSE.mjs → chunk-7XL7BPER.mjs} +52 -44
  21. package/dist/chunk-7XL7BPER.mjs.map +1 -0
  22. package/dist/{chunk-KT4SLZO6.mjs → chunk-7XRVZGET.mjs} +18 -12
  23. package/dist/chunk-7XRVZGET.mjs.map +1 -0
  24. package/dist/{chunk-S35WPDIT.mjs → chunk-AF6MSVQN.mjs} +75 -41
  25. package/dist/chunk-AF6MSVQN.mjs.map +1 -0
  26. package/dist/chunk-APJY76CK.mjs +9 -0
  27. package/dist/chunk-APJY76CK.mjs.map +1 -0
  28. package/dist/{chunk-L56KWSQO.mjs → chunk-OM7WYVSS.mjs} +18 -8
  29. package/dist/chunk-OM7WYVSS.mjs.map +1 -0
  30. package/dist/chunk-QTCZ2LU5.mjs +65 -0
  31. package/dist/chunk-QTCZ2LU5.mjs.map +1 -0
  32. package/dist/chunk-RCW53QOG.mjs +31 -0
  33. package/dist/chunk-RCW53QOG.mjs.map +1 -0
  34. package/dist/chunk-TJ7CW2M5.mjs +365 -0
  35. package/dist/chunk-TJ7CW2M5.mjs.map +1 -0
  36. package/dist/{chunk-2AQWXBLU.mjs → chunk-WU6FTFUV.mjs} +15 -7
  37. package/dist/chunk-WU6FTFUV.mjs.map +1 -0
  38. package/dist/chunk-Z4AGSEWZ.mjs +63 -0
  39. package/dist/chunk-Z4AGSEWZ.mjs.map +1 -0
  40. package/dist/color.d.mts +24 -24
  41. package/dist/color.d.ts +24 -24
  42. package/dist/color.js +212 -158
  43. package/dist/color.js.map +1 -1
  44. package/dist/color.mjs +3 -3
  45. package/dist/dom.d.mts +29 -29
  46. package/dist/dom.d.ts +29 -29
  47. package/dist/dom.js +79 -41
  48. package/dist/dom.js.map +1 -1
  49. package/dist/dom.mjs +2 -2
  50. package/dist/event.d.mts +13 -13
  51. package/dist/event.d.ts +13 -13
  52. package/dist/event.js +37 -23
  53. package/dist/event.js.map +1 -1
  54. package/dist/event.mjs +1 -1
  55. package/dist/function.d.mts +3 -3
  56. package/dist/function.d.ts +3 -3
  57. package/dist/function.js +19 -9
  58. package/dist/function.js.map +1 -1
  59. package/dist/function.mjs +2 -2
  60. package/dist/index.d.mts +1 -1
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +531 -346
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +12 -12
  65. package/dist/index.types.d.mts +5 -2
  66. package/dist/index.types.d.ts +5 -2
  67. package/dist/index.types.js.map +1 -1
  68. package/dist/module.d.mts +1 -1
  69. package/dist/module.d.ts +1 -1
  70. package/dist/module.js +3 -1
  71. package/dist/module.js.map +1 -1
  72. package/dist/module.mjs +1 -1
  73. package/dist/number.d.mts +7 -7
  74. package/dist/number.d.ts +7 -7
  75. package/dist/number.js +17 -11
  76. package/dist/number.js.map +1 -1
  77. package/dist/number.mjs +1 -1
  78. package/dist/object.d.mts +19 -15
  79. package/dist/object.d.ts +19 -15
  80. package/dist/object.js +65 -47
  81. package/dist/object.js.map +1 -1
  82. package/dist/object.mjs +2 -2
  83. package/dist/react.d.mts +25 -35
  84. package/dist/react.d.ts +25 -35
  85. package/dist/react.js +78 -49
  86. package/dist/react.js.map +1 -1
  87. package/dist/react.mjs +2 -2
  88. package/dist/string.d.mts +5 -5
  89. package/dist/string.d.ts +5 -5
  90. package/dist/string.js +14 -6
  91. package/dist/string.js.map +1 -1
  92. package/dist/string.mjs +1 -1
  93. package/package.json +1 -1
  94. package/dist/chunk-2AQWXBLU.mjs.map +0 -1
  95. package/dist/chunk-5OUUTZYQ.mjs +0 -7
  96. package/dist/chunk-5OUUTZYQ.mjs.map +0 -1
  97. package/dist/chunk-I5E5UXSE.mjs.map +0 -1
  98. package/dist/chunk-KT4SLZO6.mjs.map +0 -1
  99. package/dist/chunk-L56KWSQO.mjs.map +0 -1
  100. package/dist/chunk-MMZ4T26E.mjs +0 -51
  101. package/dist/chunk-MMZ4T26E.mjs.map +0 -1
  102. package/dist/chunk-NBL5H4TH.mjs +0 -35
  103. package/dist/chunk-NBL5H4TH.mjs.map +0 -1
  104. package/dist/chunk-S35WPDIT.mjs.map +0 -1
  105. package/dist/chunk-VRHGQ632.mjs +0 -23
  106. package/dist/chunk-VRHGQ632.mjs.map +0 -1
  107. package/dist/chunk-WV6P7ZCI.mjs +0 -7
  108. package/dist/chunk-WV6P7ZCI.mjs.map +0 -1
  109. package/dist/chunk-ZFE4ZWCP.mjs.map +0 -1
  110. package/dist/chunk-ZMR5WZIP.mjs +0 -321
  111. package/dist/chunk-ZMR5WZIP.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -164,25 +164,53 @@ __export(src_exports, {
164
164
  module.exports = __toCommonJS(src_exports);
165
165
 
166
166
  // src/assertion.ts
167
- var is = (x, y) => x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
168
- var isNumber = (value) => typeof value === "number";
169
- var isNotNumber = (value) => typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
170
- var isNumeric = (value) => !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
171
- var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
172
- var isBoolean = (value) => typeof value === "boolean";
173
- var isUndefined = (value) => typeof value === "undefined" && value === void 0;
174
- var isNull = (value) => value === null;
175
- var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
176
- var isArray = (value) => Array.isArray(value);
177
- var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
178
- var isFunction = (value) => typeof value === "function";
179
- var isUnit = (value) => /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
180
- value
181
- );
182
- var cast = (value) => value;
167
+ function is(x, y) {
168
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
169
+ }
170
+ function isNumber(value) {
171
+ return typeof value === "number";
172
+ }
173
+ function isNotNumber(value) {
174
+ return typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
175
+ }
176
+ function isNumeric(value) {
177
+ return !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
178
+ }
179
+ function isString(value) {
180
+ return Object.prototype.toString.call(value) === "[object String]";
181
+ }
182
+ function isBoolean(value) {
183
+ return typeof value === "boolean";
184
+ }
185
+ function isUndefined(value) {
186
+ return typeof value === "undefined" && value === void 0;
187
+ }
188
+ function isNull(value) {
189
+ return value === null;
190
+ }
191
+ function isObject(value) {
192
+ return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
193
+ }
194
+ function isArray(value) {
195
+ return Array.isArray(value);
196
+ }
197
+ function isEmpty(value) {
198
+ return !isArray(value) || !value.length || value.every((v) => v == null);
199
+ }
200
+ function isFunction(value) {
201
+ return typeof value === "function";
202
+ }
203
+ function isUnit(value) {
204
+ return /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
205
+ value
206
+ );
207
+ }
208
+ function cast(value) {
209
+ return value;
210
+ }
183
211
 
184
212
  // src/object.ts
185
- var omitObjectHelper = (obj, path) => {
213
+ function omitObjectHelper(obj, path) {
186
214
  if (!path.length) return obj;
187
215
  const [primaryKey, ...restKeys] = path;
188
216
  if (restKeys.length === 0 && primaryKey in obj) {
@@ -196,28 +224,30 @@ var omitObjectHelper = (obj, path) => {
196
224
  };
197
225
  }
198
226
  return obj;
199
- };
200
- var omitObject = (obj, keys) => {
227
+ }
228
+ function omitObject(obj, keys) {
201
229
  return keys.reduce((prev, key) => {
202
230
  const path = isString(key) ? key.split(".") : [];
203
231
  return omitObjectHelper(prev, path);
204
232
  }, obj);
205
- };
206
- var pickObject = (obj, keys, fallbackValue = "__fallback") => keys.reduce((prev, key) => {
207
- const path = isString(key) ? key.split(".") : [];
208
- if (!path.length) return prev;
209
- const value = getMemoizedObject(obj, key, fallbackValue);
210
- if (value === fallbackValue) return prev;
211
- prev = merge(
212
- prev,
213
- path.reduceRight(
214
- (prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
215
- {}
216
- )
217
- );
218
- return prev;
219
- }, {});
220
- var splitObject = (obj, keys) => {
233
+ }
234
+ function pickObject(obj, keys, fallbackValue = "__fallback") {
235
+ return keys.reduce((prev, key) => {
236
+ const path = isString(key) ? key.split(".") : [];
237
+ if (!path.length) return prev;
238
+ const value = getMemoizedObject(obj, key, fallbackValue);
239
+ if (value === fallbackValue) return prev;
240
+ prev = merge(
241
+ prev,
242
+ path.reduceRight(
243
+ (prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
244
+ {}
245
+ )
246
+ );
247
+ return prev;
248
+ }, {});
249
+ }
250
+ function splitObject(obj, keys) {
221
251
  const picked = {};
222
252
  const omitted = {};
223
253
  for (const [key, value] of Object.entries(obj)) {
@@ -228,17 +258,19 @@ var splitObject = (obj, keys) => {
228
258
  }
229
259
  }
230
260
  return [picked, omitted];
231
- };
232
- var filterObject = (obj, func) => {
261
+ }
262
+ function filterObject(obj, func) {
233
263
  const result = {};
234
264
  Object.entries(obj).forEach(([key, value]) => {
235
265
  const shouldPass = func(key, value, obj);
236
266
  if (shouldPass) result[key] = value;
237
267
  });
238
268
  return result;
239
- };
240
- var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
241
- var merge = (target, source, mergeArray = false) => {
269
+ }
270
+ function filterUndefined(obj) {
271
+ return filterObject(obj, (_, val) => val !== null && val !== void 0);
272
+ }
273
+ function merge(target, source, mergeArray = false) {
242
274
  let result = Object.assign({}, target);
243
275
  if (isObject(source)) {
244
276
  if (isObject(target)) {
@@ -257,8 +289,8 @@ var merge = (target, source, mergeArray = false) => {
257
289
  }
258
290
  }
259
291
  return result;
260
- };
261
- var flattenObject = (obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) => {
292
+ }
293
+ function flattenObject(obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) {
262
294
  maxDepth != null ? maxDepth : maxDepth = Infinity;
263
295
  omitKeys != null ? omitKeys : omitKeys = [];
264
296
  separator != null ? separator : separator = ".";
@@ -280,13 +312,17 @@ var flattenObject = (obj, { maxDepth, omitKeys, separator, shouldProcess } = {})
280
312
  }
281
313
  return result;
282
314
  }, {});
283
- };
284
- var objectFromEntries = (entries) => entries.reduce((result, [key, value]) => {
285
- result[key] = value;
286
- return result;
287
- }, {});
288
- var keysFormObject = (obj) => Object.keys(obj);
289
- var replaceObject = (objOrArray, callBack) => {
315
+ }
316
+ function objectFromEntries(entries) {
317
+ return entries.reduce((result, [key, value]) => {
318
+ result[key] = value;
319
+ return result;
320
+ }, {});
321
+ }
322
+ function keysFormObject(obj) {
323
+ return Object.keys(obj);
324
+ }
325
+ function replaceObject(objOrArray, callBack) {
290
326
  if (isArray(objOrArray)) {
291
327
  return objOrArray.map(callBack);
292
328
  } else if (isObject(objOrArray)) {
@@ -297,18 +333,18 @@ var replaceObject = (objOrArray, callBack) => {
297
333
  } else {
298
334
  return callBack(objOrArray);
299
335
  }
300
- };
301
- var getObject = (obj, path, fallback, i) => {
336
+ }
337
+ function getObject(obj, path, fallback, i) {
302
338
  const k = isString(path) ? path.split(/\[(.*?)\]|\./).filter(Boolean) : [path];
303
339
  for (i = 0; i < k.length; i += 1) {
304
340
  if (!obj) break;
305
341
  obj = obj[k[i]];
306
342
  }
307
343
  return obj === void 0 ? fallback : obj;
308
- };
309
- var memoizeObject = (func) => {
344
+ }
345
+ function memoizeObject(func) {
310
346
  const cache = /* @__PURE__ */ new WeakMap();
311
- const memoizedFunc = (obj, path, fallback, i) => {
347
+ function memoizedFunc(obj, path, fallback, i) {
312
348
  if (isUndefined(obj)) return func(obj, path, fallback);
313
349
  if (!cache.has(obj)) cache.set(obj, /* @__PURE__ */ new Map());
314
350
  const map = cache.get(obj);
@@ -316,11 +352,11 @@ var memoizeObject = (func) => {
316
352
  const value = func(obj, path, fallback, i);
317
353
  map.set(path, value);
318
354
  return value;
319
- };
355
+ }
320
356
  return memoizedFunc;
321
- };
357
+ }
322
358
  var getMemoizedObject = memoizeObject(getObject);
323
- var assignAfter = (target, ...sources) => {
359
+ function assignAfter(target, ...sources) {
324
360
  if (target == null)
325
361
  throw new TypeError("Cannot convert undefined or null to object");
326
362
  const result = { ...target };
@@ -333,28 +369,36 @@ var assignAfter = (target, ...sources) => {
333
369
  }
334
370
  }
335
371
  return result;
336
- };
372
+ }
337
373
 
338
374
  // src/function.ts
339
375
  var noop = () => {
340
376
  };
341
- var runIfFunc = (valOrFunc, ...args) => isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
342
- var handlerAll = (...funcs) => (event, ...args) => {
343
- funcs.some((func) => {
344
- func == null ? void 0 : func(event, ...args);
345
- return event == null ? void 0 : event.defaultPrevented;
346
- });
347
- };
348
- var funcAll = (...funcs) => (...args) => funcs.forEach((func) => func == null ? void 0 : func(...args));
377
+ function runIfFunc(valOrFunc, ...args) {
378
+ return isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
379
+ }
380
+ function handlerAll(...funcs) {
381
+ return function(event, ...args) {
382
+ funcs.some((func) => {
383
+ func == null ? void 0 : func(event, ...args);
384
+ return event == null ? void 0 : event.defaultPrevented;
385
+ });
386
+ };
387
+ }
388
+ function funcAll(...funcs) {
389
+ return function(...args) {
390
+ return funcs.forEach((func) => func == null ? void 0 : func(...args));
391
+ };
392
+ }
349
393
 
350
394
  // src/react.tsx
351
395
  var React = __toESM(require("react"));
352
- var createContext2 = ({
396
+ function createContext2({
353
397
  strict = true,
354
398
  errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",
355
399
  name,
356
400
  defaultValue
357
- } = {}) => {
401
+ } = {}) {
358
402
  const Context = React.createContext(defaultValue);
359
403
  Context.displayName = name;
360
404
  const useContext2 = () => {
@@ -373,16 +417,15 @@ var createContext2 = ({
373
417
  useContext2,
374
418
  Context
375
419
  ];
376
- };
420
+ }
377
421
  var useSafeLayoutEffect = Boolean(globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : React.useEffect;
378
- var useUnmountEffect = (callback) => (
379
- // eslint-disable-next-line react-hooks/exhaustive-deps
380
- React.useEffect(() => () => callback(), [])
381
- );
382
- var useIsMounted = ({
422
+ function useUnmountEffect(callback) {
423
+ return React.useEffect(() => () => callback(), []);
424
+ }
425
+ function useIsMounted({
383
426
  rerender = false,
384
427
  delay = 0
385
- } = {}) => {
428
+ } = {}) {
386
429
  const isMountedRef = React.useRef(false);
387
430
  const [isMounted, setIsMounted] = React.useState(false);
388
431
  useSafeLayoutEffect(() => {
@@ -402,24 +445,40 @@ var useIsMounted = ({
402
445
  };
403
446
  }, [delay, rerender]);
404
447
  return [React.useCallback(() => isMountedRef.current, []), isMounted];
405
- };
406
- var getValidChildren = (children) => React.Children.toArray(children).filter(
407
- (child) => React.isValidElement(child)
408
- );
409
- var isValidElement2 = (child) => React.isValidElement(child) || isString(child) || isNumber(child);
410
- var findChildren = (children, ...types) => children.find((child) => types.some((type) => child.type === type)) ? children.sort(
411
- (a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
412
- ) : [void 0, ...children];
413
- var includesChildren = (children, ...types) => children.some((child) => {
414
- if (types.some((type) => child.type === type)) return true;
415
- const children2 = getValidChildren(child.props.children);
416
- return children2.length ? includesChildren(children2, ...types) : false;
417
- });
418
- var omitChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type !== type));
419
- var pickChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type === type));
420
- var cx = (...classNames) => classNames.filter(Boolean).join(" ");
421
- var isRefObject = (val) => isObject(val) && "current" in val;
422
- var assignRef = (ref, value) => {
448
+ }
449
+ function getValidChildren(children) {
450
+ return React.Children.toArray(children).filter(
451
+ (child) => React.isValidElement(child)
452
+ );
453
+ }
454
+ function isValidElement2(child) {
455
+ return React.isValidElement(child) || isString(child) || isNumber(child);
456
+ }
457
+ function findChildren(children, ...types) {
458
+ return children.find((child) => types.some((type) => child.type === type)) ? children.sort(
459
+ (a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
460
+ ) : [void 0, ...children];
461
+ }
462
+ function includesChildren(children, ...types) {
463
+ return children.some((child) => {
464
+ if (types.some((type) => child.type === type)) return true;
465
+ const children2 = getValidChildren(child.props.children);
466
+ return children2.length ? includesChildren(children2, ...types) : false;
467
+ });
468
+ }
469
+ function omitChildren(children, ...types) {
470
+ return children.filter((child) => types.every((type) => child.type !== type));
471
+ }
472
+ function pickChildren(children, ...types) {
473
+ return children.filter((child) => types.every((type) => child.type === type));
474
+ }
475
+ function cx(...classNames) {
476
+ return classNames.filter(Boolean).join(" ");
477
+ }
478
+ function isRefObject(val) {
479
+ return isObject(val) && "current" in val;
480
+ }
481
+ function assignRef(ref, value) {
423
482
  if (ref == null) return;
424
483
  if (typeof ref === "function") {
425
484
  ref(value);
@@ -430,14 +489,18 @@ var assignRef = (ref, value) => {
430
489
  } catch {
431
490
  throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
432
491
  }
433
- };
434
- var mergeRefs = (...refs) => (node) => {
435
- refs.forEach((ref) => {
436
- assignRef(ref, node);
437
- });
438
- };
439
- var useMergeRefs = (...refs) => React.useMemo(() => mergeRefs(...refs), [refs]);
440
- var useCallbackRef = (callback, deps = []) => {
492
+ }
493
+ function mergeRefs(...refs) {
494
+ return function(node) {
495
+ return refs.forEach((ref) => {
496
+ assignRef(ref, node);
497
+ });
498
+ };
499
+ }
500
+ function useMergeRefs(...refs) {
501
+ return React.useMemo(() => mergeRefs(...refs), [refs]);
502
+ }
503
+ function useCallbackRef(callback, deps = []) {
441
504
  const callbackRef = React.useRef(callback);
442
505
  React.useEffect(() => {
443
506
  callbackRef.current = callback;
@@ -449,8 +512,8 @@ var useCallbackRef = (callback, deps = []) => {
449
512
  },
450
513
  deps
451
514
  );
452
- };
453
- var useUpdateEffect = (callback, deps) => {
515
+ }
516
+ function useUpdateEffect(callback, deps) {
454
517
  const renderCycleRef = React.useRef(false);
455
518
  const effectCycleRef = React.useRef(false);
456
519
  React.useEffect(() => {
@@ -465,15 +528,15 @@ var useUpdateEffect = (callback, deps) => {
465
528
  renderCycleRef.current = false;
466
529
  };
467
530
  }, []);
468
- };
469
- var useAsync = (func, deps = []) => {
531
+ }
532
+ function useAsync(func, deps = []) {
470
533
  const [state, callback] = useAsyncFunc(func, deps, { loading: true });
471
534
  React.useEffect(() => {
472
535
  callback();
473
536
  }, [callback]);
474
537
  return state;
475
- };
476
- var useAsyncFunc = (func, deps = [], initialState = { loading: false }) => {
538
+ }
539
+ function useAsyncFunc(func, deps = [], initialState = { loading: false }) {
477
540
  const lastCallId = React.useRef(0);
478
541
  const [isMounted] = useIsMounted();
479
542
  const [state, setState] = React.useState(initialState);
@@ -499,8 +562,8 @@ var useAsyncFunc = (func, deps = [], initialState = { loading: false }) => {
499
562
  deps
500
563
  );
501
564
  return [state, callback];
502
- };
503
- var useAsyncRetry = (func, deps = []) => {
565
+ }
566
+ function useAsyncRetry(func, deps = []) {
504
567
  const [attempt, setAttempt] = React.useState(0);
505
568
  const state = useAsync(func, [...deps, attempt]);
506
569
  const stateLoading = state.loading;
@@ -509,43 +572,65 @@ var useAsyncRetry = (func, deps = []) => {
509
572
  setAttempt((currentAttempt) => currentAttempt + 1);
510
573
  }, [...deps, stateLoading]);
511
574
  return { ...state, retry };
512
- };
575
+ }
513
576
  var createIdCounter = 0;
514
- var createId = (prefix) => `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
577
+ function createId(prefix) {
578
+ return `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
579
+ }
515
580
 
516
581
  // src/dom.ts
517
- var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement);
518
- var getPlatform = () => {
582
+ function createdDom() {
583
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
584
+ }
585
+ function getPlatform() {
519
586
  var _a, _b;
520
587
  return (_b = (_a = navigator.userAgentData) == null ? void 0 : _a.platform) != null ? _b : navigator.platform;
521
- };
522
- var vendor = (v) => createdDom() && v.test(navigator.vendor);
523
- var platform = (v) => createdDom() && v.test(getPlatform());
524
- var isMac = () => platform(/^mac/i);
525
- var isApple = () => platform(/mac|iphone|ipad|ipod/i);
526
- var isSafari = () => isApple() && vendor(/apple/i);
527
- var isElement = (el) => el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
528
- var isHTMLElement = (el) => {
588
+ }
589
+ function vendor(v) {
590
+ return createdDom() && v.test(navigator.vendor);
591
+ }
592
+ function platform(v) {
593
+ return createdDom() && v.test(getPlatform());
594
+ }
595
+ function isMac() {
596
+ return platform(/^mac/i);
597
+ }
598
+ function isApple() {
599
+ return platform(/mac|iphone|ipad|ipod/i);
600
+ }
601
+ function isSafari() {
602
+ return isApple() && vendor(/apple/i);
603
+ }
604
+ function isElement(el) {
605
+ return el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
606
+ }
607
+ function isHTMLElement(el) {
529
608
  var _a;
530
609
  if (!isElement(el)) return false;
531
610
  const win = (_a = el.ownerDocument.defaultView) != null ? _a : window;
532
611
  return el instanceof win.HTMLElement;
533
- };
534
- var isHidden = (el) => {
612
+ }
613
+ function isHidden(el) {
535
614
  if (el.parentElement && isHidden(el.parentElement)) return true;
536
615
  return el.hidden;
537
- };
538
- var isDisabled = (el) => Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
539
- var isVisible = (el) => el.offsetWidth > 0 && el.offsetHeight > 0;
540
- var hasTabIndex = (el) => el.hasAttribute("tabindex");
541
- var isContentEditable = (el) => {
616
+ }
617
+ function isDisabled(el) {
618
+ return Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
619
+ }
620
+ function isVisible(el) {
621
+ return el.offsetWidth > 0 && el.offsetHeight > 0;
622
+ }
623
+ function hasTabIndex(el) {
624
+ return el.hasAttribute("tabindex");
625
+ }
626
+ function isContentEditable(el) {
542
627
  const value = el.getAttribute("contenteditable");
543
628
  return value !== "false" && value != null;
544
- };
545
- var isContains = (parent, child) => {
629
+ }
630
+ function isContains(parent, child) {
546
631
  return parent === child || (parent == null ? void 0 : parent.contains(child));
547
- };
548
- var getPx = (value) => {
632
+ }
633
+ function getPx(value) {
549
634
  if (isNumber(value)) return value;
550
635
  if (isUndefined(value)) return 0;
551
636
  if (value.includes("px")) return parseFloat(value);
@@ -557,13 +642,17 @@ var getPx = (value) => {
557
642
  if (!isNaN(computedFontSize)) fontSize = computedFontSize;
558
643
  }
559
644
  return parseFloat(value) * fontSize;
560
- };
561
- var getEventRelatedTarget = (ev) => {
645
+ }
646
+ function getEventRelatedTarget(ev) {
562
647
  var _a;
563
648
  return (_a = ev.relatedTarget) != null ? _a : ev.currentTarget.ownerDocument.activeElement;
564
- };
565
- var dataAttr = (condition) => condition ? "" : void 0;
566
- var ariaAttr = (condition) => condition ? true : void 0;
649
+ }
650
+ function dataAttr(condition) {
651
+ return condition ? "" : void 0;
652
+ }
653
+ function ariaAttr(condition) {
654
+ return condition ? true : void 0;
655
+ }
567
656
  var focusableElList = [
568
657
  "input:not(:disabled):not([disabled])",
569
658
  "select:not(:disabled):not([disabled])",
@@ -581,14 +670,14 @@ var focusableElList = [
581
670
  "*[contenteditable]"
582
671
  ];
583
672
  var focusableElSelector = focusableElList.join();
584
- var getAllFocusable = (container) => {
673
+ function getAllFocusable(container) {
585
674
  const focusableEls = Array.from(
586
675
  container.querySelectorAll(focusableElSelector)
587
676
  );
588
677
  focusableEls.unshift(container);
589
678
  return focusableEls.filter((el) => isFocusable(el) && isVisible(el));
590
- };
591
- var isFocusable = (el) => {
679
+ }
680
+ function isFocusable(el) {
592
681
  if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) {
593
682
  return false;
594
683
  }
@@ -603,23 +692,35 @@ var isFocusable = (el) => {
603
692
  if (localName in others) return others[localName]();
604
693
  if (isContentEditable(el)) return true;
605
694
  return hasTabIndex(el);
606
- };
607
- var hasNegativeTabIndex = (el) => hasTabIndex(el) && el.tabIndex === -1;
608
- var isTabbable = (el) => el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
609
- var isTouchDevice = () => "ontouchstart" in window;
610
- var getOwnerWindow = (node) => {
695
+ }
696
+ function hasNegativeTabIndex(el) {
697
+ return hasTabIndex(el) && el.tabIndex === -1;
698
+ }
699
+ function isTabbable(el) {
700
+ return el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
701
+ }
702
+ function isTouchDevice() {
703
+ return "ontouchstart" in window;
704
+ }
705
+ function getOwnerWindow(node) {
611
706
  var _a, _b;
612
707
  return (_b = (_a = getOwnerDocument(node)) == null ? void 0 : _a.defaultView) != null ? _b : window;
613
- };
614
- var getOwnerDocument = (el) => isElement(el) ? el.ownerDocument : document;
615
- var getActiveElement = (el) => getOwnerDocument(el).activeElement;
616
- var isActiveElement = (el) => {
708
+ }
709
+ function getOwnerDocument(el) {
710
+ return isElement(el) ? el.ownerDocument : document;
711
+ }
712
+ function getActiveElement(el) {
713
+ return getOwnerDocument(el).activeElement;
714
+ }
715
+ function isActiveElement(el) {
617
716
  return getActiveElement(el) === el;
618
- };
717
+ }
619
718
 
620
719
  // src/string.ts
621
- var escape = (value, replaceValue = "") => value.replace(/\s+/g, replaceValue);
622
- var antonym = (value) => {
720
+ function escape(value, replaceValue = "") {
721
+ return value.replace(/\s+/g, replaceValue);
722
+ }
723
+ function antonym(value) {
623
724
  switch (value) {
624
725
  case "top":
625
726
  return "bottom";
@@ -656,22 +757,38 @@ var antonym = (value) => {
656
757
  default:
657
758
  return value;
658
759
  }
659
- };
660
- var toCamelCase = (value) => value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
661
- var toKebabCase = (value) => value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
662
- var toTitleCase = (value) => value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
760
+ }
761
+ function toCamelCase(value) {
762
+ return value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
763
+ }
764
+ function toKebabCase(value) {
765
+ return value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
766
+ }
767
+ function toTitleCase(value) {
768
+ return value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
769
+ }
663
770
 
664
771
  // src/calc.ts
665
- var toExpression = (operator, ...args) => args.join(` ${operator} `).replace(/calc/g, "");
666
- var add = (...args) => `calc(${toExpression("+", ...args)})`;
667
- var subtract = (...args) => `calc(${toExpression("-", ...args)})`;
668
- var multiply = (...args) => `calc(${toExpression("*", ...args)})`;
669
- var divide = (...args) => `calc(${toExpression("/", ...args)})`;
670
- var negate = (value) => {
772
+ function toExpression(operator, ...args) {
773
+ return args.join(` ${operator} `).replace(/calc/g, "");
774
+ }
775
+ function add(...args) {
776
+ return `calc(${toExpression("+", ...args)})`;
777
+ }
778
+ function subtract(...args) {
779
+ return `calc(${toExpression("-", ...args)})`;
780
+ }
781
+ function multiply(...args) {
782
+ return `calc(${toExpression("*", ...args)})`;
783
+ }
784
+ function divide(...args) {
785
+ return `calc(${toExpression("/", ...args)})`;
786
+ }
787
+ function negate(value) {
671
788
  if (value != null && !isNaN(parseFloat(value.toString())))
672
789
  return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
673
790
  return multiply(value, -1);
674
- };
791
+ }
675
792
  var calc = Object.assign(
676
793
  (x) => ({
677
794
  add: (...args) => calc(add(x, ...args)),
@@ -737,75 +854,93 @@ var TONES = [
737
854
  900,
738
855
  950
739
856
  ];
740
- var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
741
- var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
742
- var getColor = (color, fallback = "#000000") => (theme = {}, colorMode = "light", breakpoint = "base") => {
743
- var _a, _b, _c, _d, _e, _f;
744
- const [token, tone] = color.split(".");
745
- if (tone) {
746
- const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
747
- ([semanticToken]) => token === semanticToken
748
- )) != null ? _c : [];
749
- if (relatedToken) color = `${relatedToken}.${tone}`;
750
- } else {
751
- const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
752
- ([semanticToken]) => token === semanticToken
753
- )) != null ? _f : [];
754
- if (relatedColor) color = relatedColor;
755
- }
756
- const hex = getMemoizedObject(
757
- theme,
758
- `colors.${color}`,
759
- color
760
- );
761
- try {
762
- if (isArray(hex)) {
763
- return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
764
- } else if (isObject(hex)) {
765
- return c.toHex(String(hex[breakpoint]));
857
+ function isGray(colorScheme) {
858
+ return colorScheme === "gray" || colorScheme === "neutral";
859
+ }
860
+ function isAccessible(colorScheme) {
861
+ return colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
862
+ }
863
+ function getColor(color, fallback = "#000000") {
864
+ return function(theme = {}, colorMode = "light", breakpoint = "base") {
865
+ var _a, _b, _c, _d, _e, _f;
866
+ const [token, tone] = color.split(".");
867
+ if (tone) {
868
+ const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
869
+ ([semanticToken]) => token === semanticToken
870
+ )) != null ? _c : [];
871
+ if (relatedToken) color = `${relatedToken}.${tone}`;
766
872
  } else {
767
- return c.toHex(String(hex));
873
+ const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
874
+ ([semanticToken]) => token === semanticToken
875
+ )) != null ? _f : [];
876
+ if (relatedColor) color = relatedColor;
768
877
  }
769
- } catch {
878
+ const hex = getMemoizedObject(
879
+ theme,
880
+ `colors.${color}`,
881
+ color
882
+ );
770
883
  try {
771
- return c.toHex(fallback);
884
+ if (isArray(hex)) {
885
+ return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
886
+ } else if (isObject(hex)) {
887
+ return c.toHex(String(hex[breakpoint]));
888
+ } else {
889
+ return c.toHex(String(hex));
890
+ }
772
891
  } catch {
773
- return "#000000";
892
+ try {
893
+ return c.toHex(fallback);
894
+ } catch {
895
+ return "#000000";
896
+ }
774
897
  }
775
- }
776
- };
777
- var lightenColor = (color, amount) => (theme, colorMode, breakpoint) => {
778
- const raw = getColor(color, color)(theme, colorMode, breakpoint);
779
- return c.toHex(c.lighten(raw, amount / 100));
780
- };
781
- var darkenColor = (color, amount) => (theme, colorMode, breakpoint) => {
782
- const raw = getColor(color, color)(theme, colorMode, breakpoint);
783
- return c.toHex(c.darken(raw, amount / 100));
784
- };
785
- var tintColor = (color, amount) => (theme, colorMode, breakpoint) => {
786
- const raw = getColor(color, color)(theme, colorMode, breakpoint);
787
- return c.toHex(c.mix(raw, "#fff", amount / 100));
788
- };
789
- var shadeColor = (color, amount) => (theme, colorMode, breakpoint) => {
790
- const raw = getColor(color, color)(theme, colorMode, breakpoint);
791
- return c.toHex(c.mix(raw, "#000", amount / 100));
792
- };
793
- var transparentizeColor = (color, alpha) => (theme, colorMode, breakpoint) => {
794
- const raw = getColor(color, color)(theme, colorMode, breakpoint);
795
- return c.transparentize(raw, 1 - alpha);
796
- };
797
- var randomColor = ({
898
+ };
899
+ }
900
+ function lightenColor(color, amount) {
901
+ return function(theme, colorMode, breakpoint) {
902
+ const raw = getColor(color, color)(theme, colorMode, breakpoint);
903
+ return c.toHex(c.lighten(raw, amount / 100));
904
+ };
905
+ }
906
+ function darkenColor(color, amount) {
907
+ return function(theme, colorMode, breakpoint) {
908
+ const raw = getColor(color, color)(theme, colorMode, breakpoint);
909
+ return c.toHex(c.darken(raw, amount / 100));
910
+ };
911
+ }
912
+ function tintColor(color, amount) {
913
+ return function(theme, colorMode, breakpoint) {
914
+ const raw = getColor(color, color)(theme, colorMode, breakpoint);
915
+ return c.toHex(c.mix(raw, "#fff", amount / 100));
916
+ };
917
+ }
918
+ function shadeColor(color, amount) {
919
+ return function(theme, colorMode, breakpoint) {
920
+ const raw = getColor(color, color)(theme, colorMode, breakpoint);
921
+ return c.toHex(c.mix(raw, "#000", amount / 100));
922
+ };
923
+ }
924
+ function transparentizeColor(color, alpha) {
925
+ return function(theme, colorMode, breakpoint) {
926
+ const raw = getColor(color, color)(theme, colorMode, breakpoint);
927
+ return c.transparentize(raw, 1 - alpha);
928
+ };
929
+ }
930
+ function randomColor({
798
931
  string,
799
932
  colors
800
- } = {}) => {
933
+ } = {}) {
801
934
  const fallback = randomHex();
802
935
  if (string && colors) return randomColorFromList(string, colors);
803
936
  if (string && !colors) return randomColorFromString(string);
804
937
  if (colors && !string) return randomFromList(colors);
805
938
  return fallback;
806
- };
807
- var randomHex = () => `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
808
- var randomColorFromString = (str) => {
939
+ }
940
+ function randomHex() {
941
+ return `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
942
+ }
943
+ function randomColorFromString(str) {
809
944
  let hash = 0;
810
945
  if (str.length === 0) return hash.toString();
811
946
  for (let i = 0; i < str.length; i += 1) {
@@ -818,8 +953,8 @@ var randomColorFromString = (str) => {
818
953
  color += `00${value.toString(16)}`.substr(-2);
819
954
  }
820
955
  return color;
821
- };
822
- var randomColorFromList = (str, list) => {
956
+ }
957
+ function randomColorFromList(str, list) {
823
958
  let index = 0;
824
959
  if (str.length === 0) return list[0];
825
960
  for (let i = 0; i < str.length; i += 1) {
@@ -828,52 +963,66 @@ var randomColorFromList = (str, list) => {
828
963
  }
829
964
  index = (index % list.length + list.length) % list.length;
830
965
  return list[index];
831
- };
832
- var randomFromList = (list) => list[Math.floor(Math.random() * list.length)];
833
- var getBrightness = (color) => {
966
+ }
967
+ function randomFromList(list) {
968
+ return list[Math.floor(Math.random() * list.length)];
969
+ }
970
+ function getBrightness(color) {
834
971
  const [r, g, b] = c.parseToRgba(color);
835
972
  return (r * 299 + g * 587 + b * 114) / 1e3;
836
- };
837
- var isTone = (color) => (theme, colorMode, breakpoint) => {
838
- const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
839
- const brightness = getBrightness(raw);
840
- const isDark2 = brightness < 128;
841
- return isDark2 ? "dark" : "light";
842
- };
843
- var isLight = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "dark";
844
- var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "light";
845
- var convertColor = (color, fallback) => (format) => {
846
- try {
847
- const isAlpha = format.endsWith("a");
848
- if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
849
- if (format.startsWith("hex")) {
850
- let hexa = c.toHex(color);
851
- if (isAlpha) {
852
- if (hexa.length === 7) hexa += "ff";
973
+ }
974
+ function isTone(color) {
975
+ return function(theme, colorMode, breakpoint) {
976
+ const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
977
+ const brightness = getBrightness(raw);
978
+ const isDark2 = brightness < 128;
979
+ return isDark2 ? "dark" : "light";
980
+ };
981
+ }
982
+ function isLight(color) {
983
+ return function(theme, colorMode) {
984
+ return isTone(color)(theme, colorMode) === "dark";
985
+ };
986
+ }
987
+ function isDark(color) {
988
+ return function(theme, colorMode) {
989
+ return isTone(color)(theme, colorMode) === "light";
990
+ };
991
+ }
992
+ function convertColor(color, fallback) {
993
+ return function(format) {
994
+ try {
995
+ const isAlpha = format.endsWith("a");
996
+ if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
997
+ if (format.startsWith("hex")) {
998
+ let hexa = c.toHex(color);
999
+ if (isAlpha) {
1000
+ if (hexa.length === 7) hexa += "ff";
1001
+ } else {
1002
+ hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
1003
+ }
1004
+ return hexa;
1005
+ } else if (format.startsWith("hsl")) {
1006
+ let hsla2 = c.toHsla(color);
1007
+ if (!isAlpha) {
1008
+ hsla2 = hsla2.replace(/hsla/, "hsl");
1009
+ hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
1010
+ }
1011
+ return hsla2;
853
1012
  } else {
854
- hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
855
- }
856
- return hexa;
857
- } else if (format.startsWith("hsl")) {
858
- let hsla2 = c.toHsla(color);
859
- if (!isAlpha) {
860
- hsla2 = hsla2.replace(/hsla/, "hsl");
861
- hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
862
- }
863
- return hsla2;
864
- } else {
865
- let rgba2 = c.toRgba(color);
866
- if (!isAlpha) {
867
- rgba2 = rgba2.replace(/rgba/, "rgb");
868
- rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
1013
+ let rgba2 = c.toRgba(color);
1014
+ if (!isAlpha) {
1015
+ rgba2 = rgba2.replace(/rgba/, "rgb");
1016
+ rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
1017
+ }
1018
+ return rgba2;
869
1019
  }
870
- return rgba2;
1020
+ } catch {
1021
+ if (fallback) return convertColor(fallback)(format);
871
1022
  }
872
- } catch {
873
- if (fallback) return convertColor(fallback)(format);
874
- }
875
- };
876
- var calcFormat = (color) => {
1023
+ };
1024
+ }
1025
+ function calcFormat(color) {
877
1026
  if (color.startsWith("hsl")) {
878
1027
  return color.startsWith("hsla") ? "hsla" : "hsl";
879
1028
  } else if (color.startsWith("rgb")) {
@@ -881,30 +1030,32 @@ var calcFormat = (color) => {
881
1030
  } else {
882
1031
  return color.length === 9 ? "hexa" : "hex";
883
1032
  }
884
- };
885
- var getAlpha = (color) => c.parseToRgba(color)[3];
886
- var alphaToHex = (a) => {
1033
+ }
1034
+ function getAlpha(color) {
1035
+ return c.parseToRgba(color)[3];
1036
+ }
1037
+ function alphaToHex(a) {
887
1038
  if (0 > a) a = 0;
888
1039
  if (1 < a) a = 1;
889
1040
  return Math.round(a * 255).toString(16).padStart(2, "0");
890
- };
891
- var parseToRgba2 = (color, fallback) => {
1041
+ }
1042
+ function parseToRgba2(color, fallback) {
892
1043
  try {
893
1044
  if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
894
1045
  return c.parseToRgba(color);
895
1046
  } catch {
896
1047
  if (fallback) return c.parseToRgba(fallback);
897
1048
  }
898
- };
899
- var parseToHsla2 = (color, fallback) => {
1049
+ }
1050
+ function parseToHsla2(color, fallback) {
900
1051
  try {
901
1052
  if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
902
1053
  return c.parseToHsla(color);
903
1054
  } catch {
904
1055
  if (fallback) return c.parseToHsla(fallback);
905
1056
  }
906
- };
907
- var parseToHsv = (color, fallback) => {
1057
+ }
1058
+ function parseToHsv(color, fallback) {
908
1059
  var _a;
909
1060
  let [r, g, b, a] = (_a = parseToRgba2(color, fallback)) != null ? _a : [255, 255, 255, 1];
910
1061
  r = r / 255;
@@ -928,66 +1079,78 @@ var parseToHsv = (color, fallback) => {
928
1079
  break;
929
1080
  }
930
1081
  return [h, s, v, a];
931
- };
932
- var rgbaTo = ([r, g, b, a], fallback) => (format = "hex") => convertColor(c.rgba(r, g, b, a), fallback)(format);
933
- var hslaTo = ([h, s, l, a], fallback) => (format = "hex") => convertColor(c.hsla(h, s, l, a), fallback)(format);
934
- var hsvTo = ([h, s, v, a], fallback) => (format = "hex") => {
935
- h = h / 60;
936
- let rgb = [v, v, v];
937
- let i = Math.floor(h);
938
- let f = h - i;
939
- let p = v * (1 - s);
940
- let q = v * (1 - s * f);
941
- let t = v * (1 - s * (1 - f));
942
- switch (i) {
943
- case 0:
944
- case 6:
945
- rgb = [v, t, p];
946
- break;
947
- case 1:
948
- rgb = [q, v, p];
949
- break;
950
- case 2:
951
- rgb = [p, v, t];
952
- break;
953
- case 3:
954
- rgb = [p, q, v];
955
- break;
956
- case 4:
957
- rgb = [t, p, v];
958
- break;
959
- case 5:
960
- rgb = [v, p, q];
961
- break;
962
- }
963
- let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
964
- if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
965
- return convertColor(color, fallback)(format);
966
- };
967
- var sameColor = (color, comparison) => {
1082
+ }
1083
+ function rgbaTo([r, g, b, a], fallback) {
1084
+ return function(format = "hex") {
1085
+ return convertColor(c.rgba(r, g, b, a), fallback)(format);
1086
+ };
1087
+ }
1088
+ function hslaTo([h, s, l, a], fallback) {
1089
+ return function(format = "hex") {
1090
+ return convertColor(c.hsla(h, s, l, a), fallback)(format);
1091
+ };
1092
+ }
1093
+ function hsvTo([h, s, v, a], fallback) {
1094
+ return function(format = "hex") {
1095
+ h = h / 60;
1096
+ let rgb = [v, v, v];
1097
+ let i = Math.floor(h);
1098
+ let f = h - i;
1099
+ let p = v * (1 - s);
1100
+ let q = v * (1 - s * f);
1101
+ let t = v * (1 - s * (1 - f));
1102
+ switch (i) {
1103
+ case 0:
1104
+ case 6:
1105
+ rgb = [v, t, p];
1106
+ break;
1107
+ case 1:
1108
+ rgb = [q, v, p];
1109
+ break;
1110
+ case 2:
1111
+ rgb = [p, v, t];
1112
+ break;
1113
+ case 3:
1114
+ rgb = [p, q, v];
1115
+ break;
1116
+ case 4:
1117
+ rgb = [t, p, v];
1118
+ break;
1119
+ case 5:
1120
+ rgb = [v, p, q];
1121
+ break;
1122
+ }
1123
+ let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
1124
+ if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
1125
+ return convertColor(color, fallback)(format);
1126
+ };
1127
+ }
1128
+ function sameColor(color, comparison) {
968
1129
  var _a, _b;
969
1130
  if (!color) return false;
970
1131
  if (!comparison) return false;
971
1132
  const a = (_a = parseToRgba2(color)) != null ? _a : [];
972
1133
  const b = (_b = parseToRgba2(comparison)) != null ? _b : [];
973
1134
  return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
974
- };
1135
+ }
975
1136
 
976
1137
  // src/array.ts
977
- var filterEmpty = (array) => array.filter((value) => value != null);
1138
+ function filterEmpty(array) {
1139
+ return array.filter((value) => value != null);
1140
+ }
978
1141
 
979
1142
  // src/number.ts
980
- var toNumber = (n) => {
1143
+ function toNumber(n) {
981
1144
  const num = parseFloat(n);
982
1145
  return typeof num !== "number" || Number.isNaN(num) ? 0 : num;
983
- };
984
- var toPrecision = (n, precision) => {
1146
+ }
1147
+ function toPrecision(n, precision) {
985
1148
  n = toNumber(n);
986
1149
  const scale = 10 ** (precision != null ? precision : 10);
987
1150
  n = Math.round(n * scale) / scale;
988
1151
  return precision ? n.toFixed(precision) : n.toString();
989
- };
990
- var countDecimal = (n) => {
1152
+ }
1153
+ function countDecimal(n) {
991
1154
  if (!Number.isFinite(n)) return 0;
992
1155
  let e = 1;
993
1156
  let p = 0;
@@ -996,57 +1159,79 @@ var countDecimal = (n) => {
996
1159
  p += 1;
997
1160
  }
998
1161
  return p;
999
- };
1000
- var roundNumberToStep = (n, from, step) => {
1162
+ }
1163
+ function roundNumberToStep(n, from, step) {
1001
1164
  const nextValue = Math.round((n - from) / step) * step + from;
1002
1165
  const precision = countDecimal(step);
1003
1166
  return toPrecision(nextValue, precision);
1004
- };
1005
- var valueToPercent = (n, min, max) => (n - min) * 100 / (max - min);
1006
- var percentToValue = (n, min, max) => (max - min) * n + min;
1007
- var clampNumber = (n, min, max) => Math.min(Math.max(n, min), max);
1167
+ }
1168
+ function valueToPercent(n, min, max) {
1169
+ return (n - min) * 100 / (max - min);
1170
+ }
1171
+ function percentToValue(n, min, max) {
1172
+ return (max - min) * n + min;
1173
+ }
1174
+ function clampNumber(n, min, max) {
1175
+ return Math.min(Math.max(n, min), max);
1176
+ }
1008
1177
 
1009
1178
  // src/event.ts
1010
- var isMouseEvent = (ev) => {
1179
+ function isMouseEvent(ev) {
1011
1180
  const win = getEventWindow(ev);
1012
1181
  if (typeof win.PointerEvent !== "undefined" && ev instanceof win.PointerEvent)
1013
1182
  return !!(ev.pointerType === "mouse");
1014
1183
  return ev instanceof win.MouseEvent;
1015
- };
1016
- var isTouchEvent = (ev) => !!ev.touches;
1017
- var isMultiTouchEvent = (ev) => isTouchEvent(ev) && ev.touches.length > 1;
1018
- var getEventWindow = (ev) => {
1184
+ }
1185
+ function isTouchEvent(ev) {
1186
+ return !!ev.touches;
1187
+ }
1188
+ function isMultiTouchEvent(ev) {
1189
+ return isTouchEvent(ev) && ev.touches.length > 1;
1190
+ }
1191
+ function getEventWindow(ev) {
1019
1192
  var _a;
1020
1193
  return (_a = ev.view) != null ? _a : window;
1021
- };
1022
- var pointFromTouch = (e, type = "page") => {
1194
+ }
1195
+ function pointFromTouch(e, type = "page") {
1023
1196
  const point = e.touches[0] || e.changedTouches[0];
1024
1197
  return { x: point[`${type}X`], y: point[`${type}Y`] };
1025
- };
1026
- var pointFromMouse = (point, type = "page") => ({
1027
- x: point[`${type}X`],
1028
- y: point[`${type}Y`]
1029
- });
1030
- var getEventPoint = (ev, type = "page") => isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
1031
- var addDomEvent = (target, type, cb, options) => {
1198
+ }
1199
+ function pointFromMouse(point, type = "page") {
1200
+ return {
1201
+ x: point[`${type}X`],
1202
+ y: point[`${type}Y`]
1203
+ };
1204
+ }
1205
+ function getEventPoint(ev, type = "page") {
1206
+ return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
1207
+ }
1208
+ function addDomEvent(target, type, cb, options) {
1032
1209
  target.addEventListener(type, cb, options);
1033
1210
  return () => {
1034
1211
  target.removeEventListener(type, cb, options);
1035
1212
  };
1036
- };
1037
- var filter = (cb) => (ev) => {
1038
- const isMouse = isMouseEvent(ev);
1039
- if (!isMouse || isMouse && ev.button === 0) cb(ev);
1040
- };
1041
- var wrap = (cb, filterPrimary = false) => {
1042
- const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
1213
+ }
1214
+ function filter(cb) {
1215
+ return function(ev) {
1216
+ const isMouse = isMouseEvent(ev);
1217
+ if (!isMouse || isMouse && ev.button === 0) cb(ev);
1218
+ };
1219
+ }
1220
+ function wrap(cb, filterPrimary = false) {
1221
+ function listener(ev) {
1222
+ return cb(ev, { point: getEventPoint(ev) });
1223
+ }
1043
1224
  const fn = filterPrimary ? filter(listener) : listener;
1044
1225
  return fn;
1045
- };
1046
- var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
1226
+ }
1227
+ function addPointerEvent(target, type, cb, options) {
1228
+ return addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
1229
+ }
1047
1230
 
1048
1231
  // src/module.ts
1049
- var interopDefault = (module2) => module2.default || module2;
1232
+ function interopDefault(module2) {
1233
+ return module2.default || module2;
1234
+ }
1050
1235
  // Annotate the CommonJS export names for ESM import in node:
1051
1236
  0 && (module.exports = {
1052
1237
  COLOR_SCHEMES,