@aidc-toolkit/utility 0.9.7-beta → 0.9.9-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
1
  // src/locale/i18n.ts
2
- import { i18nAddResourceBundle, i18nAssertValidResources, i18next } from "@aidc-toolkit/core";
2
+ import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
3
+ import i18next from "i18next";
3
4
 
4
- // src/locale/en/locale_strings.ts
5
+ // src/locale/en/locale-strings.ts
5
6
  var localeStrings = {
6
7
  Transformer: {
7
8
  domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0",
8
9
  tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
9
10
  valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
10
11
  valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
11
- minValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minValue}} must be greater than or equal to 0",
12
- maxValueMustBeLessThan: "Maximum value {{maxValue}} must be less than {{domain}}"
12
+ minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
13
+ maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
13
14
  },
14
15
  RegExpValidator: {
15
16
  stringDoesNotMatchPattern: "String {{s}} does not match pattern"
@@ -35,15 +36,15 @@ var localeStrings = {
35
36
  }
36
37
  };
37
38
 
38
- // src/locale/fr/locale_strings.ts
39
+ // src/locale/fr/locale-strings.ts
39
40
  var localeStrings2 = {
40
41
  Transformer: {
41
42
  domainMustBeGreaterThanZero: "Le domaine {{domain}} doit \xEAtre sup\xE9rieur \xE0 0",
42
43
  tweakMustBeGreaterThanOrEqualToZero: "Le r\xE9glage {{tweak}} doit \xEAtre sup\xE9rieur ou \xE9gal \xE0 0",
43
44
  valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
44
45
  valueMustBeLessThan: "La valeur {{value}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}",
45
- minValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
46
- maxValueMustBeLessThan: "La valeur maximale {{maxValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"
46
+ minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
47
+ maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"
47
48
  },
48
49
  RegExpValidator: {
49
50
  stringDoesNotMatchPattern: "La cha\xEEne {{s}} ne correspond pas au mod\xE8le"
@@ -72,389 +73,21 @@ var localeStrings2 = {
72
73
  // src/locale/i18n.ts
73
74
  var utilityNS = "aidct_utility";
74
75
  i18nAssertValidResources(localeStrings, "fr", localeStrings2);
75
- i18nAddResourceBundle("en", utilityNS, localeStrings);
76
- i18nAddResourceBundle("fr", utilityNS, localeStrings2);
77
- var i18n_default = i18next;
78
-
79
- // src/iterator_proxy.ts
80
- var IteratorProxyBase = class _IteratorProxyBase {
81
- /**
82
- * Convert an iteration source to an iterable.
83
- *
84
- * @param iterationSource
85
- * Iteration source.
86
- *
87
- * @returns
88
- * Iteration source if it is already an iterable, otherwise iteration source wrapped in an iterable.
89
- */
90
- static toIterable(iterationSource) {
91
- return Symbol.iterator in iterationSource ? iterationSource : {
92
- [Symbol.iterator]() {
93
- return iterationSource;
94
- }
95
- };
96
- }
97
- /**
98
- * Initial iterable.
99
- */
100
- _initialIterable;
101
- /**
102
- * Initial iterator.
103
- */
104
- _initialIterator;
105
- /**
106
- * Constructor.
107
- *
108
- * @param initialIterationSource
109
- * Initial iteration source.
110
- */
111
- constructor(initialIterationSource) {
112
- this._initialIterable = _IteratorProxyBase.toIterable(initialIterationSource);
113
- }
114
- /**
115
- * Get the initial iterable.
116
- */
117
- get initialIterable() {
118
- return this._initialIterable;
119
- }
120
- /**
121
- * Get the initial iterator.
122
- */
123
- get initialIterator() {
124
- if (this._initialIterator === void 0) {
125
- this._initialIterator = this.initialIterable[Symbol.iterator]();
126
- }
127
- return this._initialIterator;
128
- }
129
- /**
130
- * @inheritDoc
131
- */
132
- get [Symbol.toStringTag]() {
133
- return "IteratorProxy";
134
- }
135
- /**
136
- * @inheritDoc
137
- */
138
- [Symbol.dispose]() {
139
- }
140
- /**
141
- * @inheritDoc
142
- */
143
- [Symbol.iterator]() {
144
- return this;
145
- }
146
- /**
147
- * Get the next result from the initial iterator.
148
- *
149
- * @param value
150
- * Tuple value to be passed to Iterator.next().
151
- *
152
- * @returns
153
- * Next result from the initial iterator.
154
- */
155
- initialNext(...value) {
156
- return this.initialIterator.next(...value);
157
- }
158
- /**
159
- * @inheritDoc
160
- */
161
- map(callback) {
162
- return new IteratorMapProxy(this, callback);
163
- }
164
- /**
165
- * @inheritDoc
166
- */
167
- flatMap(callback) {
168
- return new IteratorFlatMapProxy(this, callback);
169
- }
170
- /**
171
- * @inheritDoc
172
- */
173
- filter(predicate) {
174
- return new IteratorFilterProxy(this, predicate, true);
175
- }
176
- /**
177
- * @inheritDoc
178
- */
179
- take(limit) {
180
- return new IteratorTakeProxy(this, limit);
181
- }
182
- /**
183
- * @inheritDoc
184
- */
185
- drop(count) {
186
- return new IteratorDropProxy(this, count);
187
- }
188
- /**
189
- * @inheritDoc
190
- */
191
- reduce(callback, initialValue) {
192
- let index = 0;
193
- let result = initialValue;
194
- for (const value of this) {
195
- if (index === 0 && arguments.length === 1) {
196
- result = value;
197
- } else {
198
- result = callback(result, value, index);
199
- }
200
- index++;
201
- }
202
- if (index === 0 && arguments.length === 1) {
203
- throw new Error("reduce() of empty iterator with no initial value");
204
- }
205
- return result;
206
- }
207
- /**
208
- * @inheritDoc
209
- */
210
- toArray() {
211
- return Array.from(this);
212
- }
213
- /**
214
- * @inheritDoc
215
- */
216
- forEach(callback) {
217
- let index = 0;
218
- for (const element of this) {
219
- callback(element, index++);
220
- }
221
- }
222
- /**
223
- * @inheritDoc
224
- */
225
- some(predicate) {
226
- return new IteratorFilterProxy(this, predicate, true).next().done !== true;
227
- }
228
- /**
229
- * @inheritDoc
230
- */
231
- every(predicate) {
232
- return new IteratorFilterProxy(this, predicate, false).next().done === true;
233
- }
234
- /**
235
- * @inheritDoc
236
- */
237
- find(predicate) {
238
- return new IteratorFilterProxy(this, predicate, true).next().value;
239
- }
240
- };
241
- var IteratorProxyObject = class extends IteratorProxyBase {
242
- /**
243
- * @inheritDoc
244
- */
245
- next(...value) {
246
- return this.initialNext(...value);
247
- }
248
- };
249
- var IteratorMapProxyBase = class extends IteratorProxyBase {
250
- /**
251
- * Callback.
252
- */
253
- _callback;
254
- /**
255
- * Index into initial iteration source.
256
- */
257
- _index;
258
- /**
259
- * Constructor.
260
- *
261
- * @param initialIterationSource
262
- * Initial iteration source.
263
- *
264
- * @param callback
265
- * Callback.
266
- */
267
- constructor(initialIterationSource, callback) {
268
- super(initialIterationSource);
269
- this._callback = callback;
270
- this._index = 0;
271
- }
272
- /**
273
- * Get the next result from the intermediate iterator.
274
- *
275
- * @param value
276
- * Tuple value to be passed to Iterator.next().
277
- *
278
- * @returns
279
- * Next result from the intermediate iterator.
280
- */
281
- intermediateNext(...value) {
282
- const initialResult = this.initialNext(...value);
283
- return initialResult.done !== true ? {
284
- value: this._callback(initialResult.value, this._index++)
285
- } : {
286
- done: true,
287
- value: void 0
288
- };
289
- }
290
- };
291
- var IteratorMapProxy = class extends IteratorMapProxyBase {
292
- /**
293
- * @inheritDoc
294
- */
295
- next(...value) {
296
- return this.intermediateNext(...value);
297
- }
298
- };
299
- var IteratorFlatMapProxy = class extends IteratorMapProxyBase {
300
- _intermediateIterator;
301
- /**
302
- * @inheritDoc
303
- */
304
- next(...value) {
305
- let finalResult = void 0;
306
- do {
307
- if (this._intermediateIterator === void 0) {
308
- const intermediateResult = this.intermediateNext(...value);
309
- if (intermediateResult.done === true) {
310
- finalResult = intermediateResult;
311
- } else {
312
- this._intermediateIterator = IteratorProxyBase.toIterable(intermediateResult.value)[Symbol.iterator]();
313
- }
314
- } else {
315
- const pendingFinalResult = this._intermediateIterator.next();
316
- if (pendingFinalResult.done === true) {
317
- this._intermediateIterator = void 0;
318
- } else {
319
- finalResult = pendingFinalResult;
320
- }
321
- }
322
- } while (finalResult === void 0);
323
- return finalResult;
324
- }
325
- };
326
- var IteratorFilterProxy = class extends IteratorProxyBase {
327
- /**
328
- * Predicate.
329
- */
330
- _predicate;
331
- /**
332
- * Expected truthy result of the predicate.
333
- */
334
- _expectedTruthy;
335
- /**
336
- * Index into iteration source.
337
- */
338
- _index;
339
- /**
340
- * Constructor.
341
- *
342
- * @param iterationSource
343
- * Iteration source.
344
- *
345
- * @param predicate
346
- * Predicate.
347
- *
348
- * @param expectedTruthy
349
- * Expected truthy result of the predicate.
350
- */
351
- constructor(iterationSource, predicate, expectedTruthy) {
352
- super(iterationSource);
353
- this._predicate = predicate;
354
- this._expectedTruthy = expectedTruthy;
355
- this._index = 0;
356
- }
357
- /**
358
- * @inheritDoc
359
- */
360
- next(...value) {
361
- let result;
362
- const expectedTruthy = this._expectedTruthy;
363
- do {
364
- result = this.initialNext(...value);
365
- } while (result.done !== true && Boolean(this._predicate(result.value, this._index++)) !== expectedTruthy);
366
- return result;
367
- }
368
- };
369
- var IteratorCountProxyBase = class extends IteratorProxyObject {
370
- /**
371
- * Count.
372
- */
373
- _count;
374
- /**
375
- * Constructor.
376
- *
377
- * @param initialIterationSource
378
- * Initial iteration source.
379
- *
380
- * @param count
381
- * Count.
382
- */
383
- constructor(initialIterationSource, count) {
384
- super(initialIterationSource);
385
- if (!Number.isInteger(count) || count < 0) {
386
- throw new RangeError("Count must be a positive integer");
387
- }
388
- this._count = count;
389
- }
390
- /**
391
- * Determine if iterator is exhausted (by count or by iterator itself).
392
- */
393
- get exhausted() {
394
- return this._count <= 0;
395
- }
396
- /**
397
- * @inheritDoc
398
- */
399
- next(...value) {
400
- const result = super.next(...value);
401
- if (result.done !== true) {
402
- this._count--;
403
- } else {
404
- this._count = 0;
405
- }
406
- return result;
407
- }
408
- };
409
- var IteratorTakeProxy = class extends IteratorCountProxyBase {
410
- /**
411
- * @inheritDoc
412
- */
413
- next(...value) {
414
- return !this.exhausted ? super.next(...value) : {
415
- done: true,
416
- value: void 0
417
- };
418
- }
419
- };
420
- var IteratorDropProxy = class extends IteratorCountProxyBase {
421
- /**
422
- * @inheritDoc
423
- */
424
- next(...value) {
425
- while (!this.exhausted) {
426
- super.next(...value);
427
- }
428
- return super.next(...value);
76
+ var utilityResources = {
77
+ en: {
78
+ aidct_utility: localeStrings
79
+ },
80
+ fr: {
81
+ aidct_utility: localeStrings2
429
82
  }
430
83
  };
431
- function iteratorProxy() {
432
- let supported;
433
- try {
434
- supported = process.env["NODE_ENV"] !== "test";
435
- } catch (_e) {
436
- supported = true;
437
- }
438
- if (supported) {
439
- try {
440
- Iterator.from([]);
441
- } catch (_e) {
442
- supported = false;
443
- }
444
- }
445
- return supported ? Iterator : {
446
- /**
447
- * @inheritDoc
448
- */
449
- from(value) {
450
- return value instanceof IteratorProxyBase ? value : new IteratorProxyObject(value);
451
- }
452
- };
84
+ var i18nextUtility = i18next.createInstance();
85
+ async function i18nUtilityInit(environment, debug = false) {
86
+ await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
453
87
  }
454
- var IteratorProxy = iteratorProxy();
455
88
 
456
- // src/sequencer.ts
457
- var Sequencer = class {
89
+ // src/sequence.ts
90
+ var Sequence = class {
458
91
  /**
459
92
  * Start value (inclusive).
460
93
  */
@@ -474,15 +107,11 @@ var Sequencer = class {
474
107
  /**
475
108
  * Minimum value (inclusive).
476
109
  */
477
- _minValue;
110
+ _minimumValue;
478
111
  /**
479
112
  * Maximum value (inclusive).
480
113
  */
481
- _maxValue;
482
- /**
483
- * Next value.
484
- */
485
- _nextValue;
114
+ _maximumValue;
486
115
  /**
487
116
  * Constructor.
488
117
  *
@@ -497,17 +126,15 @@ var Sequencer = class {
497
126
  this._startValue = BigInt(startValue);
498
127
  this._endValue = this._startValue + BigInt(count);
499
128
  this._count = count;
500
- const ascending = count >= 0;
501
- if (ascending) {
129
+ if (count >= 0) {
502
130
  this._nextDelta = 1n;
503
- this._minValue = this._startValue;
504
- this._maxValue = this._endValue - 1n;
131
+ this._minimumValue = this._startValue;
132
+ this._maximumValue = this._endValue - 1n;
505
133
  } else {
506
134
  this._nextDelta = -1n;
507
- this._minValue = this._endValue + 1n;
508
- this._maxValue = this._startValue;
135
+ this._minimumValue = this._endValue + 1n;
136
+ this._maximumValue = this._startValue;
509
137
  }
510
- this._nextValue = this._startValue;
511
138
  }
512
139
  /**
513
140
  * Get the start value (inclusive).
@@ -530,55 +157,45 @@ var Sequencer = class {
530
157
  /**
531
158
  * Get the minimum value (inclusive).
532
159
  */
533
- get minValue() {
534
- return this._minValue;
160
+ get minimumValue() {
161
+ return this._minimumValue;
535
162
  }
536
163
  /**
537
164
  * Get the maximum value (inclusive).
538
165
  */
539
- get maxValue() {
540
- return this._maxValue;
166
+ get maximumValue() {
167
+ return this._maximumValue;
541
168
  }
542
169
  /**
543
170
  * Iterable implementation.
544
171
  *
545
- * @returns
546
- * this
547
- */
548
- [Symbol.iterator]() {
549
- return this;
550
- }
551
- /**
552
- * Iterator implementation.
553
- *
554
- * @returns
555
- * Iterator result. If iterator is exhausted, the value is absolute value of the count.
172
+ * @yields
173
+ * Next value in sequence.
556
174
  */
557
- next() {
558
- const done = this._nextValue === this._endValue;
559
- let result;
560
- if (!done) {
561
- result = {
562
- value: this._nextValue
563
- };
564
- this._nextValue += this._nextDelta;
565
- } else {
566
- result = {
567
- done: true,
568
- value: Math.abs(this._count)
569
- };
175
+ *[Symbol.iterator]() {
176
+ for (let value = this._startValue; value !== this._endValue; value += this._nextDelta) {
177
+ yield value;
570
178
  }
571
- return result;
572
- }
573
- /**
574
- * Reset the iterator.
575
- */
576
- reset() {
577
- this._nextValue = this._startValue;
578
179
  }
579
180
  };
580
181
 
581
182
  // src/transformer.ts
183
+ function transformIterable(values, transformerCallback) {
184
+ return {
185
+ /**
186
+ * Iterable implementation.
187
+ *
188
+ * @yields
189
+ * Next output value.
190
+ */
191
+ *[Symbol.iterator]() {
192
+ let index = 0;
193
+ for (const value of values) {
194
+ yield transformerCallback(value, index++);
195
+ }
196
+ }
197
+ };
198
+ }
582
199
  var Transformer = class _Transformer {
583
200
  /**
584
201
  * Transformers cache, mapping a domain to another map, which maps an optional tweak to a transformer.
@@ -597,8 +214,7 @@ var Transformer = class _Transformer {
597
214
  constructor(domain) {
598
215
  this._domain = BigInt(domain);
599
216
  if (this._domain <= 0n) {
600
- throw new RangeError(i18n_default.t("Transformer.domainMustBeGreaterThanZero", {
601
- ns: utilityNS,
217
+ throw new RangeError(i18nextUtility.t("Transformer.domainMustBeGreaterThanZero", {
602
218
  domain
603
219
  }));
604
220
  }
@@ -647,52 +263,69 @@ var Transformer = class _Transformer {
647
263
  */
648
264
  validate(value) {
649
265
  if (value < 0n) {
650
- throw new RangeError(i18n_default.t("Transformer.valueMustBeGreaterThanOrEqualToZero", {
651
- ns: utilityNS,
266
+ throw new RangeError(i18nextUtility.t("Transformer.valueMustBeGreaterThanOrEqualToZero", {
652
267
  value
653
268
  }));
654
269
  }
655
270
  if (value >= this.domain) {
656
- throw new RangeError(i18n_default.t("Transformer.valueMustBeLessThan", {
657
- ns: utilityNS,
271
+ throw new RangeError(i18nextUtility.t("Transformer.valueMustBeLessThan", {
658
272
  value,
659
273
  domain: this.domain
660
274
  }));
661
275
  }
662
276
  }
277
+ /**
278
+ * Validate that a value is within the domain and do the work of transforming it forward.
279
+ *
280
+ * @param value
281
+ * Value.
282
+ *
283
+ * @returns
284
+ * Transformed value.
285
+ */
286
+ validateDoForward(value) {
287
+ const valueN = BigInt(value);
288
+ this.validate(valueN);
289
+ return this.doForward(valueN);
290
+ }
291
+ /**
292
+ * Validate that a value is within the domain, do the work of transforming it forward, and apply a callback.
293
+ *
294
+ * @param transformerCallback
295
+ * Called after each value is transformed to convert it to its final value.
296
+ *
297
+ * @param value
298
+ * Value.
299
+ *
300
+ * @param index
301
+ * Index in sequence (0 for single transformation).
302
+ *
303
+ * @returns
304
+ * Transformed value.
305
+ */
306
+ validateDoForwardCallback(transformerCallback, value, index) {
307
+ return transformerCallback(this.validateDoForward(value), index);
308
+ }
663
309
  // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
664
310
  forward(valueOrValues, transformerCallback) {
665
311
  let result;
666
312
  if (typeof valueOrValues !== "object") {
667
- const valueN = BigInt(valueOrValues);
668
- this.validate(valueN);
669
- const transformedValue = this.doForward(valueN);
670
- result = transformerCallback === void 0 ? transformedValue : transformerCallback(transformedValue, 0);
671
- } else if (valueOrValues instanceof Sequencer) {
672
- if (valueOrValues.minValue < 0n) {
673
- throw new RangeError(i18n_default.t("Transformer.minValueMustBeGreaterThanOrEqualToZero", {
674
- ns: utilityNS,
675
- minValue: valueOrValues.minValue
313
+ result = transformerCallback === void 0 ? this.validateDoForward(valueOrValues) : this.validateDoForwardCallback(transformerCallback, valueOrValues, 0);
314
+ } else if (valueOrValues instanceof Sequence) {
315
+ if (valueOrValues.minimumValue < 0n) {
316
+ throw new RangeError(i18nextUtility.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero", {
317
+ minimumValue: valueOrValues.minimumValue
676
318
  }));
677
319
  }
678
- if (valueOrValues.maxValue >= this.domain) {
679
- throw new RangeError(i18n_default.t("Transformer.maxValueMustBeLessThan", {
680
- ns: utilityNS,
681
- maxValue: valueOrValues.maxValue,
320
+ if (valueOrValues.maximumValue >= this.domain) {
321
+ throw new RangeError(i18nextUtility.t("Transformer.maximumValueMustBeLessThan", {
322
+ maximumValue: valueOrValues.maximumValue,
682
323
  domain: this.domain
683
324
  }));
684
325
  }
685
- result = transformerCallback === void 0 ? IteratorProxy.from(valueOrValues).map((value) => this.doForward(value)) : IteratorProxy.from(valueOrValues).map((value, index) => transformerCallback(this.doForward(value), index));
326
+ result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.doForward(value)) : transformIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
686
327
  } else {
687
- result = transformerCallback === void 0 ? IteratorProxy.from(valueOrValues).map((value) => {
688
- const valueN = BigInt(value);
689
- this.validate(valueN);
690
- return this.doForward(valueN);
691
- }) : IteratorProxy.from(valueOrValues).map((value, index) => {
692
- const valueN = BigInt(value);
693
- this.validate(valueN);
694
- return transformerCallback(this.doForward(valueN), index);
695
- });
328
+ result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.validateDoForward(value)) : transformIterable(valueOrValues, (value, index) => this.validateDoForwardCallback(transformerCallback, value, index));
696
329
  }
697
330
  return result;
698
331
  }
@@ -756,10 +389,6 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
756
389
  * Number of bytes covered by the domain.
757
390
  */
758
391
  _domainBytes;
759
- /**
760
- * Tweak.
761
- */
762
- _tweak;
763
392
  /**
764
393
  * Xor bytes array generated from the domain and tweak.
765
394
  */
@@ -788,24 +417,21 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
788
417
  constructor(domain, tweak) {
789
418
  super(domain);
790
419
  if (tweak < 0n) {
791
- throw new RangeError(i18n_default.t("Transformer.tweakMustBeGreaterThanOrEqualToZero", {
792
- ns: utilityNS,
420
+ throw new RangeError(i18nextUtility.t("Transformer.tweakMustBeGreaterThanOrEqualToZero", {
793
421
  tweak
794
422
  }));
795
423
  }
796
424
  let domainBytes = 0;
797
- for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne = reducedDomainMinusOne >> 8n) {
425
+ for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne >>= 8n) {
798
426
  domainBytes++;
799
427
  }
800
428
  this._domainBytes = domainBytes;
801
- this._tweak = BigInt(tweak);
802
429
  const xorBytes = new Array();
803
430
  const bits = new Array();
804
431
  const inverseBits = new Array();
805
- for (let reducedKey = this.domain * this.tweak * 603868999n; reducedKey !== 0n; reducedKey = reducedKey >> 8n) {
806
- const keyByte = Number(reducedKey & 0xFFn);
807
- xorBytes.unshift(keyByte);
808
- const bitNumber = keyByte & 7;
432
+ for (let reducedKey = this.domain * BigInt(tweak) * 603868999n; reducedKey !== 0n; reducedKey >>= 8n) {
433
+ xorBytes.unshift(Number(BigInt.asUintN(8, reducedKey)));
434
+ const bitNumber = Number(BigInt.asUintN(3, reducedKey));
809
435
  bits.push(_EncryptionTransformer.BITS[bitNumber]);
810
436
  inverseBits.push(_EncryptionTransformer.INVERSE_BITS[bitNumber]);
811
437
  }
@@ -822,12 +448,6 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
822
448
  this._rounds = xorBytes.length;
823
449
  }
824
450
  }
825
- /**
826
- * Get the tweak.
827
- */
828
- get tweak() {
829
- return this._tweak;
830
- }
831
451
  /**
832
452
  * Convert a value to a byte array big enough to handle the entire domain.
833
453
  *
@@ -839,10 +459,8 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
839
459
  */
840
460
  valueToBytes(value) {
841
461
  const bytes = new Uint8Array(this._domainBytes);
842
- let reducedValue = value;
843
- for (let index = this._domainBytes - 1; index >= 0; index--) {
844
- bytes[index] = Number(reducedValue & 0xFFn);
845
- reducedValue = reducedValue >> 8n;
462
+ for (let index = this._domainBytes - 1, reducedValue = value; index >= 0 && reducedValue !== 0n; index--, reducedValue >>= 8n) {
463
+ bytes[index] = Number(BigInt.asUintN(8, reducedValue));
846
464
  }
847
465
  return bytes;
848
466
  }
@@ -980,7 +598,7 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
980
598
  }
981
599
  };
982
600
 
983
- // src/reg_exp.ts
601
+ // src/reg-exp.ts
984
602
  var RegExpValidator = class {
985
603
  /**
986
604
  * Regular expression.
@@ -1012,8 +630,7 @@ var RegExpValidator = class {
1012
630
  * Error message.
1013
631
  */
1014
632
  createErrorMessage(s) {
1015
- return i18n_default.t("RegExpValidator.stringDoesNotMatchPattern", {
1016
- ns: utilityNS,
633
+ return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
1017
634
  s
1018
635
  });
1019
636
  }
@@ -1069,9 +686,8 @@ var RecordValidator = class {
1069
686
  * Record key.
1070
687
  */
1071
688
  validate(key) {
1072
- if (this.record[key] === void 0) {
1073
- throw new RangeError(i18n_default.t("RecordValidator.typeNameKeyNotFound", {
1074
- ns: utilityNS,
689
+ if (!(key in this.record)) {
690
+ throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
1075
691
  typeName: this.typeName,
1076
692
  key
1077
693
  }));
@@ -1079,7 +695,7 @@ var RecordValidator = class {
1079
695
  }
1080
696
  };
1081
697
 
1082
- // src/character_set.ts
698
+ // src/character-set.ts
1083
699
  var Exclusion = /* @__PURE__ */ ((Exclusion2) => {
1084
700
  Exclusion2[Exclusion2["None"] = 0] = "None";
1085
701
  Exclusion2[Exclusion2["FirstZero"] = 1] = "FirstZero";
@@ -1098,9 +714,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
1098
714
  * Error message.
1099
715
  */
1100
716
  createErrorMessage(_s) {
1101
- return i18n_default.t("CharacterSetValidator.stringMustNotBeAllNumeric", {
1102
- ns: utilityNS
1103
- });
717
+ return i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric");
1104
718
  }
1105
719
  }(/\D/);
1106
720
  /**
@@ -1210,8 +824,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
1210
824
  */
1211
825
  validateExclusion(exclusion) {
1212
826
  if (exclusion !== 0 /* None */ && !this._exclusionSupport.includes(exclusion)) {
1213
- throw new RangeError(i18n_default.t("CharacterSetValidator.exclusionNotSupported", {
1214
- ns: utilityNS,
827
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.exclusionNotSupported", {
1215
828
  exclusion
1216
829
  }));
1217
830
  }
@@ -1233,15 +846,13 @@ var CharacterSetValidator = class _CharacterSetValidator {
1233
846
  if (minimumLength !== void 0 && length < minimumLength) {
1234
847
  let errorMessage;
1235
848
  if (maximumLength !== void 0 && maximumLength === minimumLength) {
1236
- errorMessage = i18n_default.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
1237
- ns: utilityNS,
849
+ errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
1238
850
  component: _CharacterSetValidator.componentToString(validation?.component),
1239
851
  length,
1240
852
  exactLength: minimumLength
1241
853
  });
1242
854
  } else {
1243
- errorMessage = i18n_default.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
1244
- ns: utilityNS,
855
+ errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
1245
856
  component: _CharacterSetValidator.componentToString(validation?.component),
1246
857
  length,
1247
858
  minimumLength
@@ -1250,8 +861,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
1250
861
  throw new RangeError(errorMessage);
1251
862
  }
1252
863
  if (maximumLength !== void 0 && length > maximumLength) {
1253
- throw new RangeError(i18n_default.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
1254
- ns: utilityNS,
864
+ throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
1255
865
  component: _CharacterSetValidator.componentToString(validation?.component),
1256
866
  length,
1257
867
  maximumLength
@@ -1259,8 +869,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
1259
869
  }
1260
870
  const index = this.characterIndexes(s).findIndex((characterIndex) => characterIndex === void 0);
1261
871
  if (index !== -1) {
1262
- throw new RangeError(i18n_default.t(validation?.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
1263
- ns: utilityNS,
872
+ throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
1264
873
  component: _CharacterSetValidator.componentToString(validation?.component),
1265
874
  c: s.charAt(index),
1266
875
  position: index + (validation?.positionOffset ?? 0) + 1
@@ -1273,8 +882,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
1273
882
  break;
1274
883
  case 1 /* FirstZero */:
1275
884
  if (s.startsWith("0")) {
1276
- throw new RangeError(i18n_default.t(validation.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
1277
- ns: utilityNS,
885
+ throw new RangeError(i18nextUtility.t(validation.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
1278
886
  component: _CharacterSetValidator.componentToString(validation.component),
1279
887
  c: "0",
1280
888
  position: (validation.positionOffset ?? 0) + 1
@@ -1361,9 +969,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1361
969
  exclusionDomains[0 /* None */] = exclusionNoneDomains;
1362
970
  if (exclusionSupport.includes(1 /* FirstZero */)) {
1363
971
  if (characterSet[0] !== "0") {
1364
- throw new RangeError(i18n_default.t("CharacterSetValidator.firstZeroFirstCharacter", {
1365
- ns: utilityNS
1366
- }));
972
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.firstZeroFirstCharacter"));
1367
973
  }
1368
974
  const exclusionFirstZeroDomains = new Array(_CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
1369
975
  exclusionFirstZeroDomains[0] = 0n;
@@ -1377,9 +983,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1377
983
  let expectedNumberIndex = numberIndexes2[0];
1378
984
  for (const numberIndex of numberIndexes2) {
1379
985
  if (numberIndex === void 0 || numberIndex !== expectedNumberIndex) {
1380
- throw new RangeError(i18n_default.t("CharacterSetValidator.allNumericAllNumericCharacters", {
1381
- ns: utilityNS
1382
- }));
986
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.allNumericAllNumericCharacters"));
1383
987
  }
1384
988
  expectedNumberIndex = numberIndex + 1;
1385
989
  }
@@ -1434,9 +1038,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1434
1038
  let shift;
1435
1039
  if (length === 0) {
1436
1040
  if (!shiftForward && value < 10n) {
1437
- throw new RangeError(i18n_default.t("CharacterSetValidator.stringMustNotBeAllNumeric", {
1438
- ns: utilityNS
1439
- }));
1041
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric"));
1440
1042
  }
1441
1043
  shift = 10n;
1442
1044
  } else {
@@ -1460,15 +1062,13 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1460
1062
  */
1461
1063
  validateLength(length) {
1462
1064
  if (length < 0) {
1463
- throw new RangeError(i18n_default.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
1464
- ns: utilityNS,
1065
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
1465
1066
  length,
1466
1067
  minimumLength: 0
1467
1068
  }));
1468
1069
  }
1469
1070
  if (length > _CharacterSetCreator.MAXIMUM_STRING_LENGTH) {
1470
- throw new RangeError(i18n_default.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo", {
1471
- ns: utilityNS,
1071
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo", {
1472
1072
  length,
1473
1073
  maximumLength: _CharacterSetCreator.MAXIMUM_STRING_LENGTH
1474
1074
  }));
@@ -1516,7 +1116,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1516
1116
  }
1517
1117
  s = this.character(exclusion === 1 /* FirstZero */ ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
1518
1118
  }
1519
- return creatorCallback !== void 0 ? creatorCallback(s, index) : s;
1119
+ return creatorCallback === void 0 ? s : creatorCallback(s, index);
1520
1120
  });
1521
1121
  }
1522
1122
  /**
@@ -1542,8 +1142,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1542
1142
  const characterSetSizeN = BigInt(this.characterSetSize);
1543
1143
  let value = this.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
1544
1144
  if (characterIndex === void 0) {
1545
- throw new RangeError(i18n_default.t("CharacterSetValidator.invalidCharacterAtPosition", {
1546
- ns: utilityNS,
1145
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
1547
1146
  c: s.charAt(index),
1548
1147
  position: index + 1
1549
1148
  }));
@@ -1551,8 +1150,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
1551
1150
  let value2;
1552
1151
  if (index === 0 && exclusion === 1 /* FirstZero */) {
1553
1152
  if (characterIndex === 0) {
1554
- throw new RangeError(i18n_default.t("CharacterSetValidator.invalidCharacterAtPosition", {
1555
- ns: utilityNS,
1153
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
1556
1154
  c: "0",
1557
1155
  position: 1
1558
1156
  }));
@@ -1677,11 +1275,30 @@ export {
1677
1275
  Exclusion,
1678
1276
  HEXADECIMAL_CREATOR,
1679
1277
  IdentityTransformer,
1680
- IteratorProxy,
1681
1278
  NUMERIC_CREATOR,
1682
1279
  RecordValidator,
1683
1280
  RegExpValidator,
1684
- Sequencer,
1281
+ Sequence,
1685
1282
  Transformer,
1686
- utilityNS
1283
+ i18nUtilityInit,
1284
+ i18nextUtility,
1285
+ transformIterable,
1286
+ utilityNS,
1287
+ utilityResources
1687
1288
  };
1289
+ /*!
1290
+ * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
1291
+ * contributors
1292
+ *
1293
+ * Licensed under the Apache License, Version 2.0 (the "License");
1294
+ * you may not use this file except in compliance with the License.
1295
+ * You may obtain a copy of the License at
1296
+ *
1297
+ * https://www.apache.org/licenses/LICENSE-2.0
1298
+ *
1299
+ * Unless required by applicable law or agreed to in writing, software
1300
+ * distributed under the License is distributed on an "AS IS" BASIS,
1301
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1302
+ * See the License for the specific language governing permissions and
1303
+ * limitations under the License.
1304
+ */