rattail 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,1520 @@
1
+ import { n as __reExport, t as __exportAll } from "./chunk-D1SwGrFN.mjs";
2
+ import { v4 as uuid, v6 as uuidV6 } from "uuid";
3
+ import mitt from "mitt";
4
+ export * from "mitt";
5
+ //#region src/array/at.ts
6
+ function at(arr, index) {
7
+ if (!arr.length) return;
8
+ if (index < 0) index += arr.length;
9
+ return arr[index];
10
+ }
11
+ //#endregion
12
+ //#region src/number/clamp.ts
13
+ function clamp(num, min, max) {
14
+ return Math.min(max, Math.max(min, num));
15
+ }
16
+ //#endregion
17
+ //#region src/number/clampArrayRange.ts
18
+ function clampArrayRange(index, arr) {
19
+ return clamp(index, 0, arr.length - 1);
20
+ }
21
+ //#endregion
22
+ //#region src/number/delay.ts
23
+ function delay(time) {
24
+ return new Promise((resolve) => {
25
+ setTimeout(resolve, time);
26
+ });
27
+ }
28
+ //#endregion
29
+ //#region src/number/randomNumber.ts
30
+ function randomNumber(min = 0, max = 100) {
31
+ return Math.floor(Math.random() * (max - min + 1)) + min;
32
+ }
33
+ //#endregion
34
+ //#region src/number/times.ts
35
+ function times(num, fn) {
36
+ return Array.from({ length: num }, (_, index) => fn(index));
37
+ }
38
+ //#endregion
39
+ //#region src/general/inBrowser.ts
40
+ function inBrowser() {
41
+ return typeof window !== "undefined";
42
+ }
43
+ //#endregion
44
+ //#region src/general/getGlobalThis.ts
45
+ function getGlobalThis() {
46
+ if (typeof globalThis !== "undefined") return globalThis;
47
+ if (inBrowser()) return window;
48
+ return typeof global !== "undefined" ? global : self;
49
+ }
50
+ //#endregion
51
+ //#region src/general/hasOwn.ts
52
+ const { hasOwnProperty } = Object.prototype;
53
+ function hasOwn(val, key) {
54
+ return hasOwnProperty.call(val, key);
55
+ }
56
+ //#endregion
57
+ //#region src/general/inMobile.ts
58
+ function inMobile() {
59
+ return inBrowser() && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
60
+ }
61
+ //#endregion
62
+ //#region src/general/isArray.ts
63
+ function isArray(val) {
64
+ return Array.isArray(val);
65
+ }
66
+ //#endregion
67
+ //#region src/general/toTypeString.ts
68
+ const objectToString = Object.prototype.toString;
69
+ function toTypeString(value) {
70
+ return objectToString.call(value);
71
+ }
72
+ //#endregion
73
+ //#region src/general/toRawType.ts
74
+ function toRawType(value) {
75
+ return toTypeString(value).slice(8, -1);
76
+ }
77
+ //#endregion
78
+ //#region src/general/isArrayBuffer.ts
79
+ function isArrayBuffer(val) {
80
+ return toRawType(val) === "ArrayBuffer";
81
+ }
82
+ //#endregion
83
+ //#region src/general/isBoolean.ts
84
+ function isBoolean(val) {
85
+ return typeof val === "boolean";
86
+ }
87
+ //#endregion
88
+ //#region src/general/isDataView.ts
89
+ function isDataView(val) {
90
+ return toRawType(val) === "DataView";
91
+ }
92
+ //#endregion
93
+ //#region src/general/isDate.ts
94
+ function isDate(val) {
95
+ return toRawType(val) === "Date";
96
+ }
97
+ //#endregion
98
+ //#region src/general/isDOMException.ts
99
+ function isDOMException(val) {
100
+ return toRawType(val) === "DOMException";
101
+ }
102
+ //#endregion
103
+ //#region src/general/isEmpty.ts
104
+ function isEmpty(val) {
105
+ return val === void 0 || val === null || val === "" || isArray(val) && !val.length;
106
+ }
107
+ //#endregion
108
+ //#region src/general/isError.ts
109
+ function isError(val) {
110
+ return toRawType(val) === "Error";
111
+ }
112
+ //#endregion
113
+ //#region src/general/isMap.ts
114
+ function isMap(val) {
115
+ return toRawType(val) === "Map";
116
+ }
117
+ //#endregion
118
+ //#region src/general/isObject.ts
119
+ function isObject(val) {
120
+ return typeof val === "object" && val !== null;
121
+ }
122
+ //#endregion
123
+ //#region src/general/isPlainObject.ts
124
+ function isPlainObject(val) {
125
+ return toRawType(val) === "Object";
126
+ }
127
+ //#endregion
128
+ //#region src/general/isRegExp.ts
129
+ function isRegExp(val) {
130
+ return toRawType(val) === "RegExp";
131
+ }
132
+ //#endregion
133
+ //#region src/general/isSet.ts
134
+ function isSet(val) {
135
+ return toRawType(val) === "Set";
136
+ }
137
+ //#endregion
138
+ //#region src/general/isTypedArray.ts
139
+ function isTypedArray(val) {
140
+ return [
141
+ "Int8Array",
142
+ "Uint8Array",
143
+ "Uint8ClampedArray",
144
+ "Int16Array",
145
+ "Uint16Array",
146
+ "Int32Array",
147
+ "Uint32Array",
148
+ "Float32Array",
149
+ "Float64Array",
150
+ "BigInt64Array",
151
+ "BigUint64Array"
152
+ ].includes(toRawType(val));
153
+ }
154
+ //#endregion
155
+ //#region src/general/isEqualWith.ts
156
+ function isEqualWith(value, other, fn) {
157
+ const valueStack = /* @__PURE__ */ new WeakMap();
158
+ const otherStack = /* @__PURE__ */ new WeakMap();
159
+ function baseIsEqual(value, other, valueStack, otherStack) {
160
+ if (fn(value, other) === true) return true;
161
+ if (value === other) return true;
162
+ if (value !== value && other !== other) return true;
163
+ if (!isObject(value) || !isObject(other)) return value === other;
164
+ if (value.constructor !== other.constructor) return false;
165
+ if (toRawType(value) === "String" && toRawType(other) === "String" || toRawType(value) === "Number" && toRawType(other) === "Number" || toRawType(value) === "Boolean" && toRawType(other) === "Boolean" || toRawType(value) === "BigInt" && toRawType(other) === "BigInt" || toRawType(value) === "Symbol" && toRawType(other) === "Symbol") return value.valueOf() === other.valueOf();
166
+ if (isDate(value) && isDate(other)) return value.getTime() === other.getTime();
167
+ if (isRegExp(value) && isRegExp(other)) return value.source === other.source && value.flags === other.flags;
168
+ if (isError(value) && isError(other)) return value.name === other.name && value.message === other.message && value.cause === other.cause;
169
+ if (isDOMException(value) && isDOMException(other)) return value.name === other.name && value.message === other.message;
170
+ if (isTypedArray(value) && isTypedArray(other) || isDataView(value) && isDataView(other)) {
171
+ if (value.byteLength !== other.byteLength) return false;
172
+ const valueTypedArray = new Uint8Array(value.buffer);
173
+ const otherTypedArray = new Uint8Array(other.buffer);
174
+ return valueTypedArray.every((v, i) => v === otherTypedArray[i]);
175
+ }
176
+ if (isArrayBuffer(value) && isArrayBuffer(other)) {
177
+ if (value.byteLength !== other.byteLength) return false;
178
+ const valueTypedArray = new Uint8Array(value);
179
+ const otherTypedArray = new Uint8Array(other);
180
+ return valueTypedArray.every((v, i) => v === otherTypedArray[i]);
181
+ }
182
+ if (valueStack.get(value) === other && otherStack.get(other) === value) return true;
183
+ valueStack.set(value, other);
184
+ otherStack.set(other, value);
185
+ if (isMap(value) && isMap(other) || isSet(value) && isSet(other)) {
186
+ if (value.size !== other.size) return false;
187
+ const valueArray = [...value];
188
+ const otherArray = [...other];
189
+ const result = valueArray.every((v, i) => baseIsEqual(v, otherArray[i], valueStack, otherStack));
190
+ valueStack.delete(value);
191
+ otherStack.delete(other);
192
+ return result;
193
+ }
194
+ if (isArray(value) && isArray(other)) {
195
+ if (value.length !== other.length) return false;
196
+ const result = value.every((v, i) => baseIsEqual(v, other[i], valueStack, otherStack));
197
+ valueStack.delete(value);
198
+ otherStack.delete(other);
199
+ return result;
200
+ }
201
+ if (isPlainObject(value) && isPlainObject(other)) {
202
+ const valueOwnKeys = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)];
203
+ const otherOwnKeys = [...Object.keys(other), ...Object.getOwnPropertySymbols(other)];
204
+ if (valueOwnKeys.length !== otherOwnKeys.length) return false;
205
+ const result = valueOwnKeys.every((k) => baseIsEqual(value[k], other[k], valueStack, otherStack));
206
+ valueStack.delete(value);
207
+ otherStack.delete(other);
208
+ return result;
209
+ }
210
+ return false;
211
+ }
212
+ return baseIsEqual(value, other, valueStack, otherStack);
213
+ }
214
+ //#endregion
215
+ //#region src/general/isEqual.ts
216
+ function isEqual(value, other) {
217
+ return isEqualWith(value, other, () => void 0);
218
+ }
219
+ //#endregion
220
+ //#region src/general/isFunction.ts
221
+ function isFunction(val) {
222
+ return typeof val === "function";
223
+ }
224
+ //#endregion
225
+ //#region src/general/isNonEmptyArray.ts
226
+ function isNonEmptyArray(val) {
227
+ return isArray(val) && !!val.length;
228
+ }
229
+ //#endregion
230
+ //#region src/general/isNullish.ts
231
+ function isNullish(val) {
232
+ return val == null;
233
+ }
234
+ //#endregion
235
+ //#region src/general/isNumber.ts
236
+ function isNumber(val) {
237
+ return typeof val === "number";
238
+ }
239
+ //#endregion
240
+ //#region src/general/isString.ts
241
+ function isString(val) {
242
+ return typeof val === "string";
243
+ }
244
+ //#endregion
245
+ //#region src/general/isNumeric.ts
246
+ function isNumeric(val) {
247
+ return isNumber(val) || isString(val) && /^[-+]?\d+$/.test(val);
248
+ }
249
+ //#endregion
250
+ //#region src/general/isPromise.ts
251
+ function isPromise(val) {
252
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch);
253
+ }
254
+ //#endregion
255
+ //#region src/general/isSymbol.ts
256
+ function isSymbol(val) {
257
+ return typeof val === "symbol";
258
+ }
259
+ //#endregion
260
+ //#region src/general/isTruthy.ts
261
+ function isTruthy(v) {
262
+ return Boolean(v);
263
+ }
264
+ //#endregion
265
+ //#region src/general/isWeakMap.ts
266
+ function isWeakMap(val) {
267
+ return toRawType(val) === "WeakMap";
268
+ }
269
+ //#endregion
270
+ //#region src/general/isWeakSet.ts
271
+ function isWeakSet(val) {
272
+ return toRawType(val) === "WeakSet";
273
+ }
274
+ //#endregion
275
+ //#region src/general/isWindow.ts
276
+ function isWindow(val) {
277
+ return val === window;
278
+ }
279
+ //#endregion
280
+ //#region src/general/supportTouch.ts
281
+ function supportTouch() {
282
+ return inBrowser() && "ontouchstart" in window;
283
+ }
284
+ //#endregion
285
+ //#region src/general/isFile.ts
286
+ function isFile(val) {
287
+ return toRawType(val) === "File";
288
+ }
289
+ //#endregion
290
+ //#region src/general/isBlob.ts
291
+ function isBlob(val) {
292
+ return toRawType(val) === "Blob";
293
+ }
294
+ //#endregion
295
+ //#region src/general/isPrimitive.ts
296
+ function isPrimitive(val) {
297
+ return val == null || typeof val !== "object" && typeof val !== "function";
298
+ }
299
+ //#endregion
300
+ //#region src/general/isEmptyPlainObject.ts
301
+ function isEmptyPlainObject(val) {
302
+ return isPlainObject(val) && Object.keys(val).length === 0 && Object.getOwnPropertySymbols(val).length === 0;
303
+ }
304
+ //#endregion
305
+ //#region src/general/assert.ts
306
+ function assert(condition, message) {
307
+ if (!condition) throw new Error(message);
308
+ }
309
+ //#endregion
310
+ //#region src/general/hasDuplicates.ts
311
+ function hasDuplicates(arr) {
312
+ return uniq(arr).length !== arr.length;
313
+ }
314
+ //#endregion
315
+ //#region src/general/hasDuplicatesBy.ts
316
+ function hasDuplicatesBy(arr, fn) {
317
+ return uniqBy(arr, fn).length !== arr.length;
318
+ }
319
+ //#endregion
320
+ //#region src/number/toNumber.ts
321
+ function toNumber(val) {
322
+ if (val == null) return 0;
323
+ if (isString(val)) {
324
+ val = parseFloat(val);
325
+ val = Number.isNaN(val) ? 0 : val;
326
+ return val;
327
+ }
328
+ if (isBoolean(val)) return Number(val);
329
+ return val;
330
+ }
331
+ //#endregion
332
+ //#region src/number/genNumberKey.ts
333
+ let key$1 = 0;
334
+ function genNumberKey() {
335
+ return key$1++;
336
+ }
337
+ //#endregion
338
+ //#region src/array/chunk.ts
339
+ function chunk(arr, size = 1) {
340
+ size = clamp(size, 1, arr.length);
341
+ const result = [];
342
+ let index = 0;
343
+ while (index < arr.length) {
344
+ result.push(arr.slice(index, index + size));
345
+ index += size;
346
+ }
347
+ return result;
348
+ }
349
+ //#endregion
350
+ //#region src/array/removeItem.ts
351
+ function removeItem(arr, item) {
352
+ if (arr.length) {
353
+ const index = arr.indexOf(item);
354
+ if (index > -1) return arr.splice(index, 1);
355
+ }
356
+ }
357
+ //#endregion
358
+ //#region src/array/removeItemBy.ts
359
+ function removeItemBy(arr, fn) {
360
+ if (arr.length) {
361
+ const index = arr.findIndex((v) => fn(v));
362
+ if (index > -1) return arr.splice(index, 1);
363
+ }
364
+ }
365
+ //#endregion
366
+ //#region src/array/removeItemsBy.ts
367
+ function removeItemsBy(arr, fn) {
368
+ let i = 0;
369
+ const removedItems = [];
370
+ while (i < arr.length) if (fn(arr[i])) removedItems.push(...arr.splice(i, 1));
371
+ else i++;
372
+ return removedItems;
373
+ }
374
+ //#endregion
375
+ //#region src/array/toggleItem.ts
376
+ function toggleItem(arr, item) {
377
+ arr.includes(item) ? removeItem(arr, item) : arr.push(item);
378
+ return arr;
379
+ }
380
+ //#endregion
381
+ //#region src/array/uniq.ts
382
+ function uniq(arr) {
383
+ return [...new Set(arr)];
384
+ }
385
+ //#endregion
386
+ //#region src/array/uniqBy.ts
387
+ function uniqBy(arr, fn) {
388
+ return arr.reduce((ret, i) => {
389
+ if (ret.findIndex((j) => fn(i, j)) === -1) ret.push(i);
390
+ return ret;
391
+ }, []);
392
+ }
393
+ //#endregion
394
+ //#region src/array/find.ts
395
+ function find(arr, fn, from = "start") {
396
+ let i = from === "start" ? 0 : arr.length - 1;
397
+ while (arr.length > 0 && i >= 0 && i <= arr.length - 1) {
398
+ if (fn(arr[i], i, arr)) return [arr[i], i];
399
+ from === "start" ? i++ : i--;
400
+ }
401
+ return [null, -1];
402
+ }
403
+ //#endregion
404
+ //#region src/array/shuffle.ts
405
+ function shuffle(arr) {
406
+ for (let i = arr.length - 1; i > 0; i--) {
407
+ const j = Math.floor(Math.random() * (i + 1));
408
+ [arr[i], arr[j]] = [arr[j], arr[i]];
409
+ }
410
+ return arr;
411
+ }
412
+ //#endregion
413
+ //#region src/array/removeArrayBlank.ts
414
+ function removeArrayBlank(arr) {
415
+ return arr.filter((item) => item != null);
416
+ }
417
+ //#endregion
418
+ //#region src/array/removeArrayEmpty.ts
419
+ function removeArrayEmpty(arr) {
420
+ return arr.filter((item) => item != null && item !== "");
421
+ }
422
+ //#endregion
423
+ //#region src/array/normalizeToArray.ts
424
+ function normalizeToArray(value) {
425
+ return isArray(value) ? value : [value];
426
+ }
427
+ //#endregion
428
+ //#region src/array/differenceWith.ts
429
+ function differenceWith(arr, ...values) {
430
+ const fn = at(values, -1);
431
+ const targets = values.slice(0, -1).reduce((targets, value) => [...targets, ...value], []);
432
+ return arr.filter((item) => !targets.some((value) => fn(item, value)));
433
+ }
434
+ //#endregion
435
+ //#region src/array/difference.ts
436
+ function difference(arr, ...values) {
437
+ return differenceWith(arr, ...values, (a, b) => a === b);
438
+ }
439
+ //#endregion
440
+ //#region src/array/intersectionWith.ts
441
+ function intersectionWith(...values) {
442
+ const fn = at(values, -1);
443
+ const targets = values.slice(0, -1);
444
+ if (targets.length === 0) return [];
445
+ if (targets.length === 1) return uniqBy(targets[0], fn);
446
+ function baseIntersectionWith(arr1, arr2) {
447
+ return arr1.filter((item) => arr2.some((value) => fn(item, value)));
448
+ }
449
+ return uniqBy(targets.reduce((result, target) => baseIntersectionWith(result, target)), fn);
450
+ }
451
+ //#endregion
452
+ //#region src/array/intersection.ts
453
+ function intersection(...values) {
454
+ return intersectionWith(...values, (a, b) => a === b);
455
+ }
456
+ //#endregion
457
+ //#region src/array/groupBy.ts
458
+ function groupBy(arr, fn) {
459
+ return arr.reduce((result, item) => {
460
+ const key = fn(item);
461
+ (result[key] ??= []).push(item);
462
+ return result;
463
+ }, {});
464
+ }
465
+ //#endregion
466
+ //#region src/array/xorWith.ts
467
+ function xorWith(...values) {
468
+ const fn = at(values, -1);
469
+ return uniqBy(values.slice(0, -1).reduce((result, target) => {
470
+ return [...differenceWith(result, target, fn), ...differenceWith(target, result, fn)];
471
+ }), fn);
472
+ }
473
+ //#endregion
474
+ //#region src/array/xor.ts
475
+ function xor(...values) {
476
+ return xorWith(...values, (a, b) => a === b);
477
+ }
478
+ //#endregion
479
+ //#region src/object/pick.ts
480
+ function pick(object, keys) {
481
+ return keys.reduce((result, key) => {
482
+ result[key] = object[key];
483
+ return result;
484
+ }, {});
485
+ }
486
+ //#endregion
487
+ //#region src/object/pickBy.ts
488
+ function pickBy(object, fn) {
489
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object)].reduce((result, key) => {
490
+ const value = object[key];
491
+ if (fn(value, key)) result[key] = value;
492
+ return result;
493
+ }, {});
494
+ }
495
+ //#endregion
496
+ //#region src/object/omit.ts
497
+ function omit(object, keys) {
498
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object)].reduce((result, key) => {
499
+ if (!keys.includes(key)) result[key] = object[key];
500
+ return result;
501
+ }, {});
502
+ }
503
+ //#endregion
504
+ //#region src/object/omitBy.ts
505
+ function omitBy(object, fn) {
506
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object)].reduce((result, key) => {
507
+ const value = object[key];
508
+ if (!fn(value, key)) result[key] = value;
509
+ return result;
510
+ }, {});
511
+ }
512
+ //#endregion
513
+ //#region src/object/mapObject.ts
514
+ function mapObject(object, fn) {
515
+ return Object.entries(object).reduce((result, [key, value]) => {
516
+ const entry = fn(key, value);
517
+ if (isArray(entry)) {
518
+ const [newKey, newValue] = entry;
519
+ result[newKey] = newValue;
520
+ }
521
+ return result;
522
+ }, {});
523
+ }
524
+ //#endregion
525
+ //#region src/object/promiseWithResolvers.ts
526
+ function promiseWithResolvers() {
527
+ let resolve;
528
+ let reject;
529
+ return {
530
+ promise: new Promise((_resolver, _reject) => {
531
+ resolve = _resolver;
532
+ reject = _reject;
533
+ }),
534
+ resolve,
535
+ reject
536
+ };
537
+ }
538
+ //#endregion
539
+ //#region src/object/set.ts
540
+ function set(object, path, value) {
541
+ if (!isObject(object)) return;
542
+ const keys = [...path];
543
+ if (keys.length === 0) return;
544
+ let target = object;
545
+ while (keys.length > 1) {
546
+ const key = keys.shift();
547
+ const nextKey = keys[0];
548
+ if (!isObject(target[key])) target[key] = isNumber(nextKey) ? [] : {};
549
+ target = target[key];
550
+ }
551
+ target[keys[0]] = value;
552
+ }
553
+ //#endregion
554
+ //#region src/object/objectKeys.ts
555
+ function objectKeys(object) {
556
+ return Object.keys(object);
557
+ }
558
+ //#endregion
559
+ //#region src/object/objectEntries.ts
560
+ function objectEntries(object) {
561
+ return Object.entries(object);
562
+ }
563
+ //#endregion
564
+ //#region src/integrated/index.ts
565
+ var integrated_exports = /* @__PURE__ */ __exportAll({
566
+ mitt: () => mitt,
567
+ uuid: () => uuid,
568
+ uuidV6: () => uuidV6
569
+ });
570
+ //#endregion
571
+ //#region src/util/cancelAnimationFrame.ts
572
+ function cancelAnimationFrame(handle) {
573
+ const globalThis = getGlobalThis();
574
+ globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle);
575
+ }
576
+ //#endregion
577
+ //#region src/util/classes.ts
578
+ function classes(...classes) {
579
+ return classes.map((className) => {
580
+ if (isArray(className)) {
581
+ const [condition, truthy, falsy = null] = className;
582
+ return condition ? truthy : falsy;
583
+ }
584
+ return className;
585
+ });
586
+ }
587
+ //#endregion
588
+ //#region src/util/copyText.ts
589
+ function copyText(value) {
590
+ if (!value) return;
591
+ const textArea = document.createElement("textarea");
592
+ textArea.value = value;
593
+ textArea.style.position = "fixed";
594
+ textArea.style.opacity = "0";
595
+ document.body.appendChild(textArea);
596
+ textArea.select();
597
+ document.execCommand("copy");
598
+ document.body.removeChild(textArea);
599
+ }
600
+ //#endregion
601
+ //#region src/string/camelize.ts
602
+ function camelize(s) {
603
+ s = s.replace(/[-_](\w)/g, (_, p) => p.toUpperCase());
604
+ return s.replace(s.charAt(0), s.charAt(0).toLowerCase());
605
+ }
606
+ //#endregion
607
+ //#region src/string/ensurePrefix.ts
608
+ function ensurePrefix(s, prefix) {
609
+ return s.startsWith(prefix) ? s : prefix + s;
610
+ }
611
+ //#endregion
612
+ //#region src/string/ensureSuffix.ts
613
+ function ensureSuffix(s, suffix) {
614
+ return s.endsWith(suffix) ? s : s + suffix;
615
+ }
616
+ //#endregion
617
+ //#region src/string/genStringKey.ts
618
+ let key = 0;
619
+ function genStringKey() {
620
+ return `generated-key-${key++}`;
621
+ }
622
+ //#endregion
623
+ //#region src/string/kebabCase.ts
624
+ function kebabCase(s) {
625
+ return s.replace(/([A-Z])/g, " $1").replace(/[_\s]+/g, "-").trim().replace(/^-/, "").toLowerCase();
626
+ }
627
+ //#endregion
628
+ //#region src/string/pascalCase.ts
629
+ function pascalCase(s) {
630
+ const ret = camelize(s);
631
+ return ret.replace(ret.charAt(0), ret.charAt(0).toUpperCase());
632
+ }
633
+ //#endregion
634
+ //#region src/string/lowerFirst.ts
635
+ function lowerFirst(s) {
636
+ return s.charAt(0).toLowerCase() + s.slice(1);
637
+ }
638
+ //#endregion
639
+ //#region src/string/upperFirst.ts
640
+ function upperFirst(s) {
641
+ return s.charAt(0).toUpperCase() + s.slice(1);
642
+ }
643
+ //#endregion
644
+ //#region src/string/randomColor.ts
645
+ function randomColor() {
646
+ const letters = "0123456789abcdef";
647
+ let color = "#";
648
+ for (let i = 0; i < 6; i++) color += letters[Math.floor(Math.random() * 16)];
649
+ return color;
650
+ }
651
+ //#endregion
652
+ //#region src/string/randomString.ts
653
+ function randomString(length = 10) {
654
+ let str = baseRandomString();
655
+ while (str.length < length) str += baseRandomString();
656
+ function baseRandomString() {
657
+ return Math.random().toString(36).slice(2);
658
+ }
659
+ return str.slice(0, length);
660
+ }
661
+ //#endregion
662
+ //#region src/string/slash.ts
663
+ function slash(path) {
664
+ if (path.startsWith("\\\\?\\")) return path;
665
+ return path.replace(/\\/g, "/");
666
+ }
667
+ //#endregion
668
+ //#region src/util/createNamespaceFn.ts
669
+ function createNamespaceFn(namespace) {
670
+ return (name) => {
671
+ const componentName = `${namespace}-${name}`;
672
+ const createBEM = (suffix) => {
673
+ if (!suffix) return componentName;
674
+ if (suffix[0] === "$") return suffix.replace("$", namespace);
675
+ return suffix.startsWith("--") ? `${componentName}${suffix}` : `${componentName}__${suffix}`;
676
+ };
677
+ return {
678
+ name: pascalCase(componentName),
679
+ n: createBEM,
680
+ classes
681
+ };
682
+ };
683
+ }
684
+ //#endregion
685
+ //#region src/util/requestAnimationFrame.ts
686
+ function requestAnimationFrame(fn) {
687
+ const globalThis = getGlobalThis();
688
+ return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn);
689
+ }
690
+ //#endregion
691
+ //#region src/util/doubleRaf.ts
692
+ function doubleRaf() {
693
+ return new Promise((resolve) => {
694
+ requestAnimationFrame(() => {
695
+ requestAnimationFrame(resolve);
696
+ });
697
+ });
698
+ }
699
+ //#endregion
700
+ //#region src/util/getStyle.ts
701
+ function getStyle(element) {
702
+ return window.getComputedStyle(element);
703
+ }
704
+ //#endregion
705
+ //#region src/util/getParentScroller.ts
706
+ function getParentScroller(el) {
707
+ let element = el;
708
+ while (element) {
709
+ if (!element.parentNode) break;
710
+ element = element.parentNode;
711
+ if (element === document.body || element === document.documentElement) break;
712
+ const scrollRE = /(scroll|auto)/;
713
+ const { overflowY, overflow } = getStyle(element);
714
+ if (scrollRE.test(overflowY) || scrollRE.test(overflow)) return element;
715
+ }
716
+ return window;
717
+ }
718
+ //#endregion
719
+ //#region src/util/getAllParentScroller.ts
720
+ function getAllParentScroller(el) {
721
+ const allParentScroller = [];
722
+ let element = el;
723
+ while (!isWindow(element)) {
724
+ element = getParentScroller(element);
725
+ allParentScroller.push(element);
726
+ }
727
+ return allParentScroller;
728
+ }
729
+ //#endregion
730
+ //#region src/util/getRect.ts
731
+ function getRect(element) {
732
+ if (isWindow(element)) {
733
+ const width = element.innerWidth;
734
+ const height = element.innerHeight;
735
+ const rect = {
736
+ x: 0,
737
+ y: 0,
738
+ top: 0,
739
+ left: 0,
740
+ right: width,
741
+ bottom: height,
742
+ width,
743
+ height
744
+ };
745
+ return {
746
+ ...rect,
747
+ toJSON: () => rect
748
+ };
749
+ }
750
+ return element.getBoundingClientRect();
751
+ }
752
+ //#endregion
753
+ //#region src/util/getScrollLeft.ts
754
+ function getScrollLeft(element) {
755
+ const left = "scrollLeft" in element ? element.scrollLeft : element.scrollX;
756
+ return Math.max(left, 0);
757
+ }
758
+ //#endregion
759
+ //#region src/util/getScrollTop.ts
760
+ function getScrollTop(element) {
761
+ const top = "scrollTop" in element ? element.scrollTop : element.scrollY;
762
+ return Math.max(top, 0);
763
+ }
764
+ //#endregion
765
+ //#region src/util/inViewport.ts
766
+ function inViewport(element) {
767
+ const { top, bottom, left, right } = getRect(element);
768
+ const { width, height } = getRect(window);
769
+ return left <= width && right >= 0 && top <= height && bottom >= 0;
770
+ }
771
+ //#endregion
772
+ //#region src/util/prettyJSONObject.ts
773
+ function prettyJSONObject(jsonObject) {
774
+ return JSON.stringify(jsonObject, null, 2);
775
+ }
776
+ //#endregion
777
+ //#region src/util/preventDefault.ts
778
+ function preventDefault(event) {
779
+ if (event.cancelable === false) return;
780
+ event.preventDefault();
781
+ }
782
+ //#endregion
783
+ //#region src/util/raf.ts
784
+ function raf() {
785
+ return new Promise((resolve) => {
786
+ requestAnimationFrame(resolve);
787
+ });
788
+ }
789
+ //#endregion
790
+ //#region src/util/storage.ts
791
+ function createStorage(storage) {
792
+ return {
793
+ ...storage,
794
+ set(key, value) {
795
+ if (value == null) return;
796
+ if (!isString(value)) value = JSON.stringify(value);
797
+ storage.setItem(key, value);
798
+ },
799
+ get(key) {
800
+ const data = storage.getItem(key);
801
+ try {
802
+ return JSON.parse(data);
803
+ } catch (err) {
804
+ return data;
805
+ }
806
+ },
807
+ remove(key) {
808
+ storage.removeItem(key);
809
+ }
810
+ };
811
+ }
812
+ const sessionStorage = createStorage(getGlobalThis().sessionStorage);
813
+ const localStorage = createStorage(getGlobalThis().localStorage);
814
+ //#endregion
815
+ //#region src/util/tryParseJSON.ts
816
+ function tryParseJSON(json) {
817
+ try {
818
+ return JSON.parse(json);
819
+ } catch {
820
+ return;
821
+ }
822
+ }
823
+ //#endregion
824
+ //#region src/util/download.ts
825
+ function download(val, filename = "file") {
826
+ const a = document.createElement("a");
827
+ a.style.display = "none";
828
+ a.href = isString(val) ? val : URL.createObjectURL(val);
829
+ a.download = filename;
830
+ document.body.appendChild(a);
831
+ a.click();
832
+ URL.revokeObjectURL(a.href);
833
+ document.body.removeChild(a);
834
+ }
835
+ //#endregion
836
+ //#region src/function/call.ts
837
+ function call(fn, ...args) {
838
+ if (isArray(fn)) return fn.map((f) => f(...args));
839
+ if (fn) return fn(...args);
840
+ }
841
+ //#endregion
842
+ //#region src/function/once.ts
843
+ function once(fn) {
844
+ let called = false;
845
+ let result;
846
+ return function(...args) {
847
+ if (called) return result;
848
+ called = true;
849
+ result = fn.apply(this, args);
850
+ return result;
851
+ };
852
+ }
853
+ //#endregion
854
+ //#region src/function/debounce.ts
855
+ function debounce(fn, delay = 0) {
856
+ let timer;
857
+ return function(...args) {
858
+ if (timer) clearTimeout(timer);
859
+ timer = setTimeout(() => {
860
+ fn.apply(this, args);
861
+ }, delay);
862
+ };
863
+ }
864
+ //#endregion
865
+ //#region src/function/throttle.ts
866
+ function throttle(fn, delay = 200) {
867
+ let timer;
868
+ let start = 0;
869
+ return function loop(...args) {
870
+ const now = performance.now();
871
+ const elapsed = now - start;
872
+ if (!start) start = now;
873
+ if (timer) clearTimeout(timer);
874
+ if (elapsed >= delay) {
875
+ fn.apply(this, args);
876
+ start = now;
877
+ } else timer = setTimeout(() => {
878
+ loop.apply(this, args);
879
+ }, delay - elapsed);
880
+ };
881
+ }
882
+ //#endregion
883
+ //#region src/function/NOOP.ts
884
+ function NOOP() {}
885
+ //#endregion
886
+ //#region src/function/callOrReturn.ts
887
+ function callOrReturn(fnOrValue, ...args) {
888
+ if (isFunction(fnOrValue)) return fnOrValue(...args);
889
+ return fnOrValue;
890
+ }
891
+ //#endregion
892
+ //#region src/util/enumOf.ts
893
+ function enumOf(config) {
894
+ const extractValues = Object.entries(config).reduce((result, [key, value]) => {
895
+ result[key] = isPlainObject(value) ? value.value : value;
896
+ return result;
897
+ }, {});
898
+ const configValues = Object.values(config);
899
+ function label(v) {
900
+ const valueObject = getValueObject(v);
901
+ return valueObject?.label ? callOrReturn(valueObject.label) : "";
902
+ }
903
+ function description(v) {
904
+ const valueObject = getValueObject(v);
905
+ return valueObject?.description ? callOrReturn(valueObject.description) : "";
906
+ }
907
+ function values() {
908
+ return configValues.map((option) => isPlainObject(option) ? option.value : option);
909
+ }
910
+ function labels() {
911
+ return configValues.map((option) => {
912
+ if (isPlainObject(option)) return option.label ? callOrReturn(option.label) : "";
913
+ return "";
914
+ });
915
+ }
916
+ function descriptions() {
917
+ return configValues.map((option) => {
918
+ if (isPlainObject(option)) return option.description ? callOrReturn(option.description) : "";
919
+ return "";
920
+ });
921
+ }
922
+ function resolveOption(option) {
923
+ const result = {};
924
+ for (const key of Object.keys(option)) result[key] = callOrReturn(option[key]);
925
+ return result;
926
+ }
927
+ function option(v) {
928
+ const valueObject = getValueObject(v);
929
+ if (valueObject) return resolveOption(valueObject);
930
+ return {
931
+ value: v,
932
+ label: "",
933
+ description: ""
934
+ };
935
+ }
936
+ function options() {
937
+ return configValues.map((option) => {
938
+ if (isPlainObject(option)) return resolveOption(option);
939
+ return {
940
+ value: option,
941
+ label: "",
942
+ description: ""
943
+ };
944
+ });
945
+ }
946
+ function getValueObject(v) {
947
+ return configValues.find((option) => isPlainObject(option) && option.value === v);
948
+ }
949
+ return {
950
+ ...extractValues,
951
+ values,
952
+ label,
953
+ description,
954
+ labels,
955
+ descriptions,
956
+ option,
957
+ options
958
+ };
959
+ }
960
+ //#endregion
961
+ //#region src/util/motion.ts
962
+ function motion(options) {
963
+ const { from, to, duration = 300, frame = () => {}, timingFunction = (value) => value, onStateChange = () => {} } = options;
964
+ let state = "pending";
965
+ let value = from;
966
+ const distance = to - from;
967
+ let ticker = void 0;
968
+ let startTime = void 0;
969
+ let pausedTime = void 0;
970
+ let sleepTime = 0;
971
+ function start() {
972
+ if (state === "running" || state === "finished") return;
973
+ setState("running");
974
+ const now = performance.now();
975
+ startTime = startTime != null ? startTime : now;
976
+ sleepTime += pausedTime != null ? now - pausedTime : 0;
977
+ pausedTime = void 0;
978
+ tick();
979
+ function tick() {
980
+ ticker = requestAnimationFrame(() => {
981
+ const progress = clamp((performance.now() - startTime - sleepTime) / duration, 0, 1);
982
+ value = distance * timingFunction(progress) + from;
983
+ if (progress >= 1) {
984
+ setState("finished");
985
+ frame({
986
+ value: to,
987
+ done: true
988
+ });
989
+ return;
990
+ }
991
+ frame({
992
+ value,
993
+ done: false
994
+ });
995
+ tick();
996
+ });
997
+ }
998
+ }
999
+ function pause() {
1000
+ if (state !== "running") return;
1001
+ cancelAnimationFrame(ticker);
1002
+ setState("paused");
1003
+ pausedTime = performance.now();
1004
+ }
1005
+ function reset() {
1006
+ cancelAnimationFrame(ticker);
1007
+ setState("pending");
1008
+ value = from;
1009
+ ticker = void 0;
1010
+ startTime = void 0;
1011
+ pausedTime = void 0;
1012
+ sleepTime = 0;
1013
+ }
1014
+ function getState() {
1015
+ return state;
1016
+ }
1017
+ function setState(_state) {
1018
+ state = _state;
1019
+ onStateChange(_state);
1020
+ }
1021
+ return {
1022
+ start,
1023
+ pause,
1024
+ reset,
1025
+ getState
1026
+ };
1027
+ }
1028
+ //#endregion
1029
+ //#region src/util/duration.ts
1030
+ function duration() {
1031
+ const ctx = {
1032
+ value: 0,
1033
+ years,
1034
+ months,
1035
+ weeks,
1036
+ days,
1037
+ hours,
1038
+ minutes,
1039
+ seconds,
1040
+ milliseconds,
1041
+ valueOf
1042
+ };
1043
+ function years(value) {
1044
+ ctx.value += value * 365 * 24 * 60 * 60 * 1e3;
1045
+ return ctx;
1046
+ }
1047
+ function months(value) {
1048
+ ctx.value += value * 30 * 24 * 60 * 60 * 1e3;
1049
+ return ctx;
1050
+ }
1051
+ function weeks(value) {
1052
+ ctx.value += value * 7 * 24 * 60 * 60 * 1e3;
1053
+ return ctx;
1054
+ }
1055
+ function days(value) {
1056
+ ctx.value += value * 24 * 60 * 60 * 1e3;
1057
+ return ctx;
1058
+ }
1059
+ function hours(value) {
1060
+ ctx.value += value * 60 * 60 * 1e3;
1061
+ return ctx;
1062
+ }
1063
+ function minutes(value) {
1064
+ ctx.value += value * 60 * 1e3;
1065
+ return ctx;
1066
+ }
1067
+ function seconds(value) {
1068
+ ctx.value += value * 1e3;
1069
+ return ctx;
1070
+ }
1071
+ function milliseconds(value) {
1072
+ ctx.value += value;
1073
+ return ctx;
1074
+ }
1075
+ function valueOf(options = { milliseconds: true }) {
1076
+ return options.milliseconds ? ctx.value : ctx.value / 1e3;
1077
+ }
1078
+ return ctx;
1079
+ }
1080
+ //#endregion
1081
+ //#region src/util/createCacheManager.ts
1082
+ function createCacheManager(options = {}) {
1083
+ const cacheManager = /* @__PURE__ */ new Map();
1084
+ const { ttl: defaultTtl = Infinity } = options;
1085
+ function purgeStale() {
1086
+ cacheManager.forEach((value, key) => {
1087
+ if (performance.now() > value.expiredAt) remove(key);
1088
+ });
1089
+ }
1090
+ function has(key) {
1091
+ purgeStale();
1092
+ return cacheManager.has(key);
1093
+ }
1094
+ function get(key) {
1095
+ purgeStale();
1096
+ return cacheManager.get(key)?.value;
1097
+ }
1098
+ function set(key, value, options) {
1099
+ const ttl = options?.ttl ?? defaultTtl;
1100
+ cacheManager.set(key, {
1101
+ expiredAt: performance.now() + ttl,
1102
+ value
1103
+ });
1104
+ }
1105
+ function remove(key) {
1106
+ return cacheManager.delete(key);
1107
+ }
1108
+ function clear() {
1109
+ cacheManager.clear();
1110
+ }
1111
+ return {
1112
+ has,
1113
+ get,
1114
+ set,
1115
+ remove,
1116
+ clear
1117
+ };
1118
+ }
1119
+ //#endregion
1120
+ //#region src/util/navigation.ts
1121
+ function buildNavigationUrl(target) {
1122
+ if (isString(target)) return target;
1123
+ const { to, query, hash } = target;
1124
+ const hashIndex = to.indexOf("#");
1125
+ const toWithoutHash = hashIndex >= 0 ? to.slice(0, hashIndex) : to;
1126
+ const existingHash = hashIndex >= 0 ? `#${to.slice(hashIndex + 1)}` : "";
1127
+ const queryIndex = toWithoutHash.indexOf("?");
1128
+ const base = queryIndex >= 0 ? toWithoutHash.slice(0, queryIndex) : toWithoutHash;
1129
+ const existingQueryString = queryIndex >= 0 ? toWithoutHash.slice(queryIndex + 1) : "";
1130
+ const params = new URLSearchParams(existingQueryString);
1131
+ if (query) for (const [key, value] of Object.entries(query)) params.append(key, String(value));
1132
+ const queryString = params.toString();
1133
+ const finalHash = hash ?? existingHash;
1134
+ let url = base;
1135
+ if (queryString) url += `?${queryString}`;
1136
+ if (finalHash) url += finalHash;
1137
+ return url;
1138
+ }
1139
+ const navigation = {
1140
+ push(target) {
1141
+ window.location.assign(buildNavigationUrl(target));
1142
+ },
1143
+ replace(target) {
1144
+ window.location.replace(buildNavigationUrl(target));
1145
+ },
1146
+ open(target) {
1147
+ const url = buildNavigationUrl(target);
1148
+ window.open(url);
1149
+ },
1150
+ back() {
1151
+ window.history.back();
1152
+ },
1153
+ go(delta) {
1154
+ window.history.go(delta);
1155
+ }
1156
+ };
1157
+ //#endregion
1158
+ //#region src/collection/cloneDeepWith.ts
1159
+ function cloneDeepWith(value, fn) {
1160
+ const cache = /* @__PURE__ */ new WeakMap();
1161
+ function baseCloneDeep(value, cache) {
1162
+ const customResult = fn(value);
1163
+ if (customResult !== void 0) return customResult;
1164
+ if (!isObject(value)) return value;
1165
+ if (cache.has(value)) return cache.get(value);
1166
+ if (isDate(value)) return new Date(value);
1167
+ if (isRegExp(value)) return new RegExp(value);
1168
+ if (isMap(value)) {
1169
+ const result = /* @__PURE__ */ new Map();
1170
+ cache.set(value, result);
1171
+ value.forEach((val, key) => {
1172
+ result.set(baseCloneDeep(key, cache), baseCloneDeep(val, cache));
1173
+ });
1174
+ return result;
1175
+ }
1176
+ if (isSet(value)) {
1177
+ const result = /* @__PURE__ */ new Set();
1178
+ cache.set(value, result);
1179
+ value.forEach((val) => {
1180
+ result.add(baseCloneDeep(val, cache));
1181
+ });
1182
+ return result;
1183
+ }
1184
+ if (toRawType(value) === "String" || toRawType(value) === "Number" || toRawType(value) === "Boolean") return newConstructor(value, value.valueOf());
1185
+ if (isWeakMap(value) || isWeakSet(value) || isError(value) || isDOMException(value)) return {};
1186
+ if (isTypedArray(value)) return newConstructor(value, baseCloneArrayBuffer(value.buffer), value.byteOffset, value.length);
1187
+ if (isDataView(value)) return newConstructor(value, baseCloneArrayBuffer(value.buffer), value.byteOffset, value.byteLength);
1188
+ if (isArrayBuffer(value)) return baseCloneArrayBuffer(value);
1189
+ if (isArray(value)) {
1190
+ const result = [];
1191
+ cache.set(value, result);
1192
+ value.forEach((value, index) => {
1193
+ result[index] = baseCloneDeep(value, cache);
1194
+ });
1195
+ return result;
1196
+ }
1197
+ if (isPlainObject(value)) {
1198
+ const result = Object.create(Reflect.getPrototypeOf(value));
1199
+ cache.set(value, result);
1200
+ [...Object.keys(value), ...Object.getOwnPropertySymbols(value)].forEach((key) => {
1201
+ result[key] = baseCloneDeep(value[key], cache);
1202
+ });
1203
+ return result;
1204
+ }
1205
+ return value;
1206
+ }
1207
+ function baseCloneArrayBuffer(value) {
1208
+ const result = new ArrayBuffer(value.byteLength);
1209
+ new Uint8Array(result).set(new Uint8Array(value));
1210
+ return result;
1211
+ }
1212
+ function newConstructor(value, ...args) {
1213
+ return new value.constructor(...args);
1214
+ }
1215
+ return baseCloneDeep(value, cache);
1216
+ }
1217
+ //#endregion
1218
+ //#region src/collection/cloneDeep.ts
1219
+ function cloneDeep(value) {
1220
+ return cloneDeepWith(value, () => void 0);
1221
+ }
1222
+ //#endregion
1223
+ //#region src/collection/mergeWith.ts
1224
+ function mergeWith(object, ...sources) {
1225
+ const fn = at(sources, -1);
1226
+ const targets = [object, ...sources.slice(0, -1)];
1227
+ let len = targets.length - 1;
1228
+ let result = targets[len];
1229
+ while (len) {
1230
+ result = baseMergeWith(targets[len - 1], result, fn);
1231
+ len--;
1232
+ }
1233
+ function baseMergeWith(object, source, fn) {
1234
+ function baseMerge(target, src) {
1235
+ for (const key in src) if (hasOwn(src, key)) {
1236
+ const srcValue = src[key];
1237
+ const targetValue = target[key];
1238
+ const customResult = fn(targetValue, srcValue, key, object, source);
1239
+ if (customResult !== void 0) target[key] = customResult;
1240
+ else if (isObject(srcValue)) if (isObject(targetValue)) target[key] = baseMerge(targetValue, srcValue);
1241
+ else target[key] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
1242
+ else target[key] = srcValue;
1243
+ }
1244
+ return target;
1245
+ }
1246
+ return baseMerge(object, source);
1247
+ }
1248
+ return result;
1249
+ }
1250
+ //#endregion
1251
+ //#region src/collection/merge.ts
1252
+ function merge(object, ...sources) {
1253
+ return mergeWith(object, ...sources, () => void 0);
1254
+ }
1255
+ //#endregion
1256
+ //#region src/file/toArrayBuffer.ts
1257
+ function toArrayBuffer(file) {
1258
+ return new Promise((resolve) => {
1259
+ const fileReader = new FileReader();
1260
+ fileReader.onload = () => {
1261
+ resolve(fileReader.result);
1262
+ };
1263
+ fileReader.readAsArrayBuffer(file);
1264
+ });
1265
+ }
1266
+ //#endregion
1267
+ //#region src/file/toDataURL.ts
1268
+ function toDataURL(file) {
1269
+ return new Promise((resolve) => {
1270
+ const fileReader = new FileReader();
1271
+ fileReader.onload = () => {
1272
+ resolve(fileReader.result);
1273
+ };
1274
+ fileReader.readAsDataURL(file);
1275
+ });
1276
+ }
1277
+ //#endregion
1278
+ //#region src/file/toText.ts
1279
+ function toText(file) {
1280
+ return new Promise((resolve) => {
1281
+ const fileReader = new FileReader();
1282
+ fileReader.onload = () => {
1283
+ resolve(fileReader.result);
1284
+ };
1285
+ fileReader.readAsText(file);
1286
+ });
1287
+ }
1288
+ //#endregion
1289
+ //#region src/math/maxBy.ts
1290
+ function maxBy(arr, fn) {
1291
+ return arr.reduce((result, item) => fn(result) > fn(item) ? result : item, arr[0]);
1292
+ }
1293
+ //#endregion
1294
+ //#region src/math/minBy.ts
1295
+ function minBy(arr, fn) {
1296
+ return arr.reduce((result, item) => fn(result) < fn(item) ? result : item, arr[0]);
1297
+ }
1298
+ //#endregion
1299
+ //#region src/math/sum.ts
1300
+ function sum(arr) {
1301
+ return arr.reduce((ret, val) => ret + val, 0);
1302
+ }
1303
+ //#endregion
1304
+ //#region src/math/sumBy.ts
1305
+ function sumBy(arr, fn) {
1306
+ return arr.reduce((ret, val) => ret + fn(val), 0);
1307
+ }
1308
+ //#endregion
1309
+ //#region src/math/sumHash.ts
1310
+ function sumHash(value) {
1311
+ function sum(hash, value) {
1312
+ for (let i = 0; i < value.length; i++) {
1313
+ const chr = value.charCodeAt(i);
1314
+ hash = (hash << 5) - hash + chr;
1315
+ hash |= 0;
1316
+ }
1317
+ return hash < 0 ? hash * -2 : hash;
1318
+ }
1319
+ function baseSumHash(hash, value, key, seen) {
1320
+ hash = sum(hash, key);
1321
+ hash = sum(hash, toTypeString(value));
1322
+ hash = sum(hash, typeof value);
1323
+ if (value === null) return sum(hash, "null");
1324
+ if (value === void 0) return sum(hash, "undefined");
1325
+ if (isObject(value) || isFunction(value)) {
1326
+ if (seen.includes(value)) return sum(hash, `[Circular]${key}`);
1327
+ seen.push(value);
1328
+ hash = Object.keys(value).sort().reduce((hash, key) => baseSumHash(hash, value[key], key, seen), hash);
1329
+ if (isFunction(value.valueOf)) return sum(hash, String(value.valueOf()));
1330
+ return hash;
1331
+ }
1332
+ return sum(hash, value.toString());
1333
+ }
1334
+ return baseSumHash(0, value, "", []).toString(16).padStart(8, "0");
1335
+ }
1336
+ //#endregion
1337
+ //#region src/math/mean.ts
1338
+ function mean(arr) {
1339
+ return sum(arr) / arr.length;
1340
+ }
1341
+ //#endregion
1342
+ //#region src/math/meanBy.ts
1343
+ function meanBy(arr, fn) {
1344
+ return sumBy(arr, fn) / arr.length;
1345
+ }
1346
+ //#endregion
1347
+ //#region src/math/sample.ts
1348
+ function sample(arr) {
1349
+ if (!arr.length) return;
1350
+ return arr[randomNumber(0, arr.length - 1)];
1351
+ }
1352
+ //#endregion
1353
+ //#region src/math/round.ts
1354
+ function round(val, precision = 0) {
1355
+ return baseRound(val, precision, Math.round);
1356
+ }
1357
+ function baseRound(val, precision, fn) {
1358
+ precision = clamp(precision ?? 0, -292, 292);
1359
+ if (!precision) return fn(val);
1360
+ return +`${fn(`${val}e${precision}`)}e${-precision}`;
1361
+ }
1362
+ //#endregion
1363
+ //#region src/math/floor.ts
1364
+ function floor(val, precision = 0) {
1365
+ return baseRound(val, precision, Math.floor);
1366
+ }
1367
+ //#endregion
1368
+ //#region src/math/ceil.ts
1369
+ function ceil(val, precision = 0) {
1370
+ return baseRound(val, precision, Math.ceil);
1371
+ }
1372
+ __reExport(/* @__PURE__ */ __exportAll({
1373
+ NOOP: () => NOOP,
1374
+ assert: () => assert,
1375
+ at: () => at,
1376
+ baseRound: () => baseRound,
1377
+ buildNavigationUrl: () => buildNavigationUrl,
1378
+ call: () => call,
1379
+ callOrReturn: () => callOrReturn,
1380
+ camelize: () => camelize,
1381
+ cancelAnimationFrame: () => cancelAnimationFrame,
1382
+ ceil: () => ceil,
1383
+ chunk: () => chunk,
1384
+ clamp: () => clamp,
1385
+ clampArrayRange: () => clampArrayRange,
1386
+ classes: () => classes,
1387
+ cloneDeep: () => cloneDeep,
1388
+ cloneDeepWith: () => cloneDeepWith,
1389
+ copyText: () => copyText,
1390
+ createCacheManager: () => createCacheManager,
1391
+ createNamespaceFn: () => createNamespaceFn,
1392
+ createStorage: () => createStorage,
1393
+ debounce: () => debounce,
1394
+ delay: () => delay,
1395
+ difference: () => difference,
1396
+ differenceWith: () => differenceWith,
1397
+ doubleRaf: () => doubleRaf,
1398
+ download: () => download,
1399
+ duration: () => duration,
1400
+ ensurePrefix: () => ensurePrefix,
1401
+ ensureSuffix: () => ensureSuffix,
1402
+ enumOf: () => enumOf,
1403
+ find: () => find,
1404
+ floor: () => floor,
1405
+ genNumberKey: () => genNumberKey,
1406
+ genStringKey: () => genStringKey,
1407
+ getAllParentScroller: () => getAllParentScroller,
1408
+ getGlobalThis: () => getGlobalThis,
1409
+ getParentScroller: () => getParentScroller,
1410
+ getRect: () => getRect,
1411
+ getScrollLeft: () => getScrollLeft,
1412
+ getScrollTop: () => getScrollTop,
1413
+ getStyle: () => getStyle,
1414
+ groupBy: () => groupBy,
1415
+ hasDuplicates: () => hasDuplicates,
1416
+ hasDuplicatesBy: () => hasDuplicatesBy,
1417
+ hasOwn: () => hasOwn,
1418
+ inBrowser: () => inBrowser,
1419
+ inMobile: () => inMobile,
1420
+ inViewport: () => inViewport,
1421
+ intersection: () => intersection,
1422
+ intersectionWith: () => intersectionWith,
1423
+ isArray: () => isArray,
1424
+ isArrayBuffer: () => isArrayBuffer,
1425
+ isBlob: () => isBlob,
1426
+ isBoolean: () => isBoolean,
1427
+ isDOMException: () => isDOMException,
1428
+ isDataView: () => isDataView,
1429
+ isDate: () => isDate,
1430
+ isEmpty: () => isEmpty,
1431
+ isEmptyPlainObject: () => isEmptyPlainObject,
1432
+ isEqual: () => isEqual,
1433
+ isEqualWith: () => isEqualWith,
1434
+ isError: () => isError,
1435
+ isFile: () => isFile,
1436
+ isFunction: () => isFunction,
1437
+ isMap: () => isMap,
1438
+ isNonEmptyArray: () => isNonEmptyArray,
1439
+ isNullish: () => isNullish,
1440
+ isNumber: () => isNumber,
1441
+ isNumeric: () => isNumeric,
1442
+ isObject: () => isObject,
1443
+ isPlainObject: () => isPlainObject,
1444
+ isPrimitive: () => isPrimitive,
1445
+ isPromise: () => isPromise,
1446
+ isRegExp: () => isRegExp,
1447
+ isSet: () => isSet,
1448
+ isString: () => isString,
1449
+ isSymbol: () => isSymbol,
1450
+ isTruthy: () => isTruthy,
1451
+ isTypedArray: () => isTypedArray,
1452
+ isWeakMap: () => isWeakMap,
1453
+ isWeakSet: () => isWeakSet,
1454
+ isWindow: () => isWindow,
1455
+ kebabCase: () => kebabCase,
1456
+ localStorage: () => localStorage,
1457
+ lowerFirst: () => lowerFirst,
1458
+ mapObject: () => mapObject,
1459
+ maxBy: () => maxBy,
1460
+ mean: () => mean,
1461
+ meanBy: () => meanBy,
1462
+ merge: () => merge,
1463
+ mergeWith: () => mergeWith,
1464
+ minBy: () => minBy,
1465
+ mitt: () => mitt,
1466
+ motion: () => motion,
1467
+ navigation: () => navigation,
1468
+ normalizeToArray: () => normalizeToArray,
1469
+ objectEntries: () => objectEntries,
1470
+ objectKeys: () => objectKeys,
1471
+ objectToString: () => objectToString,
1472
+ omit: () => omit,
1473
+ omitBy: () => omitBy,
1474
+ once: () => once,
1475
+ pascalCase: () => pascalCase,
1476
+ pick: () => pick,
1477
+ pickBy: () => pickBy,
1478
+ prettyJSONObject: () => prettyJSONObject,
1479
+ preventDefault: () => preventDefault,
1480
+ promiseWithResolvers: () => promiseWithResolvers,
1481
+ raf: () => raf,
1482
+ randomColor: () => randomColor,
1483
+ randomNumber: () => randomNumber,
1484
+ randomString: () => randomString,
1485
+ removeArrayBlank: () => removeArrayBlank,
1486
+ removeArrayEmpty: () => removeArrayEmpty,
1487
+ removeItem: () => removeItem,
1488
+ removeItemBy: () => removeItemBy,
1489
+ removeItemsBy: () => removeItemsBy,
1490
+ requestAnimationFrame: () => requestAnimationFrame,
1491
+ round: () => round,
1492
+ sample: () => sample,
1493
+ sessionStorage: () => sessionStorage,
1494
+ set: () => set,
1495
+ shuffle: () => shuffle,
1496
+ slash: () => slash,
1497
+ sum: () => sum,
1498
+ sumBy: () => sumBy,
1499
+ sumHash: () => sumHash,
1500
+ supportTouch: () => supportTouch,
1501
+ throttle: () => throttle,
1502
+ times: () => times,
1503
+ toArrayBuffer: () => toArrayBuffer,
1504
+ toDataURL: () => toDataURL,
1505
+ toNumber: () => toNumber,
1506
+ toRawType: () => toRawType,
1507
+ toText: () => toText,
1508
+ toTypeString: () => toTypeString,
1509
+ toggleItem: () => toggleItem,
1510
+ tryParseJSON: () => tryParseJSON,
1511
+ uniq: () => uniq,
1512
+ uniqBy: () => uniqBy,
1513
+ upperFirst: () => upperFirst,
1514
+ uuid: () => uuid,
1515
+ uuidV6: () => uuidV6,
1516
+ xor: () => xor,
1517
+ xorWith: () => xorWith
1518
+ }), integrated_exports);
1519
+ //#endregion
1520
+ export { NOOP, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };