@aidc-toolkit/gs1 0.9.11-beta → 0.9.13-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
@@ -1,2044 +1,4 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- AI39_CREATOR: () => AI39_CREATOR,
34
- AI82_CREATOR: () => AI82_CREATOR,
35
- CPID_VALIDATOR: () => CPID_VALIDATOR,
36
- ContentCharacterSet: () => ContentCharacterSet,
37
- GCN_VALIDATOR: () => GCN_VALIDATOR,
38
- GDTI_VALIDATOR: () => GDTI_VALIDATOR,
39
- GIAI_VALIDATOR: () => GIAI_VALIDATOR,
40
- GINC_VALIDATOR: () => GINC_VALIDATOR,
41
- GLN_VALIDATOR: () => GLN_VALIDATOR,
42
- GMN_VALIDATOR: () => GMN_VALIDATOR,
43
- GRAI_VALIDATOR: () => GRAI_VALIDATOR,
44
- GSIN_VALIDATOR: () => GSIN_VALIDATOR,
45
- GSRN_VALIDATOR: () => GSRN_VALIDATOR,
46
- GTIN12_VALIDATOR: () => GTIN12_VALIDATOR,
47
- GTIN13_VALIDATOR: () => GTIN13_VALIDATOR,
48
- GTIN8_VALIDATOR: () => GTIN8_VALIDATOR,
49
- GTINCreator: () => GTINCreator,
50
- GTINLevel: () => GTINLevel,
51
- GTINType: () => GTINType,
52
- GTINValidator: () => GTINValidator,
53
- GTIN_VALIDATORS: () => GTIN_VALIDATORS,
54
- IdentificationKeyType: () => IdentificationKeyType,
55
- LeaderType: () => LeaderType,
56
- NonGTINNumericIdentificationKeyCreator: () => NonGTINNumericIdentificationKeyCreator,
57
- NonGTINNumericIdentificationKeyValidator: () => NonGTINNumericIdentificationKeyValidator,
58
- NonNumericIdentificationKeyCreator: () => NonNumericIdentificationKeyCreator,
59
- NonNumericIdentificationKeyValidator: () => NonNumericIdentificationKeyValidator,
60
- PrefixManager: () => PrefixManager,
61
- PrefixType: () => PrefixType,
62
- SSCC_VALIDATOR: () => SSCC_VALIDATOR,
63
- SerializableNumericIdentificationKeyCreator: () => SerializableNumericIdentificationKeyCreator,
64
- SerializableNumericIdentificationKeyValidator: () => SerializableNumericIdentificationKeyValidator,
65
- checkCharacterPair: () => checkCharacterPair,
66
- checkDigit: () => checkDigit,
67
- checkDigitSum: () => checkDigitSum,
68
- fiveDigitPriceWeightCheckDigit: () => fiveDigitPriceWeightCheckDigit,
69
- fourDigitPriceWeightCheckDigit: () => fourDigitPriceWeightCheckDigit,
70
- gs1NS: () => gs1NS,
71
- gs1Resources: () => gs1Resources,
72
- hasValidCheckCharacterPair: () => hasValidCheckCharacterPair,
73
- hasValidCheckDigit: () => hasValidCheckDigit,
74
- i18nGS1Init: () => i18nGS1Init,
75
- i18nextGS1: () => i18nextGS1
76
- });
77
- module.exports = __toCommonJS(index_exports);
78
-
79
- // src/locale/i18n.ts
80
- var import_core = require("@aidc-toolkit/core");
81
- var import_utility = require("@aidc-toolkit/utility");
82
- var import_i18next = __toESM(require("i18next"), 1);
83
-
84
- // src/locale/en/locale-strings.ts
85
- var localeStrings = {
86
- Check: {
87
- lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",
88
- priceOrWeightComponent: "price or weight",
89
- lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
90
- },
91
- IdentificationKey: {
92
- identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
93
- invalidCheckDigit: "Invalid check digit",
94
- invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
95
- invalidGTIN14Length: "GTIN must be 14 digits long",
96
- invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
97
- invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
98
- invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
99
- invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
100
- invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
101
- invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
102
- invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
103
- indicatorDigit: "indicator digit",
104
- serialComponent: "serial component",
105
- reference: "reference",
106
- referenceCantBeAllNumeric: "Reference can't be all-numeric",
107
- invalidCheckCharacterPair: "Invalid check character pair"
108
- },
109
- Prefix: {
110
- gs1CompanyPrefix: "GS1 Company Prefix",
111
- upcCompanyPrefix: "U.P.C. Company Prefix",
112
- gs18Prefix: "GS1-8 Prefix",
113
- gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
114
- gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
115
- gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
116
- upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
117
- gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
118
- identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
119
- }
120
- };
121
-
122
- // src/locale/fr/locale-strings.ts
123
- var localeStrings2 = {
124
- Check: {
125
- lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{longueur}} de la cha\xEEne pour le prix ou la somme du poids doit \xEAtre exactement {{exactLength}}",
126
- priceOrWeightComponent: "prix ou poids",
127
- lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la cha\xEEne pour la paire de caract\xE8res de v\xE9rification doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximum Length}}"
128
- },
129
- IdentificationKey: {
130
- identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
131
- invalidCheckDigit: "Chiffre de contr\xF4le non valide",
132
- invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
133
- invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
134
- invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
135
- invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
136
- invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
137
- invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
138
- invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
139
- invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
140
- invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
141
- indicatorDigit: "chiffre indicateur",
142
- serialComponent: "composant s\xE9rie",
143
- reference: "r\xE9f\xE9rence",
144
- referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
145
- invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
146
- },
147
- Prefix: {
148
- gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
149
- upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
150
- gs18Prefix: "Pr\xE9fixe GS1-8",
151
- gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
152
- gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
153
- gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
154
- upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
155
- gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
156
- identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
157
- }
158
- };
159
-
160
- // src/locale/i18n.ts
161
- var gs1NS = "aidct_gs1";
162
- (0, import_core.i18nAssertValidResources)(localeStrings, "fr", localeStrings2);
163
- var gs1Resources = {
164
- en: {
165
- aidct_gs1: localeStrings
166
- },
167
- fr: {
168
- aidct_gs1: localeStrings2
169
- }
170
- };
171
- var i18nextGS1 = import_i18next.default.createInstance();
172
- async function i18nGS1Init(environment, debug = false) {
173
- await (0, import_utility.i18nUtilityInit)(environment, debug);
174
- await (0, import_core.i18nCoreInit)(i18nextGS1, environment, debug, gs1NS, import_utility.utilityResources, gs1Resources);
175
- }
176
-
177
- // src/character-set.ts
178
- var import_utility2 = require("@aidc-toolkit/utility");
179
- var AI82_CREATOR = new import_utility2.CharacterSetCreator([
180
- "!",
181
- '"',
182
- "%",
183
- "&",
184
- "'",
185
- "(",
186
- ")",
187
- "*",
188
- "+",
189
- ",",
190
- "-",
191
- ".",
192
- "/",
193
- "0",
194
- "1",
195
- "2",
196
- "3",
197
- "4",
198
- "5",
199
- "6",
200
- "7",
201
- "8",
202
- "9",
203
- ":",
204
- ";",
205
- "<",
206
- "=",
207
- ">",
208
- "?",
209
- "A",
210
- "B",
211
- "C",
212
- "D",
213
- "E",
214
- "F",
215
- "G",
216
- "H",
217
- "I",
218
- "J",
219
- "K",
220
- "L",
221
- "M",
222
- "N",
223
- "O",
224
- "P",
225
- "Q",
226
- "R",
227
- "S",
228
- "T",
229
- "U",
230
- "V",
231
- "W",
232
- "X",
233
- "Y",
234
- "Z",
235
- "_",
236
- "a",
237
- "b",
238
- "c",
239
- "d",
240
- "e",
241
- "f",
242
- "g",
243
- "h",
244
- "i",
245
- "j",
246
- "k",
247
- "l",
248
- "m",
249
- "n",
250
- "o",
251
- "p",
252
- "q",
253
- "r",
254
- "s",
255
- "t",
256
- "u",
257
- "v",
258
- "w",
259
- "x",
260
- "y",
261
- "z"
262
- ], import_utility2.Exclusion.AllNumeric);
263
- var AI39_CREATOR = new import_utility2.CharacterSetCreator([
264
- "#",
265
- "-",
266
- "/",
267
- "0",
268
- "1",
269
- "2",
270
- "3",
271
- "4",
272
- "5",
273
- "6",
274
- "7",
275
- "8",
276
- "9",
277
- "A",
278
- "B",
279
- "C",
280
- "D",
281
- "E",
282
- "F",
283
- "G",
284
- "H",
285
- "I",
286
- "J",
287
- "K",
288
- "L",
289
- "M",
290
- "N",
291
- "O",
292
- "P",
293
- "Q",
294
- "R",
295
- "S",
296
- "T",
297
- "U",
298
- "V",
299
- "W",
300
- "X",
301
- "Y",
302
- "Z"
303
- ], import_utility2.Exclusion.AllNumeric);
304
-
305
- // src/check.ts
306
- var import_utility3 = require("@aidc-toolkit/utility");
307
- var THREE_WEIGHT_RESULTS = [
308
- 0,
309
- 3,
310
- 6,
311
- 9,
312
- 12,
313
- 15,
314
- 18,
315
- 21,
316
- 24,
317
- 27
318
- ];
319
- var TWO_MINUS_WEIGHT_RESULTS = [
320
- 0,
321
- 2,
322
- 4,
323
- 6,
324
- 8,
325
- 9,
326
- 1,
327
- 3,
328
- 5,
329
- 7
330
- ];
331
- var FIVE_PLUS_WEIGHT_RESULTS = [
332
- 0,
333
- 5,
334
- 1,
335
- 6,
336
- 2,
337
- 7,
338
- 3,
339
- 8,
340
- 4,
341
- 9
342
- ];
343
- var FIVE_MINUS_WEIGHT_RESULTS = [
344
- 0,
345
- 5,
346
- 9,
347
- 4,
348
- 8,
349
- 3,
350
- 7,
351
- 2,
352
- 6,
353
- 1
354
- ];
355
- var INVERSE_FIVE_MINUS_WEIGHT_RESULTS = [
356
- 0,
357
- 9,
358
- 7,
359
- 5,
360
- 3,
361
- 1,
362
- 8,
363
- 6,
364
- 4,
365
- 2
366
- ];
367
- function checkDigitSum(exchangeWeights, s) {
368
- let weight3 = (s.length + Number(exchangeWeights)) % 2 === 0;
369
- return import_utility3.NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
370
- if (characterIndex === void 0) {
371
- throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
372
- ns: import_utility3.utilityNS,
373
- c: s.charAt(index),
374
- position: index + 1
375
- }));
376
- }
377
- weight3 = !weight3;
378
- return accumulator + (weight3 ? THREE_WEIGHT_RESULTS[characterIndex] : characterIndex);
379
- }, 0);
380
- }
381
- function checkDigit(s) {
382
- return import_utility3.NUMERIC_CREATOR.character(9 - (checkDigitSum(false, s) + 9) % 10);
383
- }
384
- function hasValidCheckDigit(s) {
385
- return checkDigitSum(true, s) % 10 === 0;
386
- }
387
- function priceWeightSum(weightsResults, s) {
388
- if (s.length !== weightsResults.length) {
389
- throw new RangeError(i18nextGS1.t("Check.lengthOfStringForPriceOrWeightMustBeExactly", {
390
- length: s.length,
391
- exactLength: weightsResults.length
392
- }));
393
- }
394
- const characterIndexes = import_utility3.NUMERIC_CREATOR.characterIndexes(s);
395
- return characterIndexes.reduce((accumulator, characterIndex, index) => {
396
- if (characterIndex === void 0) {
397
- throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
398
- ns: import_utility3.utilityNS,
399
- c: s.charAt(index),
400
- position: index + 1,
401
- component: i18nextGS1.t("Check.priceOrWeightComponent")
402
- }));
403
- }
404
- return accumulator + weightsResults[index][characterIndex];
405
- }, 0);
406
- }
407
- function fourDigitPriceWeightCheckDigit(s) {
408
- return import_utility3.NUMERIC_CREATOR.character(priceWeightSum([TWO_MINUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, THREE_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS], s) * 3 % 10);
409
- }
410
- function fiveDigitPriceWeightCheckDigit(s) {
411
- return import_utility3.NUMERIC_CREATOR.character(INVERSE_FIVE_MINUS_WEIGHT_RESULTS[9 - (priceWeightSum([FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS, FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS], s) + 9) % 10]);
412
- }
413
- var CHECK_CHARACTER_WEIGHTS = [
414
- 107,
415
- 103,
416
- 101,
417
- 97,
418
- 89,
419
- 83,
420
- 79,
421
- 73,
422
- 71,
423
- 67,
424
- 61,
425
- 59,
426
- 53,
427
- 47,
428
- 43,
429
- 41,
430
- 37,
431
- 31,
432
- 29,
433
- 23,
434
- 19,
435
- 17,
436
- 13,
437
- 11,
438
- 7,
439
- 5,
440
- 3,
441
- 2
442
- ];
443
- var CHECK_CHARACTERS = [
444
- "2",
445
- "3",
446
- "4",
447
- "5",
448
- "6",
449
- "7",
450
- "8",
451
- "9",
452
- "A",
453
- "B",
454
- "C",
455
- "D",
456
- "E",
457
- "F",
458
- "G",
459
- "H",
460
- "J",
461
- "K",
462
- "L",
463
- "M",
464
- "N",
465
- "P",
466
- "Q",
467
- "R",
468
- "S",
469
- "T",
470
- "U",
471
- "V",
472
- "W",
473
- "X",
474
- "Y",
475
- "Z"
476
- ];
477
- function checkCharacterPair(s) {
478
- const weightIndexStart = CHECK_CHARACTER_WEIGHTS.length - s.length;
479
- if (weightIndexStart < 0) {
480
- throw new RangeError(i18nextGS1.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo", {
481
- length: s.length,
482
- maximumLength: CHECK_CHARACTER_WEIGHTS.length
483
- }));
484
- }
485
- const checkCharacterPairSum = AI82_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
486
- if (characterIndex === void 0) {
487
- throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
488
- ns: import_utility3.utilityNS,
489
- c: s.charAt(index),
490
- position: index + 1
491
- }));
492
- }
493
- return accumulator + characterIndex * CHECK_CHARACTER_WEIGHTS[weightIndexStart + index];
494
- }, 0) % 1021;
495
- const checkCharacterPairSumMod32 = checkCharacterPairSum % 32;
496
- return CHECK_CHARACTERS[(checkCharacterPairSum - checkCharacterPairSumMod32) / 32] + CHECK_CHARACTERS[checkCharacterPairSumMod32];
497
- }
498
- function hasValidCheckCharacterPair(s) {
499
- const checkCharacterPairIndex = s.length - 2;
500
- return checkCharacterPair(s.substring(0, checkCharacterPairIndex)) === s.substring(checkCharacterPairIndex);
501
- }
502
-
503
- // src/idkey.ts
504
- var import_utility4 = require("@aidc-toolkit/utility");
505
- var import_ts_mixer = require("ts-mixer");
506
- var IdentificationKeyType = /* @__PURE__ */ ((IdentificationKeyType2) => {
507
- IdentificationKeyType2["GTIN"] = "GTIN";
508
- IdentificationKeyType2["GLN"] = "GLN";
509
- IdentificationKeyType2["SSCC"] = "SSCC";
510
- IdentificationKeyType2["GRAI"] = "GRAI";
511
- IdentificationKeyType2["GIAI"] = "GIAI";
512
- IdentificationKeyType2["GSRN"] = "GSRN";
513
- IdentificationKeyType2["GDTI"] = "GDTI";
514
- IdentificationKeyType2["GINC"] = "GINC";
515
- IdentificationKeyType2["GSIN"] = "GSIN";
516
- IdentificationKeyType2["GCN"] = "GCN";
517
- IdentificationKeyType2["CPID"] = "CPID";
518
- IdentificationKeyType2["GMN"] = "GMN";
519
- return IdentificationKeyType2;
520
- })(IdentificationKeyType || {});
521
- var PrefixType = /* @__PURE__ */ ((PrefixType2) => {
522
- PrefixType2[PrefixType2["GS1CompanyPrefix"] = 0] = "GS1CompanyPrefix";
523
- PrefixType2[PrefixType2["UPCCompanyPrefix"] = 1] = "UPCCompanyPrefix";
524
- PrefixType2[PrefixType2["GS18Prefix"] = 2] = "GS18Prefix";
525
- return PrefixType2;
526
- })(PrefixType || {});
527
- var ContentCharacterSet = /* @__PURE__ */ ((ContentCharacterSet2) => {
528
- ContentCharacterSet2[ContentCharacterSet2["Numeric"] = 0] = "Numeric";
529
- ContentCharacterSet2[ContentCharacterSet2["AI82"] = 1] = "AI82";
530
- ContentCharacterSet2[ContentCharacterSet2["AI39"] = 2] = "AI39";
531
- return ContentCharacterSet2;
532
- })(ContentCharacterSet || {});
533
- var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidator {
534
- static CHARACTER_SET_CREATORS = [
535
- import_utility4.NUMERIC_CREATOR,
536
- AI82_CREATOR,
537
- AI39_CREATOR
538
- ];
539
- /**
540
- * Identification key type.
541
- */
542
- _identificationKeyType;
543
- /**
544
- * Prefix type.
545
- */
546
- _prefixType;
547
- /**
548
- * Length.
549
- */
550
- _length;
551
- /**
552
- * Reference character set.
553
- */
554
- _referenceCharacterSet;
555
- /**
556
- * Reference creator.
557
- */
558
- _referenceCreator;
559
- /**
560
- * Get the character set creator for a character set.
561
- *
562
- * @param characterSet
563
- * Character set.
564
- *
565
- * @returns
566
- * Character set creator.
567
- */
568
- static creatorFor(characterSet) {
569
- return _AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
570
- }
571
- /**
572
- * Constructor.
573
- *
574
- * @param identificationKeyType
575
- * Identification key type.
576
- *
577
- * @param prefixType
578
- * Prefix type.
579
- *
580
- * @param length
581
- * Length.
582
- *
583
- * @param referenceCharacterSet
584
- * Reference character set.
585
- */
586
- constructor(identificationKeyType, prefixType, length, referenceCharacterSet) {
587
- this._identificationKeyType = identificationKeyType;
588
- this._prefixType = prefixType;
589
- this._length = length;
590
- this._referenceCharacterSet = referenceCharacterSet;
591
- this._referenceCreator = _AbstractIdentificationKeyValidator.creatorFor(referenceCharacterSet);
592
- }
593
- /**
594
- * @inheritDoc
595
- */
596
- get identificationKeyType() {
597
- return this._identificationKeyType;
598
- }
599
- /**
600
- * @inheritDoc
601
- */
602
- get prefixType() {
603
- return this._prefixType;
604
- }
605
- /**
606
- * @inheritDoc
607
- */
608
- get length() {
609
- return this._length;
610
- }
611
- /**
612
- * @inheritDoc
613
- */
614
- get referenceCharacterSet() {
615
- return this._referenceCharacterSet;
616
- }
617
- /**
618
- * @inheritDoc
619
- */
620
- get referenceCreator() {
621
- return this._referenceCreator;
622
- }
623
- /**
624
- * Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
625
- * identification key with a position offset for any error message that may be thrown by the reference validator.
626
- *
627
- * @param identificationKey
628
- * Identification key.
629
- *
630
- * @param validation
631
- * Identification key validation parameters.
632
- *
633
- * @returns
634
- * Padded identification key.
635
- */
636
- padIdentificationKey(identificationKey, validation) {
637
- return validation?.positionOffset === void 0 ? identificationKey : this.referenceCreator.character(0).repeat(validation.positionOffset).concat(identificationKey);
638
- }
639
- /**
640
- * Validate the prefix within an identification key.
641
- *
642
- * @param partialIdentificationKey
643
- * Partial identification key.
644
- *
645
- * @param positionOffset
646
- * Position offset within a larger string.
647
- */
648
- validatePrefix(partialIdentificationKey, positionOffset) {
649
- PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet === 0 /* Numeric */, positionOffset);
650
- }
651
- };
652
- var LeaderType = /* @__PURE__ */ ((LeaderType2) => {
653
- LeaderType2[LeaderType2["None"] = 0] = "None";
654
- LeaderType2[LeaderType2["IndicatorDigit"] = 1] = "IndicatorDigit";
655
- LeaderType2[LeaderType2["ExtensionDigit"] = 2] = "ExtensionDigit";
656
- return LeaderType2;
657
- })(LeaderType || {});
658
- var AbstractNumericIdentificationKeyValidator = class extends AbstractIdentificationKeyValidator {
659
- /**
660
- * Leader type.
661
- */
662
- _leaderType;
663
- /**
664
- * Prefix position, determined by the leader type.
665
- */
666
- _prefixPosition;
667
- /**
668
- * Constructor.
669
- *
670
- * @param identificationKeyType
671
- * Identification key type.
672
- *
673
- * @param prefixType
674
- * Prefix type.
675
- *
676
- * @param length
677
- * Length.
678
- *
679
- * @param leaderType
680
- * Leader type.
681
- */
682
- constructor(identificationKeyType, prefixType, length, leaderType) {
683
- super(identificationKeyType, prefixType, length, 0 /* Numeric */);
684
- this._leaderType = leaderType;
685
- this._prefixPosition = Number(this.leaderType === 2 /* ExtensionDigit */);
686
- }
687
- /**
688
- * @inheritDoc
689
- */
690
- get leaderType() {
691
- return this._leaderType;
692
- }
693
- /**
694
- * @inheritDoc
695
- */
696
- validate(identificationKey, validation) {
697
- if (this._prefixPosition === 0) {
698
- super.validatePrefix(identificationKey, validation?.positionOffset);
699
- } else {
700
- super.validatePrefix(identificationKey.substring(this._prefixPosition), validation?.positionOffset === void 0 ? this._prefixPosition : validation.positionOffset + this._prefixPosition);
701
- }
702
- if (identificationKey.length !== this.length) {
703
- throw new RangeError(i18nextGS1.t("IdentificationKey.identificationKeyTypeLength", {
704
- identificationKeyType: this.identificationKeyType,
705
- length: this.length
706
- }));
707
- }
708
- if (!hasValidCheckDigit(this.padIdentificationKey(identificationKey, validation))) {
709
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
710
- }
711
- }
712
- };
713
- var GTINType = /* @__PURE__ */ ((GTINType2) => {
714
- GTINType2[GTINType2["GTIN13"] = 13] = "GTIN13";
715
- GTINType2[GTINType2["GTIN12"] = 12] = "GTIN12";
716
- GTINType2[GTINType2["GTIN8"] = 8] = "GTIN8";
717
- GTINType2[GTINType2["GTIN14"] = 14] = "GTIN14";
718
- return GTINType2;
719
- })(GTINType || {});
720
- var GTINLevel = /* @__PURE__ */ ((GTINLevel2) => {
721
- GTINLevel2[GTINLevel2["Any"] = 0] = "Any";
722
- GTINLevel2[GTINLevel2["RetailConsumer"] = 1] = "RetailConsumer";
723
- GTINLevel2[GTINLevel2["OtherThanRetailConsumer"] = 2] = "OtherThanRetailConsumer";
724
- return GTINLevel2;
725
- })(GTINLevel || {});
726
- var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKeyValidator {
727
- /**
728
- * Validation parameters for optional indicator digit.
729
- */
730
- static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
731
- minimumLength: 0,
732
- maximumLength: 1,
733
- component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
734
- };
735
- /**
736
- * Validation parameters for zero-suppressed GTIN-12.
737
- */
738
- static ZERO_SUPPRESSED_GTIN12_VALIDATION = {
739
- minimumLength: 8,
740
- maximumLength: 8
741
- };
742
- /**
743
- * Constructor.
744
- *
745
- * @param gtinType
746
- * GTIN type.
747
- */
748
- constructor(gtinType) {
749
- let prefixType;
750
- switch (gtinType) {
751
- case 13 /* GTIN13 */:
752
- prefixType = 0 /* GS1CompanyPrefix */;
753
- break;
754
- case 12 /* GTIN12 */:
755
- prefixType = 1 /* UPCCompanyPrefix */;
756
- break;
757
- case 8 /* GTIN8 */:
758
- prefixType = 2 /* GS18Prefix */;
759
- break;
760
- default:
761
- throw new Error("Not supported");
762
- }
763
- super("GTIN" /* GTIN */, prefixType, gtinType, 1 /* IndicatorDigit */);
764
- }
765
- /**
766
- * @inheritDoc
767
- */
768
- get gtinType() {
769
- return this.length;
770
- }
771
- /**
772
- * @inheritDoc
773
- */
774
- validatePrefix(partialIdentificationKey, positionOffset) {
775
- PrefixManager.validatePrefix(this.prefixType, false, false, partialIdentificationKey, true, true, positionOffset);
776
- }
777
- /**
778
- * Zero suppress a GTIN-12.
779
- *
780
- * @param gtin12
781
- * GTIN-12.
782
- *
783
- * @returns
784
- * Zero-suppressed GTIN-12.
785
- */
786
- static zeroSuppress(gtin12) {
787
- GTIN12_VALIDATOR.validate(gtin12);
788
- const d = Array.from(gtin12);
789
- let zeroSuppressedGTIN12;
790
- if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
791
- if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
792
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
793
- } else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
794
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
795
- } else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
796
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
797
- } else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
798
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
799
- }
800
- }
801
- if (zeroSuppressedGTIN12 === void 0) {
802
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
803
- }
804
- return zeroSuppressedGTIN12;
805
- }
806
- /**
807
- * Zero expand a zero-suppressed GTIN-12.
808
- *
809
- * @param zeroSuppressedGTIN12
810
- * Zero-suppressed GTIN-12.
811
- *
812
- * @returns
813
- * GTIN-12.
814
- */
815
- static zeroExpand(zeroSuppressedGTIN12) {
816
- import_utility4.NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, _GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
817
- const d = Array.from(zeroSuppressedGTIN12);
818
- let gtin12;
819
- if (d[0] === "0") {
820
- if (d[6] >= "5" && d[5] !== "0") {
821
- gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}0000${d[6]}${d[7]}`;
822
- } else if (d[6] === "4" && d[4] !== "0") {
823
- gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}00000${d[5]}${d[7]}`;
824
- } else if (d[6] <= "2") {
825
- gtin12 = `0${d[1]}${d[2]}${d[6]}0000${d[3]}${d[4]}${d[5]}${d[7]}`;
826
- } else if (d[6] === "3" && d[3] >= "3") {
827
- gtin12 = `0${d[1]}${d[2]}${d[3]}00000${d[4]}${d[5]}${d[7]}`;
828
- }
829
- }
830
- if (gtin12 === void 0) {
831
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12"));
832
- }
833
- GTIN12_VALIDATOR.validate(gtin12);
834
- return gtin12;
835
- }
836
- /**
837
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
838
- *
839
- * @param indicatorDigit
840
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
841
- *
842
- * @param gtin
843
- * GTIN.
844
- *
845
- * @returns
846
- * GTIN-14.
847
- */
848
- static convertToGTIN14(indicatorDigit, gtin) {
849
- GTINCreator.validateAny(gtin);
850
- import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINValidator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
851
- const gtinLength = gtin.length;
852
- let gtin14 = "0".repeat(14 /* GTIN14 */ - gtinLength) + gtin;
853
- if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
854
- const partialGTIN14 = indicatorDigit + gtin14.substring(1, 14 /* GTIN14 */ - 1);
855
- gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
856
- }
857
- return gtin14;
858
- }
859
- /**
860
- * Normalize a GTIN of any length.
861
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
862
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
863
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
864
- * - Otherwise, the GTIN is unchanged.
865
- *
866
- * @param gtin
867
- * GTIN.
868
- *
869
- * @returns
870
- * Normalized GTIN.
871
- */
872
- static normalize(gtin) {
873
- const gtinLength = gtin.length;
874
- let normalizedGTIN;
875
- switch (gtinLength) {
876
- case 13 /* GTIN13 */:
877
- if (!gtin.startsWith("0")) {
878
- normalizedGTIN = gtin;
879
- } else if (!gtin.startsWith("00000")) {
880
- normalizedGTIN = gtin.substring(1);
881
- } else if (!gtin.startsWith("000000")) {
882
- normalizedGTIN = gtin.substring(5);
883
- } else {
884
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
885
- }
886
- break;
887
- case 12 /* GTIN12 */:
888
- normalizedGTIN = gtin;
889
- break;
890
- case 8 /* GTIN8 */:
891
- if (!gtin.startsWith("0")) {
892
- normalizedGTIN = gtin;
893
- } else {
894
- normalizedGTIN = _GTINValidator.zeroExpand(gtin);
895
- }
896
- break;
897
- case 14 /* GTIN14 */:
898
- if (!gtin.startsWith("0")) {
899
- normalizedGTIN = gtin;
900
- } else if (!gtin.startsWith("00")) {
901
- normalizedGTIN = gtin.substring(1);
902
- } else if (!gtin.startsWith("000000")) {
903
- normalizedGTIN = gtin.substring(2);
904
- } else if (!gtin.startsWith("0000000")) {
905
- normalizedGTIN = gtin.substring(6);
906
- } else {
907
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
908
- }
909
- break;
910
- default:
911
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
912
- }
913
- GTINCreator.validateAny(normalizedGTIN);
914
- return normalizedGTIN;
915
- }
916
- /**
917
- * Validate any GTIN, optionally against a level.
918
- *
919
- * @param gtin
920
- * GTIN.
921
- *
922
- * @param gtinLevel
923
- * Level at which GTIN is to be validated.
924
- */
925
- static validateAny(gtin, gtinLevel = 0 /* Any */) {
926
- let lengthValidatedGTIN = gtin;
927
- let gtinLevelRestriction;
928
- switch (gtin.length) {
929
- case 13 /* GTIN13 */:
930
- if (gtin.startsWith("0")) {
931
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN13AtRetail"));
932
- }
933
- PrefixManager.validatePrefix(0 /* GS1CompanyPrefix */, false, false, gtin, true, true);
934
- gtinLevelRestriction = 0 /* Any */;
935
- break;
936
- case 12 /* GTIN12 */:
937
- PrefixManager.validatePrefix(1 /* UPCCompanyPrefix */, false, false, gtin, true, true);
938
- gtinLevelRestriction = 0 /* Any */;
939
- break;
940
- case 8 /* GTIN8 */:
941
- if (!gtin.startsWith("0")) {
942
- PrefixManager.validatePrefix(2 /* GS18Prefix */, false, false, gtin, true, true);
943
- } else {
944
- lengthValidatedGTIN = _GTINValidator.zeroExpand(gtin);
945
- }
946
- gtinLevelRestriction = 1 /* RetailConsumer */;
947
- break;
948
- case 14 /* GTIN14 */:
949
- PrefixManager.validatePrefix(0 /* GS1CompanyPrefix */, true, true, gtin.substring(1), true, true);
950
- gtinLevelRestriction = 2 /* OtherThanRetailConsumer */;
951
- break;
952
- default:
953
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
954
- }
955
- if (!hasValidCheckDigit(lengthValidatedGTIN)) {
956
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
957
- }
958
- if (gtinLevel !== 0 /* Any */ && gtinLevelRestriction !== 0 /* Any */ && gtinLevelRestriction !== gtinLevel) {
959
- throw new RangeError(i18nextGS1.t(gtinLevel === 1 /* RetailConsumer */ ? "IdentificationKey.invalidGTINAtRetail" : "IdentificationKey.invalidGTINAtOtherThanRetail"));
960
- }
961
- }
962
- /**
963
- * Validate a GTIN-14.
964
- *
965
- * @param gtin14
966
- * GTIN-14.
967
- */
968
- static validateGTIN14(gtin14) {
969
- if (gtin14.length !== 14 /* GTIN14 */) {
970
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN14Length"));
971
- }
972
- GTINCreator.validateAny(gtin14);
973
- }
974
- };
975
- var NonGTINNumericIdentificationKeyValidator = class extends AbstractNumericIdentificationKeyValidator {
976
- /**
977
- * Constructor.
978
- *
979
- * @param identificationKeyType
980
- * Identification key type.
981
- *
982
- * @param length
983
- * Length.
984
- *
985
- * @param leaderType
986
- * Leader type.
987
- */
988
- constructor(identificationKeyType, length, leaderType = 0 /* None */) {
989
- super(identificationKeyType, 0 /* GS1CompanyPrefix */, length, leaderType);
990
- }
991
- };
992
- var SerializableNumericIdentificationKeyValidator = class _SerializableNumericIdentificationKeyValidator extends NonGTINNumericIdentificationKeyValidator {
993
- /**
994
- * Serial component length.
995
- */
996
- _serialComponentLength;
997
- /**
998
- * Serial component character set.
999
- */
1000
- _serialComponentCharacterSet;
1001
- /**
1002
- * Serial component validation parameters.
1003
- */
1004
- _serialComponentValidation;
1005
- /**
1006
- * Serial component creator.
1007
- */
1008
- _serialComponentCreator;
1009
- /**
1010
- * Constructor.
1011
- *
1012
- * @param identificationKeyType
1013
- * Identification key type.
1014
- *
1015
- * @param length
1016
- * Length.
1017
- *
1018
- * @param serialComponentLength
1019
- * Serial component length.
1020
- *
1021
- * @param serialComponentCharacterSet
1022
- * Serial component character set.
1023
- */
1024
- constructor(identificationKeyType, length, serialComponentLength, serialComponentCharacterSet) {
1025
- super(identificationKeyType, length, 0 /* None */);
1026
- this._serialComponentLength = serialComponentLength;
1027
- this._serialComponentCharacterSet = serialComponentCharacterSet;
1028
- this._serialComponentValidation = {
1029
- minimumLength: 1,
1030
- maximumLength: serialComponentLength,
1031
- component: () => i18nextGS1.t("IdentificationKey.serialComponent")
1032
- };
1033
- this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
1034
- }
1035
- /**
1036
- * Get the serial component length.
1037
- */
1038
- get serialComponentLength() {
1039
- return this._serialComponentLength;
1040
- }
1041
- /**
1042
- * Get the serial component character set.
1043
- */
1044
- get serialComponentCharacterSet() {
1045
- return this._serialComponentCharacterSet;
1046
- }
1047
- /**
1048
- * Get the serial component validation parameters.
1049
- */
1050
- get serialComponentValidation() {
1051
- return this._serialComponentValidation;
1052
- }
1053
- /**
1054
- * Get the serial component creator.
1055
- */
1056
- get serialComponentCreator() {
1057
- return this._serialComponentCreator;
1058
- }
1059
- /**
1060
- * @inheritDoc
1061
- */
1062
- validate(identificationKey, validation) {
1063
- super.validate(identificationKey.substring(0, this.length), validation);
1064
- if (identificationKey.length > this.length) {
1065
- this.serialComponentCreator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
1066
- }
1067
- }
1068
- };
1069
- var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator {
1070
- /**
1071
- * Validator to ensure that an identification key (minus check character pair) is not all numeric.
1072
- */
1073
- static NOT_ALL_NUMERIC_VALIDATOR = new class extends import_utility4.RegExpValidator {
1074
- /**
1075
- * @inheritDoc
1076
- */
1077
- createErrorMessage(_s) {
1078
- return i18nextGS1.t("IdentificationKey.referenceCantBeAllNumeric");
1079
- }
1080
- }(/\D/);
1081
- /**
1082
- * True if the identification key requires a check character pair.
1083
- */
1084
- _requiresCheckCharacterPair;
1085
- /**
1086
- * Constructor.
1087
- *
1088
- * @param identificationKeyType
1089
- * Identification key type.
1090
- *
1091
- * @param length
1092
- * Length.
1093
- *
1094
- * @param referenceCharacterSet
1095
- * Reference character set.
1096
- *
1097
- * @param requiresCheckCharacterPair
1098
- * True if the identification key requires a check character pair.
1099
- */
1100
- constructor(identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
1101
- super(identificationKeyType, 0 /* GS1CompanyPrefix */, length, referenceCharacterSet);
1102
- this._requiresCheckCharacterPair = requiresCheckCharacterPair;
1103
- }
1104
- /**
1105
- * Determine if the identification key requires a check character pair.
1106
- */
1107
- get requiresCheckCharacterPair() {
1108
- return this._requiresCheckCharacterPair;
1109
- }
1110
- /**
1111
- * Validate a non-numeric identification key and throw an error if validation fails.
1112
- *
1113
- * @param identificationKey
1114
- * Identification key.
1115
- *
1116
- * @param validation
1117
- * Validation parameters.
1118
- */
1119
- validate(identificationKey, validation) {
1120
- const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
1121
- super.validatePrefix(partialIdentificationKey, validation?.positionOffset);
1122
- if (!this.requiresCheckCharacterPair) {
1123
- this.referenceCreator.validate(identificationKey, {
1124
- maximumLength: this.length,
1125
- positionOffset: validation?.positionOffset
1126
- });
1127
- } else if (!hasValidCheckCharacterPair(this.padIdentificationKey(identificationKey, validation))) {
1128
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckCharacterPair"));
1129
- }
1130
- if (validation?.exclusion === import_utility4.Exclusion.AllNumeric) {
1131
- _NonNumericIdentificationKeyValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(partialIdentificationKey);
1132
- }
1133
- }
1134
- };
1135
- var GTIN13_VALIDATOR = new GTINValidator(13 /* GTIN13 */);
1136
- var GTIN12_VALIDATOR = new GTINValidator(12 /* GTIN12 */);
1137
- var GTIN8_VALIDATOR = new GTINValidator(8 /* GTIN8 */);
1138
- var GTIN_VALIDATORS = [
1139
- GTIN13_VALIDATOR,
1140
- GTIN12_VALIDATOR,
1141
- GTIN8_VALIDATOR
1142
- ];
1143
- var GLN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GLN" /* GLN */, 13);
1144
- var SSCC_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("SSCC" /* SSCC */, 18, 2 /* ExtensionDigit */);
1145
- var GRAI_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GRAI" /* GRAI */, 13, 16, 1 /* AI82 */);
1146
- var GIAI_VALIDATOR = new NonNumericIdentificationKeyValidator("GIAI" /* GIAI */, 30, 1 /* AI82 */);
1147
- var GSRN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GSRN" /* GSRN */, 18);
1148
- var GDTI_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GDTI" /* GDTI */, 13, 17, 1 /* AI82 */);
1149
- var GINC_VALIDATOR = new NonNumericIdentificationKeyValidator("GINC" /* GINC */, 30, 1 /* AI82 */);
1150
- var GSIN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GSIN" /* GSIN */, 17);
1151
- var GCN_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GCN" /* GCN */, 13, 12, 0 /* Numeric */);
1152
- var CPID_VALIDATOR = new NonNumericIdentificationKeyValidator("CPID" /* CPID */, 30, 2 /* AI39 */);
1153
- var GMN_VALIDATOR = new NonNumericIdentificationKeyValidator("GMN" /* GMN */, 25, 1 /* AI82 */, true);
1154
- var AbstractIdentificationKeyCreator = class {
1155
- /**
1156
- * Prefix manager.
1157
- */
1158
- _prefixManager;
1159
- /**
1160
- * Reference length.
1161
- */
1162
- _referenceLength;
1163
- /**
1164
- * Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
1165
- *
1166
- * @param prefixManager
1167
- * Prefix manager.
1168
- *
1169
- * @param prefix
1170
- * Prefix within prefix manager to use to calculate reference length.
1171
- *
1172
- * @param checkAllowance
1173
- * Number of characters to allow for check digit or check character pair.
1174
- */
1175
- init(prefixManager, prefix, checkAllowance) {
1176
- this._prefixManager = prefixManager;
1177
- this._referenceLength = this.length - prefix.length - checkAllowance;
1178
- }
1179
- /**
1180
- * @inheritDoc
1181
- */
1182
- get prefixManager() {
1183
- return this._prefixManager;
1184
- }
1185
- /**
1186
- * @inheritDoc
1187
- */
1188
- get prefix() {
1189
- return this.prefixManager.gs1CompanyPrefix;
1190
- }
1191
- /**
1192
- * @inheritDoc
1193
- */
1194
- get referenceLength() {
1195
- return this._referenceLength;
1196
- }
1197
- };
1198
- var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificationKeyCreator extends AbstractIdentificationKeyCreator {
1199
- /**
1200
- * Capacity.
1201
- */
1202
- _capacity;
1203
- /**
1204
- * Tweak for sparse creation.
1205
- */
1206
- _tweak = 0n;
1207
- /**
1208
- * Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
1209
- *
1210
- * @param prefixManager
1211
- * Prefix manager.
1212
- *
1213
- * @param prefix
1214
- * Prefix within prefix manager to use to calculate reference length.
1215
- */
1216
- init(prefixManager, prefix) {
1217
- super.init(prefixManager, prefix, 1);
1218
- this._capacity = Number(import_utility4.CharacterSetCreator.powerOf10(this.referenceLength));
1219
- }
1220
- /**
1221
- * @inheritDoc
1222
- */
1223
- get capacity() {
1224
- return this._capacity;
1225
- }
1226
- /**
1227
- * Get the tweak for sparse creation.
1228
- */
1229
- get tweak() {
1230
- return this._tweak;
1231
- }
1232
- /**
1233
- * Set the tweak for sparse creation.
1234
- */
1235
- set tweak(value) {
1236
- this._tweak = value;
1237
- }
1238
- /**
1239
- * Build an identification key from a reference by merging it with the prefix and adding the check digit.
1240
- *
1241
- * @param reference
1242
- * Identification key reference.
1243
- *
1244
- * @returns
1245
- * Identification key.
1246
- */
1247
- buildIdentificationKey(reference) {
1248
- const partialIdentificationKey = this.leaderType === 2 /* ExtensionDigit */ ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
1249
- return partialIdentificationKey + checkDigit(partialIdentificationKey);
1250
- }
1251
- /**
1252
- * @inheritDoc
1253
- */
1254
- create(valueOrValues, sparse = false) {
1255
- return import_utility4.NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, import_utility4.Exclusion.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
1256
- }
1257
- /**
1258
- * Create all identification keys from a partial identification key. Call is recursive until remaining reference
1259
- * length is 0.
1260
- *
1261
- * @param partialIdentificationKey
1262
- * Partial identification key. Initial value is `this.prefix`.
1263
- *
1264
- * @param remainingReferenceLength
1265
- * Remaining reference length. Initial value is `this.referenceLength`.
1266
- *
1267
- * @param extensionWeight
1268
- * If this value is not zero, the identification key has an extension digit, this call is setting it, and this value
1269
- * is applied to the calculation of the check digit.
1270
- *
1271
- * @param weight
1272
- * If the extension weight is zero, this value is applied to the calculation of the check digit.
1273
- *
1274
- * @param partialCheckDigitSum
1275
- * Partial check digit sum for the partial identification key.
1276
- *
1277
- * @yields
1278
- * Identification key.
1279
- */
1280
- static *createAllPartial(partialIdentificationKey, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
1281
- if (remainingReferenceLength === 0) {
1282
- yield partialIdentificationKey + import_utility4.NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
1283
- } else {
1284
- const nextRemainingReferenceLength = remainingReferenceLength - 1;
1285
- let nextPartialCheckDigitSum = partialCheckDigitSum;
1286
- if (extensionWeight !== 0) {
1287
- for (const c of import_utility4.NUMERIC_CREATOR.characterSet) {
1288
- yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(c + partialIdentificationKey, nextRemainingReferenceLength, 0, weight, nextPartialCheckDigitSum);
1289
- nextPartialCheckDigitSum += extensionWeight;
1290
- }
1291
- } else {
1292
- const nextWeight = 4 - weight;
1293
- for (const c of import_utility4.NUMERIC_CREATOR.characterSet) {
1294
- yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(partialIdentificationKey + c, nextRemainingReferenceLength, 0, nextWeight, nextPartialCheckDigitSum);
1295
- nextPartialCheckDigitSum += weight;
1296
- }
1297
- }
1298
- }
1299
- }
1300
- /**
1301
- * @inheritDoc
1302
- */
1303
- createAll() {
1304
- const hasExtensionDigit = this.leaderType === 2 /* ExtensionDigit */;
1305
- const prefix = this.prefix;
1306
- const length = this.length;
1307
- const referenceLength = this.referenceLength;
1308
- const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
1309
- return {
1310
- [Symbol.iterator]() {
1311
- return _AbstractNumericIdentificationKeyCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
1312
- }
1313
- };
1314
- }
1315
- };
1316
- var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINValidator, AbstractNumericIdentificationKeyCreator) {
1317
- /**
1318
- * Validation parameters for required indicator digit.
1319
- */
1320
- static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
1321
- minimumLength: 1,
1322
- maximumLength: 1,
1323
- component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1324
- };
1325
- /**
1326
- * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
1327
- *
1328
- * @param prefixManager
1329
- * Prefix manager.
1330
- *
1331
- * @param gtinType
1332
- * GTIN type.
1333
- */
1334
- constructor(prefixManager, gtinType) {
1335
- super(gtinType);
1336
- this.init(prefixManager, prefixManager.prefix);
1337
- }
1338
- /**
1339
- * @inheritDoc
1340
- */
1341
- get prefix() {
1342
- return this.prefixManager.prefix;
1343
- }
1344
- /**
1345
- * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
1346
- * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1347
- *
1348
- * @param indicatorDigit
1349
- * Indicator digit.
1350
- *
1351
- * @param valueOrValues
1352
- * Numeric value(s).
1353
- *
1354
- * @param sparse
1355
- * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
1356
- *
1357
- * @returns
1358
- * GTIN-14(s).
1359
- */
1360
- createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
1361
- import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1362
- return import_utility4.NUMERIC_CREATOR.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, import_utility4.Exclusion.None, sparse ? this.tweak : void 0, (reference) => {
1363
- const partialIdentificationKey = indicatorDigit + this.prefixManager.gs1CompanyPrefix + reference;
1364
- return partialIdentificationKey + checkDigit(partialIdentificationKey);
1365
- });
1366
- }
1367
- };
1368
- var NonGTINNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(NonGTINNumericIdentificationKeyValidator, AbstractNumericIdentificationKeyCreator) {
1369
- /**
1370
- * Constructor. Called internally by {@link PrefixManager} non-GTIN numeric identification key creator getters;
1371
- * should not be called by other code.
1372
- *
1373
- * @param prefixManager
1374
- * Prefix manager.
1375
- *
1376
- * @param identificationKeyType
1377
- * Identification key type.
1378
- *
1379
- * @param length
1380
- * Length.
1381
- *
1382
- * @param leaderType
1383
- * Leader type.
1384
- */
1385
- constructor(prefixManager, identificationKeyType, length, leaderType = 0 /* None */) {
1386
- super(identificationKeyType, length, leaderType);
1387
- this.init(prefixManager, prefixManager.gs1CompanyPrefix);
1388
- }
1389
- };
1390
- var SerializableNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(SerializableNumericIdentificationKeyValidator, AbstractNumericIdentificationKeyCreator) {
1391
- /**
1392
- * Constructor. Called internally by {@link PrefixManager} serialized numeric identification key creator getters;
1393
- * should not be called by other code.
1394
- *
1395
- * @param prefixManager
1396
- * Prefix manager.
1397
- *
1398
- * @param identificationKeyType
1399
- * Identification key type.
1400
- *
1401
- * @param length
1402
- * Length.
1403
- *
1404
- * @param serialComponentLength
1405
- * Serial component length.
1406
- *
1407
- * @param serialComponentCharacterSet
1408
- * Serial component character set.
1409
- */
1410
- constructor(prefixManager, identificationKeyType, length, serialComponentLength, serialComponentCharacterSet) {
1411
- super(identificationKeyType, length, serialComponentLength, serialComponentCharacterSet);
1412
- this.init(prefixManager, prefixManager.gs1CompanyPrefix);
1413
- }
1414
- /**
1415
- * Concatenate a validated base identification key with serial component(s).
1416
- *
1417
- * @param baseIdentificationKey
1418
- * Base identification key.
1419
- *
1420
- * @param serialComponentOrComponents
1421
- * Serial component(s).
1422
- *
1423
- * @returns
1424
- * Serialized identification key(s).
1425
- */
1426
- concatenateValidated(baseIdentificationKey, serialComponentOrComponents) {
1427
- let result;
1428
- const serialComponentCreator = this.serialComponentCreator;
1429
- const serialComponentValidation = this.serialComponentValidation;
1430
- function validateAndConcatenate(serialComponent) {
1431
- serialComponentCreator.validate(serialComponent, serialComponentValidation);
1432
- return baseIdentificationKey + serialComponent;
1433
- }
1434
- if (typeof serialComponentOrComponents !== "object") {
1435
- result = validateAndConcatenate(serialComponentOrComponents);
1436
- } else {
1437
- result = (0, import_utility4.transformIterable)(serialComponentOrComponents, validateAndConcatenate);
1438
- }
1439
- return result;
1440
- }
1441
- /**
1442
- * Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
1443
- * component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1444
- *
1445
- * @param value
1446
- * Numeric value of the reference.
1447
- *
1448
- * @param serialComponentOrComponents
1449
- * Serial component(s).
1450
- *
1451
- * @param sparse
1452
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1453
- *
1454
- * @returns
1455
- * Serialized identification keys.
1456
- */
1457
- createSerialized(value, serialComponentOrComponents, sparse) {
1458
- return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
1459
- }
1460
- /**
1461
- * Concatenate a base identification key with serial component(s).
1462
- *
1463
- * @param baseIdentificationKey
1464
- * Base identification key.
1465
- *
1466
- * @param serialComponentOrComponents
1467
- * Serial component(s).
1468
- *
1469
- * @returns
1470
- * Serialized identification key(s).
1471
- */
1472
- concatenate(baseIdentificationKey, serialComponentOrComponents) {
1473
- this.validate(baseIdentificationKey);
1474
- return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
1475
- }
1476
- };
1477
- var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
1478
- /**
1479
- * Reference validation parameters.
1480
- */
1481
- _referenceValidation;
1482
- /**
1483
- * Constructor. Called internally by {@link PrefixManager} non-numeric identification key creator getters; should
1484
- * not be called by other code.
1485
- *
1486
- * @param prefixManager
1487
- * Prefix manager.
1488
- *
1489
- * @param identificationKeyType
1490
- * Identification key type.
1491
- *
1492
- * @param length
1493
- * Length.
1494
- *
1495
- * @param referenceCharacterSet
1496
- * Reference character set.
1497
- *
1498
- * @param requiresCheckCharacterPair
1499
- * True if the identification key requires a check character pair.
1500
- */
1501
- constructor(prefixManager, identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
1502
- super(identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair);
1503
- this.init(prefixManager, prefixManager.gs1CompanyPrefix, 2 * Number(requiresCheckCharacterPair));
1504
- this._referenceValidation = {
1505
- minimumLength: 1,
1506
- // Maximum reference length has to account for prefix and check character pair.
1507
- maximumLength: this.referenceLength,
1508
- component: () => i18nextGS1.t("IdentificationKey.reference")
1509
- };
1510
- }
1511
- /**
1512
- * Get the reference validation parameters.
1513
- */
1514
- get referenceValidation() {
1515
- return this._referenceValidation;
1516
- }
1517
- /**
1518
- * Create identification key(s) with reference(s).
1519
- *
1520
- * @param referenceOrReferences
1521
- * Reference(s).
1522
- *
1523
- * @returns
1524
- * Identification key(s).
1525
- */
1526
- create(referenceOrReferences) {
1527
- let result;
1528
- const referenceCreator = this.referenceCreator;
1529
- const referenceValidation = this.referenceValidation;
1530
- const prefix = this.prefix;
1531
- const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
1532
- function validateAndCreate(reference) {
1533
- referenceCreator.validate(reference, referenceValidation);
1534
- const partialIdentificationKey = prefix + reference;
1535
- return requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
1536
- }
1537
- if (typeof referenceOrReferences !== "object") {
1538
- result = validateAndCreate(referenceOrReferences);
1539
- } else {
1540
- result = (0, import_utility4.transformIterable)(referenceOrReferences, validateAndCreate);
1541
- }
1542
- return result;
1543
- }
1544
- };
1545
- var PrefixManager = class _PrefixManager {
1546
- /**
1547
- * Cached prefix managers, keyed by GS1 Company Prefix.
1548
- */
1549
- static PREFIX_MANAGERS_MAP = /* @__PURE__ */ new Map();
1550
- /**
1551
- * GS1 Company Prefix minimum length.
1552
- */
1553
- static GS1_COMPANY_PREFIX_MINIMUM_LENGTH = 4;
1554
- /**
1555
- * GS1 Company Prefix maximum length.
1556
- */
1557
- static GS1_COMPANY_PREFIX_MAXIMUM_LENGTH = 12;
1558
- /**
1559
- * U.P.C. Company Prefix minimum length.
1560
- */
1561
- static UPC_COMPANY_PREFIX_MINIMUM_LENGTH = 6;
1562
- /**
1563
- * U.P.C. Company Prefix maximum length.
1564
- */
1565
- static UPC_COMPANY_PREFIX_MAXIMUM_LENGTH = 11;
1566
- /**
1567
- * GS1-8 Prefix minimum length.
1568
- */
1569
- static GS1_8_PREFIX_MINIMUM_LENGTH = 2;
1570
- /**
1571
- * GS1-8 Prefix maximum length.
1572
- */
1573
- static GS1_8_PREFIX_MAXIMUM_LENGTH = 7;
1574
- /**
1575
- * Validation parameters for GS1 Company Prefix.
1576
- */
1577
- static GS1_COMPANY_PREFIX_VALIDATION = {
1578
- minimumLength: _PrefixManager.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,
1579
- maximumLength: _PrefixManager.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,
1580
- component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1581
- };
1582
- /**
1583
- * Validation parameters for U.P.C. Company Prefix expressed as GS1 Company Prefix.
1584
- */
1585
- static UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
1586
- minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1,
1587
- maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH + 1,
1588
- component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1589
- };
1590
- /**
1591
- * Validation parameters for GS1-8 Prefix expressed as GS1 Company Prefix.
1592
- */
1593
- static GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
1594
- minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH + 5,
1595
- maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH + 5,
1596
- component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1597
- };
1598
- /**
1599
- * Validation parameters for U.P.C. Company Prefix.
1600
- */
1601
- static UPC_COMPANY_PREFIX_VALIDATION = {
1602
- minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,
1603
- maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,
1604
- component: () => i18nextGS1.t("Prefix.upcCompanyPrefix")
1605
- };
1606
- /**
1607
- * Validation parameters for GS1-8 Prefix.
1608
- */
1609
- static GS1_8_PREFIX_VALIDATION = {
1610
- minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH,
1611
- maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH,
1612
- component: () => i18nextGS1.t("Prefix.gs18Prefix")
1613
- };
1614
- /**
1615
- * Creator tweak factors. Different numeric identification key types have different tweak factors so that sparse
1616
- * creation generates different sequences for each.
1617
- */
1618
- static CREATOR_TWEAK_FACTORS_MAP = /* @__PURE__ */ new Map([
1619
- ["GTIN" /* GTIN */, 1987n],
1620
- ["GLN" /* GLN */, 4241n],
1621
- ["SSCC" /* SSCC */, 8087n],
1622
- ["GRAI" /* GRAI */, 3221n],
1623
- ["GSRN" /* GSRN */, 2341n],
1624
- ["GDTI" /* GDTI */, 7333n],
1625
- ["GSIN" /* GSIN */, 5623n],
1626
- ["GCN" /* GCN */, 6869n]
1627
- ]);
1628
- /**
1629
- * Normalized prefix type.
1630
- */
1631
- _prefixType;
1632
- /**
1633
- * Normalized prefix.
1634
- */
1635
- _prefix;
1636
- /**
1637
- * Prefix as GS1 Company Prefix.
1638
- */
1639
- _gs1CompanyPrefix;
1640
- /**
1641
- * U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix}.
1642
- */
1643
- _upcCompanyPrefix;
1644
- /**
1645
- * GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix}.
1646
- */
1647
- _gs18Prefix;
1648
- /**
1649
- * Tweak factor.
1650
- */
1651
- _tweakFactor = 0n;
1652
- /**
1653
- * Cached identification key creators.
1654
- */
1655
- _identificationKeyCreatorsMap = /* @__PURE__ */ new Map();
1656
- /**
1657
- * Constructor.
1658
- *
1659
- * @param gs1CompanyPrefix
1660
- * GS1 Company Prefix.
1661
- */
1662
- constructor(gs1CompanyPrefix) {
1663
- this._gs1CompanyPrefix = gs1CompanyPrefix;
1664
- if (!gs1CompanyPrefix.startsWith("0")) {
1665
- this._prefixType = 0 /* GS1CompanyPrefix */;
1666
- this._prefix = this._gs1CompanyPrefix;
1667
- } else if (!gs1CompanyPrefix.startsWith("00000")) {
1668
- this._prefixType = 1 /* UPCCompanyPrefix */;
1669
- this._upcCompanyPrefix = gs1CompanyPrefix.substring(1);
1670
- this._prefix = this._upcCompanyPrefix;
1671
- } else {
1672
- this._prefixType = 2 /* GS18Prefix */;
1673
- this._gs18Prefix = gs1CompanyPrefix.substring(5);
1674
- this._prefix = this._gs18Prefix;
1675
- }
1676
- this.resetTweakFactor();
1677
- }
1678
- /**
1679
- * Get the prefix type.
1680
- */
1681
- get prefixType() {
1682
- return this._prefixType;
1683
- }
1684
- /**
1685
- * Get the prefix.
1686
- */
1687
- get prefix() {
1688
- return this._prefix;
1689
- }
1690
- /**
1691
- * Get the GS1 Company Prefix.
1692
- */
1693
- get gs1CompanyPrefix() {
1694
- return this._gs1CompanyPrefix;
1695
- }
1696
- /**
1697
- * Get the U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix} or undefined if not.
1698
- */
1699
- get upcCompanyPrefix() {
1700
- return this._upcCompanyPrefix;
1701
- }
1702
- /**
1703
- * Get the GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix} or undefined if not.
1704
- */
1705
- get gs18Prefix() {
1706
- return this._gs18Prefix;
1707
- }
1708
- /**
1709
- * Set the tweak for an identification key creator if it's a numeric identification key creator.
1710
- *
1711
- * @param creator
1712
- * Identification key creator.
1713
- */
1714
- setCreatorTweak(creator) {
1715
- const creatorTweakFactor = _PrefixManager.CREATOR_TWEAK_FACTORS_MAP.get(creator.identificationKeyType);
1716
- if (creatorTweakFactor !== void 0) {
1717
- creator.tweak = this.tweakFactor * creatorTweakFactor;
1718
- }
1719
- }
1720
- /**
1721
- * Get the tweak factor.
1722
- */
1723
- get tweakFactor() {
1724
- return this._tweakFactor;
1725
- }
1726
- /**
1727
- * Set the tweak factor.
1728
- *
1729
- * @param value
1730
- * Tweak factor.
1731
- */
1732
- set tweakFactor(value) {
1733
- const tweakFactor = BigInt(value);
1734
- if (this._tweakFactor !== tweakFactor) {
1735
- this._tweakFactor = tweakFactor;
1736
- for (const creator of this._identificationKeyCreatorsMap.values()) {
1737
- this.setCreatorTweak(creator);
1738
- }
1739
- }
1740
- }
1741
- /**
1742
- * Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
1743
- */
1744
- resetTweakFactor() {
1745
- this.tweakFactor = BigInt("1" + this.gs1CompanyPrefix);
1746
- }
1747
- /**
1748
- * Get a prefix manager.
1749
- *
1750
- * @param prefixType
1751
- * Prefix type.
1752
- *
1753
- * @param prefix
1754
- * Prefix.
1755
- *
1756
- * @returns
1757
- * Prefix manager with normalized prefix type and prefix.
1758
- */
1759
- static get(prefixType, prefix) {
1760
- _PrefixManager.validatePrefix(prefixType, true, true, prefix);
1761
- let gs1CompanyPrefix;
1762
- switch (prefixType) {
1763
- case 0 /* GS1CompanyPrefix */:
1764
- gs1CompanyPrefix = prefix;
1765
- break;
1766
- case 1 /* UPCCompanyPrefix */:
1767
- gs1CompanyPrefix = "0" + prefix;
1768
- break;
1769
- case 2 /* GS18Prefix */:
1770
- gs1CompanyPrefix = "00000" + prefix;
1771
- break;
1772
- }
1773
- let prefixManager = _PrefixManager.PREFIX_MANAGERS_MAP.get(gs1CompanyPrefix);
1774
- if (prefixManager === void 0) {
1775
- prefixManager = new _PrefixManager(gs1CompanyPrefix);
1776
- _PrefixManager.PREFIX_MANAGERS_MAP.set(gs1CompanyPrefix, prefixManager);
1777
- }
1778
- return prefixManager;
1779
- }
1780
- /**
1781
- * Validate a prefix.
1782
- *
1783
- * @param prefixType
1784
- * Prefix type.
1785
- *
1786
- * @param allowUPCCompanyPrefix
1787
- * If true, a U.P.C. Company Prefix expressed as a GS1 Company Prefix is permitted.
1788
- *
1789
- * @param allowGS18Prefix
1790
- * If true, a GS1-8 Prefix expressed as a GS1 Company Prefix is permitted.
1791
- *
1792
- * @param prefix
1793
- * Prefix.
1794
- *
1795
- * @param isFromIdentificationKey
1796
- * If true, the prefix is from an identification key and should be trimmed before its character set is validated.
1797
- *
1798
- * @param isNumericIdentificationKey
1799
- * If true, the prefix is from a numeric identification key and its character set will be validated by the caller.
1800
- *
1801
- * @param positionOffset
1802
- * Position offset within a larger string.
1803
- */
1804
- static validatePrefix(prefixType, allowUPCCompanyPrefix, allowGS18Prefix, prefix, isFromIdentificationKey = false, isNumericIdentificationKey = false, positionOffset) {
1805
- let baseValidation;
1806
- switch (prefixType) {
1807
- case 0 /* GS1CompanyPrefix */:
1808
- if (!prefix.startsWith("0")) {
1809
- baseValidation = _PrefixManager.GS1_COMPANY_PREFIX_VALIDATION;
1810
- } else if (!prefix.startsWith("00000")) {
1811
- if (!allowUPCCompanyPrefix) {
1812
- throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith0"));
1813
- }
1814
- baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1815
- } else if (!prefix.startsWith("000000")) {
1816
- if (!allowGS18Prefix) {
1817
- throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith00000"));
1818
- }
1819
- baseValidation = _PrefixManager.GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1820
- } else {
1821
- throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith000000"));
1822
- }
1823
- break;
1824
- case 1 /* UPCCompanyPrefix */:
1825
- if (prefix.startsWith("0000")) {
1826
- throw new RangeError(i18nextGS1.t("Prefix.upcCompanyPrefixCantStartWith0000"));
1827
- }
1828
- baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_VALIDATION;
1829
- break;
1830
- case 2 /* GS18Prefix */:
1831
- if (prefix.startsWith("0")) {
1832
- throw new RangeError(i18nextGS1.t("Prefix.gs18PrefixCantStartWith0"));
1833
- }
1834
- baseValidation = _PrefixManager.GS1_8_PREFIX_VALIDATION;
1835
- break;
1836
- }
1837
- const mergedValidation = {
1838
- ...baseValidation,
1839
- positionOffset
1840
- };
1841
- if (!isFromIdentificationKey) {
1842
- import_utility4.NUMERIC_CREATOR.validate(prefix, mergedValidation);
1843
- } else if (!isNumericIdentificationKey) {
1844
- import_utility4.NUMERIC_CREATOR.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength, prefix.length - 1)), mergedValidation);
1845
- }
1846
- }
1847
- /**
1848
- * Get an identification key creator.
1849
- *
1850
- * @param identificationKeyType
1851
- * Identification key type.
1852
- *
1853
- * @param constructorCallback
1854
- * Constructor callback.
1855
- *
1856
- * @returns
1857
- * Identification key creator.
1858
- */
1859
- getIdentificationKeyCreator(identificationKeyType, constructorCallback) {
1860
- let creator = this._identificationKeyCreatorsMap.get(identificationKeyType);
1861
- if (creator === void 0) {
1862
- if (this.prefixType === 2 /* GS18Prefix */ && identificationKeyType !== "GTIN" /* GTIN */) {
1863
- throw new RangeError(i18nextGS1.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix", {
1864
- identificationKeyType
1865
- }));
1866
- }
1867
- creator = constructorCallback();
1868
- this.setCreatorTweak(creator);
1869
- this._identificationKeyCreatorsMap.set(identificationKeyType, creator);
1870
- }
1871
- return creator;
1872
- }
1873
- /**
1874
- * Get non-GTIN numeric identification key creator.
1875
- *
1876
- * @param validator
1877
- * Validator on which identification key creator is based.
1878
- *
1879
- * @returns
1880
- * Identification key creator.
1881
- */
1882
- getNonGTINNumericIdentificationKeyCreator(validator) {
1883
- return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new NonGTINNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.leaderType));
1884
- }
1885
- /**
1886
- * Get serialized numeric identification key creator.
1887
- *
1888
- * @param validator
1889
- * Validator on which identification key creator is based.
1890
- *
1891
- * @returns
1892
- * Identification key creator.
1893
- */
1894
- getSerializableNumericIdentificationKeyCreator(validator) {
1895
- return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new SerializableNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.serialComponentLength, validator.serialComponentCharacterSet));
1896
- }
1897
- /**
1898
- * Get non-numeric identification key creator.
1899
- *
1900
- * @param validator
1901
- * Validator on which identification key creator is based.
1902
- *
1903
- * @returns
1904
- * Identification key creator.
1905
- */
1906
- getNonNumericIdentificationKeyCreator(validator) {
1907
- return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new NonNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.referenceCharacterSet, validator.requiresCheckCharacterPair));
1908
- }
1909
- /**
1910
- * Get GTIN creator.
1911
- */
1912
- get gtinCreator() {
1913
- return this.getIdentificationKeyCreator("GTIN" /* GTIN */, () => {
1914
- let gtinType;
1915
- switch (this.prefixType) {
1916
- case 0 /* GS1CompanyPrefix */:
1917
- gtinType = 13 /* GTIN13 */;
1918
- break;
1919
- case 1 /* UPCCompanyPrefix */:
1920
- gtinType = 12 /* GTIN12 */;
1921
- break;
1922
- case 2 /* GS18Prefix */:
1923
- gtinType = 8 /* GTIN8 */;
1924
- break;
1925
- }
1926
- return new GTINCreator(this, gtinType);
1927
- });
1928
- }
1929
- /**
1930
- * Get GLN creator.
1931
- */
1932
- get glnCreator() {
1933
- return this.getNonGTINNumericIdentificationKeyCreator(GLN_VALIDATOR);
1934
- }
1935
- /**
1936
- * Get SSCC creator.
1937
- */
1938
- get ssccCreator() {
1939
- return this.getNonGTINNumericIdentificationKeyCreator(SSCC_VALIDATOR);
1940
- }
1941
- /**
1942
- * Get GRAI creator.
1943
- */
1944
- get graiCreator() {
1945
- return this.getSerializableNumericIdentificationKeyCreator(GRAI_VALIDATOR);
1946
- }
1947
- /**
1948
- * Get GIAI creator.
1949
- */
1950
- get giaiCreator() {
1951
- return this.getNonNumericIdentificationKeyCreator(GIAI_VALIDATOR);
1952
- }
1953
- /**
1954
- * Get GSRN creator.
1955
- */
1956
- get gsrnCreator() {
1957
- return this.getNonGTINNumericIdentificationKeyCreator(GSRN_VALIDATOR);
1958
- }
1959
- /**
1960
- * Get GDTI creator.
1961
- */
1962
- get gdtiCreator() {
1963
- return this.getSerializableNumericIdentificationKeyCreator(GDTI_VALIDATOR);
1964
- }
1965
- /**
1966
- * Get GINC creator.
1967
- */
1968
- get gincCreator() {
1969
- return this.getNonNumericIdentificationKeyCreator(GINC_VALIDATOR);
1970
- }
1971
- /**
1972
- * Get GSIN creator.
1973
- */
1974
- get gsinCreator() {
1975
- return this.getNonGTINNumericIdentificationKeyCreator(GSIN_VALIDATOR);
1976
- }
1977
- /**
1978
- * Get GCN creator.
1979
- */
1980
- get gcnCreator() {
1981
- return this.getSerializableNumericIdentificationKeyCreator(GCN_VALIDATOR);
1982
- }
1983
- /**
1984
- * Get CPID creator.
1985
- */
1986
- get cpidCreator() {
1987
- return this.getNonNumericIdentificationKeyCreator(CPID_VALIDATOR);
1988
- }
1989
- /**
1990
- * Get GMN creator.
1991
- */
1992
- get gmnCreator() {
1993
- return this.getNonNumericIdentificationKeyCreator(GMN_VALIDATOR);
1994
- }
1995
- };
1996
- // Annotate the CommonJS export names for ESM import in node:
1997
- 0 && (module.exports = {
1998
- AI39_CREATOR,
1999
- AI82_CREATOR,
2000
- CPID_VALIDATOR,
2001
- ContentCharacterSet,
2002
- GCN_VALIDATOR,
2003
- GDTI_VALIDATOR,
2004
- GIAI_VALIDATOR,
2005
- GINC_VALIDATOR,
2006
- GLN_VALIDATOR,
2007
- GMN_VALIDATOR,
2008
- GRAI_VALIDATOR,
2009
- GSIN_VALIDATOR,
2010
- GSRN_VALIDATOR,
2011
- GTIN12_VALIDATOR,
2012
- GTIN13_VALIDATOR,
2013
- GTIN8_VALIDATOR,
2014
- GTINCreator,
2015
- GTINLevel,
2016
- GTINType,
2017
- GTINValidator,
2018
- GTIN_VALIDATORS,
2019
- IdentificationKeyType,
2020
- LeaderType,
2021
- NonGTINNumericIdentificationKeyCreator,
2022
- NonGTINNumericIdentificationKeyValidator,
2023
- NonNumericIdentificationKeyCreator,
2024
- NonNumericIdentificationKeyValidator,
2025
- PrefixManager,
2026
- PrefixType,
2027
- SSCC_VALIDATOR,
2028
- SerializableNumericIdentificationKeyCreator,
2029
- SerializableNumericIdentificationKeyValidator,
2030
- checkCharacterPair,
2031
- checkDigit,
2032
- checkDigitSum,
2033
- fiveDigitPriceWeightCheckDigit,
2034
- fourDigitPriceWeightCheckDigit,
2035
- gs1NS,
2036
- gs1Resources,
2037
- hasValidCheckCharacterPair,
2038
- hasValidCheckDigit,
2039
- i18nGS1Init,
2040
- i18nextGS1
2041
- });
1
+ "use strict";var me=Object.create;var S=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Pe=(i,e)=>{for(var t in e)S(i,t,{get:e[t],enumerable:!0})},X=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ce(e))!Ne.call(i,n)&&n!==t&&S(i,n,{get:()=>e[n],enumerable:!(r=ye(e,n))||r.enumerable});return i};var Ge=(i,e,t)=>(t=i!=null?me(xe(i)):{},X(e||!i||!i.__esModule?S(t,"default",{value:i,enumerable:!0}):t,i)),_e=i=>X(S({},"__esModule",{value:!0}),i);var Ee={};Pe(Ee,{AI39_CREATOR:()=>U,AI82_CREATOR:()=>x,CPID_VALIDATOR:()=>Te,ContentCharacterSet:()=>te,GCN_VALIDATOR:()=>Ie,GDTI_VALIDATOR:()=>le,GIAI_VALIDATOR:()=>fe,GINC_VALIDATOR:()=>ue,GLN_VALIDATOR:()=>se,GMN_VALIDATOR:()=>ge,GRAI_VALIDATOR:()=>pe,GSIN_VALIDATOR:()=>he,GSRN_VALIDATOR:()=>de,GTIN12_VALIDATOR:()=>M,GTIN13_VALIDATOR:()=>ae,GTIN8_VALIDATOR:()=>oe,GTINCreator:()=>g,GTINLevel:()=>ne,GTINType:()=>ie,GTINValidator:()=>m,GTIN_VALIDATORS:()=>Le,IdentificationKeyType:()=>J,LeaderType:()=>re,NonGTINNumericIdentificationKeyCreator:()=>O,NonGTINNumericIdentificationKeyValidator:()=>I,NonNumericIdentificationKeyCreator:()=>k,NonNumericIdentificationKeyValidator:()=>T,PrefixManager:()=>h,PrefixType:()=>ee,SSCC_VALIDATOR:()=>ce,SerializableNumericIdentificationKeyCreator:()=>V,SerializableNumericIdentificationKeyValidator:()=>y,checkCharacterPair:()=>E,checkDigit:()=>P,checkDigitSum:()=>N,fiveDigitPriceWeightCheckDigit:()=>ve,fourDigitPriceWeightCheckDigit:()=>Re,gs1NS:()=>z,gs1Resources:()=>Y,hasValidCheckCharacterPair:()=>$,hasValidCheckDigit:()=>L,i18nGS1Init:()=>Se,i18nextGS1:()=>a});module.exports=_e(Ee);var A=require("@aidc-toolkit/core"),R=require("@aidc-toolkit/utility"),H=Ge(require("i18next"),1);var D={Check:{lengthOfStringForPriceOrWeightMustBeExactly:"Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",priceOrWeightComponent:"price or weight",lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo:"Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"},IdentificationKey:{identificationKeyTypeLength:"{{identificationKeyType}} must be {{length}} digits long",invalidCheckDigit:"Invalid check digit",invalidGTINLength:"GTIN must be 13, 12, 8, or 14 digits long",invalidGTIN14Length:"GTIN must be 14 digits long",invalidZeroSuppressedGTIN12:"Invalid zero-suppressed GTIN-12",invalidZeroSuppressibleGTIN12:"GTIN-12 not zero-suppressible",invalidZeroSuppressedGTIN12AsGTIN13:"Invalid zero-suppressed GTIN-12 as GTIN-13",invalidZeroSuppressedGTIN12AsGTIN14:"Invalid zero-suppressed GTIN-12 as GTIN-14",invalidGTIN13AtRetail:"GTIN-13 at retail consumer trade item level can't start with zero",invalidGTINAtRetail:"GTIN not supported at retail consumer trade item level",invalidGTINAtOtherThanRetail:"GTIN not supported at other than retail consumer trade item level",indicatorDigit:"indicator digit",serialComponent:"serial component",reference:"reference",referenceCantBeAllNumeric:"Reference can't be all-numeric",invalidCheckCharacterPair:"Invalid check character pair"},Prefix:{gs1CompanyPrefix:"GS1 Company Prefix",upcCompanyPrefix:"U.P.C. Company Prefix",gs18Prefix:"GS1-8 Prefix",invalidPrefixType:"Invalid prefix type",gs1CompanyPrefixCantStartWith0:`GS1 Company Prefix can't start with "0"`,gs1CompanyPrefixCantStartWith00000:`GS1 Company Prefix can't start with "00000"`,gs1CompanyPrefixCantStartWith000000:`GS1 Company Prefix can't start with "000000"`,upcCompanyPrefixCantStartWith0000:`U.P.C. Company Prefix can't start with "0000"`,gs18PrefixCantStartWith0:`GS1-8 Prefix can't start with "0"`,identificationKeyTypeNotSupportedByGS18Prefix:"{{identificationKeyType}} not supported by GS1-8 Prefix"}};var F={Check:{lengthOfStringForPriceOrWeightMustBeExactly:"La longueur {{longueur}} de la cha\xEEne pour le prix ou la somme du poids doit \xEAtre exactement {{exactLength}}",priceOrWeightComponent:"prix ou poids",lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo:"La longueur {{length}} de la cha\xEEne pour la paire de caract\xE8res de v\xE9rification doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximum Length}}"},IdentificationKey:{identificationKeyTypeLength:"{{identificationKeyType}} doit comporter {{length}} chiffres",invalidCheckDigit:"Chiffre de contr\xF4le non valide",invalidGTINLength:"Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",invalidGTIN14Length:"Le GTIN doit comporter 14 chiffres",invalidZeroSuppressedGTIN12:"Code GTIN-12 non valide avec z\xE9ro supprim\xE9",invalidZeroSuppressibleGTIN12:"Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",invalidZeroSuppressedGTIN12AsGTIN13:"GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",invalidZeroSuppressedGTIN12AsGTIN14:"GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",invalidGTIN13AtRetail:"Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",invalidGTINAtRetail:"Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",invalidGTINAtOtherThanRetail:"Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",indicatorDigit:"chiffre indicateur",serialComponent:"composant s\xE9rie",reference:"r\xE9f\xE9rence",referenceCantBeAllNumeric:"La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",invalidCheckCharacterPair:"Paire de caract\xE8res de contr\xF4le non valide"},Prefix:{gs1CompanyPrefix:"Pr\xE9fixe de l'entreprise GS1",upcCompanyPrefix:"Pr\xE9fixe de l'entreprise U.P.C.",gs18Prefix:"Pr\xE9fixe GS1-8",invalidPrefixType:"Type de pr\xE9fixe invalide",gs1CompanyPrefixCantStartWith0:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,gs1CompanyPrefixCantStartWith00000:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,gs1CompanyPrefixCantStartWith000000:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,upcCompanyPrefixCantStartWith0000:`Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,gs18PrefixCantStartWith0:'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',identificationKeyTypeNotSupportedByGS18Prefix:"{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"}};var z="aidct_gs1";(0,A.i18nAssertValidResources)(D,"fr",F);var Y={en:{aidct_gs1:D},fr:{aidct_gs1:F}},a=H.default.createInstance();async function Se(i,e=!1){await(0,R.i18nUtilityInit)(i,e),await(0,A.i18nCoreInit)(a,i,e,z,R.utilityResources,Y)}var C=require("@aidc-toolkit/utility"),x=new C.CharacterSetCreator(["!",'"',"%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],C.Exclusion.AllNumeric),U=new C.CharacterSetCreator(["#","-","/","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],C.Exclusion.AllNumeric);var l=require("@aidc-toolkit/utility");var Z=[0,3,6,9,12,15,18,21,24,27],v=[0,2,4,6,8,9,1,3,5,7],q=[0,5,1,6,2,7,3,8,4,9],Q=[0,5,9,4,8,3,7,2,6,1],Ae=[0,9,7,5,3,1,8,6,4,2];function N(i,e){let t=(e.length+Number(i))%2===0;return l.NUMERIC_CREATOR.characterIndexes(e).reduce((r,n,o)=>{if(n===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPosition",{ns:l.utilityNS,c:e.charAt(o),position:o+1}));return t=!t,r+(t?Z[n]:n)},0)}function P(i){return l.NUMERIC_CREATOR.character(9-(N(!1,i)+9)%10)}function L(i){return N(!0,i)%10===0}function j(i,e){if(e.length!==i.length)throw new RangeError(a.t("Check.lengthOfStringForPriceOrWeightMustBeExactly",{length:e.length,exactLength:i.length}));return l.NUMERIC_CREATOR.characterIndexes(e).reduce((r,n,o)=>{if(n===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent",{ns:l.utilityNS,c:e.charAt(o),position:o+1,component:a.t("Check.priceOrWeightComponent")}));return r+i[o][n]},0)}function Re(i){return l.NUMERIC_CREATOR.character(j([v,v,Z,Q],i)*3%10)}function ve(i){return l.NUMERIC_CREATOR.character(Ae[9-(j([q,v,Q,q,v],i)+9)%10])}var W=[107,103,101,97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2],B=["2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"];function E(i){let e=W.length-i.length;if(e<0)throw new RangeError(a.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo",{length:i.length,maximumLength:W.length}));let t=x.characterIndexes(i).reduce((n,o,c)=>{if(o===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPosition",{ns:l.utilityNS,c:i.charAt(c),position:c+1}));return n+o*W[e+c]},0)%1021,r=t%32;return B[(t-r)/32]+B[r]}function $(i){let e=i.length-2;return E(i.substring(0,e))===i.substring(e)}var s=require("@aidc-toolkit/utility"),_=require("ts-mixer");var J=(d=>(d.GTIN="GTIN",d.GLN="GLN",d.SSCC="SSCC",d.GRAI="GRAI",d.GIAI="GIAI",d.GSRN="GSRN",d.GDTI="GDTI",d.GINC="GINC",d.GSIN="GSIN",d.GCN="GCN",d.CPID="CPID",d.GMN="GMN",d))(J||{}),ee=(r=>(r[r.GS1CompanyPrefix=0]="GS1CompanyPrefix",r[r.UPCCompanyPrefix=1]="UPCCompanyPrefix",r[r.GS18Prefix=2]="GS18Prefix",r))(ee||{}),te=(r=>(r[r.Numeric=0]="Numeric",r[r.AI82=1]="AI82",r[r.AI39=2]="AI39",r))(te||{}),b=class i{static CHARACTER_SET_CREATORS=[s.NUMERIC_CREATOR,x,U];_identificationKeyType;_prefixType;_length;_referenceCharacterSet;_referenceCreator;static creatorFor(e){return i.CHARACTER_SET_CREATORS[e]}constructor(e,t,r,n){this._identificationKeyType=e,this._prefixType=t,this._length=r,this._referenceCharacterSet=n,this._referenceCreator=i.creatorFor(n)}get identificationKeyType(){return this._identificationKeyType}get prefixType(){return this._prefixType}get length(){return this._length}get referenceCharacterSet(){return this._referenceCharacterSet}get referenceCreator(){return this._referenceCreator}padIdentificationKey(e,t){return t?.positionOffset===void 0?e:this.referenceCreator.character(0).repeat(t.positionOffset).concat(e)}validatePrefix(e,t){h.validatePrefix(this.prefixType,!0,!1,e,!0,this.referenceCharacterSet===0,t)}},re=(r=>(r[r.None=0]="None",r[r.IndicatorDigit=1]="IndicatorDigit",r[r.ExtensionDigit=2]="ExtensionDigit",r))(re||{}),K=class extends b{_leaderType;_prefixPosition;constructor(e,t,r,n){super(e,t,r,0),this._leaderType=n,this._prefixPosition=+(this.leaderType===2)}get leaderType(){return this._leaderType}validate(e,t){if(this._prefixPosition===0?super.validatePrefix(e,t?.positionOffset):super.validatePrefix(e.substring(this._prefixPosition),t?.positionOffset===void 0?this._prefixPosition:t.positionOffset+this._prefixPosition),e.length!==this.length)throw new RangeError(a.t("IdentificationKey.identificationKeyTypeLength",{identificationKeyType:this.identificationKeyType,length:this.length}));if(!L(this.padIdentificationKey(e,t)))throw new RangeError(a.t("IdentificationKey.invalidCheckDigit"))}},ie=(n=>(n[n.GTIN13=13]="GTIN13",n[n.GTIN12=12]="GTIN12",n[n.GTIN8=8]="GTIN8",n[n.GTIN14=14]="GTIN14",n))(ie||{}),ne=(r=>(r[r.Any=0]="Any",r[r.RetailConsumer=1]="RetailConsumer",r[r.OtherThanRetailConsumer=2]="OtherThanRetailConsumer",r))(ne||{}),m=class i extends K{static OPTIONAL_INDICATOR_DIGIT_VALIDATION={minimumLength:0,maximumLength:1,component:()=>a.t("IdentificationKey.indicatorDigit")};static ZERO_SUPPRESSED_GTIN12_VALIDATION={minimumLength:8,maximumLength:8};constructor(e){let t;switch(e){case 13:t=0;break;case 12:t=1;break;case 8:t=2;break;default:throw new Error("Not supported")}super("GTIN",t,e,1)}get gtinType(){return this.length}validatePrefix(e,t){h.validatePrefix(this.prefixType,!1,!1,e,!0,!0,t)}static zeroSuppress(e){M.validate(e);let t=Array.from(e),r;if(t[0]==="0"&&t[6]==="0"&&t[7]==="0"&&(t[10]>="5"&&t[8]==="0"&&t[9]==="0"&&t[5]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[5]}${t[10]}${t[11]}`:t[5]==="0"&&t[8]==="0"&&t[9]==="0"&&t[4]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[10]}4${t[11]}`:t[3]<="2"&&t[4]==="0"&&t[5]==="0"?r=`0${t[1]}${t[2]}${t[8]}${t[9]}${t[10]}${t[3]}${t[11]}`:t[3]>="3"&&t[4]==="0"&&t[5]==="0"&&t[8]==="0"&&(r=`0${t[1]}${t[2]}${t[3]}${t[9]}${t[10]}3${t[11]}`)),r===void 0)throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));return r}static zeroExpand(e){s.NUMERIC_CREATOR.validate(e,i.ZERO_SUPPRESSED_GTIN12_VALIDATION);let t=Array.from(e),r;if(t[0]==="0"&&(t[6]>="5"&&t[5]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[5]}0000${t[6]}${t[7]}`:t[6]==="4"&&t[4]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}00000${t[5]}${t[7]}`:t[6]<="2"?r=`0${t[1]}${t[2]}${t[6]}0000${t[3]}${t[4]}${t[5]}${t[7]}`:t[6]==="3"&&t[3]>="3"&&(r=`0${t[1]}${t[2]}${t[3]}00000${t[4]}${t[5]}${t[7]}`)),r===void 0)throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12"));return M.validate(r),r}static convertToGTIN14(e,t){g.validateAny(t),s.NUMERIC_CREATOR.validate(e,i.OPTIONAL_INDICATOR_DIGIT_VALIDATION);let r=t.length,n="0".repeat(14-r)+t;if(e.length!==0&&e!==n.charAt(0)){let o=e+n.substring(1,13);n=o+P(o)}return n}static normalize(e){let t=e.length,r;switch(t){case 13:if(!e.startsWith("0"))r=e;else if(!e.startsWith("00000"))r=e.substring(1);else if(!e.startsWith("000000"))r=e.substring(5);else throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));break;case 12:r=e;break;case 8:e.startsWith("0")?r=i.zeroExpand(e):r=e;break;case 14:if(!e.startsWith("0"))r=e;else if(!e.startsWith("00"))r=e.substring(1);else if(!e.startsWith("000000"))r=e.substring(2);else if(!e.startsWith("0000000"))r=e.substring(6);else throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));break;default:throw new RangeError(a.t("IdentificationKey.invalidGTINLength"))}return g.validateAny(r),r}static validateAny(e,t=0){let r=e,n;switch(e.length){case 13:if(e.startsWith("0"))throw new RangeError(a.t("IdentificationKey.invalidGTIN13AtRetail"));h.validatePrefix(0,!1,!1,e,!0,!0),n=0;break;case 12:h.validatePrefix(1,!1,!1,e,!0,!0),n=0;break;case 8:e.startsWith("0")?r=i.zeroExpand(e):h.validatePrefix(2,!1,!1,e,!0,!0),n=1;break;case 14:h.validatePrefix(0,!0,!0,e.substring(1),!0,!0),n=2;break;default:throw new RangeError(a.t("IdentificationKey.invalidGTINLength"))}if(!L(r))throw new RangeError(a.t("IdentificationKey.invalidCheckDigit"));if(t!==0&&n!==0&&n!==t)throw new RangeError(a.t(t===1?"IdentificationKey.invalidGTINAtRetail":"IdentificationKey.invalidGTINAtOtherThanRetail"))}static validateGTIN14(e){if(e.length!==14)throw new RangeError(a.t("IdentificationKey.invalidGTIN14Length"));g.validateAny(e)}},I=class extends K{constructor(e,t,r=0){super(e,0,t,r)}},y=class i extends I{_serialComponentLength;_serialComponentCharacterSet;_serialComponentValidation;_serialComponentCreator;constructor(e,t,r,n){super(e,t,0),this._serialComponentLength=r,this._serialComponentCharacterSet=n,this._serialComponentValidation={minimumLength:1,maximumLength:r,component:()=>a.t("IdentificationKey.serialComponent")},this._serialComponentCreator=i.creatorFor(n)}get serialComponentLength(){return this._serialComponentLength}get serialComponentCharacterSet(){return this._serialComponentCharacterSet}get serialComponentValidation(){return this._serialComponentValidation}get serialComponentCreator(){return this._serialComponentCreator}validate(e,t){super.validate(e.substring(0,this.length),t),e.length>this.length&&this.serialComponentCreator.validate(e.substring(this.length),this._serialComponentValidation)}},T=class i extends b{static NOT_ALL_NUMERIC_VALIDATOR=new class extends s.RegExpValidator{createErrorMessage(e){return a.t("IdentificationKey.referenceCantBeAllNumeric")}}(/\D/);_requiresCheckCharacterPair;constructor(e,t,r,n=!1){super(e,0,t,r),this._requiresCheckCharacterPair=n}get requiresCheckCharacterPair(){return this._requiresCheckCharacterPair}validate(e,t){let r=this.requiresCheckCharacterPair?e.substring(0,e.length-2):e;if(super.validatePrefix(r,t?.positionOffset),!this.requiresCheckCharacterPair)this.referenceCreator.validate(e,{maximumLength:this.length,positionOffset:t?.positionOffset});else if(!$(this.padIdentificationKey(e,t)))throw new RangeError(a.t("IdentificationKey.invalidCheckCharacterPair"));t?.exclusion===s.Exclusion.AllNumeric&&i.NOT_ALL_NUMERIC_VALIDATOR.validate(r)}},ae=new m(13),M=new m(12),oe=new m(8),Le=[ae,M,oe],se=new I("GLN",13),ce=new I("SSCC",18,2),pe=new y("GRAI",13,16,1),fe=new T("GIAI",30,1),de=new I("GSRN",18),le=new y("GDTI",13,17,1),ue=new T("GINC",30,1),he=new I("GSIN",17),Ie=new y("GCN",13,12,0),Te=new T("CPID",30,2),ge=new T("GMN",25,1,!0),w=class{_prefixManager;_referenceLength;init(e,t,r){this._prefixManager=e,this._referenceLength=this.length-t.length-r}get prefixManager(){return this._prefixManager}get prefix(){return this.prefixManager.gs1CompanyPrefix}get referenceLength(){return this._referenceLength}},G=class i extends w{_capacity;_tweak=0n;init(e,t){super.init(e,t,1),this._capacity=Number(s.CharacterSetCreator.powerOf10(this.referenceLength))}get capacity(){return this._capacity}get tweak(){return this._tweak}set tweak(e){this._tweak=e}buildIdentificationKey(e){let t=this.leaderType===2?e.substring(0,1)+this.prefix+e.substring(1):this.prefix+e;return t+P(t)}create(e,t=!1){return s.NUMERIC_CREATOR.create(this.referenceLength,e,s.Exclusion.None,t?this.tweak:void 0,r=>this.buildIdentificationKey(r))}static*createAllPartial(e,t,r,n,o){if(t===0)yield e+s.NUMERIC_CREATOR.character(9-(o+9)%10);else{let c=t-1,f=o;if(r!==0)for(let p of s.NUMERIC_CREATOR.characterSet)yield*i.createAllPartial(p+e,c,0,n,f),f+=r;else{let p=4-n;for(let u of s.NUMERIC_CREATOR.characterSet)yield*i.createAllPartial(e+u,c,0,p,f),f+=n}}}createAll(){let e=this.leaderType===2,t=this.prefix,r=this.length,n=this.referenceLength,o=3-2*((n+1-Number(e))%2);return{[Symbol.iterator](){return i.createAllPartial(t,n,e?3-2*r%2:0,o,N(o===3,t))}}}},g=class i extends(0,_.Mixin)(m,G){static REQUIRED_INDICATOR_DIGIT_VALIDATION={minimumLength:1,maximumLength:1,component:()=>a.t("IdentificationKey.indicatorDigit")};constructor(e,t){super(t),this.init(e,e.prefix)}get prefix(){return this.prefixManager.prefix}createGTIN14(e,t,r=!1){return s.NUMERIC_CREATOR.validate(e,i.REQUIRED_INDICATOR_DIGIT_VALIDATION),s.NUMERIC_CREATOR.create(13-this.prefixManager.gs1CompanyPrefix.length-1,t,s.Exclusion.None,r?this.tweak:void 0,n=>{let o=e+this.prefixManager.gs1CompanyPrefix+n;return o+P(o)})}},O=class extends(0,_.Mixin)(I,G){constructor(e,t,r,n=0){super(t,r,n),this.init(e,e.gs1CompanyPrefix)}},V=class extends(0,_.Mixin)(y,G){constructor(e,t,r,n,o){super(t,r,n,o),this.init(e,e.gs1CompanyPrefix)}concatenateValidated(e,t){let r,n=this.serialComponentCreator,o=this.serialComponentValidation;function c(f){return n.validate(f,o),e+f}return typeof t!="object"?r=c(t):r=(0,s.transformIterable)(t,c),r}createSerialized(e,t,r){return this.concatenateValidated(this.create(e,r),t)}concatenate(e,t){return this.validate(e),this.concatenateValidated(e,t)}},k=class extends(0,_.Mixin)(T,w){_referenceValidation;constructor(e,t,r,n,o=!1){super(t,r,n,o),this.init(e,e.gs1CompanyPrefix,2*Number(o)),this._referenceValidation={minimumLength:1,maximumLength:this.referenceLength,component:()=>a.t("IdentificationKey.reference")}}get referenceValidation(){return this._referenceValidation}create(e){let t,r=this.referenceCreator,n=this.referenceValidation,o=this.prefix,c=this.requiresCheckCharacterPair;function f(p){r.validate(p,n);let u=o+p;return c?u+E(u):u}return typeof e!="object"?t=f(e):t=(0,s.transformIterable)(e,f),t}},h=class i{static PREFIX_MANAGERS_MAP=new Map;static GS1_COMPANY_PREFIX_MINIMUM_LENGTH=4;static GS1_COMPANY_PREFIX_MAXIMUM_LENGTH=12;static UPC_COMPANY_PREFIX_MINIMUM_LENGTH=6;static UPC_COMPANY_PREFIX_MAXIMUM_LENGTH=11;static GS1_8_PREFIX_MINIMUM_LENGTH=2;static GS1_8_PREFIX_MAXIMUM_LENGTH=7;static GS1_COMPANY_PREFIX_VALIDATION={minimumLength:i.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,maximumLength:i.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.gs1CompanyPrefix")};static UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION={minimumLength:i.UPC_COMPANY_PREFIX_MINIMUM_LENGTH+1,maximumLength:i.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH+1,component:()=>a.t("Prefix.gs1CompanyPrefix")};static GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION={minimumLength:i.GS1_8_PREFIX_MINIMUM_LENGTH+5,maximumLength:i.GS1_8_PREFIX_MAXIMUM_LENGTH+5,component:()=>a.t("Prefix.gs1CompanyPrefix")};static UPC_COMPANY_PREFIX_VALIDATION={minimumLength:i.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,maximumLength:i.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.upcCompanyPrefix")};static GS1_8_PREFIX_VALIDATION={minimumLength:i.GS1_8_PREFIX_MINIMUM_LENGTH,maximumLength:i.GS1_8_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.gs18Prefix")};static CREATOR_TWEAK_FACTORS_MAP=new Map([["GTIN",1987n],["GLN",4241n],["SSCC",8087n],["GRAI",3221n],["GSRN",2341n],["GDTI",7333n],["GSIN",5623n],["GCN",6869n]]);_prefixType;_prefix;_gs1CompanyPrefix;_upcCompanyPrefix;_gs18Prefix;_defaultTweakFactor;_tweakFactor=0n;_identificationKeyCreatorsMap=new Map;constructor(e){this._gs1CompanyPrefix=e,e.startsWith("0")?e.startsWith("00000")?(this._prefixType=2,this._gs18Prefix=e.substring(5),this._prefix=this._gs18Prefix):(this._prefixType=1,this._upcCompanyPrefix=e.substring(1),this._prefix=this._upcCompanyPrefix):(this._prefixType=0,this._prefix=this._gs1CompanyPrefix),this._defaultTweakFactor=BigInt(`1${this.gs1CompanyPrefix}`),this.resetTweakFactor()}get prefixType(){return this._prefixType}get prefix(){return this._prefix}get gs1CompanyPrefix(){return this._gs1CompanyPrefix}get upcCompanyPrefix(){return this._upcCompanyPrefix}get gs18Prefix(){return this._gs18Prefix}setCreatorTweak(e){let t=i.CREATOR_TWEAK_FACTORS_MAP.get(e.identificationKeyType);t!==void 0&&(e.tweak=this.tweakFactor*t)}get tweakFactor(){return this._tweakFactor}set tweakFactor(e){let t=BigInt(e);if(this._tweakFactor!==t){this._tweakFactor=t;for(let r of this._identificationKeyCreatorsMap.values())this.setCreatorTweak(r)}}resetTweakFactor(){this.tweakFactor=this._defaultTweakFactor}static get(e,t){i.validatePrefix(e,!0,!0,t);let r;switch(e){case 0:r=t;break;case 1:r="0"+t;break;case 2:r="00000"+t;break;default:throw new RangeError(a.t("Prefix.invalidPrefixType"))}let n=i.PREFIX_MANAGERS_MAP.get(r);return n===void 0&&(n=new i(r),i.PREFIX_MANAGERS_MAP.set(r,n)),n}static validatePrefix(e,t,r,n,o=!1,c=!1,f){let p;switch(e){case 0:if(!n.startsWith("0"))p=i.GS1_COMPANY_PREFIX_VALIDATION;else if(n.startsWith("00000")){if(n.startsWith("000000"))throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith000000"));if(!r)throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith00000"));p=i.GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION}else{if(!t)throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith0"));p=i.UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION}break;case 1:if(n.startsWith("0000"))throw new RangeError(a.t("Prefix.upcCompanyPrefixCantStartWith0000"));p=i.UPC_COMPANY_PREFIX_VALIDATION;break;case 2:if(n.startsWith("0"))throw new RangeError(a.t("Prefix.gs18PrefixCantStartWith0"));p=i.GS1_8_PREFIX_VALIDATION;break}let u={...p,positionOffset:f};o?c||s.NUMERIC_CREATOR.validate(n.substring(0,Math.min(u.minimumLength,n.length-1)),u):s.NUMERIC_CREATOR.validate(n,u)}getIdentificationKeyCreator(e,t){let r=this._identificationKeyCreatorsMap.get(e);if(r===void 0){if(this.prefixType===2&&e!=="GTIN")throw new RangeError(a.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix",{identificationKeyType:e}));r=t(),this.setCreatorTweak(r),this._identificationKeyCreatorsMap.set(e,r)}return r}getNonGTINNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new O(this,e.identificationKeyType,e.length,e.leaderType))}getSerializableNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new V(this,e.identificationKeyType,e.length,e.serialComponentLength,e.serialComponentCharacterSet))}getNonNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new k(this,e.identificationKeyType,e.length,e.referenceCharacterSet,e.requiresCheckCharacterPair))}get gtinCreator(){return this.getIdentificationKeyCreator("GTIN",()=>{let e;switch(this.prefixType){case 0:e=13;break;case 1:e=12;break;case 2:e=8;break}return new g(this,e)})}get glnCreator(){return this.getNonGTINNumericIdentificationKeyCreator(se)}get ssccCreator(){return this.getNonGTINNumericIdentificationKeyCreator(ce)}get graiCreator(){return this.getSerializableNumericIdentificationKeyCreator(pe)}get giaiCreator(){return this.getNonNumericIdentificationKeyCreator(fe)}get gsrnCreator(){return this.getNonGTINNumericIdentificationKeyCreator(de)}get gdtiCreator(){return this.getSerializableNumericIdentificationKeyCreator(le)}get gincCreator(){return this.getNonNumericIdentificationKeyCreator(ue)}get gsinCreator(){return this.getNonGTINNumericIdentificationKeyCreator(he)}get gcnCreator(){return this.getSerializableNumericIdentificationKeyCreator(Ie)}get cpidCreator(){return this.getNonNumericIdentificationKeyCreator(Te)}get gmnCreator(){return this.getNonNumericIdentificationKeyCreator(ge)}};0&&(module.exports={AI39_CREATOR,AI82_CREATOR,CPID_VALIDATOR,ContentCharacterSet,GCN_VALIDATOR,GDTI_VALIDATOR,GIAI_VALIDATOR,GINC_VALIDATOR,GLN_VALIDATOR,GMN_VALIDATOR,GRAI_VALIDATOR,GSIN_VALIDATOR,GSRN_VALIDATOR,GTIN12_VALIDATOR,GTIN13_VALIDATOR,GTIN8_VALIDATOR,GTINCreator,GTINLevel,GTINType,GTINValidator,GTIN_VALIDATORS,IdentificationKeyType,LeaderType,NonGTINNumericIdentificationKeyCreator,NonGTINNumericIdentificationKeyValidator,NonNumericIdentificationKeyCreator,NonNumericIdentificationKeyValidator,PrefixManager,PrefixType,SSCC_VALIDATOR,SerializableNumericIdentificationKeyCreator,SerializableNumericIdentificationKeyValidator,checkCharacterPair,checkDigit,checkDigitSum,fiveDigitPriceWeightCheckDigit,fourDigitPriceWeightCheckDigit,gs1NS,gs1Resources,hasValidCheckCharacterPair,hasValidCheckDigit,i18nGS1Init,i18nextGS1});
2042
2
  /*!
2043
3
  * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
2044
4
  * contributors