@aidc-toolkit/gs1 0.9.10-beta → 0.9.12-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.cjs CHANGED
@@ -110,6 +110,7 @@ var localeStrings = {
110
110
  gs1CompanyPrefix: "GS1 Company Prefix",
111
111
  upcCompanyPrefix: "U.P.C. Company Prefix",
112
112
  gs18Prefix: "GS1-8 Prefix",
113
+ invalidPrefixType: "Invalid prefix type",
113
114
  gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
114
115
  gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
115
116
  gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
@@ -148,6 +149,7 @@ var localeStrings2 = {
148
149
  gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
149
150
  upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
150
151
  gs18Prefix: "Pr\xE9fixe GS1-8",
152
+ invalidPrefixType: "Type de pr\xE9fixe invalide",
151
153
  gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
152
154
  gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
153
155
  gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
@@ -725,7 +727,15 @@ var GTINLevel = /* @__PURE__ */ ((GTINLevel2) => {
725
727
  })(GTINLevel || {});
726
728
  var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKeyValidator {
727
729
  /**
728
- * Zero-suppressed GTIN-12 validation parameters.
730
+ * Validation parameters for optional indicator digit.
731
+ */
732
+ static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
733
+ minimumLength: 0,
734
+ maximumLength: 1,
735
+ component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
736
+ };
737
+ /**
738
+ * Validation parameters for zero-suppressed GTIN-12.
729
739
  */
730
740
  static ZERO_SUPPRESSED_GTIN12_VALIDATION = {
731
741
  minimumLength: 8,
@@ -766,6 +776,35 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
766
776
  validatePrefix(partialIdentificationKey, positionOffset) {
767
777
  PrefixManager.validatePrefix(this.prefixType, false, false, partialIdentificationKey, true, true, positionOffset);
768
778
  }
779
+ /**
780
+ * Zero suppress a GTIN-12.
781
+ *
782
+ * @param gtin12
783
+ * GTIN-12.
784
+ *
785
+ * @returns
786
+ * Zero-suppressed GTIN-12.
787
+ */
788
+ static zeroSuppress(gtin12) {
789
+ GTIN12_VALIDATOR.validate(gtin12);
790
+ const d = Array.from(gtin12);
791
+ let zeroSuppressedGTIN12;
792
+ if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
793
+ if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
794
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
795
+ } else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
796
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
797
+ } else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
798
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
799
+ } else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
800
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
801
+ }
802
+ }
803
+ if (zeroSuppressedGTIN12 === void 0) {
804
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
805
+ }
806
+ return zeroSuppressedGTIN12;
807
+ }
769
808
  /**
770
809
  * Zero expand a zero-suppressed GTIN-12.
771
810
  *
@@ -796,6 +835,86 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
796
835
  GTIN12_VALIDATOR.validate(gtin12);
797
836
  return gtin12;
798
837
  }
838
+ /**
839
+ * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
840
+ *
841
+ * @param indicatorDigit
842
+ * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
843
+ *
844
+ * @param gtin
845
+ * GTIN.
846
+ *
847
+ * @returns
848
+ * GTIN-14.
849
+ */
850
+ static convertToGTIN14(indicatorDigit, gtin) {
851
+ GTINCreator.validateAny(gtin);
852
+ import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINValidator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
853
+ const gtinLength = gtin.length;
854
+ let gtin14 = "0".repeat(14 /* GTIN14 */ - gtinLength) + gtin;
855
+ if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
856
+ const partialGTIN14 = indicatorDigit + gtin14.substring(1, 14 /* GTIN14 */ - 1);
857
+ gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
858
+ }
859
+ return gtin14;
860
+ }
861
+ /**
862
+ * Normalize a GTIN of any length.
863
+ * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
864
+ * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
865
+ * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
866
+ * - Otherwise, the GTIN is unchanged.
867
+ *
868
+ * @param gtin
869
+ * GTIN.
870
+ *
871
+ * @returns
872
+ * Normalized GTIN.
873
+ */
874
+ static normalize(gtin) {
875
+ const gtinLength = gtin.length;
876
+ let normalizedGTIN;
877
+ switch (gtinLength) {
878
+ case 13 /* GTIN13 */:
879
+ if (!gtin.startsWith("0")) {
880
+ normalizedGTIN = gtin;
881
+ } else if (!gtin.startsWith("00000")) {
882
+ normalizedGTIN = gtin.substring(1);
883
+ } else if (!gtin.startsWith("000000")) {
884
+ normalizedGTIN = gtin.substring(5);
885
+ } else {
886
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
887
+ }
888
+ break;
889
+ case 12 /* GTIN12 */:
890
+ normalizedGTIN = gtin;
891
+ break;
892
+ case 8 /* GTIN8 */:
893
+ if (!gtin.startsWith("0")) {
894
+ normalizedGTIN = gtin;
895
+ } else {
896
+ normalizedGTIN = _GTINValidator.zeroExpand(gtin);
897
+ }
898
+ break;
899
+ case 14 /* GTIN14 */:
900
+ if (!gtin.startsWith("0")) {
901
+ normalizedGTIN = gtin;
902
+ } else if (!gtin.startsWith("00")) {
903
+ normalizedGTIN = gtin.substring(1);
904
+ } else if (!gtin.startsWith("000000")) {
905
+ normalizedGTIN = gtin.substring(2);
906
+ } else if (!gtin.startsWith("0000000")) {
907
+ normalizedGTIN = gtin.substring(6);
908
+ } else {
909
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
910
+ }
911
+ break;
912
+ default:
913
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
914
+ }
915
+ GTINCreator.validateAny(normalizedGTIN);
916
+ return normalizedGTIN;
917
+ }
799
918
  /**
800
919
  * Validate any GTIN, optionally against a level.
801
920
  *
@@ -1205,14 +1324,6 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1205
1324
  maximumLength: 1,
1206
1325
  component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1207
1326
  };
1208
- /**
1209
- * Validation parameters for optional indicator digit.
1210
- */
1211
- static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
1212
- minimumLength: 0,
1213
- maximumLength: 1,
1214
- component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1215
- };
1216
1327
  /**
1217
1328
  * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
1218
1329
  *
@@ -1255,115 +1366,6 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1255
1366
  return partialIdentificationKey + checkDigit(partialIdentificationKey);
1256
1367
  });
1257
1368
  }
1258
- /**
1259
- * Zero suppress a GTIN-12.
1260
- *
1261
- * @param gtin12
1262
- * GTIN-12.
1263
- *
1264
- * @returns
1265
- * Zero-suppressed GTIN-12.
1266
- */
1267
- static zeroSuppress(gtin12) {
1268
- GTIN12_VALIDATOR.validate(gtin12);
1269
- const d = Array.from(gtin12);
1270
- let zeroSuppressedGTIN12;
1271
- if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
1272
- if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
1273
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
1274
- } else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
1275
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
1276
- } else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
1277
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
1278
- } else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
1279
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
1280
- }
1281
- }
1282
- if (zeroSuppressedGTIN12 === void 0) {
1283
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
1284
- }
1285
- return zeroSuppressedGTIN12;
1286
- }
1287
- /**
1288
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
1289
- *
1290
- * @param indicatorDigit
1291
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
1292
- *
1293
- * @param gtin
1294
- * GTIN.
1295
- *
1296
- * @returns
1297
- * GTIN-14.
1298
- */
1299
- static convertToGTIN14(indicatorDigit, gtin) {
1300
- _GTINCreator.validateAny(gtin);
1301
- import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
1302
- const gtinLength = gtin.length;
1303
- let gtin14 = "0".repeat(14 /* GTIN14 */ - gtinLength) + gtin;
1304
- if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
1305
- const partialGTIN14 = indicatorDigit + gtin14.substring(1, 14 /* GTIN14 */ - 1);
1306
- gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
1307
- }
1308
- return gtin14;
1309
- }
1310
- /**
1311
- * Normalize a GTIN of any length.
1312
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
1313
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
1314
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
1315
- * - Otherwise, the GTIN is unchanged.
1316
- *
1317
- * @param gtin
1318
- * GTIN.
1319
- *
1320
- * @returns
1321
- * Normalized GTIN.
1322
- */
1323
- static normalize(gtin) {
1324
- const gtinLength = gtin.length;
1325
- let normalizedGTIN;
1326
- switch (gtinLength) {
1327
- case 13 /* GTIN13 */:
1328
- if (!gtin.startsWith("0")) {
1329
- normalizedGTIN = gtin;
1330
- } else if (!gtin.startsWith("00000")) {
1331
- normalizedGTIN = gtin.substring(1);
1332
- } else if (!gtin.startsWith("000000")) {
1333
- normalizedGTIN = gtin.substring(5);
1334
- } else {
1335
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
1336
- }
1337
- break;
1338
- case 12 /* GTIN12 */:
1339
- normalizedGTIN = gtin;
1340
- break;
1341
- case 8 /* GTIN8 */:
1342
- if (!gtin.startsWith("0")) {
1343
- normalizedGTIN = gtin;
1344
- } else {
1345
- normalizedGTIN = _GTINCreator.zeroExpand(gtin);
1346
- }
1347
- break;
1348
- case 14 /* GTIN14 */:
1349
- if (!gtin.startsWith("0")) {
1350
- normalizedGTIN = gtin;
1351
- } else if (!gtin.startsWith("00")) {
1352
- normalizedGTIN = gtin.substring(1);
1353
- } else if (!gtin.startsWith("000000")) {
1354
- normalizedGTIN = gtin.substring(2);
1355
- } else if (!gtin.startsWith("0000000")) {
1356
- normalizedGTIN = gtin.substring(6);
1357
- } else {
1358
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
1359
- }
1360
- break;
1361
- default:
1362
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
1363
- }
1364
- _GTINCreator.validateAny(normalizedGTIN);
1365
- return normalizedGTIN;
1366
- }
1367
1369
  };
1368
1370
  var NonGTINNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(NonGTINNumericIdentificationKeyValidator, AbstractNumericIdentificationKeyCreator) {
1369
1371
  /**
@@ -1645,6 +1647,10 @@ var PrefixManager = class _PrefixManager {
1645
1647
  * GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix}.
1646
1648
  */
1647
1649
  _gs18Prefix;
1650
+ /**
1651
+ * Default tweak factor.
1652
+ */
1653
+ _defaultTweakFactor;
1648
1654
  /**
1649
1655
  * Tweak factor.
1650
1656
  */
@@ -1673,6 +1679,7 @@ var PrefixManager = class _PrefixManager {
1673
1679
  this._gs18Prefix = gs1CompanyPrefix.substring(5);
1674
1680
  this._prefix = this._gs18Prefix;
1675
1681
  }
1682
+ this._defaultTweakFactor = BigInt(`1${this.gs1CompanyPrefix}`);
1676
1683
  this.resetTweakFactor();
1677
1684
  }
1678
1685
  /**
@@ -1742,7 +1749,7 @@ var PrefixManager = class _PrefixManager {
1742
1749
  * Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
1743
1750
  */
1744
1751
  resetTweakFactor() {
1745
- this.tweakFactor = BigInt("1" + this.gs1CompanyPrefix);
1752
+ this.tweakFactor = this._defaultTweakFactor;
1746
1753
  }
1747
1754
  /**
1748
1755
  * Get a prefix manager.
@@ -1769,6 +1776,9 @@ var PrefixManager = class _PrefixManager {
1769
1776
  case 2 /* GS18Prefix */:
1770
1777
  gs1CompanyPrefix = "00000" + prefix;
1771
1778
  break;
1779
+ // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Method may be called by unsafe means.
1780
+ default:
1781
+ throw new RangeError(i18nextGS1.t("Prefix.invalidPrefixType"));
1772
1782
  }
1773
1783
  let prefixManager = _PrefixManager.PREFIX_MANAGERS_MAP.get(gs1CompanyPrefix);
1774
1784
  if (prefixManager === void 0) {
package/dist/index.d.cts CHANGED
@@ -31,6 +31,7 @@ declare const localeStrings: {
31
31
  readonly gs1CompanyPrefix: "GS1 Company Prefix";
32
32
  readonly upcCompanyPrefix: "U.P.C. Company Prefix";
33
33
  readonly gs18Prefix: "GS1-8 Prefix";
34
+ readonly invalidPrefixType: "Invalid prefix type";
34
35
  readonly gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"";
35
36
  readonly gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"";
36
37
  readonly gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"";
@@ -78,6 +79,7 @@ declare const gs1Resources: {
78
79
  readonly gs1CompanyPrefix: "GS1 Company Prefix";
79
80
  readonly upcCompanyPrefix: "U.P.C. Company Prefix";
80
81
  readonly gs18Prefix: "GS1-8 Prefix";
82
+ readonly invalidPrefixType: "Invalid prefix type";
81
83
  readonly gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"";
82
84
  readonly gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"";
83
85
  readonly gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"";
@@ -116,6 +118,7 @@ declare const gs1Resources: {
116
118
  readonly gs1CompanyPrefix: "Préfixe de l'entreprise GS1";
117
119
  readonly upcCompanyPrefix: "Préfixe de l'entreprise U.P.C.";
118
120
  readonly gs18Prefix: "Préfixe GS1-8";
121
+ readonly invalidPrefixType: "Type de préfixe invalide";
119
122
  readonly gs1CompanyPrefixCantStartWith0: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"0\"";
120
123
  readonly gs1CompanyPrefixCantStartWith00000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"00000\"";
121
124
  readonly gs1CompanyPrefixCantStartWith000000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"000000\"";
@@ -333,7 +336,7 @@ interface IdentificationKeyValidation extends StringValidation {
333
336
  * Identification key validator. Validates an identification key against its definition in section 3 of the {@link
334
337
  * https://www.gs1.org/genspecs | GS1 General Specifications}.
335
338
  */
336
- interface IdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<V> {
339
+ interface IdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<TIdentificationKeyValidation> {
337
340
  /**
338
341
  * Get the identification key type. Per the GS1 General Specifications, the identification key type determines
339
342
  * the remaining properties.
@@ -366,12 +369,12 @@ interface IdentificationKeyValidator<V extends IdentificationKeyValidation = Ide
366
369
  * @param validation
367
370
  * Identification key validation parameters.
368
371
  */
369
- validate: (identificationKey: string, validation?: V) => void;
372
+ validate: (identificationKey: string, validation?: TIdentificationKeyValidation) => void;
370
373
  }
371
374
  /**
372
375
  * Abstract identification key validator. Implements common functionality for an identification key validator.
373
376
  */
374
- declare abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<V> {
377
+ declare abstract class AbstractIdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<TIdentificationKeyValidation> {
375
378
  private static readonly CHARACTER_SET_CREATORS;
376
379
  /**
377
380
  * Identification key type.
@@ -463,7 +466,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
463
466
  * Position offset within a larger string.
464
467
  */
465
468
  protected validatePrefix(partialIdentificationKey: string, positionOffset?: number): void;
466
- abstract validate(identificationKey: string, validation?: V): void;
469
+ abstract validate(identificationKey: string, validation?: TIdentificationKeyValidation): void;
467
470
  }
468
471
  /**
469
472
  * Leader type.
@@ -572,7 +575,11 @@ declare enum GTINLevel {
572
575
  */
573
576
  declare class GTINValidator extends AbstractNumericIdentificationKeyValidator {
574
577
  /**
575
- * Zero-suppressed GTIN-12 validation parameters.
578
+ * Validation parameters for optional indicator digit.
579
+ */
580
+ private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
581
+ /**
582
+ * Validation parameters for zero-suppressed GTIN-12.
576
583
  */
577
584
  private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION;
578
585
  /**
@@ -590,6 +597,16 @@ declare class GTINValidator extends AbstractNumericIdentificationKeyValidator {
590
597
  * @inheritDoc
591
598
  */
592
599
  protected validatePrefix(partialIdentificationKey: string, positionOffset?: number): void;
600
+ /**
601
+ * Zero suppress a GTIN-12.
602
+ *
603
+ * @param gtin12
604
+ * GTIN-12.
605
+ *
606
+ * @returns
607
+ * Zero-suppressed GTIN-12.
608
+ */
609
+ static zeroSuppress(gtin12: string): string;
593
610
  /**
594
611
  * Zero expand a zero-suppressed GTIN-12.
595
612
  *
@@ -600,6 +617,33 @@ declare class GTINValidator extends AbstractNumericIdentificationKeyValidator {
600
617
  * GTIN-12.
601
618
  */
602
619
  static zeroExpand(zeroSuppressedGTIN12: string): string;
620
+ /**
621
+ * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
622
+ *
623
+ * @param indicatorDigit
624
+ * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
625
+ *
626
+ * @param gtin
627
+ * GTIN.
628
+ *
629
+ * @returns
630
+ * GTIN-14.
631
+ */
632
+ static convertToGTIN14(indicatorDigit: string, gtin: string): string;
633
+ /**
634
+ * Normalize a GTIN of any length.
635
+ * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
636
+ * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
637
+ * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
638
+ * - Otherwise, the GTIN is unchanged.
639
+ *
640
+ * @param gtin
641
+ * GTIN.
642
+ *
643
+ * @returns
644
+ * Normalized GTIN.
645
+ */
646
+ static normalize(gtin: string): string;
603
647
  /**
604
648
  * Validate any GTIN, optionally against a level.
605
649
  *
@@ -895,7 +939,7 @@ interface NumericIdentificationKeyCreator extends NumericIdentificationKeyValida
895
939
  * @returns
896
940
  * Identification key(s).
897
941
  */
898
- create: <T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse?: boolean) => TransformerOutput<T, string>;
942
+ create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
899
943
  /**
900
944
  * Create all identification keys for the prefix from `0` to `capacity - 1`.
901
945
  *
@@ -956,7 +1000,7 @@ declare abstract class AbstractNumericIdentificationKeyCreator extends AbstractI
956
1000
  /**
957
1001
  * @inheritDoc
958
1002
  */
959
- create<T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse?: boolean): TransformerOutput<T, string>;
1003
+ create<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
960
1004
  /**
961
1005
  * Create all identification keys from a partial identification key. Call is recursive until remaining reference
962
1006
  * length is 0.
@@ -995,10 +1039,6 @@ declare class GTINCreator extends GTINCreator_base {
995
1039
  * Validation parameters for required indicator digit.
996
1040
  */
997
1041
  private static readonly REQUIRED_INDICATOR_DIGIT_VALIDATION;
998
- /**
999
- * Validation parameters for optional indicator digit.
1000
- */
1001
- private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
1002
1042
  /**
1003
1043
  * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
1004
1044
  *
@@ -1029,44 +1069,7 @@ declare class GTINCreator extends GTINCreator_base {
1029
1069
  * @returns
1030
1070
  * GTIN-14(s).
1031
1071
  */
1032
- createGTIN14<T extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: T, sparse?: boolean): TransformerOutput<T, string>;
1033
- /**
1034
- * Zero suppress a GTIN-12.
1035
- *
1036
- * @param gtin12
1037
- * GTIN-12.
1038
- *
1039
- * @returns
1040
- * Zero-suppressed GTIN-12.
1041
- */
1042
- static zeroSuppress(gtin12: string): string;
1043
- /**
1044
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
1045
- *
1046
- * @param indicatorDigit
1047
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
1048
- *
1049
- * @param gtin
1050
- * GTIN.
1051
- *
1052
- * @returns
1053
- * GTIN-14.
1054
- */
1055
- static convertToGTIN14(indicatorDigit: string, gtin: string): string;
1056
- /**
1057
- * Normalize a GTIN of any length.
1058
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
1059
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
1060
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
1061
- * - Otherwise, the GTIN is unchanged.
1062
- *
1063
- * @param gtin
1064
- * GTIN.
1065
- *
1066
- * @returns
1067
- * Normalized GTIN.
1068
- */
1069
- static normalize(gtin: string): string;
1072
+ createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1070
1073
  }
1071
1074
  declare const NonGTINNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], NonGTINNumericIdentificationKeyValidator & AbstractNumericIdentificationKeyCreator, typeof NonGTINNumericIdentificationKeyValidator & typeof AbstractNumericIdentificationKeyCreator>;
1072
1075
  /**
@@ -1145,7 +1148,7 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
1145
1148
  * @returns
1146
1149
  * Serialized identification keys.
1147
1150
  */
1148
- createSerialized<T extends TransformerInput<string>>(value: number, serialComponentOrComponents: T, sparse?: boolean): TransformerOutput<T, string>;
1151
+ createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1149
1152
  /**
1150
1153
  * Concatenate a base identification key with serial component(s).
1151
1154
  *
@@ -1158,7 +1161,7 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
1158
1161
  * @returns
1159
1162
  * Serialized identification key(s).
1160
1163
  */
1161
- concatenate<T extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: T): TransformerOutput<T, string>;
1164
+ concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1162
1165
  }
1163
1166
  declare const NonNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], NonNumericIdentificationKeyValidator & AbstractIdentificationKeyCreator, typeof NonNumericIdentificationKeyValidator & typeof AbstractIdentificationKeyCreator>;
1164
1167
  /**
@@ -1202,7 +1205,7 @@ declare class NonNumericIdentificationKeyCreator extends NonNumericIdentificatio
1202
1205
  * @returns
1203
1206
  * Identification key(s).
1204
1207
  */
1205
- create<T extends TransformerInput<string>>(referenceOrReferences: T): TransformerOutput<T, string>;
1208
+ create<TTransformerInput extends TransformerInput<string>>(referenceOrReferences: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1206
1209
  }
1207
1210
  /**
1208
1211
  * Prefix manager. This is the core class for identification key creation.
@@ -1299,6 +1302,10 @@ declare class PrefixManager {
1299
1302
  * GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix}.
1300
1303
  */
1301
1304
  private readonly _gs18Prefix;
1305
+ /**
1306
+ * Default tweak factor.
1307
+ */
1308
+ private readonly _defaultTweakFactor;
1302
1309
  /**
1303
1310
  * Tweak factor.
1304
1311
  */