@vicin/sigil 1.2.7 → 2.0.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.
@@ -3,296 +3,1765 @@
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
8
  // src/core/options.ts
9
9
  var OPTIONS = {
10
10
  labelValidation: null,
11
11
  skipLabelInheritanceCheck: false,
12
12
  autofillLabels: false,
13
- devMarker: false,
14
- registry: null,
15
- useGlobalRegistry: false,
16
- storeConstructor: false
13
+ devMarker: false
17
14
  };
18
- var __SIGIL_REGISTRY__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_REGISTRY__");
19
- var updateGlobalRegistry = (map) => {
20
- if (map === null) delete globalThis[__SIGIL_REGISTRY__];
21
- else globalThis[__SIGIL_REGISTRY__] = map;
15
+ var updateOptions = (opts) => {
16
+ for (const [k, v] of Object.entries(opts)) OPTIONS[k] = v;
22
17
  };
23
- var getGlobalRegistry = () => {
24
- const val = globalThis[__SIGIL_REGISTRY__];
25
- return val === void 0 ? null : val;
18
+ var DEFAULT_OPTIONS = {
19
+ labelValidation: null,
20
+ skipLabelInheritanceCheck: false,
21
+ autofillLabels: false,
22
+ devMarker: process.env.NODE_ENV !== "production"
26
23
  };
27
- var SigilRegistry = class _SigilRegistry {
28
- /**
29
- * @param map - Map used to register 'Sigil' classes. if not passed it will be auto-generated internally.
30
- */
31
- constructor(map) {
32
- /** Internal private registry map. */
33
- __publicField(this, "_registry");
34
- this._registry = map != null ? map : /* @__PURE__ */ new Map();
35
- }
36
- /**
37
- * Return a readonly view (array) of the current registry entries.
38
- *
39
- * @returns An array containing all registered labels, or an empty array when registry is disabled.
40
- */
41
- listLabels() {
42
- return this._registry ? Array.from(this._registry.keys()) : [];
43
- }
44
- /**
45
- * Determine whether the registry currently contains `label`.
46
- *
47
- * @param label - The label to test.
48
- * @returns `true` if present; `false` otherwise.
49
- */
50
- has(label) {
51
- return !!this._registry && this._registry.has(label);
52
- }
53
- /**
54
- * Get class constructor using its label.
55
- *
56
- * @param label - Label appended to Sigil class.
57
- * @returns Reference to Sigil class constructor or null if stored with 'SigilOptions.storeConstructor = false'.
58
- */
59
- get(label) {
60
- var _a;
61
- return (_a = this._registry.get(label)) != null ? _a : null;
62
- }
63
- /**
64
- * Register a label and class constructor in the active registry.
65
- *
66
- * If the label already exists then:
67
- * - In DEV builds: prints a console warning (HMR friendly) and returns early.
68
- * - In non-DEV builds: throws an Error to prevent duplicate registration.
69
- *
70
- * @param label - Label string to register (e.g. '@scope/pkg.ClassName').
71
- * @param Class - Constructor of the class being registered.
72
- * @param opts - Optional per-call overrides.
73
- */
74
- register(label, Class, opts) {
75
- var _a, _b, _c, _d;
76
- if (!OPTIONS.registry) return;
77
- const storeCtor = (_a = opts == null ? void 0 : opts.storeConstructor) != null ? _a : OPTIONS.storeConstructor;
78
- const devMarker = (_b = opts == null ? void 0 : opts.devMarker) != null ? _b : OPTIONS.devMarker;
79
- if (this._registry.has(label)) {
80
- const existing = this._registry.get(label);
81
- const isLikelyHMR = (existing == null ? void 0 : existing.name) === (Class == null ? void 0 : Class.name);
82
- if (devMarker) {
83
- if (isLikelyHMR) {
84
- console.warn(
85
- `[Sigil] Duplicate label "${label}" may be due to HMR \u2014 ignore if you are sure that it's defined once.`
86
- );
24
+ updateOptions(DEFAULT_OPTIONS);
25
+ var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
26
+
27
+ // src/core/symbols.ts
28
+ var __SIGIL__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL__");
29
+ var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
30
+ var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
31
+ var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
32
+ var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
33
+ var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
34
+ var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
35
+
36
+ // node_modules/@noble/hashes/_u64.js
37
+ var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
38
+ var _32n = /* @__PURE__ */ BigInt(32);
39
+ function fromBig(n, le = false) {
40
+ if (le)
41
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
42
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
43
+ }
44
+ function split(lst, le = false) {
45
+ const len = lst.length;
46
+ let Ah = new Uint32Array(len);
47
+ let Al = new Uint32Array(len);
48
+ for (let i = 0; i < len; i++) {
49
+ const { h, l } = fromBig(lst[i], le);
50
+ [Ah[i], Al[i]] = [h, l];
51
+ }
52
+ return [Ah, Al];
53
+ }
54
+ var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
55
+ var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
56
+ var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
57
+ var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
58
+
59
+ // node_modules/@noble/hashes/utils.js
60
+ function isBytes(a) {
61
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
62
+ }
63
+ function anumber(n, title = "") {
64
+ if (!Number.isSafeInteger(n) || n < 0) {
65
+ const prefix = title && `"${title}" `;
66
+ throw new Error(`${prefix}expected integer >= 0, got ${n}`);
67
+ }
68
+ }
69
+ function abytes(value, length, title = "") {
70
+ const bytes = isBytes(value);
71
+ const len = value == null ? void 0 : value.length;
72
+ const needsLen = length !== void 0;
73
+ if (!bytes || needsLen) {
74
+ const prefix = title && `"${title}" `;
75
+ const ofLen = "";
76
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
77
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
78
+ }
79
+ return value;
80
+ }
81
+ function aexists(instance, checkFinished = true) {
82
+ if (instance.destroyed)
83
+ throw new Error("Hash instance has been destroyed");
84
+ if (checkFinished && instance.finished)
85
+ throw new Error("Hash#digest() has already been called");
86
+ }
87
+ function aoutput(out, instance) {
88
+ abytes(out, void 0, "digestInto() output");
89
+ const min = instance.outputLen;
90
+ if (out.length < min) {
91
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
92
+ }
93
+ }
94
+ function u32(arr) {
95
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
96
+ }
97
+ function clean(...arrays) {
98
+ for (let i = 0; i < arrays.length; i++) {
99
+ arrays[i].fill(0);
100
+ }
101
+ }
102
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
103
+ function byteSwap(word) {
104
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
105
+ }
106
+ function byteSwap32(arr) {
107
+ for (let i = 0; i < arr.length; i++) {
108
+ arr[i] = byteSwap(arr[i]);
109
+ }
110
+ return arr;
111
+ }
112
+ var swap32IfBE = isLE ? (u) => u : byteSwap32;
113
+ function createHasher(hashCons, info = {}) {
114
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
115
+ const tmp = hashCons(void 0);
116
+ hashC.outputLen = tmp.outputLen;
117
+ hashC.blockLen = tmp.blockLen;
118
+ hashC.create = (opts) => hashCons(opts);
119
+ Object.assign(hashC, info);
120
+ return Object.freeze(hashC);
121
+ }
122
+ var oidNist = (suffix) => ({
123
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
124
+ });
125
+
126
+ // node_modules/@noble/hashes/sha3.js
127
+ var _0n = BigInt(0);
128
+ var _1n = BigInt(1);
129
+ var _2n = BigInt(2);
130
+ var _7n = BigInt(7);
131
+ var _256n = BigInt(256);
132
+ var _0x71n = BigInt(113);
133
+ var SHA3_PI = [];
134
+ var SHA3_ROTL = [];
135
+ var _SHA3_IOTA = [];
136
+ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
137
+ [x, y] = [y, (2 * x + 3 * y) % 5];
138
+ SHA3_PI.push(2 * (5 * y + x));
139
+ SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
140
+ let t = _0n;
141
+ for (let j = 0; j < 7; j++) {
142
+ R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
143
+ if (R & _2n)
144
+ t ^= _1n << (_1n << BigInt(j)) - _1n;
145
+ }
146
+ _SHA3_IOTA.push(t);
147
+ }
148
+ var IOTAS = split(_SHA3_IOTA, true);
149
+ var SHA3_IOTA_H = IOTAS[0];
150
+ var SHA3_IOTA_L = IOTAS[1];
151
+ var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
152
+ var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
153
+ function keccakP(s, rounds = 24) {
154
+ const B = new Uint32Array(5 * 2);
155
+ for (let round = 24 - rounds; round < 24; round++) {
156
+ for (let x = 0; x < 10; x++)
157
+ B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
158
+ for (let x = 0; x < 10; x += 2) {
159
+ const idx1 = (x + 8) % 10;
160
+ const idx0 = (x + 2) % 10;
161
+ const B0 = B[idx0];
162
+ const B1 = B[idx0 + 1];
163
+ const Th = rotlH(B0, B1, 1) ^ B[idx1];
164
+ const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
165
+ for (let y = 0; y < 50; y += 10) {
166
+ s[x + y] ^= Th;
167
+ s[x + y + 1] ^= Tl;
168
+ }
169
+ }
170
+ let curH = s[2];
171
+ let curL = s[3];
172
+ for (let t = 0; t < 24; t++) {
173
+ const shift = SHA3_ROTL[t];
174
+ const Th = rotlH(curH, curL, shift);
175
+ const Tl = rotlL(curH, curL, shift);
176
+ const PI = SHA3_PI[t];
177
+ curH = s[PI];
178
+ curL = s[PI + 1];
179
+ s[PI] = Th;
180
+ s[PI + 1] = Tl;
181
+ }
182
+ for (let y = 0; y < 50; y += 10) {
183
+ for (let x = 0; x < 10; x++)
184
+ B[x] = s[y + x];
185
+ for (let x = 0; x < 10; x++)
186
+ s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
187
+ }
188
+ s[0] ^= SHA3_IOTA_H[round];
189
+ s[1] ^= SHA3_IOTA_L[round];
190
+ }
191
+ clean(B);
192
+ }
193
+ var Keccak = class _Keccak {
194
+ // NOTE: we accept arguments in bytes instead of bits here.
195
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
196
+ __publicField(this, "state");
197
+ __publicField(this, "pos", 0);
198
+ __publicField(this, "posOut", 0);
199
+ __publicField(this, "finished", false);
200
+ __publicField(this, "state32");
201
+ __publicField(this, "destroyed", false);
202
+ __publicField(this, "blockLen");
203
+ __publicField(this, "suffix");
204
+ __publicField(this, "outputLen");
205
+ __publicField(this, "enableXOF", false);
206
+ __publicField(this, "rounds");
207
+ this.blockLen = blockLen;
208
+ this.suffix = suffix;
209
+ this.outputLen = outputLen;
210
+ this.enableXOF = enableXOF;
211
+ this.rounds = rounds;
212
+ anumber(outputLen, "outputLen");
213
+ if (!(0 < blockLen && blockLen < 200))
214
+ throw new Error("only keccak-f1600 function is supported");
215
+ this.state = new Uint8Array(200);
216
+ this.state32 = u32(this.state);
217
+ }
218
+ clone() {
219
+ return this._cloneInto();
220
+ }
221
+ keccak() {
222
+ swap32IfBE(this.state32);
223
+ keccakP(this.state32, this.rounds);
224
+ swap32IfBE(this.state32);
225
+ this.posOut = 0;
226
+ this.pos = 0;
227
+ }
228
+ update(data) {
229
+ aexists(this);
230
+ abytes(data);
231
+ const { blockLen, state } = this;
232
+ const len = data.length;
233
+ for (let pos = 0; pos < len; ) {
234
+ const take = Math.min(blockLen - this.pos, len - pos);
235
+ for (let i = 0; i < take; i++)
236
+ state[this.pos++] ^= data[pos++];
237
+ if (this.pos === blockLen)
238
+ this.keccak();
239
+ }
240
+ return this;
241
+ }
242
+ finish() {
243
+ if (this.finished)
244
+ return;
245
+ this.finished = true;
246
+ const { state, suffix, pos, blockLen } = this;
247
+ state[pos] ^= suffix;
248
+ if ((suffix & 128) !== 0 && pos === blockLen - 1)
249
+ this.keccak();
250
+ state[blockLen - 1] ^= 128;
251
+ this.keccak();
252
+ }
253
+ writeInto(out) {
254
+ aexists(this, false);
255
+ abytes(out);
256
+ this.finish();
257
+ const bufferOut = this.state;
258
+ const { blockLen } = this;
259
+ for (let pos = 0, len = out.length; pos < len; ) {
260
+ if (this.posOut >= blockLen)
261
+ this.keccak();
262
+ const take = Math.min(blockLen - this.posOut, len - pos);
263
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
264
+ this.posOut += take;
265
+ pos += take;
266
+ }
267
+ return out;
268
+ }
269
+ xofInto(out) {
270
+ if (!this.enableXOF)
271
+ throw new Error("XOF is not possible for this instance");
272
+ return this.writeInto(out);
273
+ }
274
+ xof(bytes) {
275
+ anumber(bytes);
276
+ return this.xofInto(new Uint8Array(bytes));
277
+ }
278
+ digestInto(out) {
279
+ aoutput(out, this);
280
+ if (this.finished)
281
+ throw new Error("digest() was already called");
282
+ this.writeInto(out);
283
+ this.destroy();
284
+ return out;
285
+ }
286
+ digest() {
287
+ return this.digestInto(new Uint8Array(this.outputLen));
288
+ }
289
+ destroy() {
290
+ this.destroyed = true;
291
+ clean(this.state);
292
+ }
293
+ _cloneInto(to) {
294
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
295
+ to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
296
+ to.state32.set(this.state32);
297
+ to.pos = this.pos;
298
+ to.posOut = this.posOut;
299
+ to.finished = this.finished;
300
+ to.rounds = rounds;
301
+ to.suffix = suffix;
302
+ to.outputLen = outputLen;
303
+ to.enableXOF = enableXOF;
304
+ to.destroyed = this.destroyed;
305
+ return to;
306
+ }
307
+ };
308
+ var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
309
+ var sha3_512 = /* @__PURE__ */ genKeccak(
310
+ 6,
311
+ 72,
312
+ 64,
313
+ /* @__PURE__ */ oidNist(10)
314
+ );
315
+
316
+ // node_modules/bignumber.js/bignumber.mjs
317
+ var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
318
+ var mathceil = Math.ceil;
319
+ var mathfloor = Math.floor;
320
+ var bignumberError = "[BigNumber Error] ";
321
+ var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
322
+ var BASE = 1e14;
323
+ var LOG_BASE = 14;
324
+ var MAX_SAFE_INTEGER = 9007199254740991;
325
+ var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
326
+ var SQRT_BASE = 1e7;
327
+ var MAX = 1e9;
328
+ function clone(configObject) {
329
+ var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
330
+ prefix: "",
331
+ groupSize: 3,
332
+ secondaryGroupSize: 0,
333
+ groupSeparator: ",",
334
+ decimalSeparator: ".",
335
+ fractionGroupSize: 0,
336
+ fractionGroupSeparator: "\xA0",
337
+ // non-breaking space
338
+ suffix: ""
339
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
340
+ function BigNumber2(v, b) {
341
+ var alphabet2, c, caseChanged, e, i, isNum, len, str, x = this;
342
+ if (!(x instanceof BigNumber2)) return new BigNumber2(v, b);
343
+ if (b == null) {
344
+ if (v && v._isBigNumber === true) {
345
+ x.s = v.s;
346
+ if (!v.c || v.e > MAX_EXP) {
347
+ x.c = x.e = null;
348
+ } else if (v.e < MIN_EXP) {
349
+ x.c = [x.e = 0];
87
350
  } else {
88
- throw new Error(
89
- `[Sigil Error] Duplicate label '${label}' (different classes: ${(_c = existing == null ? void 0 : existing.name) != null ? _c : "unknown"} vs ${(_d = Class == null ? void 0 : Class.name) != null ? _d : "unknown"}).`
90
- );
351
+ x.e = v.e;
352
+ x.c = v.c.slice();
353
+ }
354
+ return;
355
+ }
356
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
357
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
358
+ if (v === ~~v) {
359
+ for (e = 0, i = v; i >= 10; i /= 10, e++) ;
360
+ if (e > MAX_EXP) {
361
+ x.c = x.e = null;
362
+ } else {
363
+ x.e = e;
364
+ x.c = [v];
365
+ }
366
+ return;
91
367
  }
368
+ str = String(v);
92
369
  } else {
93
- throw new Error(
94
- `[Sigil Error] Duplicate label '${label}' detected. Labels must be unique.`
370
+ if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
371
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
372
+ }
373
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
374
+ if ((i = str.search(/e/i)) > 0) {
375
+ if (e < 0) e = i;
376
+ e += +str.slice(i + 1);
377
+ str = str.substring(0, i);
378
+ } else if (e < 0) {
379
+ e = str.length;
380
+ }
381
+ } else {
382
+ intCheck(b, 2, ALPHABET.length, "Base");
383
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
384
+ x = new BigNumber2(v);
385
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
386
+ }
387
+ str = String(v);
388
+ if (isNum = typeof v == "number") {
389
+ if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
390
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
391
+ if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
392
+ throw Error(tooManyDigits + v);
393
+ }
394
+ } else {
395
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
396
+ }
397
+ alphabet2 = ALPHABET.slice(0, b);
398
+ e = i = 0;
399
+ for (len = str.length; i < len; i++) {
400
+ if (alphabet2.indexOf(c = str.charAt(i)) < 0) {
401
+ if (c == ".") {
402
+ if (i > e) {
403
+ e = len;
404
+ continue;
405
+ }
406
+ } else if (!caseChanged) {
407
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
408
+ caseChanged = true;
409
+ i = -1;
410
+ e = 0;
411
+ continue;
412
+ }
413
+ }
414
+ return parseNumeric(x, String(v), isNum, b);
415
+ }
416
+ }
417
+ isNum = false;
418
+ str = convertBase(str, b, 10, x.s);
419
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
420
+ else e = str.length;
421
+ }
422
+ for (i = 0; str.charCodeAt(i) === 48; i++) ;
423
+ for (len = str.length; str.charCodeAt(--len) === 48; ) ;
424
+ if (str = str.slice(i, ++len)) {
425
+ len -= i;
426
+ if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
427
+ throw Error(tooManyDigits + x.s * v);
428
+ }
429
+ if ((e = e - i - 1) > MAX_EXP) {
430
+ x.c = x.e = null;
431
+ } else if (e < MIN_EXP) {
432
+ x.c = [x.e = 0];
433
+ } else {
434
+ x.e = e;
435
+ x.c = [];
436
+ i = (e + 1) % LOG_BASE;
437
+ if (e < 0) i += LOG_BASE;
438
+ if (i < len) {
439
+ if (i) x.c.push(+str.slice(0, i));
440
+ for (len -= LOG_BASE; i < len; ) {
441
+ x.c.push(+str.slice(i, i += LOG_BASE));
442
+ }
443
+ i = LOG_BASE - (str = str.slice(i)).length;
444
+ } else {
445
+ i -= len;
446
+ }
447
+ for (; i--; str += "0") ;
448
+ x.c.push(+str);
449
+ }
450
+ } else {
451
+ x.c = [x.e = 0];
452
+ }
453
+ }
454
+ BigNumber2.clone = clone;
455
+ BigNumber2.ROUND_UP = 0;
456
+ BigNumber2.ROUND_DOWN = 1;
457
+ BigNumber2.ROUND_CEIL = 2;
458
+ BigNumber2.ROUND_FLOOR = 3;
459
+ BigNumber2.ROUND_HALF_UP = 4;
460
+ BigNumber2.ROUND_HALF_DOWN = 5;
461
+ BigNumber2.ROUND_HALF_EVEN = 6;
462
+ BigNumber2.ROUND_HALF_CEIL = 7;
463
+ BigNumber2.ROUND_HALF_FLOOR = 8;
464
+ BigNumber2.EUCLID = 9;
465
+ BigNumber2.config = BigNumber2.set = function(obj) {
466
+ var p, v;
467
+ if (obj != null) {
468
+ if (typeof obj == "object") {
469
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
470
+ v = obj[p];
471
+ intCheck(v, 0, MAX, p);
472
+ DECIMAL_PLACES = v;
473
+ }
474
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
475
+ v = obj[p];
476
+ intCheck(v, 0, 8, p);
477
+ ROUNDING_MODE = v;
478
+ }
479
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
480
+ v = obj[p];
481
+ if (v && v.pop) {
482
+ intCheck(v[0], -MAX, 0, p);
483
+ intCheck(v[1], 0, MAX, p);
484
+ TO_EXP_NEG = v[0];
485
+ TO_EXP_POS = v[1];
486
+ } else {
487
+ intCheck(v, -MAX, MAX, p);
488
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
489
+ }
490
+ }
491
+ if (obj.hasOwnProperty(p = "RANGE")) {
492
+ v = obj[p];
493
+ if (v && v.pop) {
494
+ intCheck(v[0], -MAX, -1, p);
495
+ intCheck(v[1], 1, MAX, p);
496
+ MIN_EXP = v[0];
497
+ MAX_EXP = v[1];
498
+ } else {
499
+ intCheck(v, -MAX, MAX, p);
500
+ if (v) {
501
+ MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
502
+ } else {
503
+ throw Error(bignumberError + p + " cannot be zero: " + v);
504
+ }
505
+ }
506
+ }
507
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
508
+ v = obj[p];
509
+ if (v === !!v) {
510
+ if (v) {
511
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
512
+ CRYPTO = v;
513
+ } else {
514
+ CRYPTO = !v;
515
+ throw Error(bignumberError + "crypto unavailable");
516
+ }
517
+ } else {
518
+ CRYPTO = v;
519
+ }
520
+ } else {
521
+ throw Error(bignumberError + p + " not true or false: " + v);
522
+ }
523
+ }
524
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
525
+ v = obj[p];
526
+ intCheck(v, 0, 9, p);
527
+ MODULO_MODE = v;
528
+ }
529
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
530
+ v = obj[p];
531
+ intCheck(v, 0, MAX, p);
532
+ POW_PRECISION = v;
533
+ }
534
+ if (obj.hasOwnProperty(p = "FORMAT")) {
535
+ v = obj[p];
536
+ if (typeof v == "object") FORMAT = v;
537
+ else throw Error(bignumberError + p + " not an object: " + v);
538
+ }
539
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
540
+ v = obj[p];
541
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
542
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
543
+ ALPHABET = v;
544
+ } else {
545
+ throw Error(bignumberError + p + " invalid: " + v);
546
+ }
547
+ }
548
+ } else {
549
+ throw Error(bignumberError + "Object expected: " + obj);
550
+ }
551
+ }
552
+ return {
553
+ DECIMAL_PLACES,
554
+ ROUNDING_MODE,
555
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
556
+ RANGE: [MIN_EXP, MAX_EXP],
557
+ CRYPTO,
558
+ MODULO_MODE,
559
+ POW_PRECISION,
560
+ FORMAT,
561
+ ALPHABET
562
+ };
563
+ };
564
+ BigNumber2.isBigNumber = function(v) {
565
+ if (!v || v._isBigNumber !== true) return false;
566
+ if (!BigNumber2.DEBUG) return true;
567
+ var i, n, c = v.c, e = v.e, s = v.s;
568
+ out: if ({}.toString.call(c) == "[object Array]") {
569
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
570
+ if (c[0] === 0) {
571
+ if (e === 0 && c.length === 1) return true;
572
+ break out;
573
+ }
574
+ i = (e + 1) % LOG_BASE;
575
+ if (i < 1) i += LOG_BASE;
576
+ if (String(c[0]).length == i) {
577
+ for (i = 0; i < c.length; i++) {
578
+ n = c[i];
579
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
580
+ }
581
+ if (n !== 0) return true;
582
+ }
583
+ }
584
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
585
+ return true;
586
+ }
587
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
588
+ };
589
+ BigNumber2.maximum = BigNumber2.max = function() {
590
+ return maxOrMin(arguments, -1);
591
+ };
592
+ BigNumber2.minimum = BigNumber2.min = function() {
593
+ return maxOrMin(arguments, 1);
594
+ };
595
+ BigNumber2.random = (function() {
596
+ var pow2_53 = 9007199254740992;
597
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
598
+ return mathfloor(Math.random() * pow2_53);
599
+ } : function() {
600
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
601
+ };
602
+ return function(dp) {
603
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
604
+ if (dp == null) dp = DECIMAL_PLACES;
605
+ else intCheck(dp, 0, MAX);
606
+ k = mathceil(dp / LOG_BASE);
607
+ if (CRYPTO) {
608
+ if (crypto.getRandomValues) {
609
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
610
+ for (; i < k; ) {
611
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
612
+ if (v >= 9e15) {
613
+ b = crypto.getRandomValues(new Uint32Array(2));
614
+ a[i] = b[0];
615
+ a[i + 1] = b[1];
616
+ } else {
617
+ c.push(v % 1e14);
618
+ i += 2;
619
+ }
620
+ }
621
+ i = k / 2;
622
+ } else if (crypto.randomBytes) {
623
+ a = crypto.randomBytes(k *= 7);
624
+ for (; i < k; ) {
625
+ v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
626
+ if (v >= 9e15) {
627
+ crypto.randomBytes(7).copy(a, i);
628
+ } else {
629
+ c.push(v % 1e14);
630
+ i += 7;
631
+ }
632
+ }
633
+ i = k / 7;
634
+ } else {
635
+ CRYPTO = false;
636
+ throw Error(bignumberError + "crypto unavailable");
637
+ }
638
+ }
639
+ if (!CRYPTO) {
640
+ for (; i < k; ) {
641
+ v = random53bitInt();
642
+ if (v < 9e15) c[i++] = v % 1e14;
643
+ }
644
+ }
645
+ k = c[--i];
646
+ dp %= LOG_BASE;
647
+ if (k && dp) {
648
+ v = POWS_TEN[LOG_BASE - dp];
649
+ c[i] = mathfloor(k / v) * v;
650
+ }
651
+ for (; c[i] === 0; c.pop(), i--) ;
652
+ if (i < 0) {
653
+ c = [e = 0];
654
+ } else {
655
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE) ;
656
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++) ;
657
+ if (i < LOG_BASE) e -= LOG_BASE - i;
658
+ }
659
+ rand.e = e;
660
+ rand.c = c;
661
+ return rand;
662
+ };
663
+ })();
664
+ BigNumber2.sum = function() {
665
+ var i = 1, args = arguments, sum = new BigNumber2(args[0]);
666
+ for (; i < args.length; ) sum = sum.plus(args[i++]);
667
+ return sum;
668
+ };
669
+ convertBase = /* @__PURE__ */ (function() {
670
+ var decimal = "0123456789";
671
+ function toBaseOut(str, baseIn, baseOut, alphabet2) {
672
+ var j, arr = [0], arrL, i = 0, len = str.length;
673
+ for (; i < len; ) {
674
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
675
+ arr[0] += alphabet2.indexOf(str.charAt(i++));
676
+ for (j = 0; j < arr.length; j++) {
677
+ if (arr[j] > baseOut - 1) {
678
+ if (arr[j + 1] == null) arr[j + 1] = 0;
679
+ arr[j + 1] += arr[j] / baseOut | 0;
680
+ arr[j] %= baseOut;
681
+ }
682
+ }
683
+ }
684
+ return arr.reverse();
685
+ }
686
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
687
+ var alphabet2, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
688
+ if (i >= 0) {
689
+ k = POW_PRECISION;
690
+ POW_PRECISION = 0;
691
+ str = str.replace(".", "");
692
+ y = new BigNumber2(baseIn);
693
+ x = y.pow(str.length - i);
694
+ POW_PRECISION = k;
695
+ y.c = toBaseOut(
696
+ toFixedPoint(coeffToString(x.c), x.e, "0"),
697
+ 10,
698
+ baseOut,
699
+ decimal
700
+ );
701
+ y.e = y.c.length;
702
+ }
703
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet2 = ALPHABET, decimal) : (alphabet2 = decimal, ALPHABET));
704
+ e = k = xc.length;
705
+ for (; xc[--k] == 0; xc.pop()) ;
706
+ if (!xc[0]) return alphabet2.charAt(0);
707
+ if (i < 0) {
708
+ --e;
709
+ } else {
710
+ x.c = xc;
711
+ x.e = e;
712
+ x.s = sign;
713
+ x = div(x, y, dp, rm, baseOut);
714
+ xc = x.c;
715
+ r = x.r;
716
+ e = x.e;
717
+ }
718
+ d = e + dp + 1;
719
+ i = xc[d];
720
+ k = baseOut / 2;
721
+ r = r || d < 0 || xc[d + 1] != null;
722
+ r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
723
+ if (d < 1 || !xc[0]) {
724
+ str = r ? toFixedPoint(alphabet2.charAt(1), -dp, alphabet2.charAt(0)) : alphabet2.charAt(0);
725
+ } else {
726
+ xc.length = d;
727
+ if (r) {
728
+ for (--baseOut; ++xc[--d] > baseOut; ) {
729
+ xc[d] = 0;
730
+ if (!d) {
731
+ ++e;
732
+ xc = [1].concat(xc);
733
+ }
734
+ }
735
+ }
736
+ for (k = xc.length; !xc[--k]; ) ;
737
+ for (i = 0, str = ""; i <= k; str += alphabet2.charAt(xc[i++])) ;
738
+ str = toFixedPoint(str, e, alphabet2.charAt(0));
739
+ }
740
+ return str;
741
+ };
742
+ })();
743
+ div = /* @__PURE__ */ (function() {
744
+ function multiply(x, k, base) {
745
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
746
+ for (x = x.slice(); i--; ) {
747
+ xlo = x[i] % SQRT_BASE;
748
+ xhi = x[i] / SQRT_BASE | 0;
749
+ m = khi * xlo + xhi * klo;
750
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
751
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
752
+ x[i] = temp % base;
753
+ }
754
+ if (carry) x = [carry].concat(x);
755
+ return x;
756
+ }
757
+ function compare2(a, b, aL, bL) {
758
+ var i, cmp;
759
+ if (aL != bL) {
760
+ cmp = aL > bL ? 1 : -1;
761
+ } else {
762
+ for (i = cmp = 0; i < aL; i++) {
763
+ if (a[i] != b[i]) {
764
+ cmp = a[i] > b[i] ? 1 : -1;
765
+ break;
766
+ }
767
+ }
768
+ }
769
+ return cmp;
770
+ }
771
+ function subtract(a, b, aL, base) {
772
+ var i = 0;
773
+ for (; aL--; ) {
774
+ a[aL] -= i;
775
+ i = a[aL] < b[aL] ? 1 : 0;
776
+ a[aL] = i * base + a[aL] - b[aL];
777
+ }
778
+ for (; !a[0] && a.length > 1; a.splice(0, 1)) ;
779
+ }
780
+ return function(x, y, dp, rm, base) {
781
+ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
782
+ if (!xc || !xc[0] || !yc || !yc[0]) {
783
+ return new BigNumber2(
784
+ // Return NaN if either NaN, or both Infinity or 0.
785
+ !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
786
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
787
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
788
+ )
95
789
  );
96
790
  }
791
+ q = new BigNumber2(s);
792
+ qc = q.c = [];
793
+ e = x.e - y.e;
794
+ s = dp + e + 1;
795
+ if (!base) {
796
+ base = BASE;
797
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
798
+ s = s / LOG_BASE | 0;
799
+ }
800
+ for (i = 0; yc[i] == (xc[i] || 0); i++) ;
801
+ if (yc[i] > (xc[i] || 0)) e--;
802
+ if (s < 0) {
803
+ qc.push(1);
804
+ more = true;
805
+ } else {
806
+ xL = xc.length;
807
+ yL = yc.length;
808
+ i = 0;
809
+ s += 2;
810
+ n = mathfloor(base / (yc[0] + 1));
811
+ if (n > 1) {
812
+ yc = multiply(yc, n, base);
813
+ xc = multiply(xc, n, base);
814
+ yL = yc.length;
815
+ xL = xc.length;
816
+ }
817
+ xi = yL;
818
+ rem = xc.slice(0, yL);
819
+ remL = rem.length;
820
+ for (; remL < yL; rem[remL++] = 0) ;
821
+ yz = yc.slice();
822
+ yz = [0].concat(yz);
823
+ yc0 = yc[0];
824
+ if (yc[1] >= base / 2) yc0++;
825
+ do {
826
+ n = 0;
827
+ cmp = compare2(yc, rem, yL, remL);
828
+ if (cmp < 0) {
829
+ rem0 = rem[0];
830
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
831
+ n = mathfloor(rem0 / yc0);
832
+ if (n > 1) {
833
+ if (n >= base) n = base - 1;
834
+ prod = multiply(yc, n, base);
835
+ prodL = prod.length;
836
+ remL = rem.length;
837
+ while (compare2(prod, rem, prodL, remL) == 1) {
838
+ n--;
839
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
840
+ prodL = prod.length;
841
+ cmp = 1;
842
+ }
843
+ } else {
844
+ if (n == 0) {
845
+ cmp = n = 1;
846
+ }
847
+ prod = yc.slice();
848
+ prodL = prod.length;
849
+ }
850
+ if (prodL < remL) prod = [0].concat(prod);
851
+ subtract(rem, prod, remL, base);
852
+ remL = rem.length;
853
+ if (cmp == -1) {
854
+ while (compare2(yc, rem, yL, remL) < 1) {
855
+ n++;
856
+ subtract(rem, yL < remL ? yz : yc, remL, base);
857
+ remL = rem.length;
858
+ }
859
+ }
860
+ } else if (cmp === 0) {
861
+ n++;
862
+ rem = [0];
863
+ }
864
+ qc[i++] = n;
865
+ if (rem[0]) {
866
+ rem[remL++] = xc[xi] || 0;
867
+ } else {
868
+ rem = [xc[xi]];
869
+ remL = 1;
870
+ }
871
+ } while ((xi++ < xL || rem[0] != null) && s--);
872
+ more = rem[0] != null;
873
+ if (!qc[0]) qc.splice(0, 1);
874
+ }
875
+ if (base == BASE) {
876
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++) ;
877
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
878
+ } else {
879
+ q.e = e;
880
+ q.r = +more;
881
+ }
882
+ return q;
883
+ };
884
+ })();
885
+ function format(n, i, rm, id) {
886
+ var c0, e, ne, len, str;
887
+ if (rm == null) rm = ROUNDING_MODE;
888
+ else intCheck(rm, 0, 8);
889
+ if (!n.c) return n.toString();
890
+ c0 = n.c[0];
891
+ ne = n.e;
892
+ if (i == null) {
893
+ str = coeffToString(n.c);
894
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
97
895
  } else {
98
- this._registry.set(label, storeCtor ? Class : null);
99
- }
100
- }
101
- /**
102
- * Alias for 'SigilRegistry.register'.
103
- *
104
- * @param label - Label string to register (e.g. '@scope/pkg.ClassName').
105
- * @param Class - Constructor of the class being registered.
106
- * @param opts - Optional per-call overrides.
107
- */
108
- set(label, Class, opts) {
109
- return this.register(label, Class, opts);
110
- }
111
- /**
112
- * Unregister a previously registered class.
113
- *
114
- * @param label - The label to remove from the registry.
115
- * @returns `true` if the label was present and removed; `false` otherwise (or when registry is disabled).
116
- */
117
- unregister(label) {
118
- return this._registry.delete(label);
119
- }
120
- /**
121
- * Alias for 'SigilRegistry.unregister'.
122
- *
123
- * @param label - The label to remove from the registry.
124
- * @returns `true` if the label was present and removed; `false` otherwise (or when registry is disabled).
125
- */
126
- delete(label) {
127
- return this.unregister(label);
128
- }
129
- /**
130
- * Replace active registry with new one. deprecated use 'updateOptions({ registry: newRegistry })' instead.
131
- *
132
- * @deprecated Will be removed in v2.0.0, check https://www.npmjs.com/package/@vicin/sigil?activeTab=readme#deprecated-api for more details.
133
- * @param newRegistry - New Set<string> instance to use as the active registry, or `null` to disable checks.
134
- */
135
- replaceRegistry(newRegistry) {
136
- if (newRegistry)
137
- updateOptions({ registry: new _SigilRegistry(newRegistry) });
138
- else updateOptions({ registry: newRegistry });
139
- }
140
- /**
141
- * Clear the registry completely.
142
- *
143
- * Useful for test teardown, or when explicitly resetting state during development.
144
- * No-op when the registry is disabled.
145
- */
146
- clear() {
147
- this._registry.clear();
148
- }
149
- /**
150
- * Merge another SigilRegistry into this one.
151
- *
152
- * Entries from `other` will be registered into this registry. Duplicate labels
153
- * are handled via this registry's `register` logic (i.e., will warn in DEV or
154
- * throw in production).
155
- *
156
- * @param other - Another `SigilRegistry` whose entries will be merged into this registry.
157
- */
158
- merge(other) {
159
- if (!OPTIONS.registry) return;
160
- for (const [label, ctor] of other) this.register(label, ctor);
161
- }
162
- /**
163
- * Return a Map-style iterator over entries: `[label, constructor]`.
164
- * Equivalent to calling `registry[Symbol.iterator]()`.
165
- *
166
- * @returns IterableIterator of `[label, ISigil]`.
167
- */
168
- entries() {
169
- return this._registry.entries();
170
- }
171
- /**
172
- * Return an iterator over registered constructors.
173
- *
174
- * @returns IterableIterator of `ISigil` constructors.
175
- */
176
- values() {
177
- return this._registry.values();
178
- }
179
- /**
180
- * Return an iterator over registered labels (keys).
181
- *
182
- * @returns IterableIterator of `string` labels.
183
- */
184
- keys() {
185
- return this._registry.keys();
186
- }
187
- /**
188
- * Execute a provided function once per registry entry.
189
- *
190
- * @param callback - Function invoked with `(ctor, label)` for each entry.
191
- * @param thisArg - Optional `this` context for the callback.
192
- */
193
- forEach(callback, thisArg) {
194
- this._registry.forEach(
195
- (ctor, label) => callback.call(thisArg, ctor, label)
196
- );
896
+ n = round(new BigNumber2(n), i, rm);
897
+ e = n.e;
898
+ str = coeffToString(n.c);
899
+ len = str.length;
900
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
901
+ for (; len < i; str += "0", len++) ;
902
+ str = toExponential(str, e);
903
+ } else {
904
+ i -= ne + (id === 2 && e > ne);
905
+ str = toFixedPoint(str, e, "0");
906
+ if (e + 1 > len) {
907
+ if (--i > 0) for (str += "."; i--; str += "0") ;
908
+ } else {
909
+ i += e - len;
910
+ if (i > 0) {
911
+ if (e + 1 == len) str += ".";
912
+ for (; i--; str += "0") ;
913
+ }
914
+ }
915
+ }
916
+ }
917
+ return n.s < 0 && c0 ? "-" + str : str;
197
918
  }
198
- /**
199
- * Get the size (number of entries) of the active registry.
200
- *
201
- * @returns The number of registered labels, or 0 when registry is disabled.
202
- */
203
- get size() {
204
- return this._registry.size;
205
- }
206
- /**
207
- * Return an iterator over `[label, constructor]` pairs.
208
- *
209
- * This makes the registry compatible with `for..of` and other iterable helpers:
210
- * ```ts
211
- * for (const [label, ctor] of registry) { ... }
212
- * ```
213
- *
214
- * @returns An iterable iterator that yields `[label, ISigil]` tuples.
215
- */
216
- [Symbol.iterator]() {
217
- return this._registry[Symbol.iterator]();
919
+ function maxOrMin(args, n) {
920
+ var k, y, i = 1, x = new BigNumber2(args[0]);
921
+ for (; i < args.length; i++) {
922
+ y = new BigNumber2(args[i]);
923
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
924
+ x = y;
925
+ }
926
+ }
927
+ return x;
218
928
  }
929
+ function normalise(n, c, e) {
930
+ var i = 1, j = c.length;
931
+ for (; !c[--j]; c.pop()) ;
932
+ for (j = c[0]; j >= 10; j /= 10, i++) ;
933
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
934
+ n.c = n.e = null;
935
+ } else if (e < MIN_EXP) {
936
+ n.c = [n.e = 0];
937
+ } else {
938
+ n.e = e;
939
+ n.c = c;
940
+ }
941
+ return n;
942
+ }
943
+ parseNumeric = /* @__PURE__ */ (function() {
944
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
945
+ return function(x, str, isNum, b) {
946
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
947
+ if (isInfinityOrNaN.test(s)) {
948
+ x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
949
+ } else {
950
+ if (!isNum) {
951
+ s = s.replace(basePrefix, function(m, p1, p2) {
952
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
953
+ return !b || b == base ? p1 : m;
954
+ });
955
+ if (b) {
956
+ base = b;
957
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
958
+ }
959
+ if (str != s) return new BigNumber2(s, base);
960
+ }
961
+ if (BigNumber2.DEBUG) {
962
+ throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
963
+ }
964
+ x.s = null;
965
+ }
966
+ x.c = x.e = null;
967
+ };
968
+ })();
969
+ function round(x, sd, rm, r) {
970
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
971
+ if (xc) {
972
+ out: {
973
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++) ;
974
+ i = sd - d;
975
+ if (i < 0) {
976
+ i += LOG_BASE;
977
+ j = sd;
978
+ n = xc[ni = 0];
979
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
980
+ } else {
981
+ ni = mathceil((i + 1) / LOG_BASE);
982
+ if (ni >= xc.length) {
983
+ if (r) {
984
+ for (; xc.length <= ni; xc.push(0)) ;
985
+ n = rd = 0;
986
+ d = 1;
987
+ i %= LOG_BASE;
988
+ j = i - LOG_BASE + 1;
989
+ } else {
990
+ break out;
991
+ }
992
+ } else {
993
+ n = k = xc[ni];
994
+ for (d = 1; k >= 10; k /= 10, d++) ;
995
+ i %= LOG_BASE;
996
+ j = i - LOG_BASE + d;
997
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
998
+ }
999
+ }
1000
+ r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
1001
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
1002
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
1003
+ xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
1004
+ r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1005
+ (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1006
+ if (sd < 1 || !xc[0]) {
1007
+ xc.length = 0;
1008
+ if (r) {
1009
+ sd -= x.e + 1;
1010
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
1011
+ x.e = -sd || 0;
1012
+ } else {
1013
+ xc[0] = x.e = 0;
1014
+ }
1015
+ return x;
1016
+ }
1017
+ if (i == 0) {
1018
+ xc.length = ni;
1019
+ k = 1;
1020
+ ni--;
1021
+ } else {
1022
+ xc.length = ni + 1;
1023
+ k = pows10[LOG_BASE - i];
1024
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
1025
+ }
1026
+ if (r) {
1027
+ for (; ; ) {
1028
+ if (ni == 0) {
1029
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++) ;
1030
+ j = xc[0] += k;
1031
+ for (k = 1; j >= 10; j /= 10, k++) ;
1032
+ if (i != k) {
1033
+ x.e++;
1034
+ if (xc[0] == BASE) xc[0] = 1;
1035
+ }
1036
+ break;
1037
+ } else {
1038
+ xc[ni] += k;
1039
+ if (xc[ni] != BASE) break;
1040
+ xc[ni--] = 0;
1041
+ k = 1;
1042
+ }
1043
+ }
1044
+ }
1045
+ for (i = xc.length; xc[--i] === 0; xc.pop()) ;
1046
+ }
1047
+ if (x.e > MAX_EXP) {
1048
+ x.c = x.e = null;
1049
+ } else if (x.e < MIN_EXP) {
1050
+ x.c = [x.e = 0];
1051
+ }
1052
+ }
1053
+ return x;
1054
+ }
1055
+ function valueOf(n) {
1056
+ var str, e = n.e;
1057
+ if (e === null) return n.toString();
1058
+ str = coeffToString(n.c);
1059
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
1060
+ return n.s < 0 ? "-" + str : str;
1061
+ }
1062
+ P.absoluteValue = P.abs = function() {
1063
+ var x = new BigNumber2(this);
1064
+ if (x.s < 0) x.s = 1;
1065
+ return x;
1066
+ };
1067
+ P.comparedTo = function(y, b) {
1068
+ return compare(this, new BigNumber2(y, b));
1069
+ };
1070
+ P.decimalPlaces = P.dp = function(dp, rm) {
1071
+ var c, n, v, x = this;
1072
+ if (dp != null) {
1073
+ intCheck(dp, 0, MAX);
1074
+ if (rm == null) rm = ROUNDING_MODE;
1075
+ else intCheck(rm, 0, 8);
1076
+ return round(new BigNumber2(x), dp + x.e + 1, rm);
1077
+ }
1078
+ if (!(c = x.c)) return null;
1079
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
1080
+ if (v = c[v]) for (; v % 10 == 0; v /= 10, n--) ;
1081
+ if (n < 0) n = 0;
1082
+ return n;
1083
+ };
1084
+ P.dividedBy = P.div = function(y, b) {
1085
+ return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
1086
+ };
1087
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
1088
+ return div(this, new BigNumber2(y, b), 0, 1);
1089
+ };
1090
+ P.exponentiatedBy = P.pow = function(n, m) {
1091
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
1092
+ n = new BigNumber2(n);
1093
+ if (n.c && !n.isInteger()) {
1094
+ throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
1095
+ }
1096
+ if (m != null) m = new BigNumber2(m);
1097
+ nIsBig = n.e > 14;
1098
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
1099
+ y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
1100
+ return m ? y.mod(m) : y;
1101
+ }
1102
+ nIsNeg = n.s < 0;
1103
+ if (m) {
1104
+ if (m.c ? !m.c[0] : !m.s) return new BigNumber2(NaN);
1105
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
1106
+ if (isModExp) x = x.mod(m);
1107
+ } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
1108
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
1109
+ if (x.e > -1) k = 1 / k;
1110
+ return new BigNumber2(nIsNeg ? 1 / k : k);
1111
+ } else if (POW_PRECISION) {
1112
+ k = mathceil(POW_PRECISION / LOG_BASE + 2);
1113
+ }
1114
+ if (nIsBig) {
1115
+ half = new BigNumber2(0.5);
1116
+ if (nIsNeg) n.s = 1;
1117
+ nIsOdd = isOdd(n);
1118
+ } else {
1119
+ i = Math.abs(+valueOf(n));
1120
+ nIsOdd = i % 2;
1121
+ }
1122
+ y = new BigNumber2(ONE);
1123
+ for (; ; ) {
1124
+ if (nIsOdd) {
1125
+ y = y.times(x);
1126
+ if (!y.c) break;
1127
+ if (k) {
1128
+ if (y.c.length > k) y.c.length = k;
1129
+ } else if (isModExp) {
1130
+ y = y.mod(m);
1131
+ }
1132
+ }
1133
+ if (i) {
1134
+ i = mathfloor(i / 2);
1135
+ if (i === 0) break;
1136
+ nIsOdd = i % 2;
1137
+ } else {
1138
+ n = n.times(half);
1139
+ round(n, n.e + 1, 1);
1140
+ if (n.e > 14) {
1141
+ nIsOdd = isOdd(n);
1142
+ } else {
1143
+ i = +valueOf(n);
1144
+ if (i === 0) break;
1145
+ nIsOdd = i % 2;
1146
+ }
1147
+ }
1148
+ x = x.times(x);
1149
+ if (k) {
1150
+ if (x.c && x.c.length > k) x.c.length = k;
1151
+ } else if (isModExp) {
1152
+ x = x.mod(m);
1153
+ }
1154
+ }
1155
+ if (isModExp) return y;
1156
+ if (nIsNeg) y = ONE.div(y);
1157
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
1158
+ };
1159
+ P.integerValue = function(rm) {
1160
+ var n = new BigNumber2(this);
1161
+ if (rm == null) rm = ROUNDING_MODE;
1162
+ else intCheck(rm, 0, 8);
1163
+ return round(n, n.e + 1, rm);
1164
+ };
1165
+ P.isEqualTo = P.eq = function(y, b) {
1166
+ return compare(this, new BigNumber2(y, b)) === 0;
1167
+ };
1168
+ P.isFinite = function() {
1169
+ return !!this.c;
1170
+ };
1171
+ P.isGreaterThan = P.gt = function(y, b) {
1172
+ return compare(this, new BigNumber2(y, b)) > 0;
1173
+ };
1174
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
1175
+ return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
1176
+ };
1177
+ P.isInteger = function() {
1178
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
1179
+ };
1180
+ P.isLessThan = P.lt = function(y, b) {
1181
+ return compare(this, new BigNumber2(y, b)) < 0;
1182
+ };
1183
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
1184
+ return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
1185
+ };
1186
+ P.isNaN = function() {
1187
+ return !this.s;
1188
+ };
1189
+ P.isNegative = function() {
1190
+ return this.s < 0;
1191
+ };
1192
+ P.isPositive = function() {
1193
+ return this.s > 0;
1194
+ };
1195
+ P.isZero = function() {
1196
+ return !!this.c && this.c[0] == 0;
1197
+ };
1198
+ P.minus = function(y, b) {
1199
+ var i, j, t, xLTy, x = this, a = x.s;
1200
+ y = new BigNumber2(y, b);
1201
+ b = y.s;
1202
+ if (!a || !b) return new BigNumber2(NaN);
1203
+ if (a != b) {
1204
+ y.s = -b;
1205
+ return x.plus(y);
1206
+ }
1207
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1208
+ if (!xe || !ye) {
1209
+ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
1210
+ if (!xc[0] || !yc[0]) {
1211
+ return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : (
1212
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
1213
+ ROUNDING_MODE == 3 ? -0 : 0
1214
+ ));
1215
+ }
1216
+ }
1217
+ xe = bitFloor(xe);
1218
+ ye = bitFloor(ye);
1219
+ xc = xc.slice();
1220
+ if (a = xe - ye) {
1221
+ if (xLTy = a < 0) {
1222
+ a = -a;
1223
+ t = xc;
1224
+ } else {
1225
+ ye = xe;
1226
+ t = yc;
1227
+ }
1228
+ t.reverse();
1229
+ for (b = a; b--; t.push(0)) ;
1230
+ t.reverse();
1231
+ } else {
1232
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
1233
+ for (a = b = 0; b < j; b++) {
1234
+ if (xc[b] != yc[b]) {
1235
+ xLTy = xc[b] < yc[b];
1236
+ break;
1237
+ }
1238
+ }
1239
+ }
1240
+ if (xLTy) {
1241
+ t = xc;
1242
+ xc = yc;
1243
+ yc = t;
1244
+ y.s = -y.s;
1245
+ }
1246
+ b = (j = yc.length) - (i = xc.length);
1247
+ if (b > 0) for (; b--; xc[i++] = 0) ;
1248
+ b = BASE - 1;
1249
+ for (; j > a; ) {
1250
+ if (xc[--j] < yc[j]) {
1251
+ for (i = j; i && !xc[--i]; xc[i] = b) ;
1252
+ --xc[i];
1253
+ xc[j] += BASE;
1254
+ }
1255
+ xc[j] -= yc[j];
1256
+ }
1257
+ for (; xc[0] == 0; xc.splice(0, 1), --ye) ;
1258
+ if (!xc[0]) {
1259
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
1260
+ y.c = [y.e = 0];
1261
+ return y;
1262
+ }
1263
+ return normalise(y, xc, ye);
1264
+ };
1265
+ P.modulo = P.mod = function(y, b) {
1266
+ var q, s, x = this;
1267
+ y = new BigNumber2(y, b);
1268
+ if (!x.c || !y.s || y.c && !y.c[0]) {
1269
+ return new BigNumber2(NaN);
1270
+ } else if (!y.c || x.c && !x.c[0]) {
1271
+ return new BigNumber2(x);
1272
+ }
1273
+ if (MODULO_MODE == 9) {
1274
+ s = y.s;
1275
+ y.s = 1;
1276
+ q = div(x, y, 0, 3);
1277
+ y.s = s;
1278
+ q.s *= s;
1279
+ } else {
1280
+ q = div(x, y, 0, MODULO_MODE);
1281
+ }
1282
+ y = x.minus(q.times(y));
1283
+ if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
1284
+ return y;
1285
+ };
1286
+ P.multipliedBy = P.times = function(y, b) {
1287
+ var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber2(y, b)).c;
1288
+ if (!xc || !yc || !xc[0] || !yc[0]) {
1289
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
1290
+ y.c = y.e = y.s = null;
1291
+ } else {
1292
+ y.s *= x.s;
1293
+ if (!xc || !yc) {
1294
+ y.c = y.e = null;
1295
+ } else {
1296
+ y.c = [0];
1297
+ y.e = 0;
1298
+ }
1299
+ }
1300
+ return y;
1301
+ }
1302
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
1303
+ y.s *= x.s;
1304
+ xcL = xc.length;
1305
+ ycL = yc.length;
1306
+ if (xcL < ycL) {
1307
+ zc = xc;
1308
+ xc = yc;
1309
+ yc = zc;
1310
+ i = xcL;
1311
+ xcL = ycL;
1312
+ ycL = i;
1313
+ }
1314
+ for (i = xcL + ycL, zc = []; i--; zc.push(0)) ;
1315
+ base = BASE;
1316
+ sqrtBase = SQRT_BASE;
1317
+ for (i = ycL; --i >= 0; ) {
1318
+ c = 0;
1319
+ ylo = yc[i] % sqrtBase;
1320
+ yhi = yc[i] / sqrtBase | 0;
1321
+ for (k = xcL, j = i + k; j > i; ) {
1322
+ xlo = xc[--k] % sqrtBase;
1323
+ xhi = xc[k] / sqrtBase | 0;
1324
+ m = yhi * xlo + xhi * ylo;
1325
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
1326
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
1327
+ zc[j--] = xlo % base;
1328
+ }
1329
+ zc[j] = c;
1330
+ }
1331
+ if (c) {
1332
+ ++e;
1333
+ } else {
1334
+ zc.splice(0, 1);
1335
+ }
1336
+ return normalise(y, zc, e);
1337
+ };
1338
+ P.negated = function() {
1339
+ var x = new BigNumber2(this);
1340
+ x.s = -x.s || null;
1341
+ return x;
1342
+ };
1343
+ P.plus = function(y, b) {
1344
+ var t, x = this, a = x.s;
1345
+ y = new BigNumber2(y, b);
1346
+ b = y.s;
1347
+ if (!a || !b) return new BigNumber2(NaN);
1348
+ if (a != b) {
1349
+ y.s = -b;
1350
+ return x.minus(y);
1351
+ }
1352
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1353
+ if (!xe || !ye) {
1354
+ if (!xc || !yc) return new BigNumber2(a / 0);
1355
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
1356
+ }
1357
+ xe = bitFloor(xe);
1358
+ ye = bitFloor(ye);
1359
+ xc = xc.slice();
1360
+ if (a = xe - ye) {
1361
+ if (a > 0) {
1362
+ ye = xe;
1363
+ t = yc;
1364
+ } else {
1365
+ a = -a;
1366
+ t = xc;
1367
+ }
1368
+ t.reverse();
1369
+ for (; a--; t.push(0)) ;
1370
+ t.reverse();
1371
+ }
1372
+ a = xc.length;
1373
+ b = yc.length;
1374
+ if (a - b < 0) {
1375
+ t = yc;
1376
+ yc = xc;
1377
+ xc = t;
1378
+ b = a;
1379
+ }
1380
+ for (a = 0; b; ) {
1381
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1382
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1383
+ }
1384
+ if (a) {
1385
+ xc = [a].concat(xc);
1386
+ ++ye;
1387
+ }
1388
+ return normalise(y, xc, ye);
1389
+ };
1390
+ P.precision = P.sd = function(sd, rm) {
1391
+ var c, n, v, x = this;
1392
+ if (sd != null && sd !== !!sd) {
1393
+ intCheck(sd, 1, MAX);
1394
+ if (rm == null) rm = ROUNDING_MODE;
1395
+ else intCheck(rm, 0, 8);
1396
+ return round(new BigNumber2(x), sd, rm);
1397
+ }
1398
+ if (!(c = x.c)) return null;
1399
+ v = c.length - 1;
1400
+ n = v * LOG_BASE + 1;
1401
+ if (v = c[v]) {
1402
+ for (; v % 10 == 0; v /= 10, n--) ;
1403
+ for (v = c[0]; v >= 10; v /= 10, n++) ;
1404
+ }
1405
+ if (sd && x.e + 1 > n) n = x.e + 1;
1406
+ return n;
1407
+ };
1408
+ P.shiftedBy = function(k) {
1409
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1410
+ return this.times("1e" + k);
1411
+ };
1412
+ P.squareRoot = P.sqrt = function() {
1413
+ var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
1414
+ if (s !== 1 || !c || !c[0]) {
1415
+ return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
1416
+ }
1417
+ s = Math.sqrt(+valueOf(x));
1418
+ if (s == 0 || s == 1 / 0) {
1419
+ n = coeffToString(c);
1420
+ if ((n.length + e) % 2 == 0) n += "0";
1421
+ s = Math.sqrt(+n);
1422
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1423
+ if (s == 1 / 0) {
1424
+ n = "5e" + e;
1425
+ } else {
1426
+ n = s.toExponential();
1427
+ n = n.slice(0, n.indexOf("e") + 1) + e;
1428
+ }
1429
+ r = new BigNumber2(n);
1430
+ } else {
1431
+ r = new BigNumber2(s + "");
1432
+ }
1433
+ if (r.c[0]) {
1434
+ e = r.e;
1435
+ s = e + dp;
1436
+ if (s < 3) s = 0;
1437
+ for (; ; ) {
1438
+ t = r;
1439
+ r = half.times(t.plus(div(x, t, dp, 1)));
1440
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1441
+ if (r.e < e) --s;
1442
+ n = n.slice(s - 3, s + 1);
1443
+ if (n == "9999" || !rep && n == "4999") {
1444
+ if (!rep) {
1445
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
1446
+ if (t.times(t).eq(x)) {
1447
+ r = t;
1448
+ break;
1449
+ }
1450
+ }
1451
+ dp += 4;
1452
+ s += 4;
1453
+ rep = 1;
1454
+ } else {
1455
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1456
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
1457
+ m = !r.times(r).eq(x);
1458
+ }
1459
+ break;
1460
+ }
1461
+ }
1462
+ }
1463
+ }
1464
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1465
+ };
1466
+ P.toExponential = function(dp, rm) {
1467
+ if (dp != null) {
1468
+ intCheck(dp, 0, MAX);
1469
+ dp++;
1470
+ }
1471
+ return format(this, dp, rm, 1);
1472
+ };
1473
+ P.toFixed = function(dp, rm) {
1474
+ if (dp != null) {
1475
+ intCheck(dp, 0, MAX);
1476
+ dp = dp + this.e + 1;
1477
+ }
1478
+ return format(this, dp, rm);
1479
+ };
1480
+ P.toFormat = function(dp, rm, format2) {
1481
+ var str, x = this;
1482
+ if (format2 == null) {
1483
+ if (dp != null && rm && typeof rm == "object") {
1484
+ format2 = rm;
1485
+ rm = null;
1486
+ } else if (dp && typeof dp == "object") {
1487
+ format2 = dp;
1488
+ dp = rm = null;
1489
+ } else {
1490
+ format2 = FORMAT;
1491
+ }
1492
+ } else if (typeof format2 != "object") {
1493
+ throw Error(bignumberError + "Argument not an object: " + format2);
1494
+ }
1495
+ str = x.toFixed(dp, rm);
1496
+ if (x.c) {
1497
+ var i, arr = str.split("."), g1 = +format2.groupSize, g2 = +format2.secondaryGroupSize, groupSeparator = format2.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
1498
+ if (g2) {
1499
+ i = g1;
1500
+ g1 = g2;
1501
+ g2 = i;
1502
+ len -= i;
1503
+ }
1504
+ if (g1 > 0 && len > 0) {
1505
+ i = len % g1 || g1;
1506
+ intPart = intDigits.substr(0, i);
1507
+ for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1508
+ if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1509
+ if (isNeg) intPart = "-" + intPart;
1510
+ }
1511
+ str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
1512
+ new RegExp("\\d{" + g2 + "}\\B", "g"),
1513
+ "$&" + (format2.fractionGroupSeparator || "")
1514
+ ) : fractionPart) : intPart;
1515
+ }
1516
+ return (format2.prefix || "") + str + (format2.suffix || "");
1517
+ };
1518
+ P.toFraction = function(md) {
1519
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1520
+ if (md != null) {
1521
+ n = new BigNumber2(md);
1522
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
1523
+ throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1524
+ }
1525
+ }
1526
+ if (!xc) return new BigNumber2(x);
1527
+ d = new BigNumber2(ONE);
1528
+ n1 = d0 = new BigNumber2(ONE);
1529
+ d1 = n0 = new BigNumber2(ONE);
1530
+ s = coeffToString(xc);
1531
+ e = d.e = s.length - x.e - 1;
1532
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1533
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1534
+ exp = MAX_EXP;
1535
+ MAX_EXP = 1 / 0;
1536
+ n = new BigNumber2(s);
1537
+ n0.c[0] = 0;
1538
+ for (; ; ) {
1539
+ q = div(n, d, 0, 1);
1540
+ d2 = d0.plus(q.times(d1));
1541
+ if (d2.comparedTo(md) == 1) break;
1542
+ d0 = d1;
1543
+ d1 = d2;
1544
+ n1 = n0.plus(q.times(d2 = n1));
1545
+ n0 = d2;
1546
+ d = n.minus(q.times(d2 = d));
1547
+ n = d2;
1548
+ }
1549
+ d2 = div(md.minus(d0), d1, 0, 1);
1550
+ n0 = n0.plus(d2.times(n1));
1551
+ d0 = d0.plus(d2.times(d1));
1552
+ n0.s = n1.s = x.s;
1553
+ e = e * 2;
1554
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
1555
+ div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
1556
+ ) < 1 ? [n1, d1] : [n0, d0];
1557
+ MAX_EXP = exp;
1558
+ return r;
1559
+ };
1560
+ P.toNumber = function() {
1561
+ return +valueOf(this);
1562
+ };
1563
+ P.toPrecision = function(sd, rm) {
1564
+ if (sd != null) intCheck(sd, 1, MAX);
1565
+ return format(this, sd, rm, 2);
1566
+ };
1567
+ P.toString = function(b) {
1568
+ var str, n = this, s = n.s, e = n.e;
1569
+ if (e === null) {
1570
+ if (s) {
1571
+ str = "Infinity";
1572
+ if (s < 0) str = "-" + str;
1573
+ } else {
1574
+ str = "NaN";
1575
+ }
1576
+ } else {
1577
+ if (b == null) {
1578
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1579
+ } else if (b === 10 && alphabetHasNormalDecimalDigits) {
1580
+ n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1581
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
1582
+ } else {
1583
+ intCheck(b, 2, ALPHABET.length, "Base");
1584
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1585
+ }
1586
+ if (s < 0 && n.c[0]) str = "-" + str;
1587
+ }
1588
+ return str;
1589
+ };
1590
+ P.valueOf = P.toJSON = function() {
1591
+ return valueOf(this);
1592
+ };
1593
+ P._isBigNumber = true;
1594
+ P[Symbol.toStringTag] = "BigNumber";
1595
+ P[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P.valueOf;
1596
+ if (configObject != null) BigNumber2.set(configObject);
1597
+ return BigNumber2;
1598
+ }
1599
+ function bitFloor(n) {
1600
+ var i = n | 0;
1601
+ return n > 0 || n === i ? i : i - 1;
1602
+ }
1603
+ function coeffToString(a) {
1604
+ var s, z, i = 1, j = a.length, r = a[0] + "";
1605
+ for (; i < j; ) {
1606
+ s = a[i++] + "";
1607
+ z = LOG_BASE - s.length;
1608
+ for (; z--; s = "0" + s) ;
1609
+ r += s;
1610
+ }
1611
+ for (j = r.length; r.charCodeAt(--j) === 48; ) ;
1612
+ return r.slice(0, j + 1 || 1);
1613
+ }
1614
+ function compare(x, y) {
1615
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1616
+ if (!i || !j) return null;
1617
+ a = xc && !xc[0];
1618
+ b = yc && !yc[0];
1619
+ if (a || b) return a ? b ? 0 : -j : i;
1620
+ if (i != j) return i;
1621
+ a = i < 0;
1622
+ b = k == l;
1623
+ if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1624
+ if (!b) return k > l ^ a ? 1 : -1;
1625
+ j = (k = xc.length) < (l = yc.length) ? k : l;
1626
+ for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1627
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
1628
+ }
1629
+ function intCheck(n, min, max, name) {
1630
+ if (n < min || n > max || n !== mathfloor(n)) {
1631
+ throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1632
+ }
1633
+ }
1634
+ function isOdd(n) {
1635
+ var k = n.c.length - 1;
1636
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1637
+ }
1638
+ function toExponential(str, e) {
1639
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1640
+ }
1641
+ function toFixedPoint(str, e, z) {
1642
+ var len, zs;
1643
+ if (e < 0) {
1644
+ for (zs = z + "."; ++e; zs += z) ;
1645
+ str = zs + str;
1646
+ } else {
1647
+ len = str.length;
1648
+ if (++e > len) {
1649
+ for (zs = z, e -= len; --e; zs += z) ;
1650
+ str += zs;
1651
+ } else if (e < len) {
1652
+ str = str.slice(0, e) + "." + str.slice(e);
1653
+ }
1654
+ }
1655
+ return str;
1656
+ }
1657
+ var BigNumber = clone();
1658
+ var bignumber_default = BigNumber;
1659
+
1660
+ // node_modules/@paralleldrive/cuid2/src/index.js
1661
+ var defaultLength = 24;
1662
+ var bigLength = 32;
1663
+ var createRandom = () => {
1664
+ if (typeof globalThis !== "undefined" && globalThis.crypto && typeof globalThis.crypto.getRandomValues === "function") {
1665
+ return () => {
1666
+ const buffer = new Uint32Array(1);
1667
+ globalThis.crypto.getRandomValues(buffer);
1668
+ return buffer[0] / 4294967296;
1669
+ };
1670
+ }
1671
+ return Math.random;
219
1672
  };
220
- var getActiveRegistry = () => {
221
- const globalRegistry = getGlobalRegistry();
222
- if (globalRegistry) return globalRegistry;
223
- return OPTIONS.registry;
224
- };
225
- exports.REGISTRY = OPTIONS.registry;
226
- var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
227
- var updateOptions = (opts, mergeRegistries = true) => {
228
- applyBeforeSideEffects(OPTIONS, opts, mergeRegistries);
229
- for (const [k, v] of Object.entries(opts)) OPTIONS[k] = v;
230
- applyAfterSideEffects(OPTIONS);
1673
+ var random = createRandom();
1674
+ var createEntropy = (length = 4, rand = random) => {
1675
+ let entropy = "";
1676
+ while (entropy.length < length) {
1677
+ entropy = entropy + Math.floor(rand() * 36).toString(36);
1678
+ }
1679
+ return entropy;
231
1680
  };
232
- function applyBeforeSideEffects(oldOpts, newOpts, mergeRegistries) {
233
- if (mergeRegistries && newOpts.registry && oldOpts.registry)
234
- newOpts.registry.merge(oldOpts.registry);
235
- }
236
- function applyAfterSideEffects(opts) {
237
- if (opts.useGlobalRegistry) updateGlobalRegistry(opts.registry);
238
- else updateGlobalRegistry(null);
239
- if (OPTIONS.registry) exports.REGISTRY = OPTIONS.registry;
240
- else exports.REGISTRY = new SigilRegistry();
1681
+ function bufToBigInt(buf) {
1682
+ let value = new bignumber_default(0);
1683
+ for (const i of buf.values()) {
1684
+ value = value.multipliedBy(256).plus(i);
1685
+ }
1686
+ return value;
241
1687
  }
242
- var DEFAULT_OPTIONS = {
243
- labelValidation: null,
244
- skipLabelInheritanceCheck: false,
245
- autofillLabels: false,
246
- devMarker: process.env.NODE_ENV !== "production",
247
- registry: new SigilRegistry(),
248
- useGlobalRegistry: true,
249
- storeConstructor: true
1688
+ var hash = (input = "") => {
1689
+ const encoder = new TextEncoder();
1690
+ return bufToBigInt(sha3_512(encoder.encode(input))).toString(36).slice(1);
250
1691
  };
251
- updateOptions(DEFAULT_OPTIONS);
252
-
253
- // src/core/symbols.ts
254
- var __SIGIL__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL__");
255
- var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
256
- var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
257
- var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for(
258
- "@Sigil.__INHERITANCE_CHECKED__"
1692
+ var alphabet = Array.from(
1693
+ { length: 26 },
1694
+ (x, i) => String.fromCharCode(i + 97)
259
1695
  );
260
- var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
261
- var __TYPE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE__");
262
- var __TYPE_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE_LINEAGE__");
263
- var __TYPE_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE_SET__");
1696
+ var randomLetter = (rand) => alphabet[Math.floor(rand() * alphabet.length)];
1697
+ var createFingerprint = ({
1698
+ globalObj = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {},
1699
+ random: rand = random
1700
+ } = {}) => {
1701
+ const globals = Object.keys(globalObj).toString();
1702
+ const sourceString = globals.length ? globals + createEntropy(bigLength, rand) : createEntropy(bigLength, rand);
1703
+ return hash(sourceString).substring(0, bigLength);
1704
+ };
1705
+ var createCounter = (count) => () => {
1706
+ return count++;
1707
+ };
1708
+ var initialCountMax = 476782367;
1709
+ var init = ({
1710
+ // Fallback if the user does not pass in a CSPRNG. This should be OK
1711
+ // because we don't rely solely on the random number generator for entropy.
1712
+ // We also use the host fingerprint, current time, and a session counter.
1713
+ random: rand = random,
1714
+ counter = createCounter(Math.floor(rand() * initialCountMax)),
1715
+ length = defaultLength,
1716
+ fingerprint = createFingerprint({ random: rand })
1717
+ } = {}) => {
1718
+ if (length > bigLength) {
1719
+ throw new Error(
1720
+ `Length must be between 2 and ${bigLength}. Received: ${length}`
1721
+ );
1722
+ }
1723
+ return function cuid2() {
1724
+ const firstLetter = randomLetter(rand);
1725
+ const time = Date.now().toString(36);
1726
+ const count = counter().toString(36);
1727
+ const salt = createEntropy(length, rand);
1728
+ const hashInput = `${time + salt + count + fingerprint}`;
1729
+ return `${firstLetter + hash(hashInput).substring(1, length)}`;
1730
+ };
1731
+ };
1732
+ var createId = lazy(init);
1733
+ function lazy(fn) {
1734
+ let initialized;
1735
+ return () => {
1736
+ if (!initialized) {
1737
+ initialized = fn();
1738
+ }
1739
+ return initialized();
1740
+ };
1741
+ }
264
1742
 
265
1743
  // src/core/helpers.ts
266
- function decorateCtor(ctor, label, opts, isMixin = false) {
267
- var _a;
1744
+ function decorateCtor(ctor, label, isMixin = false) {
268
1745
  if (isDecorated(ctor))
269
1746
  throw new Error(
270
1747
  `Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
271
1748
  );
272
- const symbol = Symbol.for(label);
273
- (_a = getActiveRegistry()) == null ? void 0 : _a.register(label, ctor, opts);
274
1749
  Object.defineProperty(ctor, __LABEL__, {
275
1750
  value: label,
276
1751
  configurable: false,
277
1752
  enumerable: false,
278
1753
  writable: false
279
1754
  });
280
- Object.defineProperty(ctor, __TYPE__, {
281
- value: symbol,
282
- configurable: false,
283
- enumerable: false,
284
- writable: false
285
- });
286
1755
  const parent = Object.getPrototypeOf(ctor);
287
- const parentChain = parent && parent[__TYPE_LINEAGE__] ? parent[__TYPE_LINEAGE__] : [];
288
- const ctorChain = isMixin && label !== "Sigil" ? [/* @__PURE__ */ Symbol.for("Sigil"), ...parentChain, symbol] : [...parentChain, symbol];
289
- Object.defineProperty(ctor, __TYPE_LINEAGE__, {
1756
+ const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
1757
+ const ctorChain = isMixin && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
1758
+ Object.defineProperty(ctor, __LABEL_LINEAGE__, {
290
1759
  value: ctorChain,
291
1760
  configurable: false,
292
1761
  enumerable: false,
293
1762
  writable: false
294
1763
  });
295
- Object.defineProperty(ctor, __TYPE_SET__, {
1764
+ Object.defineProperty(ctor, __LABEL_SET__, {
296
1765
  value: new Set(ctorChain),
297
1766
  configurable: false,
298
1767
  enumerable: false,
@@ -327,7 +1796,7 @@
327
1796
  );
328
1797
  }
329
1798
  label = generateRandomLabel();
330
- decorateCtor(ctor2, label, opts);
1799
+ decorateCtor(ctor2, label);
331
1800
  }
332
1801
  labelOwner.set(label, ctor2.name);
333
1802
  }
@@ -346,10 +1815,8 @@
346
1815
  );
347
1816
  }
348
1817
  }
349
- function generateRandomLabel(length = 16) {
350
- let label = generateRandomString(length);
351
- const registry = getActiveRegistry();
352
- if (registry) while (registry.has(label)) label = generateRandomLabel();
1818
+ function generateRandomLabel() {
1819
+ let label = createId();
353
1820
  return `@Sigil.auto-${label}`;
354
1821
  }
355
1822
  function markSigil(ctor) {
@@ -411,19 +1878,10 @@
411
1878
  if (!obj || typeof obj !== "object") return null;
412
1879
  return (_c = (_b = obj.constructor) != null ? _b : (_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.constructor) != null ? _c : null;
413
1880
  }
414
- function generateRandomString(length = 16) {
415
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
416
- let result = "";
417
- for (let i = 0; i < length; i++) {
418
- result += chars.charAt(Math.floor(Math.random() * chars.length));
419
- }
420
- return result;
421
- }
422
1881
 
423
1882
  // src/core/mixin.ts
424
1883
  function Sigilify(Base, label, opts) {
425
- if (isSigilCtor(Base))
426
- throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
1884
+ if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
427
1885
  let l;
428
1886
  if (label) {
429
1887
  verifyLabel(label, opts);
@@ -437,35 +1895,26 @@
437
1895
  return this[__LABEL__];
438
1896
  }
439
1897
  /**
440
- * Class-level unique runtime symbol used as the type identifier.
441
- *
442
- * This symbol is created with `Symbol.for(label)` during decoration so it is
443
- * stable across realms that share the same global symbol registry.
444
- */
445
- static get SigilType() {
446
- return this[__TYPE__];
447
- }
448
- /**
449
- * Copy of the linearized sigil type symbol chain for the current constructor.
1898
+ * Copy of the linearized sigil type label chain for the current constructor.
450
1899
  *
451
1900
  * Useful for debugging and performing strict lineage comparisons.
452
1901
  *
453
- * @returns An array of symbols representing parent → child type symbols.
1902
+ * @returns An array of labels representing parent → child type labels.
454
1903
  */
455
- static get SigilTypeLineage() {
1904
+ static get SigilLabelLineage() {
456
1905
  var _a;
457
- return [...(_a = this[__TYPE_LINEAGE__]) != null ? _a : []];
1906
+ return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
458
1907
  }
459
1908
  /**
460
- * Copy of the sigil type symbol set for the current constructor.
1909
+ * Copy of the sigil type label set for the current constructor.
461
1910
  *
462
1911
  * Useful for quick membership checks (O(1) lookups) and debugging.
463
1912
  *
464
- * @returns A Readonly Set of symbols that represent the type lineage.
1913
+ * @returns A Readonly Set of labels that represent the type lineage.
465
1914
  */
466
- static get SigilTypeSet() {
1915
+ static get SigilLabelSet() {
467
1916
  const set = /* @__PURE__ */ new Set();
468
- for (const s of this[__TYPE_SET__]) set.add(s);
1917
+ for (const s of this[__LABEL_SET__]) set.add(s);
469
1918
  return set;
470
1919
  }
471
1920
  constructor(...args) {
@@ -476,9 +1925,7 @@
476
1925
  const ctor = getConstructor(this);
477
1926
  if (!ctor) {
478
1927
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
479
- throw new Error(
480
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
481
- );
1928
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
482
1929
  return;
483
1930
  }
484
1931
  checkInheritance(ctor);
@@ -495,10 +1942,6 @@
495
1942
  /**
496
1943
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
497
1944
  *
498
- * Implementation detail:
499
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
500
- * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
501
- *
502
1945
  * This replaces `instanceof` so that checks remain valid across bundles/realms
503
1946
  * and when subclassing.
504
1947
  *
@@ -508,18 +1951,14 @@
508
1951
  * @returns `true` if `other` is an instance of this type or a subtype.
509
1952
  */
510
1953
  static isOfType(other) {
1954
+ var _a;
511
1955
  if (!isSigilInstance(other)) return false;
512
- const otherCtor = getConstructor(other);
513
- if (!otherCtor) return false;
514
- const otherSet = otherCtor[__TYPE_SET__];
515
- return !!otherSet && otherSet.has(this.SigilType);
1956
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
1957
+ const thisType = this[__LABEL__];
1958
+ return !!otherSet && otherSet.has(thisType);
516
1959
  }
517
1960
  /**
518
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
519
- *
520
- * Implementation detail:
521
- * - Works in O(n) time where n is the depth of the lineage.
522
- * - Reliable when `OPTIONS.skipLabelInheritanceCheck` is `false`.
1961
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
523
1962
  *
524
1963
  * @typeParam T - The calling constructor type.
525
1964
  * @param this - The constructor performing the check.
@@ -527,90 +1966,99 @@
527
1966
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
528
1967
  */
529
1968
  static isOfTypeStrict(other) {
1969
+ var _a;
530
1970
  if (!isSigilInstance(other)) return false;
531
- const otherCtor = getConstructor(other);
532
- if (!otherCtor) return false;
533
- const otherLineage = otherCtor[__TYPE_LINEAGE__];
534
- const thisLineage = this[__TYPE_LINEAGE__];
1971
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
1972
+ const thisLineage = this[__LABEL_LINEAGE__];
535
1973
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
536
1974
  }
537
1975
  /**
538
- * Returns the human-readable sigil label of this instance's constructor.
1976
+ * Check whether `other` is (or inherits from) the type instance.
539
1977
  *
540
- * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
1978
+ * Allows 'instanceof' like checks but in instances.
1979
+ *
1980
+ * @typeParam T - The instance type.
1981
+ * @param this - The instance performing the check.
1982
+ * @param other - The object to test.
1983
+ * @returns `true` if `other` is the same instance of this type or a subtype.
541
1984
  */
542
- getSigilLabel() {
1985
+ isOfType(other) {
543
1986
  var _a;
544
- const ctor = getConstructor(this);
545
- if (!ctor) {
546
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
547
- throw new Error(
548
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
549
- );
550
- return "@Sigil.unknown";
551
- }
552
- return ctor.SigilLabel;
1987
+ if (!isSigilInstance(other)) return false;
1988
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
1989
+ const thisType = getConstructor(this)[__LABEL__];
1990
+ return !!otherSet && otherSet.has(thisType);
553
1991
  }
554
1992
  /**
555
- * Returns the runtime sigil type symbol of this instance's constructor.
1993
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
1994
+ *
1995
+ * Allows 'instanceof' like checks but in instances.
556
1996
  *
557
- * @returns The symbol that identifies this type at runtime.
1997
+ * @typeParam T - The instance type.
1998
+ * @param this - The instance performing the check.
1999
+ * @param other - The object to test.
2000
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
558
2001
  */
559
- getSigilType() {
2002
+ isOfTypeStrict(other) {
2003
+ var _a, _b;
2004
+ if (!isSigilInstance(other)) return false;
2005
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2006
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
2007
+ return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
2008
+ }
2009
+ /**
2010
+ * Returns the human-readable sigil label of this instance's constructor.
2011
+ *
2012
+ * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
2013
+ */
2014
+ getSigilLabel() {
560
2015
  var _a;
561
2016
  const ctor = getConstructor(this);
562
2017
  if (!ctor) {
563
2018
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
564
- throw new Error(
565
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
566
- );
567
- return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
2019
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2020
+ return "@Sigil.unknown";
568
2021
  }
569
- return ctor.SigilType;
2022
+ return ctor.SigilLabel;
570
2023
  }
571
2024
  /**
572
- * Returns a copy of the sigil type symbol lineage for this instance's constructor.
2025
+ * Returns a copy of the sigil type label lineage for this instance's constructor.
573
2026
  *
574
- * @returns readonly array of symbols representing the type lineage.
2027
+ * @returns readonly array of labels representing the type lineage.
575
2028
  */
576
- getSigilTypeLineage() {
2029
+ getSigilLabelLineage() {
577
2030
  var _a;
578
2031
  const ctor = getConstructor(this);
579
2032
  if (!ctor) {
580
2033
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
581
- throw new Error(
582
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
583
- );
584
- return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
2034
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2035
+ return ["@Sigil.unknown"];
585
2036
  }
586
- return ctor.SigilTypeLineage;
2037
+ return ctor.SigilLabelLineage;
587
2038
  }
588
2039
  /**
589
- * Returns a readonly copy of the sigil type symbol set for this instance's constructor.
2040
+ * Returns a readonly copy of the sigil type label set for this instance's constructor.
590
2041
  *
591
- * @returns A Readonly Set of symbols representing the type lineage for O(1) membership tests.
2042
+ * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
592
2043
  */
593
- getSigilTypeSet() {
2044
+ getSigilLabelSet() {
594
2045
  var _a;
595
2046
  const ctor = getConstructor(this);
596
2047
  if (!ctor) {
597
2048
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
598
- throw new Error(
599
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
600
- );
601
- return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
2049
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2050
+ return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
602
2051
  }
603
- return ctor.SigilTypeSet;
2052
+ return ctor.SigilLabelSet;
604
2053
  }
605
2054
  }
606
- decorateCtor(Sigilified, l, opts, true);
2055
+ decorateCtor(Sigilified, l, true);
607
2056
  markSigil(Sigilified);
608
2057
  markSigilBase(Sigilified);
609
2058
  return Sigilified;
610
2059
  }
611
2060
  function SigilifyAbstract(Base, label, opts) {
612
- if (isSigilCtor(Base))
613
- throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
2061
+ if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
614
2062
  let l;
615
2063
  if (label) {
616
2064
  verifyLabel(label, opts);
@@ -624,35 +2072,26 @@
624
2072
  return this[__LABEL__];
625
2073
  }
626
2074
  /**
627
- * Class-level unique runtime symbol used as the type identifier.
628
- *
629
- * This symbol is created with `Symbol.for(label)` during decoration so it is
630
- * stable across realms that share the same global symbol registry.
631
- */
632
- static get SigilType() {
633
- return this[__TYPE__];
634
- }
635
- /**
636
- * Copy of the linearized sigil type symbol chain for the current constructor.
2075
+ * Copy of the linearized sigil type label chain for the current constructor.
637
2076
  *
638
2077
  * Useful for debugging and performing strict lineage comparisons.
639
2078
  *
640
- * @returns An array of symbols representing parent → child type symbols.
2079
+ * @returns An array of labels representing parent → child type labels.
641
2080
  */
642
- static get SigilTypeLineage() {
2081
+ static get SigilLabelLineage() {
643
2082
  var _a;
644
- return [...(_a = this[__TYPE_LINEAGE__]) != null ? _a : []];
2083
+ return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
645
2084
  }
646
2085
  /**
647
- * Copy of the sigil type symbol set for the current constructor.
2086
+ * Copy of the sigil type label set for the current constructor.
648
2087
  *
649
2088
  * Useful for quick membership checks (O(1) lookups) and debugging.
650
2089
  *
651
- * @returns A Readonly Set of symbols that represent the type lineage.
2090
+ * @returns A Readonly Set of labels that represent the type lineage.
652
2091
  */
653
- static get SigilTypeSet() {
2092
+ static get SigilLabelSet() {
654
2093
  const set = /* @__PURE__ */ new Set();
655
- for (const s of this[__TYPE_SET__]) set.add(s);
2094
+ for (const s of this[__LABEL_SET__]) set.add(s);
656
2095
  return set;
657
2096
  }
658
2097
  constructor(...args) {
@@ -663,9 +2102,7 @@
663
2102
  const ctor = getConstructor(this);
664
2103
  if (!ctor) {
665
2104
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
666
- throw new Error(
667
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
668
- );
2105
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
669
2106
  return;
670
2107
  }
671
2108
  checkInheritance(ctor);
@@ -683,7 +2120,7 @@
683
2120
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
684
2121
  *
685
2122
  * Implementation detail:
686
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
2123
+ * - Uses the other instance's `__LABEL_SET__` for O(1) membership test.
687
2124
  * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
688
2125
  *
689
2126
  * This replaces `instanceof` so that checks remain valid across bundles/realms
@@ -695,14 +2132,14 @@
695
2132
  * @returns `true` if `other` is an instance of this type or a subtype.
696
2133
  */
697
2134
  static isOfType(other) {
698
- if (!isSigilInstance(other)) return false;
699
- const otherCtor = getConstructor(other);
700
- if (!otherCtor) return false;
701
- const otherSet = otherCtor[__TYPE_SET__];
702
- return !!otherSet && otherSet.has(this.SigilType);
2135
+ var _a;
2136
+ if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
2137
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
2138
+ const thisType = this[__LABEL__];
2139
+ return !!otherSet && otherSet.has(thisType);
703
2140
  }
704
2141
  /**
705
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
2142
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
706
2143
  *
707
2144
  * Implementation detail:
708
2145
  * - Works in O(n) time where n is the depth of the lineage.
@@ -714,83 +2151,93 @@
714
2151
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
715
2152
  */
716
2153
  static isOfTypeStrict(other) {
717
- if (!isSigilInstance(other)) return false;
718
- const otherCtor = getConstructor(other);
719
- if (!otherCtor) return false;
720
- const otherLineage = otherCtor[__TYPE_LINEAGE__];
721
- const thisLineage = this[__TYPE_LINEAGE__];
2154
+ var _a;
2155
+ if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
2156
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2157
+ const thisLineage = this[__LABEL_LINEAGE__];
722
2158
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
723
2159
  }
724
2160
  /**
725
- * Returns the human-readable sigil label of this instance's constructor.
2161
+ * Check whether `other` is (or inherits from) the type instance.
726
2162
  *
727
- * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
2163
+ * Allows 'instanceof' like checks but in instances.
2164
+ *
2165
+ * @typeParam T - The instance type.
2166
+ * @param this - The instance performing the check.
2167
+ * @param other - The object to test.
2168
+ * @returns `true` if `other` is the same instance of this type or a subtype.
728
2169
  */
729
- getSigilLabel() {
2170
+ isOfType(other) {
730
2171
  var _a;
731
- const ctor = getConstructor(this);
732
- if (!ctor) {
733
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
734
- throw new Error(
735
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
736
- );
737
- return "@Sigil.unknown";
738
- }
739
- return ctor.SigilLabel;
2172
+ if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
2173
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
2174
+ const thisType = getConstructor(this)[__LABEL__];
2175
+ return !!otherSet && otherSet.has(thisType);
2176
+ }
2177
+ /**
2178
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
2179
+ *
2180
+ * Allows 'instanceof' like checks but in instances.
2181
+ *
2182
+ * @typeParam T - The instance type.
2183
+ * @param this - The instance performing the check.
2184
+ * @param other - The object to test.
2185
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
2186
+ */
2187
+ isOfTypeStrict(other) {
2188
+ var _a, _b;
2189
+ if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
2190
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2191
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
2192
+ return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
740
2193
  }
741
2194
  /**
742
- * Returns the runtime sigil type symbol of this instance's constructor.
2195
+ * Returns the human-readable sigil label of this instance's constructor.
743
2196
  *
744
- * @returns The symbol that identifies this type at runtime.
2197
+ * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
745
2198
  */
746
- getSigilType() {
2199
+ getSigilLabel() {
747
2200
  var _a;
748
2201
  const ctor = getConstructor(this);
749
2202
  if (!ctor) {
750
2203
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
751
- throw new Error(
752
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
753
- );
754
- return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
2204
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2205
+ return "@Sigil.unknown";
755
2206
  }
756
- return ctor.SigilType;
2207
+ return ctor.SigilLabel;
757
2208
  }
758
2209
  /**
759
- * Returns a copy of the sigil type symbol lineage for this instance's constructor.
2210
+ * Returns a copy of the sigil type label lineage for this instance's constructor.
760
2211
  *
761
- * @returns readonly array of symbols representing the type lineage.
2212
+ * @returns readonly array of labels representing the type lineage.
762
2213
  */
763
- getSigilTypeLineage() {
2214
+ getSigilLabelLineage() {
764
2215
  var _a;
765
2216
  const ctor = getConstructor(this);
766
2217
  if (!ctor) {
767
2218
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
768
- throw new Error(
769
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
770
- );
771
- return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
2219
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2220
+ return ["@Sigil.unknown"];
772
2221
  }
773
- return ctor.SigilTypeLineage;
2222
+ return ctor.SigilLabelLineage;
774
2223
  }
775
2224
  /**
776
- * Returns a readonly copy of the sigil type symbol set for this instance's constructor.
2225
+ * Returns a readonly copy of the sigil type label set for this instance's constructor.
777
2226
  *
778
- * @returns A Readonly Set of symbols representing the type lineage for O(1) membership tests.
2227
+ * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
779
2228
  */
780
- getSigilTypeSet() {
2229
+ getSigilLabelSet() {
781
2230
  var _a;
782
2231
  const ctor = getConstructor(this);
783
2232
  if (!ctor) {
784
2233
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
785
- throw new Error(
786
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
787
- );
788
- return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
2234
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2235
+ return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
789
2236
  }
790
- return ctor.SigilTypeSet;
2237
+ return ctor.SigilLabelSet;
791
2238
  }
792
2239
  }
793
- decorateCtor(Sigilified, l, opts, true);
2240
+ decorateCtor(Sigilified, l, true);
794
2241
  markSigil(Sigilified);
795
2242
  markSigilBase(Sigilified);
796
2243
  return Sigilified;
@@ -814,7 +2261,7 @@
814
2261
  throw new Error(
815
2262
  `[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
816
2263
  );
817
- decorateCtor(value, l, opts);
2264
+ decorateCtor(value, l);
818
2265
  checkInheritance(value, opts);
819
2266
  };
820
2267
  }
@@ -832,26 +2279,10 @@
832
2279
  l = label;
833
2280
  } else l = generateRandomLabel();
834
2281
  const ctor = Class;
835
- decorateCtor(ctor, l, opts);
2282
+ decorateCtor(ctor, l);
836
2283
  checkInheritance(ctor, opts);
837
2284
  return Class;
838
2285
  }
839
- function typed(Class, label, opts) {
840
- var _a, _b;
841
- const devMarker = (_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker;
842
- if (!isSigilCtor(Class))
843
- throw new Error(
844
- `[Sigil Error] 'typed' HOF accept only Sigil classes but used on class ${(_b = Class == null ? void 0 : Class.name) != null ? _b : "unknown"}`
845
- );
846
- if (devMarker && label) {
847
- const runtimeLabel = Class.SigilLabel;
848
- if (runtimeLabel && runtimeLabel !== label)
849
- throw new Error(
850
- `[Sigil Error][typed] runtime label "${runtimeLabel}" does not match asserted label "${label}".`
851
- );
852
- }
853
- return Class;
854
- }
855
2286
  function withSigilTyped(Class, label, opts) {
856
2287
  var _a;
857
2288
  if (!isSigilCtor(Class))
@@ -864,26 +2295,28 @@
864
2295
  l = label;
865
2296
  } else l = generateRandomLabel();
866
2297
  const ctor = Class;
867
- decorateCtor(ctor, l, opts);
2298
+ decorateCtor(ctor, l);
868
2299
  checkInheritance(ctor, opts);
869
2300
  return Class;
870
2301
  }
2302
+ /*! Bundled license information:
2303
+
2304
+ @noble/hashes/utils.js:
2305
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2306
+ */
871
2307
 
872
2308
  exports.DEFAULT_LABEL_REGEX = DEFAULT_LABEL_REGEX;
873
2309
  exports.Sigil = Sigil;
874
2310
  exports.SigilError = SigilError;
875
- exports.SigilRegistry = SigilRegistry;
876
2311
  exports.Sigilify = Sigilify;
877
2312
  exports.SigilifyAbstract = SigilifyAbstract;
878
2313
  exports.WithSigil = WithSigil;
879
- exports.getActiveRegistry = getActiveRegistry;
880
2314
  exports.isDecorated = isDecorated;
881
2315
  exports.isInheritanceChecked = isInheritanceChecked;
882
2316
  exports.isSigilBaseCtor = isSigilBaseCtor;
883
2317
  exports.isSigilBaseInstance = isSigilBaseInstance;
884
2318
  exports.isSigilCtor = isSigilCtor;
885
2319
  exports.isSigilInstance = isSigilInstance;
886
- exports.typed = typed;
887
2320
  exports.updateOptions = updateOptions;
888
2321
  exports.withSigil = withSigil;
889
2322
  exports.withSigilTyped = withSigilTyped;