@aidc-toolkit/utility 0.9.14-beta → 0.9.15-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,1291 @@
1
- import{i18nAssertValidResources as v,i18nCoreInit as w}from"@aidc-toolkit/core";import A from"i18next";var E={Transformer:{domainMustBeGreaterThanZero:"Domain {{domain}} must be greater than 0",tweakMustBeGreaterThanOrEqualToZero:"Tweak {{tweak}} must be greater than or equal to 0",valueMustBeGreaterThanOrEqualToZero:"Value {{value}} must be greater than or equal to 0",valueMustBeLessThan:"Value {{value}} must be less than {{domain}}",minimumValueMustBeGreaterThanOrEqualToZero:"Minimum value {{minimumValue}} must be greater than or equal to 0",maximumValueMustBeLessThan:"Maximum value {{maximumValue}} must be less than {{domain}}"},RegExpValidator:{stringDoesNotMatchPattern:"String {{s}} does not match pattern"},CharacterSetValidator:{firstZeroFirstCharacter:"Character set must support zero as first character",allNumericAllNumericCharacters:"Character set must support all numeric characters in sequence",stringMustNotBeAllNumeric:"String must not be all numeric",lengthMustBeGreaterThanOrEqualTo:"Length {{length}} must be greater than or equal to {{minimumLength}}",lengthMustBeLessThanOrEqualTo:"Length {{length}} must be less than or equal to {{maximumLength}}",lengthMustBeEqualTo:"Length {{length}} must be equal to {{exactLength}}",lengthOfComponentMustBeGreaterThanOrEqualTo:"Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}",lengthOfComponentMustBeLessThanOrEqualTo:"Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}",lengthOfComponentMustBeEqualTo:"Length {{length}} of {{component}} must be equal to {{exactLength}}",invalidCharacterAtPosition:"Invalid character '{{c}}' at position {{position}}",invalidCharacterAtPositionOfComponent:"Invalid character '{{c}}' at position {{position}} of {{component}}",exclusionNotSupported:"Exclusion value of {{exclusion}} is not supported",invalidTweakWithAllNumericExclusion:"Tweak must not be used with all-numeric exclusion",endSequenceValueMustBeLessThanOrEqualTo:"End sequence value (start sequence value + count - 1) must be less than {{domain}}"},RecordValidator:{typeNameKeyNotFound:'{{typeName}} "{{key}}" not found'}};var S={Transformer:{domainMustBeGreaterThanZero:"Le domaine {{domain}} doit \xEAtre sup\xE9rieur \xE0 0",tweakMustBeGreaterThanOrEqualToZero:"Le r\xE9glage {{tweak}} doit \xEAtre sup\xE9rieur ou \xE9gal \xE0 0",valueMustBeGreaterThanOrEqualToZero:"La valeur {{value}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",valueMustBeLessThan:"La valeur {{value}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}",minimumValueMustBeGreaterThanOrEqualToZero:"La valeur minimale {{minimumValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",maximumValueMustBeLessThan:"La valeur maximale {{maximumValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"},RegExpValidator:{stringDoesNotMatchPattern:"La cha\xEEne {{s}} ne correspond pas au mod\xE8le"},CharacterSetValidator:{firstZeroFirstCharacter:"Le jeu de caract\xE8res doit prendre en charge z\xE9ro comme premier caract\xE8re",allNumericAllNumericCharacters:"Le jeu de caract\xE8res doit prendre en charge tous les caract\xE8res num\xE9riques en s\xE9quence",stringMustNotBeAllNumeric:"La cha\xEEne ne doit pas \xEAtre enti\xE8rement num\xE9rique",lengthMustBeGreaterThanOrEqualTo:"La longueur {{length}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",lengthMustBeLessThanOrEqualTo:"La longueur {{length}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",lengthMustBeEqualTo:"La longueur {{length}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",lengthOfComponentMustBeGreaterThanOrEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",lengthOfComponentMustBeLessThanOrEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",lengthOfComponentMustBeEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",invalidCharacterAtPosition:"Caract\xE8re non valide '{{c}}' \xE0 la position {{position}}",invalidCharacterAtPositionOfComponent:"Caract\xE8re non valide '{{c}}' \xE0 la position {{position}} de {{component}}",exclusionNotSupported:"La valeur d'exclusion de {{exclusion}} n'est pas prise en charge",invalidTweakWithAllNumericExclusion:"Le r\xE9glage ne doit pas \xEAtre utilis\xE9 avec une exclusion enti\xE8rement num\xE9rique",endSequenceValueMustBeLessThanOrEqualTo:"La valeur de la s\xE9quence de fin (valeur de la s\xE9quence de d\xE9but + nombre - 1) doit \xEAtre inf\xE9rieure \xE0 {{domaine}}"},RecordValidator:{typeNameKeyNotFound:'{{typeName}} "{{key}}" introuvable'}};var B="aidct_utility";v(E,"fr",S);var V={en:{aidct_utility:E},fr:{aidct_utility:S}},u=A.createInstance();async function F(i,e=!1){await w(u,i,e,B,V)}var T=class{_startValue;_endValue;_count;_nextDelta;_minimumValue;_maximumValue;constructor(e,t){this._startValue=BigInt(e),this._endValue=this._startValue+BigInt(t),this._count=t,t>=0?(this._nextDelta=1n,this._minimumValue=this._startValue,this._maximumValue=this._endValue-1n):(this._nextDelta=-1n,this._minimumValue=this._endValue+1n,this._maximumValue=this._startValue)}get startValue(){return this._startValue}get endValue(){return this._endValue}get count(){return this._count}get minimumValue(){return this._minimumValue}get maximumValue(){return this._maximumValue}*[Symbol.iterator](){for(let e=this._startValue;e!==this._endValue;e+=this._nextDelta)yield e}};function b(i,e){return{*[Symbol.iterator](){let t=0;for(let r of i)yield e(r,t++)}}}var g=class i{static TRANSFORMER_MAPS_MAP=new Map;_domain;constructor(e){if(this._domain=BigInt(e),this._domain<=0n)throw new RangeError(u.t("Transformer.domainMustBeGreaterThanZero",{domain:e}))}static get(e,t){let r=BigInt(e),n=i.TRANSFORMER_MAPS_MAP.get(r);n===void 0&&(n=new Map,i.TRANSFORMER_MAPS_MAP.set(r,n));let a=t===void 0?void 0:BigInt(t),o=n.get(a);return o===void 0&&(o=a===void 0?new N(r):new M(r,a),n.set(a,o)),o}get domain(){return this._domain}validate(e){if(e<0n)throw new RangeError(u.t("Transformer.valueMustBeGreaterThanOrEqualToZero",{value:e}));if(e>=this.domain)throw new RangeError(u.t("Transformer.valueMustBeLessThan",{value:e,domain:this.domain}))}validateDoForward(e){let t=BigInt(e);return this.validate(t),this.doForward(t)}validateDoForwardCallback(e,t,r){return e(this.validateDoForward(t),r)}forward(e,t){let r;if(typeof e!="object")r=t===void 0?this.validateDoForward(e):this.validateDoForwardCallback(t,e,0);else if(e instanceof T){if(e.minimumValue<0n)throw new RangeError(u.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero",{minimumValue:e.minimumValue}));if(e.maximumValue>=this.domain)throw new RangeError(u.t("Transformer.maximumValueMustBeLessThan",{maximumValue:e.maximumValue,domain:this.domain}));r=t===void 0?b(e,n=>this.doForward(n)):b(e,(n,a)=>t(this.doForward(n),a))}else r=t===void 0?b(e,n=>this.validateDoForward(n)):b(e,(n,a)=>this.validateDoForwardCallback(t,n,a));return r}reverse(e){let t=BigInt(e);return this.validate(t),this.doReverse(t)}},N=class extends g{doForward(e){return e}doReverse(e){return e}},M=class i extends g{static BITS=new Uint8Array([1,2,4,8,16,32,64,128]);static INVERSE_BITS=new Uint8Array([254,253,251,247,239,223,191,127]);_domainBytes;_xorBytes;_bits;_inverseBits;_rounds;constructor(e,t){if(super(e),t<0n)throw new RangeError(u.t("Transformer.tweakMustBeGreaterThanOrEqualToZero",{tweak:t}));let r=0;for(let s=this.domain-1n;s!==0n;s>>=8n)r++;this._domainBytes=r;let n=new Array,a=new Array,o=new Array;for(let s=this.domain*BigInt(t)*603868999n;s!==0n;s>>=8n){n.unshift(Number(BigInt.asUintN(8,s)));let l=Number(BigInt.asUintN(3,s));a.push(i.BITS[l]),o.push(i.INVERSE_BITS[l])}if(r===1){let s=i.BITS.filter(l=>l<e).reduce((l,h)=>l|h,0);this._xorBytes=new Uint8Array([n.reduce((l,h)=>l^h,0)&s]),this._bits=new Uint8Array([i.BITS[0]]),this._inverseBits=new Uint8Array([i.INVERSE_BITS[0]]),this._rounds=1}else this._xorBytes=new Uint8Array(n),this._bits=new Uint8Array(a),this._inverseBits=new Uint8Array(o),this._rounds=n.length}valueToBytes(e){let t=new Uint8Array(this._domainBytes);for(let r=this._domainBytes-1,n=e;r>=0&&n!==0n;r--,n>>=8n)t[r]=Number(BigInt.asUintN(8,n));return t}static bytesToValue(e){return e.reduce((t,r)=>t<<8n|BigInt(r),0n)}shuffle(e,t,r){let n=e.length,a=new Uint8Array(n),o=new Array,s=new Array,l=this._bits[t];e.forEach((m,c)=>{let p=m&l;a[c]=p,(p!==0?o:s).push(c)});let h=this._inverseBits[t],d=new Uint8Array(n);return[...o,...s].forEach((m,c)=>{r?d[c]=e[m]&h|a[c]:d[m]=e[c]&h|a[m]}),d}xor(e,t,r){let n=this._xorBytes[t];return e.map(a=>{let o=a^n;return n=r?o:a,o})}doForward(e){let t=this.valueToBytes(e),r;do{for(let n=0;n<this._rounds;n++)t=this.xor(this.shuffle(t,n,!0),n,!0);r=i.bytesToValue(t)}while(r>=this.domain);return r}doReverse(e){let t=this.valueToBytes(e),r;do{for(let n=this._rounds-1;n>=0;n--)t=this.shuffle(this.xor(t,n,!1),n,!1);r=i.bytesToValue(t)}while(r>=this.domain);return r}};var x=class{_regExp;constructor(e){this._regExp=e}get regExp(){return this._regExp}createErrorMessage(e){return u.t("RegExpValidator.stringDoesNotMatchPattern",{s:e})}validate(e){if(!this._regExp.test(e))throw new RangeError(this.createErrorMessage(e))}};var _=class{_typeName;_record;constructor(e,t){this._typeName=e,this._record=t}get typeName(){return this._typeName}get record(){return this._record}validate(e){if(!(e in this.record))throw new RangeError(u.t("RecordValidator.typeNameKeyNotFound",{typeName:this.typeName,key:e}))}};var O=(r=>(r[r.None=0]="None",r[r.FirstZero=1]="FirstZero",r[r.AllNumeric=2]="AllNumeric",r))(O||{}),I=class i{static NOT_ALL_NUMERIC_VALIDATOR=new class extends x{createErrorMessage(e){return u.t("CharacterSetValidator.stringMustNotBeAllNumeric")}}(/\D/);_characterSet;_characterSetMap;_exclusionSupport;constructor(e,...t){this._characterSet=e;let r=new Map;e.forEach((n,a)=>{r.set(n,a)}),this._characterSetMap=r,this._exclusionSupport=t}get characterSet(){return this._characterSet}get characterSetSize(){return this._characterSet.length}get exclusionSupport(){return this._exclusionSupport}character(e){return this._characterSet[e]}characterIndex(e){return this._characterSetMap.get(e)}characterIndexes(e){return Array.from(e).map(t=>this._characterSetMap.get(t))}static componentToString(e){return typeof e=="function"?e():e}validateExclusion(e){if(e!==0&&!this._exclusionSupport.includes(e))throw new RangeError(u.t("CharacterSetValidator.exclusionNotSupported",{exclusion:e}))}validate(e,t){let r=e.length,n=t?.minimumLength,a=t?.maximumLength;if(n!==void 0&&r<n){let s;throw a!==void 0&&a===n?s=u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeEqualTo":"CharacterSetValidator.lengthOfComponentMustBeEqualTo",{component:i.componentToString(t?.component),length:r,exactLength:n}):s=u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo":"CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo",{component:i.componentToString(t?.component),length:r,minimumLength:n}),new RangeError(s)}if(a!==void 0&&r>a)throw new RangeError(u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeLessThanOrEqualTo":"CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo",{component:i.componentToString(t?.component),length:r,maximumLength:a}));let o=this.characterIndexes(e).findIndex(s=>s===void 0);if(o!==-1)throw new RangeError(u.t(t?.component===void 0?"CharacterSetValidator.invalidCharacterAtPosition":"CharacterSetValidator.invalidCharacterAtPositionOfComponent",{component:i.componentToString(t?.component),c:e.charAt(o),position:o+(t?.positionOffset??0)+1}));if(t?.exclusion!==void 0)switch(this.validateExclusion(t.exclusion),t.exclusion){case 0:break;case 1:if(e.startsWith("0"))throw new RangeError(u.t(t.component===void 0?"CharacterSetValidator.invalidCharacterAtPosition":"CharacterSetValidator.invalidCharacterAtPositionOfComponent",{component:i.componentToString(t.component),c:"0",position:(t.positionOffset??0)+1}));break;case 2:i.NOT_ALL_NUMERIC_VALIDATOR.validate(e);break}}},f=class i extends I{static MAXIMUM_STRING_LENGTH=40;static _powersOf10=i.createPowersOf(10);static createPowersOf(e){let t=new Array(this.MAXIMUM_STRING_LENGTH+1),r=BigInt(e);for(let n=0,a=1n;n<=this.MAXIMUM_STRING_LENGTH;n++,a*=r)t[n]=a;return t}static powerOf10(e){return this._powersOf10[e]}_characterSetSizeN;_characterSetSizeMinusOneN;_exclusionDomains;_allZerosValues;constructor(e,...t){super(e,...t),this._characterSetSizeN=BigInt(this.characterSetSize),this._characterSetSizeMinusOneN=BigInt(this.characterSetSize-1);let r=[],n=i.createPowersOf(this.characterSetSize);if(r[0]=n,t.includes(1)){if(e[0]!=="0")throw new RangeError(u.t("CharacterSetValidator.firstZeroFirstCharacter"));let o=new Array(i.MAXIMUM_STRING_LENGTH+1);o[0]=0n;for(let s=1;s<=i.MAXIMUM_STRING_LENGTH;s++)o[s]=this._characterSetSizeMinusOneN*n[s-1];r[1]=o}if(t.includes(2)){let s=function(c){let p=c[0];for(let y of c){if(y===void 0||y!==p)throw new RangeError(u.t("CharacterSetValidator.allNumericAllNumericCharacters"));p=y+1}};var a=s;let o=new Array(i.MAXIMUM_STRING_LENGTH+1),l=this.characterIndexes("0123456789");s(l);let h=BigInt(l[0]),d=new Array(i.MAXIMUM_STRING_LENGTH+1),m=0n;for(let c=0;c<=i.MAXIMUM_STRING_LENGTH;c++)o[c]=n[c]-i.powerOf10(c),d[c]=m,m=m*this._characterSetSizeN+h;this._allZerosValues=d,r[2]=o}else this._allZerosValues=[];this._exclusionDomains=r}powerOfSize(e){return this._exclusionDomains[0][e]}allNumericShift(e,t,r){let n;if(t===0){if(!e&&r<10n)throw new RangeError(u.t("CharacterSetValidator.stringMustNotBeAllNumeric"));n=10n}else{let a=this.powerOfSize(t),o=i.powerOf10(t),s=e?a-o:a,l=r/s;l>=10n?n=i.powerOf10(t+1):n=l*o+this.allNumericShift(e,t-1,r-l*s)}return n}validateLength(e){if(e<0)throw new RangeError(u.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo",{length:e,minimumLength:0}));if(e>i.MAXIMUM_STRING_LENGTH)throw new RangeError(u.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo",{length:e,maximumLength:i.MAXIMUM_STRING_LENGTH}))}create(e,t,r=0,n,a){this.validateLength(e),this.validateExclusion(r);let o=r===2?this._allZerosValues[e]:0n;return g.get(this._exclusionDomains[r][e],n).forward(t,(l,h)=>{let d="";if(e!==0){let m=l;r===2&&m>=o&&(m=m+this.allNumericShift(!0,e,m-o));for(let c=e-1;c>0;c--){let p=m/this._characterSetSizeN;d=this.character(Number(m-p*this._characterSetSizeN))+d,m=p}d=this.character(r===1?Number(m%this._characterSetSizeMinusOneN)+1:Number(m%this._characterSetSizeN))+d}return a===void 0?d:a(d,h)})}valueFor(e,t=0,r){let n=e.length;this.validateLength(n),this.validateExclusion(t);let a=BigInt(this.characterSetSize),o=this.characterIndexes(e).reduce((s,l,h)=>{if(l===void 0)throw new RangeError(u.t("CharacterSetValidator.invalidCharacterAtPosition",{c:e.charAt(h),position:h+1}));let d;if(h===0&&t===1){if(l===0)throw new RangeError(u.t("CharacterSetValidator.invalidCharacterAtPosition",{c:"0",position:1}));d=BigInt(l-1)}else d=s*a+BigInt(l);return d},0n);if(t===2){let s=this._allZerosValues[n];o>=s&&(o-=this.allNumericShift(!1,n,o-s))}return g.get(this._exclusionDomains[t][n],r).reverse(o)}},Y=new f(["0","1","2","3","4","5","6","7","8","9"],1),$=new f(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],1,2),ee=new f(["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"]),te=new f(["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"],1,2);export{ee as ALPHABETIC_CREATOR,te as ALPHANUMERIC_CREATOR,f as CharacterSetCreator,I as CharacterSetValidator,M as EncryptionTransformer,O as Exclusion,$ as HEXADECIMAL_CREATOR,N as IdentityTransformer,Y as NUMERIC_CREATOR,_ as RecordValidator,x as RegExpValidator,T as Sequence,g as Transformer,F as i18nUtilityInit,u as i18nextUtility,b as transformIterable,B as utilityNS,V as utilityResources};
1
+ // src/locale/i18n.ts
2
+ import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
3
+ import i18next from "i18next";
4
+
5
+ // src/locale/en/locale-strings.ts
6
+ var localeStrings = {
7
+ Transformer: {
8
+ domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0",
9
+ tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
10
+ valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
11
+ valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
12
+ minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
13
+ maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
14
+ },
15
+ RegExpValidator: {
16
+ stringDoesNotMatchPattern: "String {{s}} does not match pattern"
17
+ },
18
+ CharacterSetValidator: {
19
+ firstZeroFirstCharacter: "Character set must support zero as first character",
20
+ allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence",
21
+ stringMustNotBeAllNumeric: "String must not be all numeric",
22
+ lengthMustBeGreaterThanOrEqualTo: "Length {{length}} must be greater than or equal to {{minimumLength}}",
23
+ lengthMustBeLessThanOrEqualTo: "Length {{length}} must be less than or equal to {{maximumLength}}",
24
+ lengthMustBeEqualTo: "Length {{length}} must be equal to {{exactLength}}",
25
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}",
26
+ lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}",
27
+ lengthOfComponentMustBeEqualTo: "Length {{length}} of {{component}} must be equal to {{exactLength}}",
28
+ invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position}}",
29
+ invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position}} of {{component}}",
30
+ exclusionNotSupported: "Exclusion value of {{exclusion}} is not supported",
31
+ invalidTweakWithAllNumericExclusion: "Tweak must not be used with all-numeric exclusion",
32
+ endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain}}"
33
+ },
34
+ RecordValidator: {
35
+ typeNameKeyNotFound: '{{typeName}} "{{key}}" not found'
36
+ }
37
+ };
38
+
39
+ // src/locale/fr/locale-strings.ts
40
+ var localeStrings2 = {
41
+ Transformer: {
42
+ domainMustBeGreaterThanZero: "Le domaine {{domain}} doit \xEAtre sup\xE9rieur \xE0 0",
43
+ tweakMustBeGreaterThanOrEqualToZero: "Le r\xE9glage {{tweak}} doit \xEAtre sup\xE9rieur ou \xE9gal \xE0 0",
44
+ valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
45
+ valueMustBeLessThan: "La valeur {{value}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}",
46
+ minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
47
+ maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"
48
+ },
49
+ RegExpValidator: {
50
+ stringDoesNotMatchPattern: "La cha\xEEne {{s}} ne correspond pas au mod\xE8le"
51
+ },
52
+ CharacterSetValidator: {
53
+ firstZeroFirstCharacter: "Le jeu de caract\xE8res doit prendre en charge z\xE9ro comme premier caract\xE8re",
54
+ allNumericAllNumericCharacters: "Le jeu de caract\xE8res doit prendre en charge tous les caract\xE8res num\xE9riques en s\xE9quence",
55
+ stringMustNotBeAllNumeric: "La cha\xEEne ne doit pas \xEAtre enti\xE8rement num\xE9rique",
56
+ lengthMustBeGreaterThanOrEqualTo: "La longueur {{length}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",
57
+ lengthMustBeLessThanOrEqualTo: "La longueur {{length}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",
58
+ lengthMustBeEqualTo: "La longueur {{length}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",
59
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length}} de {{component}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",
60
+ lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length}} de {{component}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",
61
+ lengthOfComponentMustBeEqualTo: "La longueur {{length}} de {{component}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",
62
+ invalidCharacterAtPosition: "Caract\xE8re non valide '{{c}}' \xE0 la position {{position}}",
63
+ invalidCharacterAtPositionOfComponent: "Caract\xE8re non valide '{{c}}' \xE0 la position {{position}} de {{component}}",
64
+ exclusionNotSupported: "La valeur d'exclusion de {{exclusion}} n'est pas prise en charge",
65
+ invalidTweakWithAllNumericExclusion: "Le r\xE9glage ne doit pas \xEAtre utilis\xE9 avec une exclusion enti\xE8rement num\xE9rique",
66
+ endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la s\xE9quence de fin (valeur de la s\xE9quence de d\xE9but + nombre - 1) doit \xEAtre inf\xE9rieure \xE0 {{domaine}}"
67
+ },
68
+ RecordValidator: {
69
+ typeNameKeyNotFound: '{{typeName}} "{{key}}" introuvable'
70
+ }
71
+ };
72
+
73
+ // src/locale/i18n.ts
74
+ var utilityNS = "aidct_utility";
75
+ i18nAssertValidResources(localeStrings, "fr", localeStrings2);
76
+ var utilityResources = {
77
+ en: {
78
+ aidct_utility: localeStrings
79
+ },
80
+ fr: {
81
+ aidct_utility: localeStrings2
82
+ }
83
+ };
84
+ var i18nextUtility = i18next.createInstance();
85
+ async function i18nUtilityInit(environment, debug = false) {
86
+ await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
87
+ }
88
+
89
+ // src/sequence.ts
90
+ var Sequence = class {
91
+ /**
92
+ * Start value (inclusive).
93
+ */
94
+ _startValue;
95
+ /**
96
+ * End value (exclusive).
97
+ */
98
+ _endValue;
99
+ /**
100
+ * Count of values.
101
+ */
102
+ _count;
103
+ /**
104
+ * Delta to the next value; equal to the sign of the count.
105
+ */
106
+ _nextDelta;
107
+ /**
108
+ * Minimum value (inclusive).
109
+ */
110
+ _minimumValue;
111
+ /**
112
+ * Maximum value (inclusive).
113
+ */
114
+ _maximumValue;
115
+ /**
116
+ * Constructor.
117
+ *
118
+ * @param startValue
119
+ * Start value.
120
+ *
121
+ * @param count
122
+ * Count of values. If count is zero or positive, iteration ascends from start value, otherwise it descends from
123
+ * start value.
124
+ */
125
+ constructor(startValue, count) {
126
+ this._startValue = BigInt(startValue);
127
+ this._endValue = this._startValue + BigInt(count);
128
+ this._count = count;
129
+ if (count >= 0) {
130
+ this._nextDelta = 1n;
131
+ this._minimumValue = this._startValue;
132
+ this._maximumValue = this._endValue - 1n;
133
+ } else {
134
+ this._nextDelta = -1n;
135
+ this._minimumValue = this._endValue + 1n;
136
+ this._maximumValue = this._startValue;
137
+ }
138
+ }
139
+ /**
140
+ * Get the start value (inclusive).
141
+ */
142
+ get startValue() {
143
+ return this._startValue;
144
+ }
145
+ /**
146
+ * Get the end value (exclusive).
147
+ */
148
+ get endValue() {
149
+ return this._endValue;
150
+ }
151
+ /**
152
+ * Get the count of values.
153
+ */
154
+ get count() {
155
+ return this._count;
156
+ }
157
+ /**
158
+ * Get the minimum value (inclusive).
159
+ */
160
+ get minimumValue() {
161
+ return this._minimumValue;
162
+ }
163
+ /**
164
+ * Get the maximum value (inclusive).
165
+ */
166
+ get maximumValue() {
167
+ return this._maximumValue;
168
+ }
169
+ /**
170
+ * Iterable implementation.
171
+ *
172
+ * @yields
173
+ * Next value in sequence.
174
+ */
175
+ *[Symbol.iterator]() {
176
+ for (let value = this._startValue; value !== this._endValue; value += this._nextDelta) {
177
+ yield value;
178
+ }
179
+ }
180
+ };
181
+
182
+ // src/transformer.ts
183
+ function transformIterable(values, transformerCallback) {
184
+ return {
185
+ /**
186
+ * Iterable implementation.
187
+ *
188
+ * @yields
189
+ * Next output value.
190
+ */
191
+ *[Symbol.iterator]() {
192
+ let index = 0;
193
+ for (const value of values) {
194
+ yield transformerCallback(value, index++);
195
+ }
196
+ }
197
+ };
198
+ }
199
+ var Transformer = class _Transformer {
200
+ /**
201
+ * Transformers cache, mapping a domain to another map, which maps an optional tweak to a transformer.
202
+ */
203
+ static TRANSFORMER_MAPS_MAP = /* @__PURE__ */ new Map();
204
+ /**
205
+ * Domain.
206
+ */
207
+ _domain;
208
+ /**
209
+ * Constructor.
210
+ *
211
+ * @param domain
212
+ * Domain.
213
+ */
214
+ constructor(domain) {
215
+ this._domain = BigInt(domain);
216
+ if (this._domain <= 0n) {
217
+ throw new RangeError(i18nextUtility.t("Transformer.domainMustBeGreaterThanZero", {
218
+ domain
219
+ }));
220
+ }
221
+ }
222
+ /**
223
+ * Get a transformer, constructing it if necessary. The type returned is {@link IdentityTransformer} if tweak is
224
+ * undefined, {@link EncryptionTransformer} if tweak is defined. Note that although an {@link EncryptionTransformer}
225
+ * with a zero tweak operates as an {@link IdentityTransformer}, {@link EncryptionTransformer} is still the type
226
+ * returned if a zero tweak is explicitly specified.
227
+ *
228
+ * @param domain
229
+ * Domain.
230
+ *
231
+ * @param tweak
232
+ * Tweak.
233
+ *
234
+ * @returns
235
+ * {@link IdentityTransformer} if tweak is undefined, {@link EncryptionTransformer} if tweak is defined.
236
+ */
237
+ static get(domain, tweak) {
238
+ const domainN = BigInt(domain);
239
+ let transformersMap = _Transformer.TRANSFORMER_MAPS_MAP.get(domainN);
240
+ if (transformersMap === void 0) {
241
+ transformersMap = /* @__PURE__ */ new Map();
242
+ _Transformer.TRANSFORMER_MAPS_MAP.set(domainN, transformersMap);
243
+ }
244
+ const tweakN = tweak === void 0 ? void 0 : BigInt(tweak);
245
+ let transformer = transformersMap.get(tweakN);
246
+ if (transformer === void 0) {
247
+ transformer = tweakN === void 0 ? new IdentityTransformer(domainN) : new EncryptionTransformer(domainN, tweakN);
248
+ transformersMap.set(tweakN, transformer);
249
+ }
250
+ return transformer;
251
+ }
252
+ /**
253
+ * Get the domain.
254
+ */
255
+ get domain() {
256
+ return this._domain;
257
+ }
258
+ /**
259
+ * Validate that a value is within the domain.
260
+ *
261
+ * @param value
262
+ * Value.
263
+ */
264
+ validate(value) {
265
+ if (value < 0n) {
266
+ throw new RangeError(i18nextUtility.t("Transformer.valueMustBeGreaterThanOrEqualToZero", {
267
+ value
268
+ }));
269
+ }
270
+ if (value >= this.domain) {
271
+ throw new RangeError(i18nextUtility.t("Transformer.valueMustBeLessThan", {
272
+ value,
273
+ domain: this.domain
274
+ }));
275
+ }
276
+ }
277
+ /**
278
+ * Validate that a value is within the domain and do the work of transforming it forward.
279
+ *
280
+ * @param value
281
+ * Value.
282
+ *
283
+ * @returns
284
+ * Transformed value.
285
+ */
286
+ validateDoForward(value) {
287
+ const valueN = BigInt(value);
288
+ this.validate(valueN);
289
+ return this.doForward(valueN);
290
+ }
291
+ /**
292
+ * Validate that a value is within the domain, do the work of transforming it forward, and apply a callback.
293
+ *
294
+ * @param transformerCallback
295
+ * Called after each value is transformed to convert it to its final value.
296
+ *
297
+ * @param value
298
+ * Value.
299
+ *
300
+ * @param index
301
+ * Index in sequence (0 for single transformation).
302
+ *
303
+ * @returns
304
+ * Transformed value.
305
+ */
306
+ validateDoForwardCallback(transformerCallback, value, index) {
307
+ return transformerCallback(this.validateDoForward(value), index);
308
+ }
309
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
310
+ forward(valueOrValues, transformerCallback) {
311
+ let result;
312
+ if (typeof valueOrValues !== "object") {
313
+ result = transformerCallback === void 0 ? this.validateDoForward(valueOrValues) : this.validateDoForwardCallback(transformerCallback, valueOrValues, 0);
314
+ } else if (valueOrValues instanceof Sequence) {
315
+ if (valueOrValues.minimumValue < 0n) {
316
+ throw new RangeError(i18nextUtility.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero", {
317
+ minimumValue: valueOrValues.minimumValue
318
+ }));
319
+ }
320
+ if (valueOrValues.maximumValue >= this.domain) {
321
+ throw new RangeError(i18nextUtility.t("Transformer.maximumValueMustBeLessThan", {
322
+ maximumValue: valueOrValues.maximumValue,
323
+ domain: this.domain
324
+ }));
325
+ }
326
+ result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.doForward(value)) : transformIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
327
+ } else {
328
+ result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.validateDoForward(value)) : transformIterable(valueOrValues, (value, index) => this.validateDoForwardCallback(transformerCallback, value, index));
329
+ }
330
+ return result;
331
+ }
332
+ /**
333
+ * Transform a value in reverse.
334
+ *
335
+ * @param transformedValue
336
+ * Transformed value.
337
+ *
338
+ * @returns
339
+ * Value.
340
+ */
341
+ reverse(transformedValue) {
342
+ const transformedValueN = BigInt(transformedValue);
343
+ this.validate(transformedValueN);
344
+ return this.doReverse(transformedValueN);
345
+ }
346
+ };
347
+ var IdentityTransformer = class extends Transformer {
348
+ /**
349
+ * @inheritDoc
350
+ */
351
+ doForward(value) {
352
+ return value;
353
+ }
354
+ /**
355
+ * @inheritDoc
356
+ */
357
+ doReverse(transformedValue) {
358
+ return transformedValue;
359
+ }
360
+ };
361
+ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
362
+ /**
363
+ * Individual bits, pre-calculated for performance.
364
+ */
365
+ static BITS = new Uint8Array([
366
+ 1,
367
+ 2,
368
+ 4,
369
+ 8,
370
+ 16,
371
+ 32,
372
+ 64,
373
+ 128
374
+ ]);
375
+ /**
376
+ * Inverse individual bits, pre-calculated for performance.
377
+ */
378
+ static INVERSE_BITS = new Uint8Array([
379
+ 254,
380
+ 253,
381
+ 251,
382
+ 247,
383
+ 239,
384
+ 223,
385
+ 191,
386
+ 127
387
+ ]);
388
+ /**
389
+ * Number of bytes covered by the domain.
390
+ */
391
+ _domainBytes;
392
+ /**
393
+ * Xor bytes array generated from the domain and tweak.
394
+ */
395
+ _xorBytes;
396
+ /**
397
+ * Bits array generated from the domain and tweak.
398
+ */
399
+ _bits;
400
+ /**
401
+ * Inverse bits array generated from the domain and tweak.
402
+ */
403
+ _inverseBits;
404
+ /**
405
+ * Number of rounds (length of arrays) generated from the domain and tweak.
406
+ */
407
+ _rounds;
408
+ /**
409
+ * Constructor.
410
+ *
411
+ * @param domain
412
+ * Domain.
413
+ *
414
+ * @param tweak
415
+ * Tweak.
416
+ */
417
+ constructor(domain, tweak) {
418
+ super(domain);
419
+ if (tweak < 0n) {
420
+ throw new RangeError(i18nextUtility.t("Transformer.tweakMustBeGreaterThanOrEqualToZero", {
421
+ tweak
422
+ }));
423
+ }
424
+ let domainBytes = 0;
425
+ for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne >>= 8n) {
426
+ domainBytes++;
427
+ }
428
+ this._domainBytes = domainBytes;
429
+ const xorBytes = new Array();
430
+ const bits = new Array();
431
+ const inverseBits = new Array();
432
+ for (let reducedKey = this.domain * BigInt(tweak) * 603868999n; reducedKey !== 0n; reducedKey >>= 8n) {
433
+ xorBytes.unshift(Number(BigInt.asUintN(8, reducedKey)));
434
+ const bitNumber = Number(BigInt.asUintN(3, reducedKey));
435
+ bits.push(_EncryptionTransformer.BITS[bitNumber]);
436
+ inverseBits.push(_EncryptionTransformer.INVERSE_BITS[bitNumber]);
437
+ }
438
+ if (domainBytes === 1) {
439
+ const domainMask = _EncryptionTransformer.BITS.filter((bit) => bit < domain).reduce((accumulator, bit) => accumulator | bit, 0);
440
+ this._xorBytes = new Uint8Array([xorBytes.reduce((accumulator, xorByte) => accumulator ^ xorByte, 0) & domainMask]);
441
+ this._bits = new Uint8Array([_EncryptionTransformer.BITS[0]]);
442
+ this._inverseBits = new Uint8Array([_EncryptionTransformer.INVERSE_BITS[0]]);
443
+ this._rounds = 1;
444
+ } else {
445
+ this._xorBytes = new Uint8Array(xorBytes);
446
+ this._bits = new Uint8Array(bits);
447
+ this._inverseBits = new Uint8Array(inverseBits);
448
+ this._rounds = xorBytes.length;
449
+ }
450
+ }
451
+ /**
452
+ * Convert a value to a byte array big enough to handle the entire domain.
453
+ *
454
+ * @param value
455
+ * Value.
456
+ *
457
+ * @returns
458
+ * Big-endian byte array equivalent to the value.
459
+ */
460
+ valueToBytes(value) {
461
+ const bytes = new Uint8Array(this._domainBytes);
462
+ for (let index = this._domainBytes - 1, reducedValue = value; index >= 0 && reducedValue !== 0n; index--, reducedValue >>= 8n) {
463
+ bytes[index] = Number(BigInt.asUintN(8, reducedValue));
464
+ }
465
+ return bytes;
466
+ }
467
+ /**
468
+ * Convert a byte array to a value.
469
+ *
470
+ * @param bytes
471
+ * Big-endian byte array equivalent to the value.
472
+ *
473
+ * @returns
474
+ * Value.
475
+ */
476
+ static bytesToValue(bytes) {
477
+ return bytes.reduce((accumulator, byte) => accumulator << 8n | BigInt(byte), 0n);
478
+ }
479
+ /**
480
+ * Shuffle a byte array.
481
+ *
482
+ * The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
483
+ * the forward operation (input to the reverse operation) is `bytes'`.
484
+ *
485
+ * The shuffle operation starts by testing the bit at `bits[round]` for each `byte` in `bytes`. The indexes for all
486
+ * bytes with that bit set are put into one array (`shuffleIndexes1`) and the rest are put into another
487
+ * (`shuffleIndexes0`). The two arrays are concatenated and used to shuffle the input array, using their values
488
+ * (`shuffleIndex`) and the indexes of those values (`index`) in the concatenated array.
489
+ *
490
+ * Forward shuffling moves the entry at `shuffleIndex` to the `index` position.
491
+ *
492
+ * Reverse shuffling moves the entry at `index` to the `shuffleIndex` position.
493
+ *
494
+ * As each byte is moved, the bit at `bits[round]` is preserved in its original position. This ensures that the
495
+ * process is reversible.
496
+ *
497
+ * @param bytes
498
+ * Byte array.
499
+ *
500
+ * @param round
501
+ * Round number.
502
+ *
503
+ * @param forward
504
+ * True if operating forward (encrypting), false if operating in reverse (decrypting).
505
+ *
506
+ * @returns
507
+ * Shuffled byte array.
508
+ */
509
+ shuffle(bytes, round, forward) {
510
+ const bytesLength = bytes.length;
511
+ const determinants = new Uint8Array(bytesLength);
512
+ const shuffleIndexes1 = new Array();
513
+ const shuffleIndexes0 = new Array();
514
+ const bit = this._bits[round];
515
+ bytes.forEach((byte, index) => {
516
+ const determinant = byte & bit;
517
+ determinants[index] = determinant;
518
+ (determinant !== 0 ? shuffleIndexes1 : shuffleIndexes0).push(index);
519
+ });
520
+ const inverseBit = this._inverseBits[round];
521
+ const shuffleBytes = new Uint8Array(bytesLength);
522
+ [...shuffleIndexes1, ...shuffleIndexes0].forEach((shuffleIndex, index) => {
523
+ if (forward) {
524
+ shuffleBytes[index] = bytes[shuffleIndex] & inverseBit | determinants[index];
525
+ } else {
526
+ shuffleBytes[shuffleIndex] = bytes[index] & inverseBit | determinants[shuffleIndex];
527
+ }
528
+ });
529
+ return shuffleBytes;
530
+ }
531
+ /**
532
+ * Xor a byte array.
533
+ *
534
+ * The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
535
+ * the forward operation (input to the reverse operation) is `bytes'`.
536
+ *
537
+ * Forward:
538
+ * - `bytes'[0] = bytes[0] ^ xorBytes[round]`
539
+ * - `bytes'[1] = bytes[1] ^ bytes'[0]`
540
+ * - `bytes'[2] = bytes[2] ^ bytes'[1]`
541
+ * - `...`
542
+ * - `bytes'[domainBytes - 1] = bytes[domainBytes - 1] ^ bytes'[domainBytes - 2]`
543
+ *
544
+ * Reverse:
545
+ * - `bytes[0] = bytes'[0] ^ xorBytes[round]`
546
+ * - `bytes[1] = bytes'[1] ^ bytes'[0]`
547
+ * - `bytes[2] = bytes'[2] ^ bytes'[1]`
548
+ * - `...`
549
+ * - `bytes[domainBytes - 1] = bytes'[domainBytes - 1] ^ bytes'[domainBytes - 2]`
550
+ *
551
+ * @param bytes
552
+ * Byte array.
553
+ *
554
+ * @param round
555
+ * Round number.
556
+ *
557
+ * @param forward
558
+ * True if operating forward (encrypting), false if operating in reverse (decrypting).
559
+ *
560
+ * @returns
561
+ * Xored byte array.
562
+ */
563
+ xor(bytes, round, forward) {
564
+ let cumulativeXorByte = this._xorBytes[round];
565
+ return bytes.map((byte) => {
566
+ const xorByte = byte ^ cumulativeXorByte;
567
+ cumulativeXorByte = forward ? xorByte : byte;
568
+ return xorByte;
569
+ });
570
+ }
571
+ /**
572
+ * @inheritDoc
573
+ */
574
+ doForward(value) {
575
+ let bytes = this.valueToBytes(value);
576
+ let transformedValue;
577
+ do {
578
+ for (let round = 0; round < this._rounds; round++) {
579
+ bytes = this.xor(this.shuffle(bytes, round, true), round, true);
580
+ }
581
+ transformedValue = _EncryptionTransformer.bytesToValue(bytes);
582
+ } while (transformedValue >= this.domain);
583
+ return transformedValue;
584
+ }
585
+ /**
586
+ * @inheritDoc
587
+ */
588
+ doReverse(transformedValue) {
589
+ let bytes = this.valueToBytes(transformedValue);
590
+ let value;
591
+ do {
592
+ for (let round = this._rounds - 1; round >= 0; round--) {
593
+ bytes = this.shuffle(this.xor(bytes, round, false), round, false);
594
+ }
595
+ value = _EncryptionTransformer.bytesToValue(bytes);
596
+ } while (value >= this.domain);
597
+ return value;
598
+ }
599
+ };
600
+
601
+ // src/reg-exp.ts
602
+ var RegExpValidator = class {
603
+ /**
604
+ * Regular expression.
605
+ */
606
+ _regExp;
607
+ /**
608
+ * Constructor.
609
+ *
610
+ * @param regExp
611
+ * Regular expression. See {@link RegExpValidator | class documentation} for notes.
612
+ */
613
+ constructor(regExp) {
614
+ this._regExp = regExp;
615
+ }
616
+ /**
617
+ * Get the regular expression.
618
+ */
619
+ get regExp() {
620
+ return this._regExp;
621
+ }
622
+ /**
623
+ * Create an error message for a string. The generic error message is sufficient for many use cases but a more
624
+ * domain-specific error message, possibly including the pattern itself, is often required.
625
+ *
626
+ * @param s
627
+ * String.
628
+ *
629
+ * @returns
630
+ * Error message.
631
+ */
632
+ createErrorMessage(s) {
633
+ return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
634
+ s
635
+ });
636
+ }
637
+ /**
638
+ * @inheritDoc
639
+ */
640
+ validate(s) {
641
+ if (!this._regExp.test(s)) {
642
+ throw new RangeError(this.createErrorMessage(s));
643
+ }
644
+ }
645
+ };
646
+
647
+ // src/record.ts
648
+ var RecordValidator = class {
649
+ /**
650
+ * Type name for error message.
651
+ */
652
+ _typeName;
653
+ /**
654
+ * Record in which to look up keys.
655
+ */
656
+ _record;
657
+ /**
658
+ * Constructor.
659
+ *
660
+ * @param typeName
661
+ * Type name for error message.
662
+ *
663
+ * @param record
664
+ * Record in which to look up keys.
665
+ */
666
+ constructor(typeName, record) {
667
+ this._typeName = typeName;
668
+ this._record = record;
669
+ }
670
+ /**
671
+ * Get the type name.
672
+ */
673
+ get typeName() {
674
+ return this._typeName;
675
+ }
676
+ /**
677
+ * Get the record.
678
+ */
679
+ get record() {
680
+ return this._record;
681
+ }
682
+ /**
683
+ * Validate a key by looking it up in the record.
684
+ *
685
+ * @param key
686
+ * Record key.
687
+ */
688
+ validate(key) {
689
+ if (!(key in this.record)) {
690
+ throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
691
+ typeName: this.typeName,
692
+ key
693
+ }));
694
+ }
695
+ }
696
+ };
697
+
698
+ // src/character-set.ts
699
+ var Exclusion = /* @__PURE__ */ ((Exclusion2) => {
700
+ Exclusion2[Exclusion2["None"] = 0] = "None";
701
+ Exclusion2[Exclusion2["FirstZero"] = 1] = "FirstZero";
702
+ Exclusion2[Exclusion2["AllNumeric"] = 2] = "AllNumeric";
703
+ return Exclusion2;
704
+ })(Exclusion || {});
705
+ var CharacterSetValidator = class _CharacterSetValidator {
706
+ static NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
707
+ /**
708
+ * Create an error message for an all-numeric string.
709
+ *
710
+ * @param _s
711
+ * String.
712
+ *
713
+ * @returns
714
+ * Error message.
715
+ */
716
+ createErrorMessage(_s) {
717
+ return i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric");
718
+ }
719
+ }(/\D/);
720
+ /**
721
+ * Character set.
722
+ */
723
+ _characterSet;
724
+ /**
725
+ * Character set map, mapping each character in the character set to its index such that
726
+ * `_characterSetMap.get(_characterSet[index]) === index`.
727
+ */
728
+ _characterSetMap;
729
+ /**
730
+ * Exclusions supported by the character set.
731
+ */
732
+ _exclusionSupport;
733
+ /**
734
+ * Constructor.
735
+ *
736
+ * @param characterSet
737
+ * Character set. Each element is a single-character string, unique within the array, that defines the character
738
+ * set.
739
+ *
740
+ * @param exclusionSupport
741
+ * Exclusions supported by the character set. All character sets implicitly support {@link Exclusion.None}.
742
+ */
743
+ constructor(characterSet, ...exclusionSupport) {
744
+ this._characterSet = characterSet;
745
+ const characterSetMap = /* @__PURE__ */ new Map();
746
+ characterSet.forEach((c, index) => {
747
+ characterSetMap.set(c, index);
748
+ });
749
+ this._characterSetMap = characterSetMap;
750
+ this._exclusionSupport = exclusionSupport;
751
+ }
752
+ /**
753
+ * Get the character set.
754
+ */
755
+ get characterSet() {
756
+ return this._characterSet;
757
+ }
758
+ /**
759
+ * Get the character set size.
760
+ */
761
+ get characterSetSize() {
762
+ return this._characterSet.length;
763
+ }
764
+ /**
765
+ * Get the exclusions supported by the character set.
766
+ */
767
+ get exclusionSupport() {
768
+ return this._exclusionSupport;
769
+ }
770
+ /**
771
+ * Get the character at an index.
772
+ *
773
+ * @param index
774
+ * Index into the character set.
775
+ *
776
+ * @returns
777
+ * Character at the index.
778
+ */
779
+ character(index) {
780
+ return this._characterSet[index];
781
+ }
782
+ /**
783
+ * Get the index for a character.
784
+ *
785
+ * @param c
786
+ * Character.
787
+ *
788
+ * @returns
789
+ * Index for the character or undefined if the character is not in the character set.
790
+ */
791
+ characterIndex(c) {
792
+ return this._characterSetMap.get(c);
793
+ }
794
+ /**
795
+ * Get the indexes for all characters in a string.
796
+ *
797
+ * @param s
798
+ * String.
799
+ *
800
+ * @returns
801
+ * Array of indexes for each character or undefined if the character is not in the character set.
802
+ */
803
+ characterIndexes(s) {
804
+ return Array.from(s).map((c) => this._characterSetMap.get(c));
805
+ }
806
+ /**
807
+ * Convert a component definition to a string or undefined. Checks the type of the component and makes the callback
808
+ * if required.
809
+ *
810
+ * @param component
811
+ * Component definition as a string, callback, or undefined.
812
+ *
813
+ * @returns
814
+ * Component as a string or undefined.
815
+ */
816
+ static componentToString(component) {
817
+ return typeof component === "function" ? component() : component;
818
+ }
819
+ /**
820
+ * Validate that an exclusion is supported. If not, an error is thrown.
821
+ *
822
+ * @param exclusion
823
+ * Exclusion.
824
+ */
825
+ validateExclusion(exclusion) {
826
+ if (exclusion !== 0 /* None */ && !this._exclusionSupport.includes(exclusion)) {
827
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.exclusionNotSupported", {
828
+ exclusion
829
+ }));
830
+ }
831
+ }
832
+ /**
833
+ * Validate a string. If the string violates the character set or any of the character set validation parameters, an
834
+ * error is thrown.
835
+ *
836
+ * @param s
837
+ * String.
838
+ *
839
+ * @param validation
840
+ * Character set validation parameters.
841
+ */
842
+ validate(s, validation) {
843
+ const length = s.length;
844
+ const minimumLength = validation?.minimumLength;
845
+ const maximumLength = validation?.maximumLength;
846
+ if (minimumLength !== void 0 && length < minimumLength) {
847
+ let errorMessage;
848
+ if (maximumLength !== void 0 && maximumLength === minimumLength) {
849
+ errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
850
+ component: _CharacterSetValidator.componentToString(validation?.component),
851
+ length,
852
+ exactLength: minimumLength
853
+ });
854
+ } else {
855
+ errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
856
+ component: _CharacterSetValidator.componentToString(validation?.component),
857
+ length,
858
+ minimumLength
859
+ });
860
+ }
861
+ throw new RangeError(errorMessage);
862
+ }
863
+ if (maximumLength !== void 0 && length > maximumLength) {
864
+ throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
865
+ component: _CharacterSetValidator.componentToString(validation?.component),
866
+ length,
867
+ maximumLength
868
+ }));
869
+ }
870
+ const index = this.characterIndexes(s).findIndex((characterIndex) => characterIndex === void 0);
871
+ if (index !== -1) {
872
+ throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
873
+ component: _CharacterSetValidator.componentToString(validation?.component),
874
+ c: s.charAt(index),
875
+ position: index + (validation?.positionOffset ?? 0) + 1
876
+ }));
877
+ }
878
+ if (validation?.exclusion !== void 0) {
879
+ this.validateExclusion(validation.exclusion);
880
+ switch (validation.exclusion) {
881
+ case 0 /* None */:
882
+ break;
883
+ case 1 /* FirstZero */:
884
+ if (s.startsWith("0")) {
885
+ throw new RangeError(i18nextUtility.t(validation.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
886
+ component: _CharacterSetValidator.componentToString(validation.component),
887
+ c: "0",
888
+ position: (validation.positionOffset ?? 0) + 1
889
+ }));
890
+ }
891
+ break;
892
+ case 2 /* AllNumeric */:
893
+ _CharacterSetValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(s);
894
+ break;
895
+ }
896
+ }
897
+ }
898
+ };
899
+ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidator {
900
+ /**
901
+ * Maximum string length supported.
902
+ */
903
+ static MAXIMUM_STRING_LENGTH = 40;
904
+ /**
905
+ * Powers of 10 from 1 (`10**0`) to `10**MAXIMUM_STRING_LENGTH`.
906
+ */
907
+ static _powersOf10 = _CharacterSetCreator.createPowersOf(10);
908
+ /**
909
+ * Create powers of a given base from 1 (`base**0`) to `base**MAXIMUM_STRING_LENGTH`.
910
+ *
911
+ * @param base
912
+ * Number base.
913
+ *
914
+ * @returns
915
+ * Array of powers of base.
916
+ */
917
+ static createPowersOf(base) {
918
+ const powersOf = new Array(this.MAXIMUM_STRING_LENGTH + 1);
919
+ const baseN = BigInt(base);
920
+ for (let index = 0, powerOf = 1n; index <= this.MAXIMUM_STRING_LENGTH; index++, powerOf *= baseN) {
921
+ powersOf[index] = powerOf;
922
+ }
923
+ return powersOf;
924
+ }
925
+ /**
926
+ * Get a power of 10.
927
+ *
928
+ * @param power
929
+ * Power.
930
+ *
931
+ * @returns
932
+ * `10**power`.
933
+ */
934
+ static powerOf10(power) {
935
+ return this._powersOf10[power];
936
+ }
937
+ /**
938
+ * Character set size as big integer, cached for performance purposes.
939
+ */
940
+ _characterSetSizeN;
941
+ /**
942
+ * Character set size minus 1 as big integer, cached for performance purposes.
943
+ */
944
+ _characterSetSizeMinusOneN;
945
+ /**
946
+ * Domains for every length for every supported {@link Exclusion}.
947
+ */
948
+ _exclusionDomains;
949
+ /**
950
+ * Values that would generate all zeros in the created string.
951
+ */
952
+ _allZerosValues;
953
+ /**
954
+ * Constructor.
955
+ *
956
+ * @param characterSet
957
+ * Character set. Each element is a single-character string, unique within the array, that defines the character
958
+ * set.
959
+ *
960
+ * @param exclusionSupport
961
+ * Exclusions supported by the character set. All character sets implicitly support {@link Exclusion.None}.
962
+ */
963
+ constructor(characterSet, ...exclusionSupport) {
964
+ super(characterSet, ...exclusionSupport);
965
+ this._characterSetSizeN = BigInt(this.characterSetSize);
966
+ this._characterSetSizeMinusOneN = BigInt(this.characterSetSize - 1);
967
+ const exclusionDomains = [];
968
+ const exclusionNoneDomains = _CharacterSetCreator.createPowersOf(this.characterSetSize);
969
+ exclusionDomains[0 /* None */] = exclusionNoneDomains;
970
+ if (exclusionSupport.includes(1 /* FirstZero */)) {
971
+ if (characterSet[0] !== "0") {
972
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.firstZeroFirstCharacter"));
973
+ }
974
+ const exclusionFirstZeroDomains = new Array(_CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
975
+ exclusionFirstZeroDomains[0] = 0n;
976
+ for (let index = 1; index <= _CharacterSetCreator.MAXIMUM_STRING_LENGTH; index++) {
977
+ exclusionFirstZeroDomains[index] = this._characterSetSizeMinusOneN * exclusionNoneDomains[index - 1];
978
+ }
979
+ exclusionDomains[1 /* FirstZero */] = exclusionFirstZeroDomains;
980
+ }
981
+ if (exclusionSupport.includes(2 /* AllNumeric */)) {
982
+ let validateNumberIndexes2 = function(numberIndexes2) {
983
+ let expectedNumberIndex = numberIndexes2[0];
984
+ for (const numberIndex of numberIndexes2) {
985
+ if (numberIndex === void 0 || numberIndex !== expectedNumberIndex) {
986
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.allNumericAllNumericCharacters"));
987
+ }
988
+ expectedNumberIndex = numberIndex + 1;
989
+ }
990
+ };
991
+ var validateNumberIndexes = validateNumberIndexes2;
992
+ const exclusionAllNumericDomains = new Array(_CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
993
+ const numberIndexes = this.characterIndexes("0123456789");
994
+ validateNumberIndexes2(numberIndexes);
995
+ const zeroIndex = BigInt(numberIndexes[0]);
996
+ const allZerosValues = new Array(_CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
997
+ let allZerosValue = 0n;
998
+ for (let index = 0; index <= _CharacterSetCreator.MAXIMUM_STRING_LENGTH; index++) {
999
+ exclusionAllNumericDomains[index] = exclusionNoneDomains[index] - _CharacterSetCreator.powerOf10(index);
1000
+ allZerosValues[index] = allZerosValue;
1001
+ allZerosValue = allZerosValue * this._characterSetSizeN + zeroIndex;
1002
+ }
1003
+ this._allZerosValues = allZerosValues;
1004
+ exclusionDomains[2 /* AllNumeric */] = exclusionAllNumericDomains;
1005
+ } else {
1006
+ this._allZerosValues = [];
1007
+ }
1008
+ this._exclusionDomains = exclusionDomains;
1009
+ }
1010
+ /**
1011
+ * Get a power of character set size.
1012
+ *
1013
+ * @param power
1014
+ * Power.
1015
+ *
1016
+ * @returns
1017
+ * `characterSetSize**power`.
1018
+ */
1019
+ powerOfSize(power) {
1020
+ return this._exclusionDomains[0 /* None */][power];
1021
+ }
1022
+ /**
1023
+ * Determine the shift required to skip all all-numeric strings up to the value.
1024
+ *
1025
+ * @param shiftForward
1026
+ * True to shift forward (value to string), false to shift backward (string to value).
1027
+ *
1028
+ * @param length
1029
+ * Length of string for which to get the all-numeric shift.
1030
+ *
1031
+ * @param value
1032
+ * Value for which to get the all-numeric shift.
1033
+ *
1034
+ * @returns
1035
+ * Shift required to skip all all-numeric strings.
1036
+ */
1037
+ allNumericShift(shiftForward, length, value) {
1038
+ let shift;
1039
+ if (length === 0) {
1040
+ if (!shiftForward && value < 10n) {
1041
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric"));
1042
+ }
1043
+ shift = 10n;
1044
+ } else {
1045
+ const powerOfSize = this.powerOfSize(length);
1046
+ const powerOf10 = _CharacterSetCreator.powerOf10(length);
1047
+ const gap = shiftForward ? powerOfSize - powerOf10 : powerOfSize;
1048
+ const gaps = value / gap;
1049
+ if (gaps >= 10n) {
1050
+ shift = _CharacterSetCreator.powerOf10(length + 1);
1051
+ } else {
1052
+ shift = gaps * powerOf10 + this.allNumericShift(shiftForward, length - 1, value - gaps * gap);
1053
+ }
1054
+ }
1055
+ return shift;
1056
+ }
1057
+ /**
1058
+ * Validate that a length is less than or equal to {@link MAXIMUM_STRING_LENGTH}. If not, an error is thrown.
1059
+ *
1060
+ * @param length
1061
+ * Length.
1062
+ */
1063
+ validateLength(length) {
1064
+ if (length < 0) {
1065
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
1066
+ length,
1067
+ minimumLength: 0
1068
+ }));
1069
+ }
1070
+ if (length > _CharacterSetCreator.MAXIMUM_STRING_LENGTH) {
1071
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo", {
1072
+ length,
1073
+ maximumLength: _CharacterSetCreator.MAXIMUM_STRING_LENGTH
1074
+ }));
1075
+ }
1076
+ }
1077
+ /**
1078
+ * Create string(s) by mapping value(s) to the equivalent characters in the character set across the length of the
1079
+ * string.
1080
+ *
1081
+ * @param length
1082
+ * Required string length.
1083
+ *
1084
+ * @param valueOrValues
1085
+ * Numeric value(s) of the string(s).
1086
+ *
1087
+ * @param exclusion
1088
+ * String(s) to be excluded from the range of outputs. See {@link Exclusion} for possible values and their meaning.
1089
+ *
1090
+ * @param tweak
1091
+ * If provided, the numerical value of the string(s) is/are "tweaked" using an {@link EncryptionTransformer |
1092
+ * encryption transformer}.
1093
+ *
1094
+ * @param creatorCallback
1095
+ * If provided, called after each string is constructed to create the final value.
1096
+ *
1097
+ * @returns
1098
+ * String(s) created from the value(s).
1099
+ */
1100
+ create(length, valueOrValues, exclusion = 0 /* None */, tweak, creatorCallback) {
1101
+ this.validateLength(length);
1102
+ this.validateExclusion(exclusion);
1103
+ const allZerosValue = exclusion === 2 /* AllNumeric */ ? this._allZerosValues[length] : 0n;
1104
+ const transformer = Transformer.get(this._exclusionDomains[exclusion][length], tweak);
1105
+ return transformer.forward(valueOrValues, (transformedValue, index) => {
1106
+ let s = "";
1107
+ if (length !== 0) {
1108
+ let convertValue = transformedValue;
1109
+ if (exclusion === 2 /* AllNumeric */ && convertValue >= allZerosValue) {
1110
+ convertValue = convertValue + this.allNumericShift(true, length, convertValue - allZerosValue);
1111
+ }
1112
+ for (let position = length - 1; position > 0; position--) {
1113
+ const nextConvertValue = convertValue / this._characterSetSizeN;
1114
+ s = this.character(Number(convertValue - nextConvertValue * this._characterSetSizeN)) + s;
1115
+ convertValue = nextConvertValue;
1116
+ }
1117
+ s = this.character(exclusion === 1 /* FirstZero */ ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
1118
+ }
1119
+ return creatorCallback === void 0 ? s : creatorCallback(s, index);
1120
+ });
1121
+ }
1122
+ /**
1123
+ * Determine the value for a string.
1124
+ *
1125
+ * @param s
1126
+ * String.
1127
+ *
1128
+ * @param exclusion
1129
+ * Strings excluded from the range of inputs. See {@link Exclusion} for possible values and their meaning.
1130
+ *
1131
+ * @param tweak
1132
+ * If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
1133
+ * transformer}.
1134
+ *
1135
+ * @returns
1136
+ * Numeric value of the string.
1137
+ */
1138
+ valueFor(s, exclusion = 0 /* None */, tweak) {
1139
+ const length = s.length;
1140
+ this.validateLength(length);
1141
+ this.validateExclusion(exclusion);
1142
+ const characterSetSizeN = BigInt(this.characterSetSize);
1143
+ let value = this.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
1144
+ if (characterIndex === void 0) {
1145
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
1146
+ c: s.charAt(index),
1147
+ position: index + 1
1148
+ }));
1149
+ }
1150
+ let value2;
1151
+ if (index === 0 && exclusion === 1 /* FirstZero */) {
1152
+ if (characterIndex === 0) {
1153
+ throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
1154
+ c: "0",
1155
+ position: 1
1156
+ }));
1157
+ }
1158
+ value2 = BigInt(characterIndex - 1);
1159
+ } else {
1160
+ value2 = accumulator * characterSetSizeN + BigInt(characterIndex);
1161
+ }
1162
+ return value2;
1163
+ }, 0n);
1164
+ if (exclusion === 2 /* AllNumeric */) {
1165
+ const allZerosValue = this._allZerosValues[length];
1166
+ if (value >= allZerosValue) {
1167
+ value -= this.allNumericShift(false, length, value - allZerosValue);
1168
+ }
1169
+ }
1170
+ return Transformer.get(this._exclusionDomains[exclusion][length], tweak).reverse(value);
1171
+ }
1172
+ };
1173
+ var NUMERIC_CREATOR = new CharacterSetCreator([
1174
+ "0",
1175
+ "1",
1176
+ "2",
1177
+ "3",
1178
+ "4",
1179
+ "5",
1180
+ "6",
1181
+ "7",
1182
+ "8",
1183
+ "9"
1184
+ ], 1 /* FirstZero */);
1185
+ var HEXADECIMAL_CREATOR = new CharacterSetCreator([
1186
+ "0",
1187
+ "1",
1188
+ "2",
1189
+ "3",
1190
+ "4",
1191
+ "5",
1192
+ "6",
1193
+ "7",
1194
+ "8",
1195
+ "9",
1196
+ "A",
1197
+ "B",
1198
+ "C",
1199
+ "D",
1200
+ "E",
1201
+ "F"
1202
+ ], 1 /* FirstZero */, 2 /* AllNumeric */);
1203
+ var ALPHABETIC_CREATOR = new CharacterSetCreator([
1204
+ "A",
1205
+ "B",
1206
+ "C",
1207
+ "D",
1208
+ "E",
1209
+ "F",
1210
+ "G",
1211
+ "H",
1212
+ "I",
1213
+ "J",
1214
+ "K",
1215
+ "L",
1216
+ "M",
1217
+ "N",
1218
+ "O",
1219
+ "P",
1220
+ "Q",
1221
+ "R",
1222
+ "S",
1223
+ "T",
1224
+ "U",
1225
+ "V",
1226
+ "W",
1227
+ "X",
1228
+ "Y",
1229
+ "Z"
1230
+ ]);
1231
+ var ALPHANUMERIC_CREATOR = new CharacterSetCreator([
1232
+ "0",
1233
+ "1",
1234
+ "2",
1235
+ "3",
1236
+ "4",
1237
+ "5",
1238
+ "6",
1239
+ "7",
1240
+ "8",
1241
+ "9",
1242
+ "A",
1243
+ "B",
1244
+ "C",
1245
+ "D",
1246
+ "E",
1247
+ "F",
1248
+ "G",
1249
+ "H",
1250
+ "I",
1251
+ "J",
1252
+ "K",
1253
+ "L",
1254
+ "M",
1255
+ "N",
1256
+ "O",
1257
+ "P",
1258
+ "Q",
1259
+ "R",
1260
+ "S",
1261
+ "T",
1262
+ "U",
1263
+ "V",
1264
+ "W",
1265
+ "X",
1266
+ "Y",
1267
+ "Z"
1268
+ ], 1 /* FirstZero */, 2 /* AllNumeric */);
1269
+ export {
1270
+ ALPHABETIC_CREATOR,
1271
+ ALPHANUMERIC_CREATOR,
1272
+ CharacterSetCreator,
1273
+ CharacterSetValidator,
1274
+ EncryptionTransformer,
1275
+ Exclusion,
1276
+ HEXADECIMAL_CREATOR,
1277
+ IdentityTransformer,
1278
+ NUMERIC_CREATOR,
1279
+ RecordValidator,
1280
+ RegExpValidator,
1281
+ Sequence,
1282
+ Transformer,
1283
+ i18nUtilityInit,
1284
+ i18nextUtility,
1285
+ transformIterable,
1286
+ utilityNS,
1287
+ utilityResources
1288
+ };
2
1289
  /*!
3
1290
  * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
4
1291
  * contributors