@dxos/util 0.8.3 → 0.8.4-main.84f28bd

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,2309 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var node_exports = {};
30
- __export(node_exports, {
31
- BitField: () => BitField,
32
- Callback: () => Callback,
33
- CallbackCollection: () => CallbackCollection,
34
- CircularBuffer: () => CircularBuffer,
35
- ComplexMap: () => ComplexMap,
36
- ComplexSet: () => ComplexSet,
37
- HumanHasher: () => HumanHasher,
38
- MapEntry: () => MapEntry,
39
- SlidingWindowSummary: () => SlidingWindowSummary,
40
- Tracer: () => Tracer,
41
- WeakDictionary: () => WeakDictionary,
42
- accessBy: () => accessBy,
43
- arrayMove: () => arrayMove,
44
- arrayToBuffer: () => arrayToBuffer,
45
- arrayToHex: () => arrayToHex,
46
- arrayToString: () => arrayToString,
47
- arraysEqual: () => arraysEqual,
48
- assumeType: () => assumeType,
49
- bufferToArray: () => bufferToArray,
50
- byPosition: () => byPosition,
51
- capitalize: () => capitalize,
52
- chunkArray: () => chunkArray,
53
- clamp: () => clamp,
54
- clearUndefined: () => clearUndefined,
55
- compareMulti: () => compareMulti,
56
- compareObject: () => compareObject,
57
- compareScalar: () => compareScalar,
58
- compareString: () => compareString,
59
- createBinder: () => createBinder,
60
- createBucketReducer: () => createBucketReducer,
61
- createGroupReducer: () => createGroupReducer,
62
- createSetDispatch: () => createSetDispatch,
63
- decamelize: () => decamelize,
64
- deepMapValues: () => deepMapValues,
65
- deepMapValuesAsync: () => deepMapValuesAsync,
66
- defaultMap: () => defaultMap,
67
- defer: () => defer,
68
- deferAsync: () => deferAsync,
69
- deferFunction: () => deferFunction,
70
- diff: () => diff,
71
- distinctBy: () => distinctBy,
72
- doAsync: () => doAsync,
73
- entries: () => entries,
74
- entry: () => entry,
75
- exponentialBackoffInterval: () => exponentialBackoffInterval,
76
- forEachAsync: () => forEachAsync,
77
- get: () => import_lodash.default,
78
- getAsyncProviderValue: () => getAsyncProviderValue,
79
- getDate: () => getDate,
80
- getDebugName: () => getDebugName,
81
- getDeep: () => getDeep,
82
- getFirstTwoRenderableChars: () => getFirstTwoRenderableChars,
83
- getHostPlatform: () => getHostPlatform,
84
- getPrototypeSpecificInstanceId: () => getPrototypeSpecificInstanceId,
85
- getProviderValue: () => getProviderValue,
86
- hexToEmoji: () => hexToEmoji,
87
- hexToFallback: () => hexToFallback,
88
- hexToHue: () => hexToHue,
89
- humanize: () => humanize,
90
- hyphenize: () => hyphenize,
91
- idEmoji: () => idEmoji,
92
- idHue: () => idHue,
93
- inferObjectOrder: () => inferObjectOrder,
94
- inferRecordOrder: () => inferRecordOrder,
95
- intersectBy: () => intersectBy,
96
- intersection: () => intersection,
97
- iosCheck: () => iosCheck,
98
- isNode: () => isNode,
99
- isNonNullable: () => isNonNullable,
100
- isNotFalsy: () => isNotFalsy,
101
- joinTables: () => joinTables,
102
- jsonKeyReplacer: () => jsonKeyReplacer,
103
- jsonReplacer: () => jsonReplacer,
104
- jsonify: () => jsonify,
105
- jsonlogify: () => jsonlogify,
106
- keyToEmoji: () => keyToEmoji,
107
- keyToFallback: () => keyToFallback,
108
- keyToHue: () => keyToHue,
109
- keys: () => keys,
110
- makeMap: () => makeMap,
111
- makeSet: () => makeSet,
112
- mapValues: () => mapValues,
113
- median: () => median,
114
- mobileAndTabletCheck: () => mobileAndTabletCheck,
115
- numericalValues: () => numericalValues,
116
- omit: () => omit,
117
- orderKeys: () => orderKeys,
118
- partition: () => partition,
119
- pick: () => pick,
120
- pickBy: () => pickBy,
121
- randomInt: () => randomInt,
122
- range: () => range,
123
- rangeFromTo: () => rangeFromTo,
124
- reduceGroupBy: () => reduceGroupBy,
125
- reduceSeries: () => reduceSeries,
126
- reduceSet: () => reduceSet,
127
- removeBy: () => removeBy,
128
- removeProperties: () => removeProperties,
129
- removeUndefinedProperties: () => removeUndefinedProperties,
130
- safariCheck: () => safariCheck,
131
- safeAwaitAll: () => safeAwaitAll,
132
- safeInstanceof: () => safeInstanceof,
133
- safeParseFloat: () => safeParseFloat,
134
- safeParseInt: () => safeParseInt,
135
- safeParseJson: () => safeParseJson,
136
- set: () => import_lodash2.default,
137
- setDeep: () => setDeep,
138
- sortKeys: () => sortKeys,
139
- stringToArray: () => stringToArray,
140
- stringifyTree: () => stringifyTree,
141
- stripUndefined: () => stripUndefined,
142
- sum: () => sum,
143
- throwUnhandledError: () => throwUnhandledError,
144
- toEmoji: () => toEmoji,
145
- toFallback: () => toFallback,
146
- toHue: () => toHue,
147
- tracer: () => tracer,
148
- visitValues: () => visitValues
149
- });
150
- module.exports = __toCommonJS(node_exports);
151
- var import_node_util = __toESM(require("node:util"));
152
- var import_invariant = require("@dxos/invariant");
153
- var import_invariant2 = require("@dxos/invariant");
154
- var import_invariant3 = require("@dxos/invariant");
155
- var import_node_util2 = require("node:util");
156
- var import_debug = require("@dxos/debug");
157
- var import_lodash = __toESM(require("lodash.get"));
158
- var import_lodash2 = __toESM(require("lodash.set"));
159
- var import_invariant4 = require("@dxos/invariant");
160
- var import_keys = require("@dxos/keys");
161
- var import_node_util3 = require("node:util");
162
- var import_keys2 = require("@dxos/keys");
163
- var import_invariant5 = require("@dxos/invariant");
164
- var import_debug2 = require("@dxos/debug");
165
- var byteToHex = [];
166
- for (let n = 0; n <= 255; ++n) {
167
- const hexOctet = n.toString(16).padStart(2, "0");
168
- byteToHex.push(hexOctet);
169
- }
170
- var arrayToHex = (buf) => {
171
- const buff = new Uint8Array(buf);
172
- const hexOctets = [];
173
- for (let i = 0; i < buff.length; ++i) {
174
- hexOctets.push(byteToHex[buff[i]]);
175
- }
176
- return hexOctets.join("");
177
- };
178
- var diff = (previous, next, comparator) => {
179
- const remaining = [
180
- ...previous
181
- ];
182
- const result = {
183
- added: [],
184
- updated: [],
185
- removed: remaining
186
- };
187
- for (const object of next) {
188
- const index = remaining.findIndex((item) => comparator(item, object));
189
- if (index === -1) {
190
- result.added.push(object);
191
- } else {
192
- result.updated.push(object);
193
- remaining.splice(index, 1);
194
- }
195
- }
196
- return result;
197
- };
198
- var intersection = (a, b, comparator) => a.filter((a2) => b.find((b2) => comparator(a2, b2)) !== void 0);
199
- var distinctBy = (array, selector) => {
200
- const seenKeys = /* @__PURE__ */ new Set();
201
- return array.filter((item) => {
202
- const key = selector(item);
203
- if (seenKeys.has(key)) {
204
- return false;
205
- }
206
- seenKeys.add(key);
207
- return true;
208
- });
209
- };
210
- var removeBy = (array, test) => {
211
- const removed = [];
212
- for (let i = array.length - 1; i >= 0; i--) {
213
- if (test(array[i], i)) {
214
- removed.push(...array.splice(i, 1));
215
- }
216
- }
217
- return removed;
218
- };
219
- var partition = (array, guard) => {
220
- return array.reduce(([accepted, rejected], item, index, array2) => guard(item, index, array2) ? [
221
- [
222
- ...accepted,
223
- item
224
- ],
225
- rejected
226
- ] : [
227
- accepted,
228
- [
229
- ...rejected,
230
- item
231
- ]
232
- ], [
233
- [],
234
- []
235
- ]);
236
- };
237
- var intersectBy = (arrays, selector) => {
238
- if (arrays.length === 0) {
239
- return [];
240
- }
241
- if (arrays.length === 1) {
242
- return [
243
- ...arrays[0]
244
- ];
245
- }
246
- const [first, ...rest] = arrays;
247
- const lookups = rest.map((array) => {
248
- const map = /* @__PURE__ */ new Map();
249
- for (const item of array) {
250
- map.set(selector(item), item);
251
- }
252
- return map;
253
- });
254
- return first.filter((item) => {
255
- const key = selector(item);
256
- return lookups.every((lookup) => lookup.has(key));
257
- });
258
- };
259
- var createBinder = (obj) => ({
260
- fn: (fn) => fn.bind(obj),
261
- async: (fn) => import_node_util.default.promisify(fn.bind(obj))
262
- });
263
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/util/src/bitfield.ts";
264
- var BitField = class _BitField {
265
- static get(data, idx) {
266
- const bit = data[idx >> 3] >> 7 - idx % 8 & 1;
267
- return !!bit;
268
- }
269
- static set(data, idx, value) {
270
- if (value) {
271
- data[idx >> 3] = data[idx >> 3] | 1 << 7 - idx % 8;
272
- } else {
273
- data[idx >> 3] = data[idx >> 3] & ~(1 << 7 - idx % 8);
274
- }
275
- }
276
- /**
277
- * [start; end)
278
- */
279
- static count(data, begin, end) {
280
- let count = 0;
281
- for (let i = begin; i < end; i++) {
282
- const bit = data[i >> 3] >> 7 - i % 8 & 1;
283
- count += bit;
284
- }
285
- return count;
286
- }
287
- static invert(data) {
288
- const result = new Uint8Array(data.length);
289
- for (let i = 0; i < data.length; i++) {
290
- result[i] = ~data[i];
291
- }
292
- return result;
293
- }
294
- static and(first, second) {
295
- (0, import_invariant.invariant)(first.length === second.length, "Bitfields must be of the same length", {
296
- F: __dxlog_file,
297
- L: 52,
298
- S: this,
299
- A: [
300
- "first.length === second.length",
301
- "'Bitfields must be of the same length'"
302
- ]
303
- });
304
- const result = new Uint8Array(first.length);
305
- for (let i = 0; i < first.length; i++) {
306
- result[i] = first[i] & second[i];
307
- }
308
- return result;
309
- }
310
- static findIndexes(data, opts = {}) {
311
- const { start = 0, end = data.length * 8, value = true } = opts;
312
- const result = [];
313
- for (let i = start; i < end; i++) {
314
- if (_BitField.get(data, i) === value) {
315
- result.push(i);
316
- }
317
- }
318
- return result;
319
- }
320
- static ones(count) {
321
- const res = new Uint8Array(Math.ceil(Math.ceil(count) / 8)).fill(255);
322
- const bitInLastByte = Math.ceil(count % 8);
323
- res[res.length - 1] = 255 << 8 - bitInLastByte;
324
- return res;
325
- }
326
- static zeros(count) {
327
- return new Uint8Array(Math.ceil(Math.ceil(count) / 8)).fill(0);
328
- }
329
- };
330
- var CallbackCollection = class {
331
- #callbacks = [];
332
- append(callback) {
333
- this.#callbacks.push(callback);
334
- }
335
- prepend(callback) {
336
- this.#callbacks.unshift(callback);
337
- }
338
- remove(callback) {
339
- this.#callbacks = this.#callbacks.filter((c) => c !== callback);
340
- }
341
- callParallel(...args) {
342
- return Promise.all(this.#callbacks.map((callback) => callback(...args)));
343
- }
344
- async callSerial(...args) {
345
- const results = [];
346
- for (const callback of this.#callbacks) {
347
- results.push(await callback(...args));
348
- }
349
- return results;
350
- }
351
- };
352
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/util/src/callback.ts";
353
- var Callback = class {
354
- call(...args) {
355
- (0, import_invariant2.invariant)(this._callback, "Callback not set", {
356
- F: __dxlog_file2,
357
- L: 20,
358
- S: this,
359
- A: [
360
- "this._callback",
361
- "'Callback not set'"
362
- ]
363
- });
364
- return this._callback(...args);
365
- }
366
- callIfSet(...args) {
367
- return this._callback?.(...args);
368
- }
369
- set(callback) {
370
- (0, import_invariant2.invariant)(!this._callback, "Callback already set", {
371
- F: __dxlog_file2,
372
- L: 29,
373
- S: this,
374
- A: [
375
- "!this._callback",
376
- "'Callback already set'"
377
- ]
378
- });
379
- this._callback = callback;
380
- }
381
- isSet() {
382
- return !!this._callback;
383
- }
384
- };
385
- var createSetDispatch = ({ handlers }) => {
386
- return new Proxy({
387
- handlers
388
- }, {
389
- get: (target, prop) => {
390
- return (...args) => {
391
- handlers.forEach((handler) => {
392
- const method = handler[prop];
393
- if (method) {
394
- method.apply(handler, args);
395
- }
396
- });
397
- };
398
- }
399
- });
400
- };
401
- var LOW_DASH = "_".codePointAt(0);
402
- var HI_DASH = "-".codePointAt(0);
403
- var SMALL_A = "a".codePointAt(0);
404
- var CAPITAL_A = "A".codePointAt(0);
405
- var SMALL_Z = "z".codePointAt(0);
406
- var CAPITAL_Z = "Z".codePointAt(0);
407
- var isLower = (char) => char >= SMALL_A && char <= SMALL_Z;
408
- var isUpper = (char) => char >= CAPITAL_A && char <= CAPITAL_Z;
409
- var toLower = (char) => char + 32;
410
- var changeCase = (str, delim) => {
411
- const firstChar = str.charCodeAt(0);
412
- if (!isLower(firstChar)) {
413
- return str;
414
- }
415
- const length = str.length;
416
- let changed = false;
417
- const out = [];
418
- for (let i = 0; i < length; ++i) {
419
- const c = str.charCodeAt(i);
420
- if (isUpper(c)) {
421
- out.push(delim);
422
- out.push(toLower(c));
423
- changed = true;
424
- } else {
425
- out.push(c);
426
- }
427
- }
428
- return changed ? String.fromCharCode.apply(void 0, out) : str;
429
- };
430
- var decamelize = (str) => changeCase(str, LOW_DASH);
431
- var hyphenize = (str) => changeCase(str, HI_DASH);
432
- var chunkArray = (array, size) => {
433
- const result = [];
434
- for (let i = 0; i < array.length; i += size) {
435
- result.push(array.slice(i, i + size));
436
- }
437
- return result;
438
- };
439
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/util/src/circular-buffer.ts";
440
- var CircularBuffer = class {
441
- constructor(size) {
442
- this._nextIndex = 0;
443
- this._elementCount = 0;
444
- (0, import_invariant3.invariant)(size >= 1, void 0, {
445
- F: __dxlog_file3,
446
- L: 13,
447
- S: this,
448
- A: [
449
- "size >= 1",
450
- ""
451
- ]
452
- });
453
- this._buffer = new Array(size);
454
- }
455
- push(element) {
456
- const evicted = this._elementCount === this._buffer.length ? this._buffer[this._nextIndex] : void 0;
457
- this._buffer[this._nextIndex] = element;
458
- this._nextIndex = (this._nextIndex + 1) % this._buffer.length;
459
- this._elementCount = Math.min(this._buffer.length, this._elementCount + 1);
460
- return evicted;
461
- }
462
- get elementCount() {
463
- return this._elementCount;
464
- }
465
- getLast() {
466
- if (this._elementCount === 0) {
467
- return void 0;
468
- }
469
- if (this._nextIndex === 0) {
470
- return this._buffer[this._buffer.length - 1];
471
- }
472
- return this._buffer[this._nextIndex - 1];
473
- }
474
- [Symbol.iterator]() {
475
- return this.values();
476
- }
477
- *values() {
478
- if (this._elementCount === 0) {
479
- return;
480
- }
481
- if (this._elementCount < this._buffer.length) {
482
- for (let i = 0; i < this._elementCount; i++) {
483
- yield this._buffer[i];
484
- }
485
- return;
486
- }
487
- for (let i = this._nextIndex; i < this._buffer.length; i++) {
488
- yield this._buffer[i];
489
- }
490
- for (let i = 0; i < this._nextIndex; i++) {
491
- yield this._buffer[i];
492
- }
493
- }
494
- };
495
- var clearUndefined = (obj) => {
496
- for (const key of [
497
- ...Object.getOwnPropertyNames(obj),
498
- ...Object.getOwnPropertySymbols(obj)
499
- ]) {
500
- if (obj[key] === void 0) {
501
- delete obj[key];
502
- }
503
- }
504
- return obj;
505
- };
506
- var MAX_SERIALIZATION_LENGTH = 10;
507
- var ComplexSet = class {
508
- // prettier-ignore
509
- constructor(_projection, values) {
510
- this._projection = _projection;
511
- this._values = /* @__PURE__ */ new Map();
512
- if (values) {
513
- for (const value of values) {
514
- this.add(value);
515
- }
516
- }
517
- }
518
- toString() {
519
- return (0, import_debug.inspectObject)(this);
520
- }
521
- toJSON() {
522
- return this._values.size > MAX_SERIALIZATION_LENGTH ? {
523
- size: this._values.size
524
- } : Array.from(this._values.values());
525
- }
526
- [import_node_util2.inspect.custom]() {
527
- return (0, import_debug.inspectObject)(this);
528
- }
529
- add(value) {
530
- this._values.set(this._projection(value), value);
531
- return this;
532
- }
533
- clear() {
534
- this._values.clear();
535
- }
536
- delete(value) {
537
- return this._values.delete(this._projection(value));
538
- }
539
- forEach(callbackfn, thisArg) {
540
- if (thisArg) {
541
- callbackfn = callbackfn.bind(thisArg);
542
- }
543
- this._values.forEach((value) => callbackfn(value, value, this));
544
- }
545
- has(value) {
546
- return this._values.has(this._projection(value));
547
- }
548
- get size() {
549
- return this._values.size;
550
- }
551
- [Symbol.iterator]() {
552
- return this._values.values();
553
- }
554
- *entries() {
555
- for (const value of this._values.values()) {
556
- yield [
557
- value,
558
- value
559
- ];
560
- }
561
- }
562
- keys() {
563
- return this[Symbol.iterator]();
564
- }
565
- values() {
566
- return this[Symbol.iterator]();
567
- }
568
- get [Symbol.toStringTag]() {
569
- return "ComplexSet";
570
- }
571
- union(other) {
572
- throw new Error("Method not implemented.");
573
- }
574
- intersection(other) {
575
- throw new Error("Method not implemented.");
576
- }
577
- difference(other) {
578
- throw new Error("Method not implemented.");
579
- }
580
- symmetricDifference(other) {
581
- throw new Error("Method not implemented.");
582
- }
583
- isSubsetOf(other) {
584
- throw new Error("Method not implemented.");
585
- }
586
- isSupersetOf(other) {
587
- throw new Error("Method not implemented.");
588
- }
589
- isDisjointFrom(other) {
590
- throw new Error("Method not implemented.");
591
- }
592
- };
593
- var makeSet = (projection) => {
594
- return class BoundComplexSet extends ComplexSet {
595
- constructor(values) {
596
- super(projection, values);
597
- }
598
- };
599
- };
600
- var ComplexMap = class _ComplexMap {
601
- // prettier-ignore
602
- constructor(_keyProjection, entries2) {
603
- this._keyProjection = _keyProjection;
604
- this._keys = /* @__PURE__ */ new Map();
605
- this._values = /* @__PURE__ */ new Map();
606
- if (entries2) {
607
- for (const [key, value] of entries2) {
608
- this.set(key, value);
609
- }
610
- }
611
- }
612
- toString() {
613
- return (0, import_debug.inspectObject)(this);
614
- }
615
- toJSON() {
616
- return this._values.size > MAX_SERIALIZATION_LENGTH ? {
617
- size: this._values.size
618
- } : Array.from(this._values.values());
619
- }
620
- [import_node_util2.inspect.custom]() {
621
- return (0, import_debug.inspectObject)(this);
622
- }
623
- clear() {
624
- this._keys.clear();
625
- this._values.clear();
626
- }
627
- delete(key) {
628
- const keyDeleted = this._keys.delete(this._keyProjection(key));
629
- const valueDeleted = this._values.delete(this._keyProjection(key));
630
- return keyDeleted || valueDeleted;
631
- }
632
- forEach(callbackfn, thisArg) {
633
- if (thisArg) {
634
- callbackfn = callbackfn.bind(thisArg);
635
- }
636
- this._keys.forEach((key, primitive) => callbackfn(this._values.get(primitive) ?? (0, import_debug.raise)(new Error("Map corrupted.")), key, this));
637
- }
638
- get(key) {
639
- return this._values.get(this._keyProjection(key));
640
- }
641
- has(key) {
642
- return this._keys.has(this._keyProjection(key));
643
- }
644
- set(key, value) {
645
- const primitive = this._keyProjection(key);
646
- this._keys.set(primitive, key);
647
- this._values.set(primitive, value);
648
- return this;
649
- }
650
- get size() {
651
- return this._keys.size;
652
- }
653
- *[Symbol.iterator]() {
654
- for (const [primitive, key] of this._keys) {
655
- const value = this._values.get(primitive) ?? (0, import_debug.raise)(new Error("Map corrupted."));
656
- yield [
657
- key,
658
- value
659
- ];
660
- }
661
- }
662
- entries() {
663
- return this[Symbol.iterator]();
664
- }
665
- keys() {
666
- return this._keys.values();
667
- }
668
- values() {
669
- return this._values.values();
670
- }
671
- mapValues(mapper) {
672
- return new _ComplexMap(this._keyProjection, [
673
- ...this.entries()
674
- ].map(([key, value]) => [
675
- key,
676
- mapper(value, key)
677
- ]));
678
- }
679
- get [Symbol.toStringTag]() {
680
- return "ComplexMap";
681
- }
682
- };
683
- var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
684
- constructor(entries2) {
685
- super(keyProjection, entries2);
686
- }
687
- };
688
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/common/util/src/deep.ts";
689
- var setDeep = (obj, path, value) => {
690
- (0, import_invariant4.invariant)(path.length > 0, void 0, {
691
- F: __dxlog_file4,
692
- L: 18,
693
- S: void 0,
694
- A: [
695
- "path.length > 0",
696
- ""
697
- ]
698
- });
699
- let parent = obj;
700
- for (const key of path.slice(0, -1)) {
701
- if (parent[key] === void 0) {
702
- const isArrayIndex = !isNaN(Number(key));
703
- parent[key] = isArrayIndex ? [] : {};
704
- }
705
- parent = parent[key];
706
- }
707
- parent[path.at(-1)] = value;
708
- return obj;
709
- };
710
- var getDeep = (obj, path) => {
711
- let parent = obj;
712
- for (const key of path) {
713
- parent = parent?.[key];
714
- }
715
- return parent;
716
- };
717
- var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
718
- Symbol.dispose ??= Symbol("Symbol.dispose");
719
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
720
- var defer = (fn) => new DeferGuard(fn);
721
- var DeferGuard = class {
722
- /**
723
- * @internal
724
- */
725
- constructor(_fn) {
726
- this._fn = _fn;
727
- }
728
- [Symbol.dispose]() {
729
- const result = this._fn();
730
- if (result instanceof Promise) {
731
- throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
732
- }
733
- }
734
- };
735
- var deferAsync = (fn) => new DeferAsyncGuard(fn);
736
- var DeferAsyncGuard = class {
737
- /**
738
- * @internal
739
- */
740
- constructor(_fn) {
741
- this._fn = _fn;
742
- }
743
- async [Symbol.asyncDispose]() {
744
- await this._fn();
745
- }
746
- };
747
- var entry = (map, key) => new MapEntry(map, key);
748
- var MapEntry = class {
749
- /**
750
- * @internal
751
- */
752
- // prettier-ignore
753
- constructor(_map, _key) {
754
- this._map = _map;
755
- this._key = _key;
756
- }
757
- get key() {
758
- return this._key;
759
- }
760
- get value() {
761
- return this._map.get(this._key);
762
- }
763
- orInsert(value) {
764
- if (!this._map.has(this._key)) {
765
- this._map.set(this._key, value);
766
- }
767
- return this;
768
- }
769
- deep(key) {
770
- return entry(this.value, key);
771
- }
772
- };
773
- var renderableCharRegex = /^(?![\p{Control}\p{Mark}\p{Separator}\p{Surrogate}\p{Unassigned}\p{P}])[\p{L}\p{N}\p{S}\p{Emoji}]$/u;
774
- var getFirstTwoRenderableChars = (label) => {
775
- const characters = Array.from(label);
776
- const result = [
777
- "",
778
- ""
779
- ];
780
- let foundFirst = false;
781
- for (let i = 0; i < characters.length; i++) {
782
- const char = characters[i];
783
- if (renderableCharRegex.test(char)) {
784
- if (!foundFirst) {
785
- result[0] = char;
786
- foundFirst = true;
787
- } else {
788
- const textBetween = characters.slice(result[0].length, i).join("");
789
- if (/[^\p{L}\p{N}_]/u.test(textBetween)) {
790
- result[1] = char;
791
- break;
792
- }
793
- }
794
- }
795
- }
796
- return result;
797
- };
798
- var forEachAsync = (items, fn) => Promise.all(items.map(fn));
799
- var DEFAULT_WORDLIST = [
800
- "ack",
801
- "alabama",
802
- "alanine",
803
- "alaska",
804
- "alpha",
805
- "angel",
806
- "apart",
807
- "april",
808
- "arizona",
809
- "arkansas",
810
- "artist",
811
- "asparagus",
812
- "aspen",
813
- "august",
814
- "autumn",
815
- "avocado",
816
- "bacon",
817
- "bakerloo",
818
- "batman",
819
- "beer",
820
- "berlin",
821
- "beryllium",
822
- "black",
823
- "blossom",
824
- "blue",
825
- "bluebird",
826
- "bravo",
827
- "bulldog",
828
- "burger",
829
- "butter",
830
- "california",
831
- "carbon",
832
- "cardinal",
833
- "carolina",
834
- "carpet",
835
- "cat",
836
- "ceiling",
837
- "charlie",
838
- "chicken",
839
- "coffee",
840
- "cola",
841
- "cold",
842
- "colorado",
843
- "comet",
844
- "connecticut",
845
- "crazy",
846
- "cup",
847
- "dakota",
848
- "december",
849
- "delaware",
850
- "delta",
851
- "diet",
852
- "don",
853
- "double",
854
- "early",
855
- "earth",
856
- "east",
857
- "echo",
858
- "edward",
859
- "eight",
860
- "eighteen",
861
- "eleven",
862
- "emma",
863
- "enemy",
864
- "equal",
865
- "failed",
866
- "fanta",
867
- "fifteen",
868
- "fillet",
869
- "finch",
870
- "fish",
871
- "five",
872
- "fix",
873
- "floor",
874
- "florida",
875
- "football",
876
- "four",
877
- "fourteen",
878
- "foxtrot",
879
- "freddie",
880
- "friend",
881
- "fruit",
882
- "gee",
883
- "georgia",
884
- "glucose",
885
- "golf",
886
- "green",
887
- "grey",
888
- "hamper",
889
- "happy",
890
- "harry",
891
- "hawaii",
892
- "helium",
893
- "high",
894
- "hot",
895
- "hotel",
896
- "hydrogen",
897
- "idaho",
898
- "illinois",
899
- "india",
900
- "indigo",
901
- "ink",
902
- "iowa",
903
- "island",
904
- "item",
905
- "jersey",
906
- "jig",
907
- "johnny",
908
- "juliet",
909
- "july",
910
- "jupiter",
911
- "kansas",
912
- "kentucky",
913
- "kilo",
914
- "king",
915
- "kitten",
916
- "lactose",
917
- "lake",
918
- "lamp",
919
- "lemon",
920
- "leopard",
921
- "lima",
922
- "lion",
923
- "lithium",
924
- "london",
925
- "louisiana",
926
- "low",
927
- "magazine",
928
- "magnesium",
929
- "maine",
930
- "mango",
931
- "march",
932
- "mars",
933
- "maryland",
934
- "massachusetts",
935
- "may",
936
- "mexico",
937
- "michigan",
938
- "mike",
939
- "minnesota",
940
- "mirror",
941
- "mississippi",
942
- "missouri",
943
- "mobile",
944
- "mockingbird",
945
- "monkey",
946
- "montana",
947
- "moon",
948
- "mountain",
949
- "muppet",
950
- "music",
951
- "nebraska",
952
- "neptune",
953
- "network",
954
- "nevada",
955
- "nine",
956
- "nineteen",
957
- "nitrogen",
958
- "north",
959
- "november",
960
- "nuts",
961
- "october",
962
- "ohio",
963
- "oklahoma",
964
- "one",
965
- "orange",
966
- "oranges",
967
- "oregon",
968
- "oscar",
969
- "oven",
970
- "oxygen",
971
- "papa",
972
- "paris",
973
- "pasta",
974
- "pennsylvania",
975
- "pip",
976
- "pizza",
977
- "pluto",
978
- "potato",
979
- "princess",
980
- "purple",
981
- "quebec",
982
- "queen",
983
- "quiet",
984
- "red",
985
- "river",
986
- "robert",
987
- "robin",
988
- "romeo",
989
- "rugby",
990
- "sad",
991
- "salami",
992
- "saturn",
993
- "september",
994
- "seven",
995
- "seventeen",
996
- "shade",
997
- "sierra",
998
- "single",
999
- "sink",
1000
- "six",
1001
- "sixteen",
1002
- "skylark",
1003
- "snake",
1004
- "social",
1005
- "sodium",
1006
- "solar",
1007
- "south",
1008
- "spaghetti",
1009
- "speaker",
1010
- "spring",
1011
- "stairway",
1012
- "steak",
1013
- "stream",
1014
- "summer",
1015
- "sweet",
1016
- "table",
1017
- "tango",
1018
- "ten",
1019
- "tennessee",
1020
- "tennis",
1021
- "texas",
1022
- "thirteen",
1023
- "three",
1024
- "timing",
1025
- "triple",
1026
- "twelve",
1027
- "twenty",
1028
- "two",
1029
- "uncle",
1030
- "undress",
1031
- "uniform",
1032
- "uranus",
1033
- "utah",
1034
- "vegan",
1035
- "venus",
1036
- "vermont",
1037
- "victor",
1038
- "video",
1039
- "violet",
1040
- "virginia",
1041
- "washington",
1042
- "west",
1043
- "whiskey",
1044
- "white",
1045
- "william",
1046
- "winner",
1047
- "winter",
1048
- "wisconsin",
1049
- "wolfram",
1050
- "wyoming",
1051
- "xray",
1052
- "yankee",
1053
- "yellow",
1054
- "zebra",
1055
- "zulu"
1056
- ];
1057
- var HumanHasher = class {
1058
- /**
1059
- * Transforms hex digests to human-readable strings.
1060
- *
1061
- * The format of these strings will look something like:
1062
- * `victor-bacon-zulu-lima`. The output is obtained by compressing the input
1063
- * digest to a fixed number of bytes, then mapping those bytes to one of 256
1064
- * words. A default wordlist is provided, but you can override this if you
1065
- * prefer.
1066
- * As long as you use the same wordlist, the output will be consistent (i.e.
1067
- * the same digest will always render the same representation).
1068
- *
1069
- * @param wordlist A list of exactly 256 words to choose from
1070
- */
1071
- constructor(wordlist = DEFAULT_WORDLIST) {
1072
- this.wordlist = wordlist;
1073
- if (wordlist.length !== 256) {
1074
- throw new Error("Wordlist must have exactly 256 items");
1075
- }
1076
- this.wordlist = wordlist;
1077
- }
1078
- /**
1079
- * Humanize a given hexadecimal digest.
1080
- *
1081
- * Change the number of words output by specifying `words`. Change the
1082
- * word separator with `separator`.
1083
- *
1084
- * @param hexdigest A string of hexadecimal characters to humanize
1085
- * @param words How many words to output (more = safer)
1086
- * @param separator The string used to seperate the words
1087
- */
1088
- humanize(hexdigest, words = 4, separator = "-") {
1089
- const pairs = hexdigest.match(/(..?)/g);
1090
- if (!pairs) {
1091
- throw new Error("");
1092
- }
1093
- const bytes = pairs.map((x) => parseInt(x, 16));
1094
- const compressed = this._compress(bytes, words);
1095
- return compressed.map((x) => this.wordlist[x]).join(separator);
1096
- }
1097
- /**
1098
- * Compress a list of byte values to a fixed target length.
1099
- *
1100
- * @param bytes A list of bytes (numbers from 0-254)
1101
- * @param target The number of bytes to return / compress to
1102
- */
1103
- _compress(bytes, target) {
1104
- const length = bytes.length;
1105
- if (target > length) {
1106
- throw new Error("Fewer input bytes than requested output");
1107
- }
1108
- const segSize = length / target >> 0;
1109
- const segments = [];
1110
- for (let i = 0; i < segSize * target; i += segSize) {
1111
- segments.push(bytes.slice(i, i + segSize));
1112
- }
1113
- segments[segments.length - 1] = segments[segments.length - 1].concat(bytes.slice(target * segSize));
1114
- const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
1115
- return checksums;
1116
- }
1117
- };
1118
- var hasher = new HumanHasher();
1119
- var humanize = (value) => {
1120
- if (value instanceof Buffer || value instanceof Uint8Array || value instanceof ArrayBuffer) {
1121
- value = import_keys.PublicKey.stringify(value);
1122
- } else if (value instanceof import_keys.PublicKey) {
1123
- value = value.toHex();
1124
- }
1125
- return hasher.humanize(value);
1126
- };
1127
- var defaultMap = (map, key, def) => {
1128
- let value = map.get(key);
1129
- if (value === void 0) {
1130
- value = typeof def === "function" ? def() : def;
1131
- map.set(key, value);
1132
- }
1133
- return value;
1134
- };
1135
- var symbol = Symbol.for("dxos.instance-contexts");
1136
- var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
1137
- var getPrototypeSpecificInstanceId = (instance) => {
1138
- const prototype = Object.getPrototypeOf(instance);
1139
- const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
1140
- nextId: 0,
1141
- instanceIds: /* @__PURE__ */ new WeakMap()
1142
- }));
1143
- let id = instanceCtx.instanceIds.get(instance);
1144
- if (id === void 0) {
1145
- id = instanceCtx.nextId++;
1146
- instanceCtx.instanceIds.set(instance, id);
1147
- }
1148
- return id;
1149
- };
1150
- var getDebugName = (instance) => {
1151
- if (instance == null) {
1152
- return "null";
1153
- }
1154
- const prototype = Object.getPrototypeOf(instance);
1155
- return `${prototype.constructor?.name ?? "Object"}#${getPrototypeSpecificInstanceId(instance)}`;
1156
- };
1157
- var exponentialBackoffInterval = (cb, initialInterval) => {
1158
- let interval = initialInterval;
1159
- const repeat = () => {
1160
- cb();
1161
- interval *= 2;
1162
- timeoutId = setTimeout(repeat, interval);
1163
- };
1164
- let timeoutId = setTimeout(repeat, interval);
1165
- return () => clearTimeout(timeoutId);
1166
- };
1167
- var joinTables = (leftColumn, rightColumn, left, right) => {
1168
- const map = /* @__PURE__ */ new Map();
1169
- const used = /* @__PURE__ */ new Set();
1170
- for (const row of right) {
1171
- map.set(row[rightColumn], row);
1172
- }
1173
- const result = [];
1174
- for (const row of left) {
1175
- const right2 = map.get(row[leftColumn]);
1176
- used.add(right2);
1177
- result.push(Object.assign(right2 ?? {}, row));
1178
- }
1179
- for (const row of right) {
1180
- if (!used.has(row)) {
1181
- result.push(row);
1182
- }
1183
- }
1184
- return result;
1185
- };
1186
- var arraysEqual = (a, b) => {
1187
- if (a.length !== b.length) {
1188
- return false;
1189
- }
1190
- for (let i = 0; i < a.length; i++) {
1191
- if (a[i] !== b[i]) {
1192
- return false;
1193
- }
1194
- }
1195
- return true;
1196
- };
1197
- var arrayToBuffer = (array) => {
1198
- return Buffer.from(array.buffer, array.byteOffset, array.byteLength);
1199
- };
1200
- var bufferToArray = (buffer) => {
1201
- return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1202
- };
1203
- var stringToArray = (string) => bufferToArray(Buffer.from(string, "hex"));
1204
- var arrayToString = (array) => arrayToBuffer(array).toString("hex");
1205
- var MAX_DEPTH = 5;
1206
- var LOG_MAX_DEPTH = 7;
1207
- function jsonReplacer(key, value) {
1208
- if (value !== null && typeof value === "object" && typeof value[import_node_util3.inspect.custom] === "function") {
1209
- return value[import_node_util3.inspect.custom]();
1210
- }
1211
- if (value !== null && typeof value === "object" && value.type === "Buffer" && Array.isArray(value.data)) {
1212
- if (value.data.length === 32) {
1213
- const key2 = Buffer.from(value.data);
1214
- return `[${humanize(key2)}]:[${import_keys2.PublicKey.stringify(key2)}]`;
1215
- } else {
1216
- return Buffer.from(value.data).toString("hex");
1217
- }
1218
- }
1219
- return value;
1220
- }
1221
- var jsonify = (value, depth = 0, visitedObjects = /* @__PURE__ */ new WeakSet()) => {
1222
- if (depth > MAX_DEPTH) {
1223
- return null;
1224
- } else if (typeof value === "function") {
1225
- return null;
1226
- } else if (typeof value === "object" && value !== null) {
1227
- if (visitedObjects.has(value)) {
1228
- return null;
1229
- }
1230
- visitedObjects.add(value);
1231
- try {
1232
- if (value instanceof Uint8Array) {
1233
- return arrayToBuffer(value).toString("hex");
1234
- } else if (Array.isArray(value)) {
1235
- return value.map((x) => jsonify(x, depth + 1, visitedObjects));
1236
- } else if (typeof value.toJSON === "function") {
1237
- return value.toJSON();
1238
- } else {
1239
- const res = {};
1240
- for (const key of Object.keys(value)) {
1241
- res[key] = jsonify(value[key], depth + 1, visitedObjects);
1242
- }
1243
- return res;
1244
- }
1245
- } finally {
1246
- visitedObjects.delete(value);
1247
- }
1248
- } else {
1249
- return value;
1250
- }
1251
- };
1252
- var jsonlogify = (value, depth = 0, visitedObjects = /* @__PURE__ */ new WeakSet()) => {
1253
- if (depth > LOG_MAX_DEPTH) {
1254
- return null;
1255
- } else if (typeof value === "function") {
1256
- return null;
1257
- } else if (typeof value === "object" && value !== null) {
1258
- if (visitedObjects.has(value)) {
1259
- return null;
1260
- }
1261
- visitedObjects.add(value);
1262
- try {
1263
- if (value instanceof Uint8Array) {
1264
- return arrayToBuffer(value).toString("hex");
1265
- } else if (Array.isArray(value)) {
1266
- return value.map((x) => jsonlogify(x, depth + 1, visitedObjects));
1267
- } else if (typeof value.toJSONL === "function") {
1268
- return value.toJSONL();
1269
- } else if (typeof value.toJSON === "function") {
1270
- return value.toJSON();
1271
- } else {
1272
- const res = {};
1273
- for (const key of Object.keys(value)) {
1274
- res[key] = jsonlogify(value[key], depth + 1, visitedObjects);
1275
- }
1276
- return res;
1277
- }
1278
- } finally {
1279
- visitedObjects.delete(value);
1280
- }
1281
- } else {
1282
- return value;
1283
- }
1284
- };
1285
- var jsonKeyReplacer = (options = {}) => (key, value) => {
1286
- if (typeof value === "string") {
1287
- const key2 = import_keys2.PublicKey.fromHex(value);
1288
- if (key2.toHex() === value) {
1289
- return options.humanize ? humanize(key2) : options.truncate ? key2.truncate() : key2.toHex();
1290
- }
1291
- }
1292
- return value;
1293
- };
1294
- var mapValues = (obj, fn) => {
1295
- const result = {};
1296
- Object.keys(obj).forEach((key) => {
1297
- result[key] = fn(obj[key], key);
1298
- });
1299
- return result;
1300
- };
1301
- var deepMapValues = (value, fn) => {
1302
- return new DeepMapper(fn).map(value);
1303
- };
1304
- var DeepMapper = class {
1305
- constructor(_fn) {
1306
- this._fn = _fn;
1307
- this._cyclic = /* @__PURE__ */ new Map();
1308
- this._recurse = (value) => {
1309
- if (this._cyclic.has(value)) {
1310
- return this._cyclic.get(value);
1311
- }
1312
- if (Array.isArray(value)) {
1313
- const res = new Array(value.length);
1314
- this._cyclic.set(value, res);
1315
- for (let i = 0; i < value.length; i++) {
1316
- res[i] = this._map(value[i], i);
1317
- }
1318
- return res;
1319
- } else if (value !== null && typeof value === "object") {
1320
- const res = {};
1321
- this._cyclic.set(value, res);
1322
- for (const key in value) {
1323
- res[key] = this._map(value[key], key);
1324
- }
1325
- return res;
1326
- } else {
1327
- return value;
1328
- }
1329
- };
1330
- }
1331
- map(value) {
1332
- return this._map(value, void 0);
1333
- }
1334
- _map(value, key) {
1335
- if (this._cyclic.has(value)) {
1336
- return this._cyclic.get(value);
1337
- }
1338
- return this._fn(value, this._recurse, key);
1339
- }
1340
- };
1341
- var deepMapValuesAsync = (value, fn) => {
1342
- return new DeepMapperAsync(fn).map(value);
1343
- };
1344
- var DeepMapperAsync = class {
1345
- constructor(_fn) {
1346
- this._fn = _fn;
1347
- this._cyclic = /* @__PURE__ */ new Map();
1348
- this._recurse = async (value) => {
1349
- if (this._cyclic.has(value)) {
1350
- return this._cyclic.get(value);
1351
- }
1352
- if (Array.isArray(value)) {
1353
- const res = new Array(value.length);
1354
- this._cyclic.set(value, res);
1355
- for (let i = 0; i < value.length; i++) {
1356
- res[i] = await this._map(value[i], i);
1357
- }
1358
- return res;
1359
- } else if (value !== null && typeof value === "object") {
1360
- const res = {};
1361
- this._cyclic.set(value, res);
1362
- for (const key in value) {
1363
- res[key] = await this._map(value[key], key);
1364
- }
1365
- return res;
1366
- } else {
1367
- return value;
1368
- }
1369
- };
1370
- }
1371
- map(value) {
1372
- return this._map(value, void 0);
1373
- }
1374
- _map(value, key) {
1375
- if (this._cyclic.has(value)) {
1376
- return this._cyclic.get(value);
1377
- }
1378
- return this._fn(value, this._recurse, key);
1379
- }
1380
- };
1381
- var visitValues = (object, visitor) => {
1382
- if (Array.isArray(object)) {
1383
- object.forEach((item, index) => visitor(item, index));
1384
- } else if (typeof object === "object" && object !== null) {
1385
- for (const [key, value] of Object.entries(object)) {
1386
- visitor(value, key);
1387
- }
1388
- }
1389
- };
1390
- var keys = (obj) => Object.keys(obj);
1391
- var entries = (obj) => Object.entries(obj);
1392
- var orderKeys = (obj, order) => {
1393
- const ordered = {};
1394
- for (const key of order) {
1395
- if (key in obj) {
1396
- ordered[key] = obj[key];
1397
- }
1398
- }
1399
- for (const key in obj) {
1400
- if (!(key in ordered)) {
1401
- ordered[key] = obj[key];
1402
- }
1403
- }
1404
- return ordered;
1405
- };
1406
- var inferObjectOrder = (objectMap, order = []) => {
1407
- const orderedObjects = order.reduce((acc, id) => {
1408
- if (id in objectMap) {
1409
- acc.objects.push(objectMap[id]);
1410
- acc.ids.add(id);
1411
- }
1412
- return acc;
1413
- }, {
1414
- objects: [],
1415
- ids: /* @__PURE__ */ new Set()
1416
- });
1417
- const { objects } = Object.keys(objectMap).reduce((acc, id) => {
1418
- if (!acc.ids.has(id)) {
1419
- acc.objects.push(objectMap[id]);
1420
- }
1421
- return acc;
1422
- }, orderedObjects);
1423
- return objects;
1424
- };
1425
- var inferRecordOrder = (objectMap, order = []) => {
1426
- return Object.assign(order.filter((id) => id in objectMap).reduce((acc, id) => {
1427
- acc[id] = null;
1428
- return acc;
1429
- }, {}), objectMap);
1430
- };
1431
- var pick = (obj, keys2) => {
1432
- return keys2.reduce((result, key) => {
1433
- if (obj && key in obj) {
1434
- result[key] = obj[key];
1435
- }
1436
- return result;
1437
- }, {});
1438
- };
1439
- var pickBy = (obj, predicate) => {
1440
- const result = {};
1441
- for (const key in obj) {
1442
- if (predicate(obj[key])) {
1443
- result[key] = obj[key];
1444
- }
1445
- }
1446
- return result;
1447
- };
1448
- var omit = (obj, keys2) => {
1449
- const result = {
1450
- ...obj
1451
- };
1452
- keys2.forEach((key) => {
1453
- delete result[key];
1454
- });
1455
- return result;
1456
- };
1457
- var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1458
- var mobileAndTabletCheck = () => {
1459
- let check = false;
1460
- ((a) => {
1461
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
1462
- check = true;
1463
- }
1464
- })(navigator.userAgent || navigator.vendor || window.opera);
1465
- return check;
1466
- };
1467
- var iosCheck = () => {
1468
- return [
1469
- "iPad Simulator",
1470
- "iPhone Simulator",
1471
- "iPod Simulator",
1472
- "iPad",
1473
- "iPhone",
1474
- "iPod"
1475
- ].includes(navigator.platform) || // iPad on iOS 13 detection
1476
- navigator.userAgent.includes("Mac") && "ontouchend" in document;
1477
- };
1478
- var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1479
- var getHostPlatform = () => {
1480
- if (!("navigator" in window)) {
1481
- return "unknown";
1482
- }
1483
- const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
1484
- if (platform.startsWith("win")) {
1485
- return "windows";
1486
- } else if (platform.startsWith("mac")) {
1487
- return "macos";
1488
- } else if (platform.startsWith("ipad") || platform.startsWith("iphone") || platform.startsWith("ipod")) {
1489
- return "ios";
1490
- } else if (platform.startsWith("linux")) {
1491
- return "linux";
1492
- } else {
1493
- return "unknown";
1494
- }
1495
- };
1496
- var byPosition = ({ position: a = "static" }, { position: b = "static" }) => {
1497
- if (a === b) {
1498
- return 0;
1499
- } else if (a === "hoist" || b === "fallback") {
1500
- return -1;
1501
- } else if (b === "hoist" || a === "fallback") {
1502
- return 1;
1503
- } else {
1504
- return 0;
1505
- }
1506
- };
1507
- var randomInt = (max, min = 0) => {
1508
- min = Math.ceil(min);
1509
- max = Math.floor(max);
1510
- return Math.floor(Math.random() * (max - min + 1)) + min;
1511
- };
1512
- var range = (n = 0, mapper) => {
1513
- const range2 = Array.from(Array(n).keys());
1514
- return mapper == null ? range2 : range2.map(mapper);
1515
- };
1516
- var rangeFromTo = (from, to, mapper) => {
1517
- return mapper == null ? range(to - from, (i) => i + from) : range(to - from, (i) => mapper(i + from));
1518
- };
1519
- var clamp = (value, min, max) => {
1520
- return Math.min(Math.max(value, min), max);
1521
- };
1522
- var accessBy = (value, accessor) => typeof accessor === "function" ? accessor(value) : value[accessor];
1523
- var median = (values) => {
1524
- const mid = Math.floor(values.length / 2);
1525
- if (values.length % 2 === 1) {
1526
- return values[mid];
1527
- } else {
1528
- return (values[mid - 1] + values[mid]) / 2;
1529
- }
1530
- };
1531
- var numericalValues = (values, accessor) => {
1532
- const result = {
1533
- total: 0,
1534
- count: 0
1535
- };
1536
- const sorted = values.map((value) => {
1537
- const v = accessBy(value, accessor);
1538
- if (v === void 0 || isNaN(v)) {
1539
- return void 0;
1540
- }
1541
- result.total += v;
1542
- if (result.min === void 0 || v < result.min) {
1543
- result.min = v;
1544
- }
1545
- if (result.max === void 0 || v > result.max) {
1546
- result.max = v;
1547
- }
1548
- return v;
1549
- }).filter((value) => value !== void 0).sort((a, b) => a - b);
1550
- if (sorted.length) {
1551
- Object.assign(result, {
1552
- count: sorted.length,
1553
- mean: result.total / sorted.length,
1554
- median: median(sorted)
1555
- });
1556
- }
1557
- return result;
1558
- };
1559
- var reduceSet = (values, accessor) => {
1560
- return values.reduce((values2, value) => {
1561
- const v = accessBy(value, accessor);
1562
- values2.add(v);
1563
- return values2;
1564
- }, /* @__PURE__ */ new Set());
1565
- };
1566
- var reduceGroupBy = (values, accessor) => {
1567
- return values.reduce((values2, value) => {
1568
- const key = accessBy(value, accessor);
1569
- defaultMap(values2, key, []).push(value);
1570
- return values2;
1571
- }, /* @__PURE__ */ new Map());
1572
- };
1573
- var reduceSeries = (reducer, events) => {
1574
- const state = reducer.initialState();
1575
- for (const event of events) {
1576
- reducer.reduce(state, event);
1577
- }
1578
- return state;
1579
- };
1580
- var createGroupReducer = (groupBy, sub) => ({
1581
- initialState: () => ({}),
1582
- reduce: (state, event) => {
1583
- const key = groupBy(event);
1584
- state[key] = sub.reduce(state[key] ?? sub.initialState(), event);
1585
- return state;
1586
- }
1587
- });
1588
- var getDate = (value) => value instanceof Date ? value : new Date(value);
1589
- var createBucketReducer = (period) => ({
1590
- initialState: () => [],
1591
- reduce: (series, event) => {
1592
- const timestamp = getDate(event.timestamp);
1593
- let bucket = series[series.length - 1];
1594
- if (!bucket || bucket.start + period < timestamp.getTime()) {
1595
- bucket = {
1596
- start: timestamp.getTime(),
1597
- period,
1598
- count: 0
1599
- };
1600
- series.push(bucket);
1601
- }
1602
- bucket.count++;
1603
- return series;
1604
- }
1605
- });
1606
- var removeUndefinedProperties = (object) => {
1607
- for (const prop of [
1608
- ...Object.getOwnPropertyNames(object),
1609
- ...Object.getOwnPropertySymbols(object)
1610
- ]) {
1611
- if (object[prop] === void 0) {
1612
- delete object[prop];
1613
- }
1614
- }
1615
- return object;
1616
- };
1617
- var removeProperties = (root, condition) => {
1618
- if (!root || typeof root !== "object") {
1619
- return root;
1620
- }
1621
- if (Array.isArray(root)) {
1622
- return root.map((item) => removeProperties(item, condition));
1623
- }
1624
- const result = {
1625
- ...root
1626
- };
1627
- if (typeof condition === "function") {
1628
- for (const [key, value] of Object.entries(result)) {
1629
- if (condition(key, value)) {
1630
- delete result[key];
1631
- }
1632
- }
1633
- } else {
1634
- for (const key of condition) {
1635
- delete result[key];
1636
- }
1637
- }
1638
- for (const [key, value] of Object.entries(result)) {
1639
- if (typeof value === "object") {
1640
- result[key] = removeProperties(value, condition);
1641
- }
1642
- }
1643
- return result;
1644
- };
1645
- var safeAwaitAll = async (source, taskFactory, onError) => {
1646
- const failedItems = [];
1647
- await Promise.all([
1648
- ...source
1649
- ].map(async (item, idx) => {
1650
- try {
1651
- await taskFactory(item);
1652
- } catch (err) {
1653
- if (onError) {
1654
- onError(err, item, idx);
1655
- }
1656
- failedItems.push(item);
1657
- }
1658
- }));
1659
- return failedItems;
1660
- };
1661
- var instanceTag = Symbol("instanceTag");
1662
- var safeInstanceof = (tag) => (target) => {
1663
- target.prototype[instanceTag] = tag;
1664
- Object.defineProperty(target.prototype, Symbol.hasInstance, {
1665
- value: (instance) => instance?.[instanceTag] === tag
1666
- });
1667
- Object.defineProperty(target, Symbol.hasInstance, {
1668
- value: (instance) => instance?.[instanceTag] === tag
1669
- });
1670
- };
1671
- var safeParseInt = (value, defaultValue) => {
1672
- try {
1673
- const n = parseInt(value ?? "");
1674
- return isNaN(n) ? defaultValue : n;
1675
- } catch (err) {
1676
- return defaultValue;
1677
- }
1678
- };
1679
- var safeParseFloat = (str, defaultValue) => {
1680
- try {
1681
- return parseFloat(str);
1682
- } catch {
1683
- return defaultValue ?? 0;
1684
- }
1685
- };
1686
- var safeParseJson = (data, defaultValue) => {
1687
- if (data && data.length > 0) {
1688
- try {
1689
- return JSON.parse(data);
1690
- } catch (err) {
1691
- }
1692
- }
1693
- return defaultValue;
1694
- };
1695
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
1696
- var SlidingWindowSummary = class {
1697
- constructor(options) {
1698
- this._sum = 0;
1699
- this._buffer = new CircularBuffer(options.dataPoints);
1700
- if (options.precision != null) {
1701
- (0, import_invariant5.invariant)(options.precision >= 0, void 0, {
1702
- F: __dxlog_file5,
1703
- L: 26,
1704
- S: this,
1705
- A: [
1706
- "options.precision >= 0",
1707
- ""
1708
- ]
1709
- });
1710
- this._precision = Math.pow(10, options.precision);
1711
- }
1712
- }
1713
- record(value) {
1714
- const evicted = this._buffer.push(value);
1715
- this._sum += value - (evicted ?? 0);
1716
- }
1717
- average() {
1718
- return this._buffer.elementCount === 0 ? 0 : this._withPrecision(this._sum / this._buffer.elementCount);
1719
- }
1720
- computeWindowSummary() {
1721
- const mean = this.average();
1722
- const sortedElements = [
1723
- ...this._buffer
1724
- ].sort();
1725
- const median2 = this._withPrecision(sortedElements.length % 2 === 0 ? (sortedElements[sortedElements.length / 2] + sortedElements[sortedElements.length / 2 - 1]) / 2 : sortedElements[sortedElements.length / 2]);
1726
- const p90 = this._withPrecision(sortedElements[Math.round(sortedElements.length * 0.9)]);
1727
- const variance = sortedElements.reduce((acc, v) => acc + Math.pow(v - mean, 2)) / sortedElements.length;
1728
- const stdDev = this._withPrecision(Math.sqrt(variance));
1729
- const histogram = sortedElements.reduce((acc, v) => {
1730
- acc[v] += 1;
1731
- return acc;
1732
- }, {});
1733
- return {
1734
- mean,
1735
- median: median2,
1736
- p90,
1737
- stdDev,
1738
- histogram
1739
- };
1740
- }
1741
- _withPrecision(value) {
1742
- if (this._precision == null) {
1743
- return value;
1744
- }
1745
- return Math.round(value * this._precision) / this._precision;
1746
- }
1747
- };
1748
- var compareScalar = (inc = true) => (a, b) => (inc ? 1 : -1) * (a < b ? -1 : a > b ? 1 : 0);
1749
- var compareString = (inc = true, caseInsensitive = true) => (a, b) => {
1750
- if (caseInsensitive) {
1751
- a = a?.toLowerCase();
1752
- b = b?.toLowerCase();
1753
- }
1754
- return (inc ? 1 : -1) * (a < b ? -1 : a > b ? 1 : 0);
1755
- };
1756
- var compareObject = (prop, sorter, inc = true) => (a, b) => (inc ? 1 : -1) * sorter(a[prop], b[prop]);
1757
- var compareMulti = (sorters) => (a, b) => {
1758
- const sort = (i = 0) => {
1759
- const s = sorters[i](a, b);
1760
- if (s === 0 && i < sorters.length - 1) {
1761
- return sort(i + 1);
1762
- } else {
1763
- return s;
1764
- }
1765
- };
1766
- return sort();
1767
- };
1768
- var capitalize = (str) => {
1769
- if (str.length === 0) {
1770
- return "";
1771
- }
1772
- return str.charAt(0).toUpperCase() + str.slice(1);
1773
- };
1774
- var sum = (values) => values.reduce((a, b) => a + b, 0);
1775
- var throwUnhandledError = (error) => {
1776
- queueMicrotask(() => {
1777
- throw error;
1778
- });
1779
- };
1780
- var idEmoji = [
1781
- // When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
1782
- // Emoji sometimes use a combination of code points, and some code points aren't visible on their own, so by adding or deleting you may unintentionally create non-visible items.
1783
- // This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
1784
- // – not people or isolated anthropomorphic faces
1785
- // – not flags
1786
- // – more concrete than abstract
1787
- // – less culturally specific
1788
- // – less easily confused with another emoji in the set
1789
- // – requires less special knowledge to identify
1790
- // – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
1791
- // – less common as a signifier in UX
1792
- // NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
1793
- "\u{1F47B}",
1794
- "\u{1F479}",
1795
- "\u{1F47D}",
1796
- "\u{1F916}",
1797
- "\u{1F383}",
1798
- "\u{1F9BE}",
1799
- "\u{1F9BF}",
1800
- "\u{1F9B7}",
1801
- "\u{1F463}",
1802
- "\u{1F441}\uFE0F",
1803
- "\u{1F9F6}",
1804
- "\u{1F451}",
1805
- "\u{1F412}",
1806
- "\u{1F986}",
1807
- "\u{1F989}",
1808
- "\u{1F434}",
1809
- "\u{1F984}",
1810
- "\u{1F41D}",
1811
- "\u{1F98B}",
1812
- "\u{1F41E}",
1813
- "\u{1FAB2}",
1814
- "\u{1F422}",
1815
- "\u{1F98E}",
1816
- "\u{1F995}",
1817
- "\u{1F991}",
1818
- "\u{1F980}",
1819
- "\u{1F420}",
1820
- "\u{1F42C}",
1821
- "\u{1F40B}",
1822
- "\u{1F9AD}",
1823
- "\u{1F405}",
1824
- "\u{1F406}",
1825
- "\u{1F993}",
1826
- "\u{1F98D}",
1827
- "\u{1F9A7}",
1828
- "\u{1F418}",
1829
- "\u{1F42B}",
1830
- "\u{1F992}",
1831
- "\u{1F998}",
1832
- "\u{1F9AC}",
1833
- "\u{1F416}",
1834
- "\u{1F40F}",
1835
- "\u{1F98C}",
1836
- "\u{1F415}",
1837
- "\u{1F408}",
1838
- "\u{1F413}",
1839
- "\u{1F99A}",
1840
- "\u{1F99C}",
1841
- "\u{1F9A2}",
1842
- "\u{1F9A9}",
1843
- "\u{1F9A6}",
1844
- "\u{1F401}",
1845
- "\u{1F43F}\uFE0F",
1846
- "\u{1F335}",
1847
- "\u{1F332}",
1848
- "\u{1F333}",
1849
- "\u{1FAB5}",
1850
- "\u{1F331}",
1851
- "\u{1F341}",
1852
- "\u{1FABA}",
1853
- "\u{1F344}",
1854
- "\u{1F41A}",
1855
- "\u{1FAB8}",
1856
- "\u{1FAA8}",
1857
- "\u{1F33E}",
1858
- "\u{1F337}",
1859
- "\u{1F33B}",
1860
- "\u2600\uFE0F",
1861
- "\u{1F319}",
1862
- "\u{1FA90}",
1863
- "\u2B50\uFE0F",
1864
- "\u26A1\uFE0F",
1865
- "\u2604\uFE0F",
1866
- "\u{1F525}",
1867
- "\u{1F308}",
1868
- "\u2601\uFE0F",
1869
- "\u{1F4A7}",
1870
- "\u26F1\uFE0F",
1871
- "\u{1F30A}",
1872
- "\u{1F34E}",
1873
- "\u{1F34B}",
1874
- "\u{1F349}",
1875
- "\u{1F347}",
1876
- "\u{1FAD0}",
1877
- "\u{1F348}",
1878
- "\u{1F352}",
1879
- "\u{1F351}",
1880
- "\u{1F96D}",
1881
- "\u{1F34D}",
1882
- "\u{1F965}",
1883
- "\u{1F95D}",
1884
- "\u{1F951}",
1885
- "\u{1F336}\uFE0F",
1886
- "\u{1F33D}",
1887
- "\u{1F955}",
1888
- "\u{1F36C}",
1889
- "\u{1F95C}",
1890
- "\u{1FAD6}",
1891
- "\u2615\uFE0F",
1892
- "\u{1F375}",
1893
- "\u{1F9CA}",
1894
- "\u{1F9C2}",
1895
- "\u{1F3D4}\uFE0F",
1896
- "\u2693\uFE0F",
1897
- "\u{1F6DF}",
1898
- "\u{1F3DD}\uFE0F",
1899
- "\u{1F6F6}",
1900
- "\u{1F680}",
1901
- "\u{1F6F0}\uFE0F",
1902
- "\u26F2\uFE0F",
1903
- "\u{1F3F0}",
1904
- "\u{1F6B2}",
1905
- "\u26FA\uFE0F",
1906
- "\u{1F399}\uFE0F",
1907
- "\u{1F9F2}",
1908
- "\u2699\uFE0F",
1909
- "\u{1F529}",
1910
- "\u{1F52E}",
1911
- "\u{1F52D}",
1912
- "\u{1F52C}",
1913
- "\u{1F9EC}",
1914
- "\u{1F321}\uFE0F",
1915
- "\u{1F9FA}",
1916
- "\u{1F6CE}\uFE0F",
1917
- "\u{1F511}",
1918
- "\u{1FA91}",
1919
- "\u{1F9F8}",
1920
- "\u{1F388}",
1921
- "\u{1F380}",
1922
- "\u{1F38A}",
1923
- "\u267B\uFE0F",
1924
- "\u{1F3B5}"
1925
- ];
1926
- var idHue = [
1927
- "red",
1928
- // 'orange' as const, /* More shades in these palettes are considered “ugly” */
1929
- "amber",
1930
- // 'yellow' as const, /* More shades in these palettes are considered “ugly” */
1931
- "lime",
1932
- "green",
1933
- "emerald",
1934
- "teal",
1935
- "cyan",
1936
- // 'sky' as const, /* Omitted since it is quite similar to the primary accent palette */
1937
- // 'blue' as const, /* Omitted since it is quite similar to the primary accent palette */
1938
- // 'indigo' as const, /* Omitted since it is quite similar to the primary accent palette */
1939
- "violet",
1940
- "purple",
1941
- "fuchsia",
1942
- "pink",
1943
- "rose"
1944
- ];
1945
- var keyToEmoji = (key) => keyToFallback(key).emoji;
1946
- var hexToEmoji = (hex) => hexToFallback(hex).emoji;
1947
- var toEmoji = (hash) => toFallback(hash).emoji;
1948
- var keyToHue = (key) => keyToFallback(key).hue;
1949
- var hexToHue = (hex) => hexToFallback(hex).hue;
1950
- var toHue = (hash) => toFallback(hash).hue;
1951
- var keyToFallback = (key) => hexToFallback(key.toHex());
1952
- var hexToFallback = (hex) => toFallback(parseInt(hex, 16));
1953
- var toFallback = (hash) => {
1954
- const totalCombinations = idEmoji.length * idHue.length;
1955
- const combinationIndex = hash % totalCombinations;
1956
- const emojiIndex = Math.floor(combinationIndex / idHue.length);
1957
- const hueIndex = combinationIndex % idHue.length;
1958
- return {
1959
- emoji: idEmoji[emojiIndex],
1960
- hue: idHue[hueIndex]
1961
- };
1962
- };
1963
- var Tracer = class {
1964
- constructor() {
1965
- this._events = /* @__PURE__ */ new Map();
1966
- this._recording = false;
1967
- }
1968
- // TODO(burdon): Start/stop methods for recording data? By id?
1969
- // Alternatively, enable subscriptions to track/compute series.
1970
- // TODO(burdon): Hierarchical traces?
1971
- get recording() {
1972
- return this._recording;
1973
- }
1974
- keys() {
1975
- return Array.from(this._events.keys());
1976
- }
1977
- get(id, filter) {
1978
- const events = this._events.get(id);
1979
- if (filter) {
1980
- return events?.filter((event) => Object.entries(filter).every(([key, value]) => event?.value[key] === value));
1981
- }
1982
- return events;
1983
- }
1984
- clear() {
1985
- this._events.clear();
1986
- }
1987
- start() {
1988
- this._recording = true;
1989
- return this;
1990
- }
1991
- stop() {
1992
- this._recording = false;
1993
- return this;
1994
- }
1995
- emit(id, value) {
1996
- this._post(this._createEvent(id, value));
1997
- }
1998
- mark(id, value) {
1999
- const event = this._createEvent(id, value);
2000
- const start = performance.now();
2001
- return {
2002
- start,
2003
- end: () => {
2004
- event.duration = performance.now() - start;
2005
- this._post(event);
2006
- }
2007
- };
2008
- }
2009
- _createEvent(id, value) {
2010
- const event = {
2011
- id,
2012
- timestamp: Date.now()
2013
- };
2014
- if (value !== void 0) {
2015
- event.value = value;
2016
- }
2017
- return event;
2018
- }
2019
- _post(event) {
2020
- if (this._recording) {
2021
- defaultMap(this._events, event.id, []).push(event);
2022
- }
2023
- }
2024
- };
2025
- var tracer = new Tracer();
2026
- var stringifyTree = (node, ancestors = [], rows = []) => {
2027
- if (node.children?.length) {
2028
- node.children.forEach((child, i) => {
2029
- stringifyTree(child, [
2030
- ...ancestors,
2031
- [
2032
- node,
2033
- i
2034
- ]
2035
- ], rows);
2036
- });
2037
- } else {
2038
- const keyLen = 8;
2039
- const name = (node2) => (0, import_debug2.truncateKey)(node2.id, keyLen);
2040
- const parts = [];
2041
- ancestors.forEach(([node2, i], j) => {
2042
- const first = ancestors.slice(j).every(([_, i2]) => i2 === 0);
2043
- parts.push(j === 0 ? first ? "\u251C" : " " : "");
2044
- parts.push(first ? `\u2500(${name(node2)})\u2500` : "".padEnd(keyLen + 4));
2045
- if (node2.children) {
2046
- if (first) {
2047
- parts.push(node2.children.length > 1 ? "\u252C" : "\u2500");
2048
- } else {
2049
- const childFirst = ancestors.slice(j + 1).every(([_, i2]) => i2 === 0);
2050
- if (node2.children.length - 1 === i) {
2051
- parts.push(childFirst ? "\u2570" : " ");
2052
- } else {
2053
- parts.push(childFirst ? "\u251C" : "\u2502");
2054
- }
2055
- }
2056
- }
2057
- });
2058
- parts.push(`\u2500(${name(node)})`);
2059
- rows.push(parts.join(""));
2060
- }
2061
- return rows;
2062
- };
2063
- var isNotFalsy = (value) => !!value;
2064
- var isNonNullable = (value) => value != null;
2065
- var doAsync = async (fn) => fn();
2066
- var getProviderValue = (provider, arg) => {
2067
- return typeof provider === "function" ? provider(arg) : provider;
2068
- };
2069
- var getAsyncProviderValue = (provider, arg) => {
2070
- return getProviderValue(provider, arg);
2071
- };
2072
- var stripUndefined = (obj) => {
2073
- if (typeof obj === "object") {
2074
- Object.keys(obj).forEach((key) => {
2075
- const value = obj[key];
2076
- if (value === void 0) {
2077
- delete obj[key];
2078
- } else if (value !== null && typeof value === "object") {
2079
- stripUndefined(value);
2080
- }
2081
- });
2082
- }
2083
- return obj;
2084
- };
2085
- var sortKeys = (obj) => Object.keys(obj).sort().reduce((sorted, key) => {
2086
- sorted[key] = obj[key];
2087
- return sorted;
2088
- }, {});
2089
- var arrayMove = (array, from, to) => {
2090
- array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
2091
- return array;
2092
- };
2093
- var WeakDictionary = class {
2094
- constructor(entries2) {
2095
- this._internal = /* @__PURE__ */ new Map();
2096
- this._finalization = new FinalizationRegistry((cleanUpCallback) => {
2097
- cleanUpCallback();
2098
- });
2099
- this._internal = new Map(entries2?.map(([key, value]) => [
2100
- key,
2101
- new WeakRef(value)
2102
- ]));
2103
- entries2?.forEach(([key, value]) => this._register(key, value));
2104
- }
2105
- *entries() {
2106
- for (const [key, value] of this._internal) {
2107
- yield [
2108
- key,
2109
- value.deref()
2110
- ];
2111
- }
2112
- }
2113
- keys() {
2114
- return this._internal.keys();
2115
- }
2116
- *values() {
2117
- for (const value of this._internal.values()) {
2118
- const deref = value.deref();
2119
- if (!deref) {
2120
- continue;
2121
- }
2122
- yield deref;
2123
- }
2124
- }
2125
- *[Symbol.iterator]() {
2126
- for (const [key, value] of this._internal) {
2127
- yield [
2128
- key,
2129
- value.deref()
2130
- ];
2131
- }
2132
- }
2133
- get [Symbol.toStringTag]() {
2134
- return "WeakDictionary";
2135
- }
2136
- get size() {
2137
- return this._internal.size;
2138
- }
2139
- get(key) {
2140
- return this._internal.get(key)?.deref();
2141
- }
2142
- set(key, value) {
2143
- this._internal.set(key, new WeakRef(value));
2144
- this._register(key, value);
2145
- return this;
2146
- }
2147
- has(key) {
2148
- return this._internal.has(key) && this._internal.get(key).deref() !== void 0;
2149
- }
2150
- delete(key) {
2151
- const value = this._internal.get(key)?.deref();
2152
- if (value) {
2153
- this._unregister(value);
2154
- }
2155
- return this._internal.delete(key);
2156
- }
2157
- clear() {
2158
- this._internal.forEach((value) => {
2159
- const v = value.deref();
2160
- if (v) {
2161
- this._unregister(v);
2162
- }
2163
- });
2164
- this._internal.clear();
2165
- }
2166
- forEach(callbackfn, thisArg) {
2167
- if (thisArg) {
2168
- callbackfn = callbackfn.bind(thisArg);
2169
- }
2170
- this._internal.forEach((value, key) => {
2171
- const v = value.deref();
2172
- if (v) {
2173
- callbackfn(v, key, this);
2174
- }
2175
- });
2176
- }
2177
- _register(key, value) {
2178
- this._finalization.register(value, () => {
2179
- this._internal.delete(key);
2180
- }, value);
2181
- }
2182
- _unregister(value) {
2183
- this._finalization.unregister(value);
2184
- }
2185
- };
2186
- function assumeType(value) {
2187
- }
2188
- // Annotate the CommonJS export names for ESM import in node:
2189
- 0 && (module.exports = {
2190
- BitField,
2191
- Callback,
2192
- CallbackCollection,
2193
- CircularBuffer,
2194
- ComplexMap,
2195
- ComplexSet,
2196
- HumanHasher,
2197
- MapEntry,
2198
- SlidingWindowSummary,
2199
- Tracer,
2200
- WeakDictionary,
2201
- accessBy,
2202
- arrayMove,
2203
- arrayToBuffer,
2204
- arrayToHex,
2205
- arrayToString,
2206
- arraysEqual,
2207
- assumeType,
2208
- bufferToArray,
2209
- byPosition,
2210
- capitalize,
2211
- chunkArray,
2212
- clamp,
2213
- clearUndefined,
2214
- compareMulti,
2215
- compareObject,
2216
- compareScalar,
2217
- compareString,
2218
- createBinder,
2219
- createBucketReducer,
2220
- createGroupReducer,
2221
- createSetDispatch,
2222
- decamelize,
2223
- deepMapValues,
2224
- deepMapValuesAsync,
2225
- defaultMap,
2226
- defer,
2227
- deferAsync,
2228
- deferFunction,
2229
- diff,
2230
- distinctBy,
2231
- doAsync,
2232
- entries,
2233
- entry,
2234
- exponentialBackoffInterval,
2235
- forEachAsync,
2236
- get,
2237
- getAsyncProviderValue,
2238
- getDate,
2239
- getDebugName,
2240
- getDeep,
2241
- getFirstTwoRenderableChars,
2242
- getHostPlatform,
2243
- getPrototypeSpecificInstanceId,
2244
- getProviderValue,
2245
- hexToEmoji,
2246
- hexToFallback,
2247
- hexToHue,
2248
- humanize,
2249
- hyphenize,
2250
- idEmoji,
2251
- idHue,
2252
- inferObjectOrder,
2253
- inferRecordOrder,
2254
- intersectBy,
2255
- intersection,
2256
- iosCheck,
2257
- isNode,
2258
- isNonNullable,
2259
- isNotFalsy,
2260
- joinTables,
2261
- jsonKeyReplacer,
2262
- jsonReplacer,
2263
- jsonify,
2264
- jsonlogify,
2265
- keyToEmoji,
2266
- keyToFallback,
2267
- keyToHue,
2268
- keys,
2269
- makeMap,
2270
- makeSet,
2271
- mapValues,
2272
- median,
2273
- mobileAndTabletCheck,
2274
- numericalValues,
2275
- omit,
2276
- orderKeys,
2277
- partition,
2278
- pick,
2279
- pickBy,
2280
- randomInt,
2281
- range,
2282
- rangeFromTo,
2283
- reduceGroupBy,
2284
- reduceSeries,
2285
- reduceSet,
2286
- removeBy,
2287
- removeProperties,
2288
- removeUndefinedProperties,
2289
- safariCheck,
2290
- safeAwaitAll,
2291
- safeInstanceof,
2292
- safeParseFloat,
2293
- safeParseInt,
2294
- safeParseJson,
2295
- set,
2296
- setDeep,
2297
- sortKeys,
2298
- stringToArray,
2299
- stringifyTree,
2300
- stripUndefined,
2301
- sum,
2302
- throwUnhandledError,
2303
- toEmoji,
2304
- toFallback,
2305
- toHue,
2306
- tracer,
2307
- visitValues
2308
- });
2309
- //# sourceMappingURL=index.cjs.map