@rebon/cli-linux-arm64 1.18.0 → 1.19.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.
@@ -1,357 +1,418 @@
1
- // src/misc.ts
2
- function noop() {
3
- }
1
+ //#region lib/types/misc.js
2
+ /** No-op callback returning `undefined` at runtime and `any` at type level. */
3
+ function noop() {}
4
+ /** Return true when a value is `null` or `undefined`. */
4
5
  function isNullable(value) {
5
- return value === null || value === void 0;
6
+ return value === null || value === void 0;
6
7
  }
8
+ /** Return true when a value is neither `null` nor `undefined`. */
7
9
  function isNonNullable(value) {
8
- return !isNullable(value);
10
+ return !isNullable(value);
9
11
  }
12
+ /** Return true for non-array object values. */
10
13
  function isPlainObject(data) {
11
- return data && typeof data === "object" && !Array.isArray(data);
14
+ return data && typeof data === "object" && !Array.isArray(data);
12
15
  }
16
+ /** Filter object entries and return a new object. */
13
17
  function filterKeys(object, filter) {
14
- return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
18
+ return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
15
19
  }
20
+ /** Map object values while preserving the original key set. */
16
21
  function mapValues(object, transform) {
17
- return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
22
+ return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
18
23
  }
24
+ /** Pick selected keys from an object, optionally including `undefined` values. */
19
25
  function pick(source, keys, forced) {
20
- if (!keys) return { ...source };
21
- const result = {};
22
- for (const key of keys) {
23
- if (forced || source[key] !== void 0) result[key] = source[key];
24
- }
25
- return result;
26
+ if (!keys) return { ...source };
27
+ const result = {};
28
+ for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
29
+ return result;
26
30
  }
31
+ /** Omit selected keys from a shallow object copy. */
27
32
  function omit(source, keys) {
28
- if (!keys) return { ...source };
29
- const result = { ...source };
30
- for (const key of keys) {
31
- Reflect.deleteProperty(result, key);
32
- }
33
- return result;
33
+ if (!keys) return { ...source };
34
+ const result = { ...source };
35
+ for (const key of keys) Reflect.deleteProperty(result, key);
36
+ return result;
34
37
  }
38
+ /** Define a non-enumerable writable property and return the object. */
35
39
  function defineProperty(object, key, value) {
36
- return Object.defineProperty(object, key, { writable: true, value, enumerable: false });
40
+ return Object.defineProperty(object, key, {
41
+ writable: true,
42
+ value,
43
+ enumerable: false
44
+ });
37
45
  }
38
-
39
- // src/array.ts
46
+ //#endregion
47
+ //#region lib/types/array.js
48
+ /** Return true when every item in `array2` is present in `array1`. */
40
49
  function contain(array1, array2) {
41
- return array2.every((item) => array1.includes(item));
50
+ return array2.every((item) => array1.includes(item));
42
51
  }
52
+ /** Return items that appear in both arrays. */
43
53
  function intersection(array1, array2) {
44
- return array1.filter((item) => array2.includes(item));
54
+ return array1.filter((item) => array2.includes(item));
45
55
  }
56
+ /** Return items from `array1` that do not appear in `array2`. */
46
57
  function difference(array1, array2) {
47
- return array1.filter((item) => !array2.includes(item));
58
+ return array1.filter((item) => !array2.includes(item));
48
59
  }
60
+ /** Return the set-union of two arrays while preserving first occurrence order. */
49
61
  function union(array1, array2) {
50
- return Array.from(/* @__PURE__ */ new Set([...array1, ...array2]));
62
+ return Array.from(new Set([...array1, ...array2]));
51
63
  }
64
+ /** Remove duplicate values while preserving first occurrence order. */
52
65
  function deduplicate(array) {
53
- return [...new Set(array)];
66
+ return [...new Set(array)];
54
67
  }
68
+ /** Remove one item from an array and report whether it was found. */
55
69
  function remove(list, item) {
56
- const index = list?.indexOf(item);
57
- if (index >= 0) {
58
- list.splice(index, 1);
59
- return true;
60
- } else {
61
- return false;
62
- }
70
+ const index = list?.indexOf(item);
71
+ if (index >= 0) {
72
+ list.splice(index, 1);
73
+ return true;
74
+ } else return false;
63
75
  }
76
+ /** Normalize nullish, scalar, or array input to an array. */
64
77
  function makeArray(source) {
65
- return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
78
+ return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
79
+ }
80
+ //#endregion
81
+ //#region lib/types/volatile.js
82
+ /** Shared config references used by schema validators and plugin runtimes. */
83
+ const write = Symbol.for("cosmokit.volatile.write");
84
+ function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
85
+ if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
86
+ if (value === null || typeof value !== "object") return value;
87
+ if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
88
+ ancestors.add(value);
89
+ try {
90
+ if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
91
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
92
+ return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
93
+ } finally {
94
+ ancestors.delete(value);
95
+ }
96
+ }
97
+ /**
98
+ * Create a detached reference containing an immutable copy of the supplied data.
99
+ * @param value - validated config data; class instances and functions are unsupported.
100
+ * @returns a reference whose value is updated only by its owning runtime.
101
+ */
102
+ function createVolatile(value) {
103
+ let current = snapshot(value);
104
+ return Object.freeze({
105
+ get: () => current,
106
+ [write]: (value) => {
107
+ current = value;
108
+ }
109
+ });
110
+ }
111
+ /**
112
+ * Identify references across ESM/CJS copies of the shared library.
113
+ * @param value - a parsed config value.
114
+ * @returns whether the value implements the shared reference protocol.
115
+ */
116
+ function isVolatile(value) {
117
+ return typeof value === "object" && value !== null && write in value;
66
118
  }
67
-
68
- // src/types.ts
119
+ /**
120
+ * Collect config references without descending into their snapshots or opaque objects.
121
+ * @internal
122
+ * @param value - parsed config; cyclic ordinary fields are visited once per path.
123
+ * @returns references and their object-key paths, including an empty path for a root reference.
124
+ */
125
+ function volatileEntries(value) {
126
+ const ancestors = /* @__PURE__ */ new Set();
127
+ function visit(value, path) {
128
+ if (isVolatile(value)) return [{
129
+ path,
130
+ ref: value
131
+ }];
132
+ if (!value || typeof value !== "object" || ancestors.has(value)) return [];
133
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return [];
134
+ ancestors.add(value);
135
+ try {
136
+ return Object.entries(value).flatMap(([key, child]) => visit(child, [...path, key]));
137
+ } finally {
138
+ ancestors.delete(value);
139
+ }
140
+ }
141
+ return visit(value, []);
142
+ }
143
+ /**
144
+ * Commit an already validated immutable snapshot from another reference.
145
+ * @internal
146
+ * @param target - the owning plugin's stable reference.
147
+ * @param source - a newly parsed candidate reference.
148
+ */
149
+ function updateVolatile(target, source) {
150
+ target[write](source.get());
151
+ }
152
+ //#endregion
153
+ //#region lib/types/types.js
154
+ /** Test values using `instanceof` with a `toStringTag` fallback. */
69
155
  function is(type, value) {
70
- if (arguments.length === 1) return (value2) => is(type, value2);
71
- return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
156
+ if (arguments.length === 1) return (value) => is(type, value);
157
+ return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
72
158
  }
73
159
  function isArrayBufferLike(value) {
74
- return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
160
+ return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
75
161
  }
76
162
  function isArrayBufferSource(value) {
77
- return isArrayBufferLike(value) || ArrayBuffer.isView(value);
163
+ return isArrayBufferLike(value) || ArrayBuffer.isView(value);
78
164
  }
165
+ /** Binary source detection and base64/hex conversion helpers. */
79
166
  var Binary;
80
- ((Binary2) => {
81
- Binary2.is = isArrayBufferLike;
82
- Binary2.isSource = isArrayBufferSource;
83
- function fromSource(source) {
84
- if (ArrayBuffer.isView(source)) {
85
- return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
86
- } else {
87
- return source;
88
- }
89
- }
90
- Binary2.fromSource = fromSource;
91
- function toBase64(source) {
92
- source = fromSource(source);
93
- if (typeof Buffer !== "undefined") {
94
- return Buffer.from(source).toString("base64");
95
- }
96
- let binary = "";
97
- const bytes = new Uint8Array(source);
98
- for (let i = 0; i < bytes.byteLength; i++) {
99
- binary += String.fromCharCode(bytes[i]);
100
- }
101
- return btoa(binary);
102
- }
103
- Binary2.toBase64 = toBase64;
104
- function fromBase64(source) {
105
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
106
- return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
107
- }
108
- Binary2.fromBase64 = fromBase64;
109
- function toHex(source) {
110
- source = fromSource(source);
111
- if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
112
- return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
113
- }
114
- Binary2.toHex = toHex;
115
- function fromHex(source) {
116
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
117
- const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
118
- const buffer = [];
119
- for (let i = 0; i < hex.length; i += 2) {
120
- buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
121
- }
122
- return Uint8Array.from(buffer).buffer;
123
- }
124
- Binary2.fromHex = fromHex;
167
+ (function(Binary) {
168
+ Binary.is = isArrayBufferLike;
169
+ Binary.isSource = isArrayBufferSource;
170
+ function fromSource(source) {
171
+ if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
172
+ else return source;
173
+ }
174
+ Binary.fromSource = fromSource;
175
+ function toBase64(source) {
176
+ source = fromSource(source);
177
+ if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
178
+ let binary = "";
179
+ const bytes = new Uint8Array(source);
180
+ for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
181
+ return btoa(binary);
182
+ }
183
+ Binary.toBase64 = toBase64;
184
+ function fromBase64(source) {
185
+ if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
186
+ return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
187
+ }
188
+ Binary.fromBase64 = fromBase64;
189
+ function toHex(source) {
190
+ source = fromSource(source);
191
+ if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
192
+ return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
193
+ }
194
+ Binary.toHex = toHex;
195
+ function fromHex(source) {
196
+ if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
197
+ const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
198
+ const buffer = [];
199
+ for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
200
+ return Uint8Array.from(buffer).buffer;
201
+ }
202
+ Binary.fromHex = fromHex;
125
203
  })(Binary || (Binary = {}));
126
- var base64ToArrayBuffer = Binary.fromBase64;
127
- var arrayBufferToBase64 = Binary.toBase64;
128
- var hexToArrayBuffer = Binary.fromHex;
129
- var arrayBufferToHex = Binary.toHex;
204
+ /** Decode a base64 string into binary data. */
205
+ const base64ToArrayBuffer = Binary.fromBase64;
206
+ /** Encode binary data as base64. */
207
+ const arrayBufferToBase64 = Binary.toBase64;
208
+ /** Decode a hex string into binary data. */
209
+ const hexToArrayBuffer = Binary.fromHex;
210
+ /** Encode binary data as hex. */
211
+ const arrayBufferToHex = Binary.toHex;
212
+ /** Deep-clone common JavaScript values while preserving prototypes and cycles. */
130
213
  function clone(source, refs = /* @__PURE__ */ new Map()) {
131
- if (!source || typeof source !== "object") return source;
132
- if (is("Date", source)) return new Date(source.valueOf());
133
- if (is("RegExp", source)) return new RegExp(source.source, source.flags);
134
- if (isArrayBufferLike(source)) return source.slice(0);
135
- if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
136
- const cached = refs.get(source);
137
- if (cached) return cached;
138
- if (Array.isArray(source)) {
139
- const result2 = [];
140
- refs.set(source, result2);
141
- source.forEach((value, index) => {
142
- result2[index] = Reflect.apply(clone, null, [value, refs]);
143
- });
144
- return result2;
145
- }
146
- const result = Object.create(Object.getPrototypeOf(source));
147
- refs.set(source, result);
148
- for (const key of Reflect.ownKeys(source)) {
149
- const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
150
- if ("value" in descriptor) {
151
- descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
152
- }
153
- Reflect.defineProperty(result, key, descriptor);
154
- }
155
- return result;
214
+ if (!source || typeof source !== "object") return source;
215
+ if (is("Date", source)) return new Date(source.valueOf());
216
+ if (is("RegExp", source)) return new RegExp(source.source, source.flags);
217
+ if (isArrayBufferLike(source)) return source.slice(0);
218
+ if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
219
+ const cached = refs.get(source);
220
+ if (cached) return cached;
221
+ if (Array.isArray(source)) {
222
+ const result = [];
223
+ refs.set(source, result);
224
+ source.forEach((value, index) => {
225
+ result[index] = Reflect.apply(clone, null, [value, refs]);
226
+ });
227
+ return result;
228
+ }
229
+ const result = Object.create(Object.getPrototypeOf(source));
230
+ refs.set(source, result);
231
+ for (const key of Reflect.ownKeys(source)) {
232
+ const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
233
+ if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
234
+ Reflect.defineProperty(result, key, descriptor);
235
+ }
236
+ return result;
156
237
  }
238
+ /**
239
+ * Compare values recursively, treating two volatile references as equal regardless of value.
240
+ * Strict comparison distinguishes null/undefined, treats opaque objects by identity,
241
+ * compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
242
+ * @param a - first value.
243
+ * @param b - second value.
244
+ * @param strict - whether to require strict data equality outside volatile references.
245
+ * @returns whether the values compare equal.
246
+ */
157
247
  function deepEqual(a, b, strict) {
158
- if (a === b) return true;
159
- if (!strict && isNullable(a) && isNullable(b)) return true;
160
- if (typeof a !== typeof b) return false;
161
- if (typeof a !== "object") return false;
162
- if (!a || !b) return false;
163
- function check(test, then) {
164
- return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
165
- }
166
- return check(Array.isArray, (a2, b2) => a2.length === b2.length && a2.every((item, index) => deepEqual(item, b2[index]))) ?? check(is("Date"), (a2, b2) => a2.valueOf() === b2.valueOf()) ?? check(is("RegExp"), (a2, b2) => a2.source === b2.source && a2.flags === b2.flags) ?? check(isArrayBufferLike, (a2, b2) => {
167
- if (a2.byteLength !== b2.byteLength) return false;
168
- const viewA = new Uint8Array(a2);
169
- const viewB = new Uint8Array(b2);
170
- for (let i = 0; i < viewA.length; i++) {
171
- if (viewA[i] !== viewB[i]) return false;
172
- }
173
- return true;
174
- }) ?? Object.keys({ ...a, ...b }).every((key) => deepEqual(a[key], b[key], strict));
175
- }
176
-
177
- // src/string.ts
248
+ const ancestors = /* @__PURE__ */ new Set();
249
+ function compare(a, b) {
250
+ if (a === b) return true;
251
+ if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
252
+ if (!strict && isNullable(a) && isNullable(b)) return true;
253
+ if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
254
+ if (ancestors.has(a)) return false;
255
+ function check(test, then) {
256
+ return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
257
+ }
258
+ ancestors.add(a);
259
+ try {
260
+ return check(Array.isArray, (a, b) => {
261
+ if (a.length !== b.length) return false;
262
+ for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
263
+ return true;
264
+ }) ?? check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ?? check(is("URL"), (a, b) => a.href === b.href) ?? check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ?? check(isArrayBufferLike, (a, b) => {
265
+ if (a.byteLength !== b.byteLength) return false;
266
+ const viewA = new Uint8Array(a);
267
+ const viewB = new Uint8Array(b);
268
+ for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
269
+ return true;
270
+ }) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
271
+ ...a,
272
+ ...b
273
+ }).every((key) => compare(a[key], b[key])));
274
+ } finally {
275
+ ancestors.delete(a);
276
+ }
277
+ }
278
+ return compare(a, b);
279
+ }
280
+ //#endregion
281
+ //#region lib/types/string.js
282
+ /** Uppercase the first character of a string. */
178
283
  function capitalize(source) {
179
- return source.charAt(0).toUpperCase() + source.slice(1);
284
+ return source.charAt(0).toUpperCase() + source.slice(1);
180
285
  }
286
+ /** Lowercase the first character of a string. */
181
287
  function uncapitalize(source) {
182
- return source.charAt(0).toLowerCase() + source.slice(1);
288
+ return source.charAt(0).toLowerCase() + source.slice(1);
183
289
  }
290
+ /** Convert dash or underscore delimited text to camelCase. */
184
291
  function camelCase(source) {
185
- return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
292
+ return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
186
293
  }
187
294
  function tokenize(source, delimiters, delimiter) {
188
- const output = [];
189
- let state = 0 /* DELIM */;
190
- for (let i = 0; i < source.length; i++) {
191
- const code = source.charCodeAt(i);
192
- if (code >= 65 && code <= 90) {
193
- if (state === 1 /* UPPER */) {
194
- const next = source.charCodeAt(i + 1);
195
- if (next >= 97 && next <= 122) {
196
- output.push(delimiter);
197
- }
198
- output.push(code + 32);
199
- } else {
200
- if (state !== 0 /* DELIM */) {
201
- output.push(delimiter);
202
- }
203
- output.push(code + 32);
204
- }
205
- state = 1 /* UPPER */;
206
- } else if (code >= 97 && code <= 122) {
207
- output.push(code);
208
- state = 2 /* LOWER */;
209
- } else if (delimiters.includes(code)) {
210
- if (state !== 0 /* DELIM */) {
211
- output.push(delimiter);
212
- }
213
- state = 0 /* DELIM */;
214
- } else {
215
- output.push(code);
216
- }
217
- }
218
- return String.fromCharCode(...output);
295
+ const output = [];
296
+ let state = 0;
297
+ for (let i = 0; i < source.length; i++) {
298
+ const code = source.charCodeAt(i);
299
+ if (code >= 65 && code <= 90) {
300
+ if (state === 1) {
301
+ const next = source.charCodeAt(i + 1);
302
+ if (next >= 97 && next <= 122) output.push(delimiter);
303
+ output.push(code + 32);
304
+ } else {
305
+ if (state !== 0) output.push(delimiter);
306
+ output.push(code + 32);
307
+ }
308
+ state = 1;
309
+ } else if (code >= 97 && code <= 122) {
310
+ output.push(code);
311
+ state = 2;
312
+ } else if (delimiters.includes(code)) {
313
+ if (state !== 0) output.push(delimiter);
314
+ state = 0;
315
+ } else output.push(code);
316
+ }
317
+ return String.fromCharCode(...output);
219
318
  }
319
+ /** Convert text to dash-delimited parameter case. */
220
320
  function paramCase(source) {
221
- return tokenize(source, [45, 95], 45);
321
+ return tokenize(source, [45, 95], 45);
222
322
  }
323
+ /** Convert text to underscore-delimited snake case. */
223
324
  function snakeCase(source) {
224
- return tokenize(source, [45, 95], 95);
325
+ return tokenize(source, [45, 95], 95);
225
326
  }
226
- var camelize = camelCase;
227
- var hyphenate = paramCase;
327
+ /** Runtime alias for `camelCase`. */
328
+ const camelize = camelCase;
329
+ /** Runtime alias for `paramCase`. */
330
+ const hyphenate = paramCase;
331
+ /** Format a property key as a JavaScript member access suffix. */
228
332
  function formatProperty(key) {
229
- if (typeof key !== "string") return `[${key.toString()}]`;
230
- return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
333
+ if (typeof key !== "string") return `[${key.toString()}]`;
334
+ return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
231
335
  }
336
+ /** Remove one trailing slash from a path string. */
232
337
  function trimSlash(source) {
233
- return source.replace(/\/$/, "");
338
+ return source.replace(/\/$/, "");
234
339
  }
340
+ /** Ensure a path starts with `/` and has no trailing slash. */
235
341
  function sanitize(source) {
236
- if (!source.startsWith("/")) source = "/" + source;
237
- return trimSlash(source);
342
+ if (!source.startsWith("/")) source = "/" + source;
343
+ return trimSlash(source);
238
344
  }
239
-
240
- // src/time.ts
345
+ //#endregion
346
+ //#region lib/types/time.js
347
+ /** Time constants plus parsing and formatting helpers. */
241
348
  var Time;
242
- ((Time2) => {
243
- Time2.millisecond = 1;
244
- Time2.second = 1e3;
245
- Time2.minute = Time2.second * 60;
246
- Time2.hour = Time2.minute * 60;
247
- Time2.day = Time2.hour * 24;
248
- Time2.week = Time2.day * 7;
249
- let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
250
- function setTimezoneOffset(offset) {
251
- timezoneOffset = offset;
252
- }
253
- Time2.setTimezoneOffset = setTimezoneOffset;
254
- function getTimezoneOffset() {
255
- return timezoneOffset;
256
- }
257
- Time2.getTimezoneOffset = getTimezoneOffset;
258
- function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
259
- if (typeof date === "number") date = new Date(date);
260
- if (offset === void 0) offset = timezoneOffset;
261
- return Math.floor((date.valueOf() / Time2.minute - offset) / 1440);
262
- }
263
- Time2.getDateNumber = getDateNumber;
264
- function fromDateNumber(value, offset) {
265
- const date = new Date(value * Time2.day);
266
- if (offset === void 0) offset = timezoneOffset;
267
- return new Date(+date + offset * Time2.minute);
268
- }
269
- Time2.fromDateNumber = fromDateNumber;
270
- const numeric = /\d+(?:\.\d+)?/.source;
271
- const timeRegExp = new RegExp(`^${[
272
- "w(?:eek(?:s)?)?",
273
- "d(?:ay(?:s)?)?",
274
- "h(?:our(?:s)?)?",
275
- "m(?:in(?:ute)?(?:s)?)?",
276
- "s(?:ec(?:ond)?(?:s)?)?"
277
- ].map((unit) => `(${numeric}${unit})?`).join("")}$`);
278
- function parseTime(source) {
279
- const capture = timeRegExp.exec(source);
280
- if (!capture) return 0;
281
- return (parseFloat(capture[1]) * Time2.week || 0) + (parseFloat(capture[2]) * Time2.day || 0) + (parseFloat(capture[3]) * Time2.hour || 0) + (parseFloat(capture[4]) * Time2.minute || 0) + (parseFloat(capture[5]) * Time2.second || 0);
282
- }
283
- Time2.parseTime = parseTime;
284
- function parseDate(date) {
285
- const parsed = parseTime(date);
286
- if (parsed) {
287
- date = Date.now() + parsed;
288
- } else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
289
- date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
290
- } else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
291
- date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
292
- }
293
- return date ? new Date(date) : /* @__PURE__ */ new Date();
294
- }
295
- Time2.parseDate = parseDate;
296
- function format(ms) {
297
- const abs = Math.abs(ms);
298
- if (abs >= Time2.day - Time2.hour / 2) {
299
- return Math.round(ms / Time2.day) + "d";
300
- } else if (abs >= Time2.hour - Time2.minute / 2) {
301
- return Math.round(ms / Time2.hour) + "h";
302
- } else if (abs >= Time2.minute - Time2.second / 2) {
303
- return Math.round(ms / Time2.minute) + "m";
304
- } else if (abs >= Time2.second) {
305
- return Math.round(ms / Time2.second) + "s";
306
- }
307
- return ms + "ms";
308
- }
309
- Time2.format = format;
310
- function toDigits(source, length = 2) {
311
- return source.toString().padStart(length, "0");
312
- }
313
- Time2.toDigits = toDigits;
314
- function template(template2, time = /* @__PURE__ */ new Date()) {
315
- return template2.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
316
- }
317
- Time2.template = template;
349
+ (function(Time) {
350
+ Time.millisecond = 1;
351
+ Time.second = 1e3;
352
+ Time.minute = Time.second * 60;
353
+ Time.hour = Time.minute * 60;
354
+ Time.day = Time.hour * 24;
355
+ Time.week = Time.day * 7;
356
+ let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
357
+ function setTimezoneOffset(offset) {
358
+ timezoneOffset = offset;
359
+ }
360
+ Time.setTimezoneOffset = setTimezoneOffset;
361
+ function getTimezoneOffset() {
362
+ return timezoneOffset;
363
+ }
364
+ Time.getTimezoneOffset = getTimezoneOffset;
365
+ function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
366
+ if (typeof date === "number") date = new Date(date);
367
+ if (offset === void 0) offset = timezoneOffset;
368
+ return Math.floor((date.valueOf() / Time.minute - offset) / 1440);
369
+ }
370
+ Time.getDateNumber = getDateNumber;
371
+ function fromDateNumber(value, offset) {
372
+ const date = new Date(value * Time.day);
373
+ if (offset === void 0) offset = timezoneOffset;
374
+ return new Date(+date + offset * Time.minute);
375
+ }
376
+ Time.fromDateNumber = fromDateNumber;
377
+ const numeric = /\d+(?:\.\d+)?/.source;
378
+ const timeRegExp = new RegExp(`^${[
379
+ "w(?:eek(?:s)?)?",
380
+ "d(?:ay(?:s)?)?",
381
+ "h(?:our(?:s)?)?",
382
+ "m(?:in(?:ute)?(?:s)?)?",
383
+ "s(?:ec(?:ond)?(?:s)?)?"
384
+ ].map((unit) => `(${numeric}${unit})?`).join("")}$`);
385
+ function parseTime(source) {
386
+ const capture = timeRegExp.exec(source);
387
+ if (!capture) return 0;
388
+ return (parseFloat(capture[1]) * Time.week || 0) + (parseFloat(capture[2]) * Time.day || 0) + (parseFloat(capture[3]) * Time.hour || 0) + (parseFloat(capture[4]) * Time.minute || 0) + (parseFloat(capture[5]) * Time.second || 0);
389
+ }
390
+ Time.parseTime = parseTime;
391
+ function parseDate(date) {
392
+ const parsed = parseTime(date);
393
+ if (parsed) date = Date.now() + parsed;
394
+ else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
395
+ else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
396
+ return date ? new Date(date) : /* @__PURE__ */ new Date();
397
+ }
398
+ Time.parseDate = parseDate;
399
+ function format(ms) {
400
+ const abs = Math.abs(ms);
401
+ if (abs >= Time.day - Time.hour / 2) return Math.round(ms / Time.day) + "d";
402
+ else if (abs >= Time.hour - Time.minute / 2) return Math.round(ms / Time.hour) + "h";
403
+ else if (abs >= Time.minute - Time.second / 2) return Math.round(ms / Time.minute) + "m";
404
+ else if (abs >= Time.second) return Math.round(ms / Time.second) + "s";
405
+ return ms + "ms";
406
+ }
407
+ Time.format = format;
408
+ function toDigits(source, length = 2) {
409
+ return source.toString().padStart(length, "0");
410
+ }
411
+ Time.toDigits = toDigits;
412
+ function template(template, time = /* @__PURE__ */ new Date()) {
413
+ return template.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
414
+ }
415
+ Time.template = template;
318
416
  })(Time || (Time = {}));
319
- export {
320
- Binary,
321
- Time,
322
- arrayBufferToBase64,
323
- arrayBufferToHex,
324
- base64ToArrayBuffer,
325
- camelCase,
326
- camelize,
327
- capitalize,
328
- clone,
329
- contain,
330
- deduplicate,
331
- deepEqual,
332
- defineProperty,
333
- difference,
334
- filterKeys,
335
- formatProperty,
336
- hexToArrayBuffer,
337
- hyphenate,
338
- intersection,
339
- is,
340
- isNonNullable,
341
- isNullable,
342
- isPlainObject,
343
- makeArray,
344
- mapValues,
345
- noop,
346
- omit,
347
- paramCase,
348
- pick,
349
- remove,
350
- sanitize,
351
- snakeCase,
352
- trimSlash,
353
- uncapitalize,
354
- union,
355
- mapValues as valueMap
356
- };
357
- //# sourceMappingURL=index.mjs.map
417
+ //#endregion
418
+ export { Binary, Time, arrayBufferToBase64, arrayBufferToHex, base64ToArrayBuffer, camelCase, camelize, capitalize, clone, contain, createVolatile, deduplicate, deepEqual, defineProperty, difference, filterKeys, formatProperty, hexToArrayBuffer, hyphenate, intersection, is, isNonNullable, isNullable, isPlainObject, isVolatile, makeArray, mapValues, mapValues as valueMap, noop, omit, paramCase, pick, remove, sanitize, snakeCase, trimSlash, uncapitalize, union, updateVolatile, volatileEntries };