@aidc-toolkit/core 1.0.44 → 1.0.45-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/app-data-storage.d.ts +118 -0
- package/dist/app-data-storage.d.ts.map +1 -0
- package/dist/app-data-storage.js +117 -0
- package/dist/app-data-storage.js.map +1 -0
- package/dist/app-data.d.ts +26 -0
- package/dist/app-data.d.ts.map +1 -0
- package/dist/app-data.js +79 -0
- package/dist/app-data.js.map +1 -0
- package/dist/browser-app-data-storage.d.ts +26 -0
- package/dist/browser-app-data-storage.d.ts.map +1 -0
- package/dist/browser-app-data-storage.js +34 -0
- package/dist/browser-app-data-storage.js.map +1 -0
- package/dist/cache.d.ts +58 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +12 -0
- package/dist/cache.js.map +1 -0
- package/dist/file-app-data-storage.d.ts +27 -0
- package/dist/file-app-data-storage.d.ts.map +1 -0
- package/dist/file-app-data-storage.js +52 -0
- package/dist/file-app-data-storage.js.map +1 -0
- package/dist/http-fetch.d.ts +45 -0
- package/dist/http-fetch.d.ts.map +1 -0
- package/dist/http-fetch.js +26 -0
- package/dist/http-fetch.js.map +1 -0
- package/dist/hyperlink.d.ts +18 -0
- package/dist/hyperlink.d.ts.map +1 -0
- package/dist/hyperlink.js +2 -0
- package/dist/hyperlink.js.map +1 -0
- package/dist/index.d.ts +30 -801
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -0
- package/dist/local-app-data-storage.d.ts +8 -0
- package/dist/local-app-data-storage.d.ts.map +1 -0
- package/dist/local-app-data-storage.js +11 -0
- package/dist/local-app-data-storage.js.map +1 -0
- package/dist/locale/en/locale-resources.d.ts +10 -0
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/locale-resources.js +9 -0
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/locale-resources.d.ts +10 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/locale-resources.js +9 -0
- package/dist/locale/fr/locale-resources.js.map +1 -0
- package/dist/locale/i18n.d.ts +95 -0
- package/dist/locale/i18n.d.ts.map +1 -0
- package/dist/locale/i18n.js +162 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/logger.d.ts +136 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +256 -0
- package/dist/logger.js.map +1 -0
- package/dist/parse-version.d.ts +36 -0
- package/dist/parse-version.d.ts.map +1 -0
- package/dist/parse-version.js +23 -0
- package/dist/parse-version.js.map +1 -0
- package/dist/remote-app-data-storage.d.ts +23 -0
- package/dist/remote-app-data-storage.d.ts.map +1 -0
- package/dist/remote-app-data-storage.js +42 -0
- package/dist/remote-app-data-storage.js.map +1 -0
- package/dist/type-helper.d.ts +115 -0
- package/dist/type-helper.d.ts.map +1 -0
- package/dist/type-helper.js +163 -0
- package/dist/type-helper.js.map +1 -0
- package/dist/type.d.ts +111 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/website-url.d.ts +29 -0
- package/dist/website-url.d.ts.map +1 -0
- package/dist/website-url.js +60 -0
- package/dist/website-url.js.map +1 -0
- package/package.json +3 -3
- package/src/locale/i18n.ts +34 -2
- package/src/version.ts +1 -1
- package/tsconfig-src.tsbuildinfo +1 -1
- package/dist/browser-app-data-storage-G62WSQ5Z.js +0 -1
- package/dist/chunk-FIUBVWNN.js +0 -1
- package/dist/file-app-data-storage-M6RA7QOG.js +0 -1
- package/dist/index.cjs +0 -18
- package/dist/index.d.cts +0 -801
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mBAAmB,WAAW,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAE3B,mBAAmB,gBAAgB,CAAC;AAEpC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import{a as z,b as G,c as h,d as J}from"./chunk-FIUBVWNN.js";function x(e,t,...r){return Object.fromEntries(Object.entries(t).filter(([o])=>r.includes(o)!==e))}function O(e,...t){return x(!0,e,...t)}function K(e,...t){return x(!1,e,...t)}function X(e,t){return O(e,...Object.keys(t))}function Y(e,t){return K(e,...Object.keys(t))}function q(e,t){return t in e?{[t]:e[t]}:{}}function Q(e){return e==null}import{Logger as M}from"tslog";import E from"i18next";import S from"i18next-browser-languagedetector";import C from"i18next-cli-language-detector";var y={Logger:{unknownLogLevel:'Unknown log level "{{logLevel}}"'},RemoteAppDataStorage:{httpError:"HTTP error {{status, number}} retrieving file"}};var L={Logger:{unknownLogLevel:"Niveau de journalisation inconnu \xAB\xA0{{logLevel}}\xA0\xBB"},RemoteAppDataStorage:{httpError:"Erreur HTTP {{status, number}} lors de la r\xE9cup\xE9ration du fichier"}};var ae={CLI:C,Browser:S};function V(e){return typeof e=="string"?e.split(" ").map(t=>/[a-z]/u.test(t)?t.toLowerCase():t).join(" "):String(e)}var _="aidct_core",F={en:{aidct_core:y},fr:{aidct_core:L}},u=E.createInstance();async function H(e,t,r,o,s,...i){let n;if(!e.isInitialized){let p=function(l){for(let[c,I]of Object.entries(l)){c in a||(a[c]={});let b=a[c];for(let[f,j]of Object.entries(I)){if(f in b)throw new Error(`Duplicate namespace ${f} in merged resource bundle for language ${c}`);b[f]=j}}};var m=p;let a={};p(s);for(let l of i){let c=l(t,r).then(p);n=n===void 0?c:n.then(async()=>c)}let T=e.use(t).init({debug:r,defaultNS:o,resources:a,nonExplicitSupportedLngs:!0,fallbackLng:Object.keys(a)[0],detection:{caches:[]}}).then(()=>{e.services.formatter?.add("toLowerCase",V)});n=n===void 0?T:n.then(async()=>T)}return n!==void 0?n.then(()=>s):s}async function ce(e,t=!1){return H(u,e,t,_,F)}var d={Silly:0,Trace:1,Debug:2,Info:3,Warn:4,Error:5,Fatal:6};function U(e){let t;if(typeof e=="string")if(e in d)t=d[e];else throw new RangeError(u.t("Logger.unknownLogLevel",{logLevel:e}));else if(e!==void 0)if(Object.values(d).includes(e))t=e;else throw new RangeError(u.t("Logger.unknownLogLevel",{logLevel:e}));else t=d.Info;return t}function le(e,t,r){let o=U(e);return new M({hideLogPositionForProduction:o>=d.Info,...t??{},minLevel:o},r)}function g(e){let t;switch(typeof e){case"string":case"number":case"boolean":case"undefined":t=e;break;case"bigint":t=e>=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER?Number(e):e.toString(10);break;case"object":e===null?t=e:Array.isArray(e)?t=(e.length<=10?e:[...e.slice(0,4),"...",...e.slice(-4)]).map(r=>g(r)):e instanceof Error?t=g({name:e.name,message:e.message,stack:e.stack?.split(`
|
|
2
|
-
`)}):t=Object.fromEntries(Object.entries(e).map(([r,o])=>[r,g(o)]));break;case"symbol":t=e.toString();break;case"function":t=`Function(${e.name})`;break}return t}var P=class{#e=new Map;#t=[];#r=0;#o=0;constructor(t,r,o){this.resize(r,o),t.attachTransport(s=>{this.#t.length>=this.#r&&this.#t.splice(0,this.#r-this.#o);let i=JSON.stringify(s);this.#t.push(i);for(let n of this.#e.values())n(i,this.#t)})}get messages(){return this.#t}get maximumLength(){return this.#r}get truncateLength(){return this.#o}addNotificationCallback(t,r){let o=!this.#e.has(t);return o&&(this.#e.set(t,r),r(void 0,this.#t)),o}removeNotificationCallback(t){this.#e.delete(t)}resize(t,r){this.#r=t,this.#o=r!==void 0?Math.min(r,Math.floor(t*.8)):Math.floor(t/2)}};function w(e){let t=/^(?<majorVersion>\d+)\.(?<minorVersion>\d+)\.(?<patchVersion>\d+)(?:-(?<preReleaseIdentifier>alpha|beta)(?:\.(?<dateTime>\d{12}))?)?$/u.exec(e)?.groups;if(t===void 0)throw new Error(`Invalid package version ${e}`);return{majorVersion:Number(t.majorVersion),minorVersion:Number(t.minorVersion),patchVersion:Number(t.patchVersion),preReleaseIdentifier:t.preReleaseIdentifier,dateTime:t.dateTime}}var R=globalThis.localStorage===void 0?import("./file-app-data-storage-M6RA7QOG.js").then(e=>e.FileAppDataStorage):import("./browser-app-data-storage-G62WSQ5Z.js").then(e=>e.BrowserAppDataStorage);var $="http://localhost:5173",v="config",B="resources.local",he=R.then(async e=>new e(v).read(B)).then(e=>e?.alphaURL??$),W="https://aidc-toolkit.com";function xe(e,t,r,o){let s=w(e),i=s.preReleaseIdentifier,n;if(i==="alpha")n=r;else{let m=i!==void 0?`/${i}`:"",a=i!==void 0||t?`/v${s.majorVersion}.${s.minorVersion}`:"",p=o!==void 0&&o!==""?`/${o}`:"";n=`${W}${m}${a}${p}`}return n}var Le=200,k=404;async function D(e){return fetch(e).then(t=>({ok:t.ok,status:t.status,arrayBuffer:async()=>t.arrayBuffer(),text:async()=>t.text()}))}var A=class extends h{#e;constructor(t,r=D){super(!0,t),this.#e=r}async doRead(t,r){let o=await this.#e(t),s;if(o.ok)s=r===!0?new Uint8Array(await o.arrayBuffer()):await o.text();else if(o.status===404)s=void 0;else throw new RangeError(u.t("RemoteAppDataStorage.httpError",{status:o.status}));return s}};var N=class{};export{he as ALPHA_URL,J as AppDataStorage,N as Cache,k as HTTP_NOT_FOUND,Le as HTTP_OK,ae as I18nLanguageDetectors,R as LocalAppDataStorage,d as LogLevels,P as MemoryTransport,h as ReadOnlyAppDataStorage,A as RemoteAppDataStorage,W as WEBSITE_BASE_URL,_ as coreNS,F as coreResourceBundle,z as decodeAppData,D as defaultHTTPFetch,G as encodeAppData,X as exclude,le as getLogger,ce as i18nCoreInit,H as i18nInit,u as i18nextCore,Y as include,Q as isNullish,U as logLevelOf,g as loggableValue,O as omit,w as parseVersion,K as pick,q as propertyAs,xe as websiteURL};
|
|
3
1
|
/*!
|
|
4
2
|
* Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
|
|
5
3
|
* contributors
|
|
@@ -16,3 +14,15 @@ import{a as z,b as G,c as h,d as J}from"./chunk-FIUBVWNN.js";function x(e,t,...r
|
|
|
16
14
|
* See the License for the specific language governing permissions and
|
|
17
15
|
* limitations under the License.
|
|
18
16
|
*/
|
|
17
|
+
export * from "./type-helper.js";
|
|
18
|
+
export * from "./logger.js";
|
|
19
|
+
export * from "./parse-version.js";
|
|
20
|
+
export * from "./website-url.js";
|
|
21
|
+
export * from "./app-data.js";
|
|
22
|
+
export * from "./app-data-storage.js";
|
|
23
|
+
export * from "./local-app-data-storage.js";
|
|
24
|
+
export * from "./http-fetch.js";
|
|
25
|
+
export * from "./remote-app-data-storage.js";
|
|
26
|
+
export * from "./cache.js";
|
|
27
|
+
export * from "./locale/i18n.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAI3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppDataStorage } from "./app-data-storage.js";
|
|
2
|
+
/**
|
|
3
|
+
* Local application data storage class for the current environment. This is a variable representing a `Promise` as the
|
|
4
|
+
* implementing class is loaded dynamically to prevent the inclusion of unnecessary node dependencies in a browser
|
|
5
|
+
* environment.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LocalAppDataStorage: Promise<new (path?: string) => AppDataStorage<boolean>>;
|
|
8
|
+
//# sourceMappingURL=local-app-data-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-app-data-storage.d.ts","sourceRoot":"","sources":["../src/local-app-data-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,KAAK,cAAc,CAAC,OAAO,CAAC,CAII,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local application data storage class for the current environment. This is a variable representing a `Promise` as the
|
|
3
|
+
* implementing class is loaded dynamically to prevent the inclusion of unnecessary node dependencies in a browser
|
|
4
|
+
* environment.
|
|
5
|
+
*/
|
|
6
|
+
export const LocalAppDataStorage =
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- localStorage is undefined when running under Node.js.
|
|
8
|
+
globalThis.localStorage === undefined ?
|
|
9
|
+
import("./file-app-data-storage.js").then(module => module.FileAppDataStorage) :
|
|
10
|
+
import("./browser-app-data-storage.js").then(module => module.BrowserAppDataStorage);
|
|
11
|
+
//# sourceMappingURL=local-app-data-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-app-data-storage.js","sourceRoot":"","sources":["../src/local-app-data-storage.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB;AAC5B,gIAAgI;AAChI,UAAU,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC;IACnC,MAAM,CAAC,4BAA4B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChF,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":";;;;;;;;AAAA,wBAOE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,MAAM,EAAE;QACJ,eAAe,EAAE,oCAAoC;KACxD;IACD,oBAAoB,EAAE;QAClB,SAAS,EAAE,+CAA+C;KAC7D;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":";;;;;;;;AAAA,wBAOE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
Logger: {
|
|
3
|
+
unknownLogLevel: "Niveau de journalisation inconnu « {{logLevel}} »"
|
|
4
|
+
},
|
|
5
|
+
RemoteAppDataStorage: {
|
|
6
|
+
httpError: "Erreur HTTP {{status, number}} lors de la récupération du fichier"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=locale-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,MAAM,EAAE;QACJ,eAAe,EAAE,mDAAmD;KACvE;IACD,oBAAoB,EAAE;QAClB,SAAS,EAAE,mEAAmE;KACjF;CACJ,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type DefaultNamespace, type i18n, type LanguageDetectorModule, type Namespace, type Newable, type NewableModule, type ParseKeys, type Resource, type TOptions } from "i18next";
|
|
2
|
+
import enLocaleResources from "./en/locale-resources.js";
|
|
3
|
+
/**
|
|
4
|
+
* Locale strings type for generic manipulation.
|
|
5
|
+
*/
|
|
6
|
+
export interface LocaleResources {
|
|
7
|
+
[key: string]: LocaleResources | string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Internationalization language detectors.
|
|
11
|
+
*/
|
|
12
|
+
export declare const I18nLanguageDetectors: {
|
|
13
|
+
/**
|
|
14
|
+
* Command-line interface (e.g., unit tests).
|
|
15
|
+
*/
|
|
16
|
+
readonly CLI: LanguageDetectorModule;
|
|
17
|
+
/**
|
|
18
|
+
* Web browser.
|
|
19
|
+
*/
|
|
20
|
+
readonly Browser: Newable<LanguageDetectorModule>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Internationalization language detector.
|
|
24
|
+
*/
|
|
25
|
+
export type I18nLanguageDetector = LanguageDetectorModule | Newable<LanguageDetectorModule> | NewableModule<LanguageDetectorModule>;
|
|
26
|
+
/**
|
|
27
|
+
* Determine if a key exists.
|
|
28
|
+
*
|
|
29
|
+
* @param i18next
|
|
30
|
+
* Internationalization object.
|
|
31
|
+
*
|
|
32
|
+
* @param key
|
|
33
|
+
* Key to check.
|
|
34
|
+
*
|
|
35
|
+
* @param options
|
|
36
|
+
* Options.
|
|
37
|
+
*
|
|
38
|
+
* @returns
|
|
39
|
+
* True if key exists in the specified namespace with the given options.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isI18nParseKey<TNamespace extends Namespace = DefaultNamespace, TNamespaceOptions extends TOptions = TNamespace extends DefaultNamespace ? {
|
|
42
|
+
ns?: DefaultNamespace;
|
|
43
|
+
} : {
|
|
44
|
+
ns: TNamespace;
|
|
45
|
+
}>(i18next: i18n, key: string, options?: TNamespaceOptions): key is ParseKeys<TNamespace, TNamespaceOptions>;
|
|
46
|
+
export declare const coreNS = "aidct_core";
|
|
47
|
+
/**
|
|
48
|
+
* Locale resources type is extracted from the English locale resources object.
|
|
49
|
+
*/
|
|
50
|
+
export type CoreLocaleResources = typeof enLocaleResources;
|
|
51
|
+
/**
|
|
52
|
+
* Core resource bundle.
|
|
53
|
+
*/
|
|
54
|
+
export declare const coreResourceBundle: Resource;
|
|
55
|
+
export declare const i18nextCore: i18n;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize internationalization.
|
|
58
|
+
*
|
|
59
|
+
* @param i18next
|
|
60
|
+
* Internationalization object. As multiple objects exist, this parameter represents the one for the module for which
|
|
61
|
+
* internationalization is being initialized.
|
|
62
|
+
*
|
|
63
|
+
* @param languageDetector
|
|
64
|
+
* Language detector.
|
|
65
|
+
*
|
|
66
|
+
* @param debug
|
|
67
|
+
* Debug setting.
|
|
68
|
+
*
|
|
69
|
+
* @param defaultNS
|
|
70
|
+
* Default namespace.
|
|
71
|
+
*
|
|
72
|
+
* @param defaultResourceBundle
|
|
73
|
+
* Default resource bundle.
|
|
74
|
+
*
|
|
75
|
+
* @param i18nDependencyInits
|
|
76
|
+
* Dependency internationalization initialization functions.
|
|
77
|
+
*
|
|
78
|
+
* @returns
|
|
79
|
+
* Default resource bundle.
|
|
80
|
+
*/
|
|
81
|
+
export declare function i18nInit(i18next: i18n, languageDetector: I18nLanguageDetector, debug: boolean, defaultNS: string, defaultResourceBundle: Resource, ...i18nDependencyInits: Array<(languageDetector: I18nLanguageDetector, debug: boolean) => Promise<Resource>>): Promise<Resource>;
|
|
82
|
+
/**
|
|
83
|
+
* Initialize internationalization.
|
|
84
|
+
*
|
|
85
|
+
* @param languageDetector
|
|
86
|
+
* Language detector.
|
|
87
|
+
*
|
|
88
|
+
* @param debug
|
|
89
|
+
* Debug setting.
|
|
90
|
+
*
|
|
91
|
+
* @returns
|
|
92
|
+
* Core resource bundle.
|
|
93
|
+
*/
|
|
94
|
+
export declare function i18nCoreInit(languageDetector: I18nLanguageDetector, debug?: boolean): Promise<Resource>;
|
|
95
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAgB,EACZ,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAGzD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;CACvD;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAC9B;;OAEG;kBAG2C,sBAAsB;IAEpE;;OAEG;sBACwC,OAAO,CAAC,sBAAsB,CAAC;CACpE,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,aAAa,CAAC,sBAAsB,CAAC,CAAC;AAkBrG;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC1B,UAAU,SAAS,SAAS,GAAG,gBAAgB,EAC/C,iBAAiB,SAAS,QAAQ,GAAG,UAAU,SAAS,gBAAgB,GACpE;IACI,EAAE,CAAC,EAAE,gBAAgB,CAAC;CACzB,GACD;IACI,EAAE,EAAE,UAAU,CAAC;CAClB,EACP,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAE1G;AAED,eAAO,MAAM,MAAM,eAAe,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAOhC,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,IAA+B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,KAAK,CAAC,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgEzR;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE3G"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import i18next from "i18next";
|
|
2
|
+
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
|
|
3
|
+
import I18nextCLILanguageDetector from "i18next-cli-language-detector";
|
|
4
|
+
import enLocaleResources from "./en/locale-resources.js";
|
|
5
|
+
import frLocaleResources from "./fr/locale-resources.js";
|
|
6
|
+
/**
|
|
7
|
+
* Internationalization language detectors.
|
|
8
|
+
*/
|
|
9
|
+
export const I18nLanguageDetectors = {
|
|
10
|
+
/**
|
|
11
|
+
* Command-line interface (e.g., unit tests).
|
|
12
|
+
*/
|
|
13
|
+
// TODO Refactor when https://github.com/neet/i18next-cli-language-detector/issues/281 resolved.
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Per above.
|
|
15
|
+
CLI: I18nextCLILanguageDetector,
|
|
16
|
+
/**
|
|
17
|
+
* Web browser.
|
|
18
|
+
*/
|
|
19
|
+
Browser: I18nextBrowserLanguageDetector
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Convert a string to lower case, skipping words that are all upper case.
|
|
23
|
+
*
|
|
24
|
+
* @param value
|
|
25
|
+
* Value.
|
|
26
|
+
*
|
|
27
|
+
* @returns
|
|
28
|
+
* Lower case string if value is a string. If not, value is returned as a string but not converted to lower case.
|
|
29
|
+
*/
|
|
30
|
+
function toLowerCase(value) {
|
|
31
|
+
return typeof value === "string" ?
|
|
32
|
+
// Words with no lower case letters are preserved as they are likely mnemonics.
|
|
33
|
+
value.split(" ").map(word => /[a-z]/u.test(word) ? word.toLowerCase() : word).join(" ") :
|
|
34
|
+
String(value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determine if a key exists.
|
|
38
|
+
*
|
|
39
|
+
* @param i18next
|
|
40
|
+
* Internationalization object.
|
|
41
|
+
*
|
|
42
|
+
* @param key
|
|
43
|
+
* Key to check.
|
|
44
|
+
*
|
|
45
|
+
* @param options
|
|
46
|
+
* Options.
|
|
47
|
+
*
|
|
48
|
+
* @returns
|
|
49
|
+
* True if key exists in the specified namespace with the given options.
|
|
50
|
+
*/
|
|
51
|
+
export function isI18nParseKey(i18next, key, options) {
|
|
52
|
+
return i18next.exists(key, options);
|
|
53
|
+
}
|
|
54
|
+
export const coreNS = "aidct_core";
|
|
55
|
+
/**
|
|
56
|
+
* Core resource bundle.
|
|
57
|
+
*/
|
|
58
|
+
export const coreResourceBundle = {
|
|
59
|
+
en: {
|
|
60
|
+
aidct_core: enLocaleResources
|
|
61
|
+
},
|
|
62
|
+
fr: {
|
|
63
|
+
aidct_core: frLocaleResources
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Explicit type is necessary because type can't be inferred without additional references.
|
|
67
|
+
export const i18nextCore = i18next.createInstance();
|
|
68
|
+
/**
|
|
69
|
+
* Initialize internationalization.
|
|
70
|
+
*
|
|
71
|
+
* @param i18next
|
|
72
|
+
* Internationalization object. As multiple objects exist, this parameter represents the one for the module for which
|
|
73
|
+
* internationalization is being initialized.
|
|
74
|
+
*
|
|
75
|
+
* @param languageDetector
|
|
76
|
+
* Language detector.
|
|
77
|
+
*
|
|
78
|
+
* @param debug
|
|
79
|
+
* Debug setting.
|
|
80
|
+
*
|
|
81
|
+
* @param defaultNS
|
|
82
|
+
* Default namespace.
|
|
83
|
+
*
|
|
84
|
+
* @param defaultResourceBundle
|
|
85
|
+
* Default resource bundle.
|
|
86
|
+
*
|
|
87
|
+
* @param i18nDependencyInits
|
|
88
|
+
* Dependency internationalization initialization functions.
|
|
89
|
+
*
|
|
90
|
+
* @returns
|
|
91
|
+
* Default resource bundle.
|
|
92
|
+
*/
|
|
93
|
+
export async function i18nInit(i18next, languageDetector, debug, defaultNS, defaultResourceBundle, ...i18nDependencyInits) {
|
|
94
|
+
let initAll = undefined;
|
|
95
|
+
// Initialization may be called more than once.
|
|
96
|
+
if (!i18next.isInitialized) {
|
|
97
|
+
const mergedResourceBundle = {};
|
|
98
|
+
/**
|
|
99
|
+
* Merge a package resource bundle into the merged resource bundle.
|
|
100
|
+
*
|
|
101
|
+
* @param resourceBundle
|
|
102
|
+
* Package resource bundle.
|
|
103
|
+
*/
|
|
104
|
+
function mergeResourceBundle(resourceBundle) {
|
|
105
|
+
// Merge languages.
|
|
106
|
+
for (const [language, languageResourceBundle] of Object.entries(resourceBundle)) {
|
|
107
|
+
if (!(language in mergedResourceBundle)) {
|
|
108
|
+
mergedResourceBundle[language] = {};
|
|
109
|
+
}
|
|
110
|
+
const mergedLanguageResourceBundle = mergedResourceBundle[language];
|
|
111
|
+
// Merge namespaces.
|
|
112
|
+
for (const [namespace, resourceKey] of Object.entries(languageResourceBundle)) {
|
|
113
|
+
if (namespace in mergedLanguageResourceBundle) {
|
|
114
|
+
// Error prior to internationalization initialization; no localization possible.
|
|
115
|
+
throw new Error(`Duplicate namespace ${namespace} in merged resource bundle for language ${language}`);
|
|
116
|
+
}
|
|
117
|
+
mergedLanguageResourceBundle[namespace] = resourceKey;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
mergeResourceBundle(defaultResourceBundle);
|
|
122
|
+
// Build chain to initialize dependencies and merge their resource bundles.
|
|
123
|
+
for (const i18nDependencyInit of i18nDependencyInits) {
|
|
124
|
+
const initDependency = i18nDependencyInit(languageDetector, debug).then(mergeResourceBundle);
|
|
125
|
+
initAll = initAll === undefined ? initDependency : initAll.then(async () => initDependency);
|
|
126
|
+
}
|
|
127
|
+
const initThis = i18next.use(languageDetector).init({
|
|
128
|
+
debug,
|
|
129
|
+
defaultNS,
|
|
130
|
+
resources: mergedResourceBundle,
|
|
131
|
+
// Allow fallback by removing variant code then country code until match is found.
|
|
132
|
+
nonExplicitSupportedLngs: true,
|
|
133
|
+
// Fallback to first language defined.
|
|
134
|
+
fallbackLng: Object.keys(mergedResourceBundle)[0],
|
|
135
|
+
detection: {
|
|
136
|
+
// Disabling cache allows read but requires explicit saving of i18nextLng attribute (e.g., via UI).
|
|
137
|
+
caches: []
|
|
138
|
+
}
|
|
139
|
+
}).then(() => {
|
|
140
|
+
// Add toLowerCase formatter.
|
|
141
|
+
i18next.services.formatter?.add("toLowerCase", toLowerCase);
|
|
142
|
+
});
|
|
143
|
+
initAll = initAll === undefined ? initThis : initAll.then(async () => initThis);
|
|
144
|
+
}
|
|
145
|
+
return initAll !== undefined ? initAll.then(() => defaultResourceBundle) : defaultResourceBundle;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Initialize internationalization.
|
|
149
|
+
*
|
|
150
|
+
* @param languageDetector
|
|
151
|
+
* Language detector.
|
|
152
|
+
*
|
|
153
|
+
* @param debug
|
|
154
|
+
* Debug setting.
|
|
155
|
+
*
|
|
156
|
+
* @returns
|
|
157
|
+
* Core resource bundle.
|
|
158
|
+
*/
|
|
159
|
+
export async function i18nCoreInit(languageDetector, debug = false) {
|
|
160
|
+
return i18nInit(i18nextCore, languageDetector, debug, coreNS, coreResourceBundle);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,OAUN,MAAM,SAAS,CAAC;AACjB,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,0BAA0B,MAAM,+BAA+B,CAAC;AACvE,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AASzD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC;;OAEG;IACH,gGAAgG;IAChG,qFAAqF;IACrF,GAAG,EAAE,0BAA+D;IAEpE;;OAEG;IACH,OAAO,EAAE,8BAAiE;CACpE,CAAC;AAQX;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;QAC9B,+EAA+E;QAC/E,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACzF,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAS5B,OAAa,EAAE,GAAW,EAAE,OAA2B;IACrD,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;AAO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G;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,gBAAsC,EAAE,KAAK,GAAG,KAAK;IACpF,OAAO,QAAQ,CAAC,WAAW,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACtF,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type ISettingsParam, Logger } from "tslog";
|
|
2
|
+
/**
|
|
3
|
+
* Log levels.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LogLevels: {
|
|
6
|
+
readonly Silly: 0;
|
|
7
|
+
readonly Trace: 1;
|
|
8
|
+
readonly Debug: 2;
|
|
9
|
+
readonly Info: 3;
|
|
10
|
+
readonly Warn: 4;
|
|
11
|
+
readonly Error: 5;
|
|
12
|
+
readonly Fatal: 6;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Log level key.
|
|
16
|
+
*/
|
|
17
|
+
export type LogLevelKey = keyof typeof LogLevels;
|
|
18
|
+
/**
|
|
19
|
+
* Log level.
|
|
20
|
+
*/
|
|
21
|
+
export type LogLevel = typeof LogLevels[LogLevelKey];
|
|
22
|
+
/**
|
|
23
|
+
* Get the log level enumeration value corresponding to a string or number.
|
|
24
|
+
*
|
|
25
|
+
* @param untypedLogLevel
|
|
26
|
+
* Untyped log level.
|
|
27
|
+
*
|
|
28
|
+
* @returns
|
|
29
|
+
* Typed log level or default `LogLevels.Info` if untyped log level not provided..
|
|
30
|
+
*/
|
|
31
|
+
export declare function logLevelOf(untypedLogLevel?: string | number): LogLevel;
|
|
32
|
+
/**
|
|
33
|
+
* Get a logger with an optional log level. The underlying implementation is
|
|
34
|
+
* [`tslog`](https://tslog.js.org/).
|
|
35
|
+
*
|
|
36
|
+
* @param logLevel
|
|
37
|
+
* Log level as enumeration value or string. Mapped to `minLevel` and sets `hideLogPositionForProduction` to true in
|
|
38
|
+
* settings if at {@linkcode LogLevels.Info} or higher. Default is {@linkcode LogLevels.Info}.
|
|
39
|
+
*
|
|
40
|
+
* @param settings
|
|
41
|
+
* Detailed settings. See [`tslog`](https://tslog.js.org/#/?id=settings) documentation for details. The `minLevel` is
|
|
42
|
+
* ignored in favour of `logLevel` but `hideLogPositionForProduction` will override the default logic.
|
|
43
|
+
*
|
|
44
|
+
* @param logObj
|
|
45
|
+
* Default log object. See [`tslog`](https://tslog.js.org/#/?id=defining-and-accessing-logobj) documentation for
|
|
46
|
+
* details.
|
|
47
|
+
*
|
|
48
|
+
* @returns
|
|
49
|
+
* Logger.
|
|
50
|
+
*
|
|
51
|
+
* @template T
|
|
52
|
+
* Log object type.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getLogger<T extends object = object>(logLevel?: string | number, settings?: ISettingsParam<T>, logObj?: T): Logger<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Get a loggable representation of a value. Values are returned unmodified, except as follows:
|
|
57
|
+
*
|
|
58
|
+
* - Big integers are converted to whole numbers where possible, otherwise as their decimal string representations.
|
|
59
|
+
* - Arrays are limited to a maximum of ten elements. Any array longer than ten elements is replaced with the first four
|
|
60
|
+
* elements, a string of three dots, and the last four elements. This may still create large results for
|
|
61
|
+
* multidimensional arrays.
|
|
62
|
+
* - Errors are converted to objects with `name`, `message`, and `stack` properties.
|
|
63
|
+
* - Symbols are converted to their string representations.
|
|
64
|
+
* - Functions are converted to strings of the form `Function(name)`.
|
|
65
|
+
*
|
|
66
|
+
* @param value
|
|
67
|
+
* Value.
|
|
68
|
+
*
|
|
69
|
+
* @returns
|
|
70
|
+
* Loggable value.
|
|
71
|
+
*/
|
|
72
|
+
export declare function loggableValue(value: unknown): unknown;
|
|
73
|
+
/**
|
|
74
|
+
* Logger transport that stores messages in memory.
|
|
75
|
+
*/
|
|
76
|
+
export declare class MemoryTransport<T extends object> {
|
|
77
|
+
#private;
|
|
78
|
+
/**
|
|
79
|
+
* Constructor.
|
|
80
|
+
*
|
|
81
|
+
* @param logger
|
|
82
|
+
* Logger.
|
|
83
|
+
*
|
|
84
|
+
* @param maximumLength
|
|
85
|
+
* Maximum length of messages array.
|
|
86
|
+
*
|
|
87
|
+
* @param truncateLength
|
|
88
|
+
* Length to which messages array is truncated when maximum is reached. Default is 50% of `maximumLength`, maximum
|
|
89
|
+
* is 80% of `maximumLength`.
|
|
90
|
+
*/
|
|
91
|
+
constructor(logger: Logger<T>, maximumLength: number, truncateLength?: number);
|
|
92
|
+
/**
|
|
93
|
+
* Get the messages.
|
|
94
|
+
*/
|
|
95
|
+
get messages(): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Get the maximum length of messages array.
|
|
98
|
+
*/
|
|
99
|
+
get maximumLength(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Get the length to which messages array is truncated when maximum is reached.
|
|
102
|
+
*/
|
|
103
|
+
get truncateLength(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Add a notification callback. If one already exists under the current name, do nothing.
|
|
106
|
+
*
|
|
107
|
+
* @param name
|
|
108
|
+
* Callback name.
|
|
109
|
+
*
|
|
110
|
+
* @param notificationCallback
|
|
111
|
+
* Callback.
|
|
112
|
+
*
|
|
113
|
+
* @returns
|
|
114
|
+
* True if successfully added.
|
|
115
|
+
*/
|
|
116
|
+
addNotificationCallback(name: string, notificationCallback: (message: string | undefined, messages: readonly string[]) => void): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Remove a notification callback.
|
|
119
|
+
*
|
|
120
|
+
* @param name
|
|
121
|
+
* Callback name.
|
|
122
|
+
*/
|
|
123
|
+
removeNotificationCallback(name: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Resize the messages array.
|
|
126
|
+
*
|
|
127
|
+
* @param maximumLength
|
|
128
|
+
* Maximum length of messages array.
|
|
129
|
+
*
|
|
130
|
+
* @param truncateLength
|
|
131
|
+
* Length to which messages array is truncated when maximum is reached. Default is 50% of `maximumLength`, maximum
|
|
132
|
+
* is 80% of `maximumLength`.
|
|
133
|
+
*/
|
|
134
|
+
resize(maximumLength: number, truncateLength?: number): void;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,SAAS,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CA2BtE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAUpI;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA4CrD;AAED;;GAEG;AACH,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM;;IAqBzC;;;;;;;;;;;;OAYG;gBACS,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;IAoB7E;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,EAAE,CAEvB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;;;;;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