@tonysamperi/ts-mapi-core 2.0.0-beta.1 → 2.0.0-beta.2
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +5 -5
- package/dist/cjs/rxjs.cjs.map +1 -1
- package/dist/cjs/rxjs.d.cts +3 -3
- package/dist/cjs/{smp-cached-value.interface-BdPg-J7L.d.cts → smp-cached-value.interface-DoiEsQxI.d.cts} +2 -2
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/rxjs.d.ts +3 -3
- package/dist/esm/{smp-cached-value.interface-BdPg-J7L.d.ts → smp-cached-value.interface-DoiEsQxI.d.ts} +2 -2
- package/package.json +1 -1
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-
|
|
1
|
+
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-DoiEsQxI.cjs';
|
|
2
2
|
import { SmpLoggerMethods } from '@tonysamperi/logger';
|
|
3
3
|
export { smpNoop } from '@tonysamperi/logger';
|
|
4
4
|
import { S as SmpResponseMessage, a as SmpGenericResponseBase } from './smp-generic-response-base.interface-D0jHrkjw.cjs';
|
|
@@ -13,9 +13,9 @@ declare abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrat
|
|
|
13
13
|
protected abstract _removeRaw(key: string): void;
|
|
14
14
|
protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;
|
|
15
15
|
flush(): void;
|
|
16
|
-
read<T =
|
|
16
|
+
read<T = any>(key: string): T | undefined;
|
|
17
17
|
remove(key: string): void;
|
|
18
|
-
write<T =
|
|
18
|
+
write<T = any>(key: string, value: T, ttl?: number): void;
|
|
19
19
|
protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -127,7 +127,7 @@ declare class SmpHttpService {
|
|
|
127
127
|
static cacheFlush(): void;
|
|
128
128
|
static mergeQueryParams(url: string, queryParams: SmpHttpConfig["queryParams"]): string;
|
|
129
129
|
protected static _cacheKey(key: string): string;
|
|
130
|
-
protected static _cachePop<T =
|
|
130
|
+
protected static _cachePop<T = any>(key: string): T | void;
|
|
131
131
|
protected static _cacheRead<T>(key: string): T | void;
|
|
132
132
|
protected static _cacheRemove(key: string): void;
|
|
133
133
|
protected static _cacheWrite<T>(key: string, value: T): void;
|
|
@@ -998,6 +998,6 @@ declare class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {
|
|
|
998
998
|
*/
|
|
999
999
|
declare function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
1000
1000
|
|
|
1001
|
-
declare const VERSION: "2.0.0-beta.
|
|
1001
|
+
declare const VERSION: "2.0.0-beta.2";
|
|
1002
1002
|
|
|
1003
1003
|
export { SMP_HEALTHZ, SmpAbstractCacheStrategy, SmpAbstractTtlCacheStrategy, SmpAesCrypt, SmpApiCommonUtils, SmpBaseJwtToken, SmpBaseJwtTokenPlain, SmpBrowserCache, SmpCachedValue, SmpCommonUtils, SmpCrypto, SmpErrorResponse, type SmpErrorResponseCreateOpts, SmpFilterException, SmpFirebaseErrors, type SmpGenericConstructor, SmpGenericResponse, SmpGenericResponseBase, SmpGiftcardTransaction, type SmpGiftcardTransactionConfig, SmpGiftcardTransactionHashStrategies, SmpGiftcardTransactionOps, type SmpGiftcardTransactionPlain, type SmpHttpConfig, SmpHttpService, SmpHttpSessionStorageCache, SmpHttpStatusCodes, SmpInMemoryCache, type SmpMarketingCloudValidationResponse, type SmpMarketingCloudValidationResponseKo, type SmpMarketingCloudValidationResponseOk, SmpMarketingCloudValidators, type SmpPrimitive, SmpRegularExpressions, SmpResponseMessage, SmpRestVerbs, SmpSecureCode, SmpSid, VERSION, smpApplyMixin, smpIsSmpCachedValue };
|
package/dist/cjs/rxjs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rxjs.ts","../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../src/shared/rxjs/smp-rxjs-catch-only.function.ts","../../src/shared/rxjs/smp-rxjs-in-memory-cache.class.ts","../../src/shared/rxjs/smp-rxjs-queue.function.ts","../../src/shared/rxjs/smp-rxjs-sequence.function.ts","../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts","../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts"],"sourcesContent":["export * from \"./shared/rxjs/index.js\";\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\n/**\n * Abstract class representing a caching strategy. This class is intended to be extended by concrete implementations\n * and provides an interface for performing common caching operations such as reading, writing, removing, and flushing cache entries.\n * You shouldn't need to implement this: you can go with SmpAbstractTtlCacheStrategy or SmpRxjsAbstractCacheStrategy, depending on what type of cache you want to implement.\n * For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.\n */\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {Observable, OperatorFunction, catchError, throwError} from \"rxjs\";\nimport type {ObservableInput, ObservedValueOf} from \"rxjs\";\n\nexport function smpRxjsCatchOnly<T, E extends Error, O extends ObservableInput<any>>(\n errorFilter: (new (...args: any[]) => E) | ((err: unknown) => boolean),\n selector: (err: E) => O\n): OperatorFunction<T, T | ObservedValueOf<O>> {\n return (source: Observable<T>) =>\n source.pipe(\n catchError((err: unknown) => {\n const matches = typeof errorFilter === typeof isNaN\n ? isConstructor(errorFilter)\n ? isExactInstance(err, errorFilter as new (...args: any[]) => E)\n : (errorFilter as (err: unknown) => boolean)(err)\n : false;\n\n if (matches) {\n return selector(err as E);\n }\n return throwError(() => err);\n })\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isConstructor(fn: unknown): fn is Function {\n try {\n // try creating a dummy instance\n Reflect.construct(String, [], fn as any);\n return true;\n }\n catch {\n return false;\n }\n}\n\n// Ensures that the error is an *exact* instance of the given error constructor, not a subclass\nfunction isExactInstance<E extends Error>(err: unknown, ctor: new (...args: any[]) => E): boolean {\n return (\n typeof err === \"object\" &&\n err !== null &&\n err.constructor === ctor\n );\n}\n","import {defer, Observable, of} from \"rxjs\";\n//\nimport {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\";\n\nexport class SmpRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n });\n }\n\n protected _readRaw(key: string): Observable<unknown | undefined> {\n return defer(() => {\n\n return of(this._staticSelf._storage.get(key));\n });\n }\n\n protected _removeRaw(key: string): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n });\n }\n\n protected _writeRaw(key: string, value: unknown): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n });\n }\n}\n\n","import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T extends any[]>(steps: { [K in keyof T]: () => Observable<T[K]> }): Observable<T> {\n const results: Partial<T>[] = [];\n\n function runStep(index: number): Observable<T> {\n if (index >= steps.length) {\n return of(results as T);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results[index] = value;\n return runStep(index + 1);\n })\n );\n }\n\n return runStep(0);\n}\n\n// Overloads for array or object input\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\nexport function smpRxjsQueue<T extends any[]>(source: { [K in keyof T]: () => Observable<T[K]> }): Observable<T>;\nexport function smpRxjsQueue<T extends ObsFnMap>(source: T): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue(\n source: (() => Observable<any>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n // use a strongly typed sequence for the array of steps\n return smpRxjsSequence(source as any);\n }\n else {\n // for object, convert values, then reconstruct object mapping with correct types\n const keys = Object.keys(source);\n const stepsArray = keys.map((key) => source[key]);\n\n return smpRxjsSequence(stepsArray as any).pipe(\n map((results: any[]) => {\n const acc: any = {};\n keys.forEach((key, i) => {\n acc[key] = results[i];\n });\n return acc;\n })\n );\n }\n}\n\n\n","import {concatMap, from, Observable, toArray} from \"rxjs\";\n\n/**\n * Old version of the sequence. Now rewritten using recursion, which is way faster.\n * But you can use this if you want to stick with the rxjs pattern\n * @param steps\n */\nexport function smpRxjsSequence<T extends any[]>(\n steps: { [K in keyof T]: () => Observable<T[K]> }\n): Observable<T> {\n // Cast to readonly tuple of functions to keep tuple inference\n const stepFunctions = steps as readonly (() => Observable<T[number]>)[];\n\n return from(stepFunctions).pipe(\n concatMap(step => step()),\n toArray()\n // TS loses tuple typing here, so we cast the result back to T\n // This cast is safe because we control the input and ordering\n ) as Observable<T>;\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n","import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { smpRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * smpRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * smpRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy smpRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n"],"mappings":"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","names":["rxjs_exports","__export","SmpAbstractRxjsTtlCacheStrategy","SmpRxjsInMemoryCache","smpRxjsCatchOnly","smpRxjsQueue","smpRxjsSequence","smpRxjsThrowIfEmpty","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","import_rxjs","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","_flushRaw","defer","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set","import_rxjs","smpRxjsSequence","steps","results","runStep","index","length","of","defer","pipe","switchMap","value","smpRxjsQueue","source","Array","isArray","keys","Object","stepsArray","map","key","acc","forEach","i","import_rxjs","smpRxjsSequence","steps","from","stepFunctions","pipe","concatMap","step","toArray","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","import_rxjs","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
|
|
1
|
+
{"version":3,"sources":["../../src/rxjs.ts","../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../src/shared/rxjs/smp-rxjs-catch-only.function.ts","../../src/shared/rxjs/smp-rxjs-in-memory-cache.class.ts","../../src/shared/rxjs/smp-rxjs-queue.function.ts","../../src/shared/rxjs/smp-rxjs-sequence.function.ts","../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts","../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts"],"sourcesContent":["export * from \"./shared/rxjs/index.js\";\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = any>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = any>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\n/**\n * Abstract class representing a caching strategy. This class is intended to be extended by concrete implementations\n * and provides an interface for performing common caching operations such as reading, writing, removing, and flushing cache entries.\n * You shouldn't need to implement this: you can go with SmpAbstractTtlCacheStrategy or SmpRxjsAbstractCacheStrategy, depending on what type of cache you want to implement.\n * For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.\n */\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = any>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = any>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {Observable, OperatorFunction, catchError, throwError} from \"rxjs\";\nimport type {ObservableInput, ObservedValueOf} from \"rxjs\";\n\nexport function smpRxjsCatchOnly<T, E extends Error, O extends ObservableInput<any>>(\n errorFilter: (new (...args: any[]) => E) | ((err: unknown) => boolean),\n selector: (err: E) => O\n): OperatorFunction<T, T | ObservedValueOf<O>> {\n return (source: Observable<T>) =>\n source.pipe(\n catchError((err: unknown) => {\n const matches = typeof errorFilter === typeof isNaN\n ? isConstructor(errorFilter)\n ? isExactInstance(err, errorFilter as new (...args: any[]) => E)\n : (errorFilter as (err: unknown) => boolean)(err)\n : false;\n\n if (matches) {\n return selector(err as E);\n }\n return throwError(() => err);\n })\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isConstructor(fn: unknown): fn is Function {\n try {\n // try creating a dummy instance\n Reflect.construct(String, [], fn as any);\n return true;\n }\n catch {\n return false;\n }\n}\n\n// Ensures that the error is an *exact* instance of the given error constructor, not a subclass\nfunction isExactInstance<E extends Error>(err: unknown, ctor: new (...args: any[]) => E): boolean {\n return (\n typeof err === \"object\" &&\n err !== null &&\n err.constructor === ctor\n );\n}\n","import {defer, Observable, of} from \"rxjs\";\n//\nimport {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\";\n\nexport class SmpRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n });\n }\n\n protected _readRaw(key: string): Observable<unknown | undefined> {\n return defer(() => {\n\n return of(this._staticSelf._storage.get(key));\n });\n }\n\n protected _removeRaw(key: string): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n });\n }\n\n protected _writeRaw(key: string, value: unknown): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n });\n }\n}\n\n","import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T extends any[]>(steps: { [K in keyof T]: () => Observable<T[K]> }): Observable<T> {\n const results: Partial<T>[] = [];\n\n function runStep(index: number): Observable<T> {\n if (index >= steps.length) {\n return of(results as T);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results[index] = value;\n return runStep(index + 1);\n })\n );\n }\n\n return runStep(0);\n}\n\n// Overloads for array or object input\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\nexport function smpRxjsQueue<T extends any[]>(source: { [K in keyof T]: () => Observable<T[K]> }): Observable<T>;\nexport function smpRxjsQueue<T extends ObsFnMap>(source: T): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue(\n source: (() => Observable<any>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n // use a strongly typed sequence for the array of steps\n return smpRxjsSequence(source as any);\n }\n else {\n // for object, convert values, then reconstruct object mapping with correct types\n const keys = Object.keys(source);\n const stepsArray = keys.map((key) => source[key]);\n\n return smpRxjsSequence(stepsArray as any).pipe(\n map((results: any[]) => {\n const acc: any = {};\n keys.forEach((key, i) => {\n acc[key] = results[i];\n });\n return acc;\n })\n );\n }\n}\n\n\n","import {concatMap, from, Observable, toArray} from \"rxjs\";\n\n/**\n * Old version of the sequence. Now rewritten using recursion, which is way faster.\n * But you can use this if you want to stick with the rxjs pattern\n * @param steps\n */\nexport function smpRxjsSequence<T extends any[]>(\n steps: { [K in keyof T]: () => Observable<T[K]> }\n): Observable<T> {\n // Cast to readonly tuple of functions to keep tuple inference\n const stepFunctions = steps as readonly (() => Observable<T[number]>)[];\n\n return from(stepFunctions).pipe(\n concatMap(step => step()),\n toArray()\n // TS loses tuple typing here, so we cast the result back to T\n // This cast is safe because we control the input and ordering\n ) as Observable<T>;\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n","import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { smpRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * smpRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * smpRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy smpRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n"],"mappings":"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","names":["rxjs_exports","__export","SmpAbstractRxjsTtlCacheStrategy","SmpRxjsInMemoryCache","smpRxjsCatchOnly","smpRxjsQueue","smpRxjsSequence","smpRxjsThrowIfEmpty","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","import_rxjs","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","_flushRaw","defer","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set","import_rxjs","smpRxjsSequence","steps","results","runStep","index","length","of","defer","pipe","switchMap","value","smpRxjsQueue","source","Array","isArray","keys","Object","stepsArray","map","key","acc","forEach","i","import_rxjs","smpRxjsSequence","steps","from","stepFunctions","pipe","concatMap","step","toArray","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","import_rxjs","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
|
package/dist/cjs/rxjs.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable, ObservableInput, OperatorFunction, ObservedValueOf } from 'rxjs';
|
|
2
|
-
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-
|
|
2
|
+
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-DoiEsQxI.cjs';
|
|
3
3
|
|
|
4
4
|
declare abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {
|
|
5
5
|
protected abstract _flushRaw(): Observable<void>;
|
|
@@ -7,9 +7,9 @@ declare abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheS
|
|
|
7
7
|
protected abstract _removeRaw(key: string): Observable<void>;
|
|
8
8
|
protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;
|
|
9
9
|
flush(): Observable<void>;
|
|
10
|
-
read<T =
|
|
10
|
+
read<T = any>(key: string): Observable<T | undefined>;
|
|
11
11
|
remove(key: string): Observable<void>;
|
|
12
|
-
write<T =
|
|
12
|
+
write<T = any>(key: string, value: T, ttl?: number): Observable<void>;
|
|
13
13
|
protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -7,8 +7,8 @@ import { Observable } from 'rxjs';
|
|
|
7
7
|
* For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.
|
|
8
8
|
*/
|
|
9
9
|
declare abstract class SmpAbstractCacheStrategy {
|
|
10
|
-
abstract read<T =
|
|
11
|
-
abstract write<T =
|
|
10
|
+
abstract read<T = any>(key: string): T | undefined | Observable<T | undefined>;
|
|
11
|
+
abstract write<T = any>(key: string, value: T, ttl?: number): void | Observable<void>;
|
|
12
12
|
abstract remove(key: string): void | Observable<void>;
|
|
13
13
|
abstract flush(): void | Observable<void>;
|
|
14
14
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-
|
|
1
|
+
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-DoiEsQxI.js';
|
|
2
2
|
import { SmpLoggerMethods } from '@tonysamperi/logger';
|
|
3
3
|
export { smpNoop } from '@tonysamperi/logger';
|
|
4
4
|
import { S as SmpResponseMessage, a as SmpGenericResponseBase } from './smp-generic-response-base.interface-D0jHrkjw.js';
|
|
@@ -13,9 +13,9 @@ declare abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrat
|
|
|
13
13
|
protected abstract _removeRaw(key: string): void;
|
|
14
14
|
protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;
|
|
15
15
|
flush(): void;
|
|
16
|
-
read<T =
|
|
16
|
+
read<T = any>(key: string): T | undefined;
|
|
17
17
|
remove(key: string): void;
|
|
18
|
-
write<T =
|
|
18
|
+
write<T = any>(key: string, value: T, ttl?: number): void;
|
|
19
19
|
protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -127,7 +127,7 @@ declare class SmpHttpService {
|
|
|
127
127
|
static cacheFlush(): void;
|
|
128
128
|
static mergeQueryParams(url: string, queryParams: SmpHttpConfig["queryParams"]): string;
|
|
129
129
|
protected static _cacheKey(key: string): string;
|
|
130
|
-
protected static _cachePop<T =
|
|
130
|
+
protected static _cachePop<T = any>(key: string): T | void;
|
|
131
131
|
protected static _cacheRead<T>(key: string): T | void;
|
|
132
132
|
protected static _cacheRemove(key: string): void;
|
|
133
133
|
protected static _cacheWrite<T>(key: string, value: T): void;
|
|
@@ -998,6 +998,6 @@ declare class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {
|
|
|
998
998
|
*/
|
|
999
999
|
declare function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
1000
1000
|
|
|
1001
|
-
declare const VERSION: "2.0.0-beta.
|
|
1001
|
+
declare const VERSION: "2.0.0-beta.2";
|
|
1002
1002
|
|
|
1003
1003
|
export { SMP_HEALTHZ, SmpAbstractCacheStrategy, SmpAbstractTtlCacheStrategy, SmpAesCrypt, SmpApiCommonUtils, SmpBaseJwtToken, SmpBaseJwtTokenPlain, SmpBrowserCache, SmpCachedValue, SmpCommonUtils, SmpCrypto, SmpErrorResponse, type SmpErrorResponseCreateOpts, SmpFilterException, SmpFirebaseErrors, type SmpGenericConstructor, SmpGenericResponse, SmpGenericResponseBase, SmpGiftcardTransaction, type SmpGiftcardTransactionConfig, SmpGiftcardTransactionHashStrategies, SmpGiftcardTransactionOps, type SmpGiftcardTransactionPlain, type SmpHttpConfig, SmpHttpService, SmpHttpSessionStorageCache, SmpHttpStatusCodes, SmpInMemoryCache, type SmpMarketingCloudValidationResponse, type SmpMarketingCloudValidationResponseKo, type SmpMarketingCloudValidationResponseOk, SmpMarketingCloudValidators, type SmpPrimitive, SmpRegularExpressions, SmpResponseMessage, SmpRestVerbs, SmpSecureCode, SmpSid, VERSION, smpApplyMixin, smpIsSmpCachedValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Tr,b as jr,c as Lr}from"./chunk-DIVAYUSN.js";import{a as qe,b as Xe}from"./chunk-VBEMFJKM.js";import{a as $}from"./chunk-F3OJMKBL.js";import{a as c}from"./chunk-EI7MMDWY.js";import{Expose as Qe,plainToInstance as or}from"class-transformer";import{Expose as tr,instanceToPlain as rr,plainToInstance as sr,Transform as ir}from"class-transformer";import{Expose as He}from"class-transformer";function Ze(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(Ze,"_ts_decorate");function le(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(le,"_ts_metadata");var F=class i{static{c(this,"SmpResponseMessage")}_message;_type;get message(){return this._message}get type(){return this._type}constructor(e,t=$.ERROR){this._message=e,this._type=t}static sanitizeMessages(e){return typeof e=="string"?e.length?[new i(e)]:[]:[e].flat().map(t=>typeof t=="string"?new i(t):t)}};Ze([He(),le("design:type",String),le("design:paramtypes",[])],F.prototype,"message",null);Ze([He(),le("design:type",typeof $>"u"?Object:$),le("design:paramtypes",[])],F.prototype,"type",null);function er(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(er,"_ts_decorate");function Je(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(Je,"_ts_metadata");var oe=class i{static{c(this,"SmpGenericResponse")}_messages;data;set messages(e){this._messages=F.sanitizeMessages(e)}get messages(){return this._messages}constructor(e=[],t){this._messages=e,this.data=t}static buildInfo(e,t){return new i([e].flat().map(r=>new F(r,$.INFO)),t)}static buildSuccess(e,t){return new i([e].flat().map(r=>new F(r,$.SUCCESS)),t)}static fromPlain(e){return sr(i,e)}isError(){return!this.isSuccess()}isSuccess(){return"_errorCode"in this&&this._errorCode!==null&&this._errorCode!==void 0}serialize(){return rr(this,{excludePrefixes:["_"]})}};er([tr(),ir(({value:i})=>i?.length?i:void 0),Je("design:type",Object),Je("design:paramtypes",[])],oe.prototype,"messages",null);function Ye(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(Ye,"_ts_decorate");function fe(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(fe,"_ts_metadata");var D=class i extends oe{static{c(this,"SmpErrorResponse")}_errorCode;_status;static get DEFAULT_MESSAGES(){return[new F("GENERIC_ERROR")]}get errorCode(){return this._errorCode}get status(){return this._status}get timestamp(){return this._timestamp}_timestamp=Date.now();constructor(e=i.DEFAULT_MESSAGES,t="GENERIC_ERROR",r=500,s){super(e,s),this._errorCode=t,this._status=r}static create({messages:e=i.DEFAULT_MESSAGES,...t}={}){return new i(F.sanitizeMessages(e),t.errorCode,t.status,t.data)}static fromPlain(e){let t=or(nr,e,{excludePrefixes:["_"]}),r=new i;return Object.getOwnPropertyNames(t).forEach(s=>{s in r&&(r[s]=t[s])}),r}};Ye([Qe(),fe("design:type",Object),fe("design:paramtypes",[])],D.prototype,"errorCode",null);Ye([Qe(),fe("design:type",Number),fe("design:paramtypes",[])],D.prototype,"timestamp",null);var nr=class extends D{static{c(this,"SmpErrorResponseMutable")}set errorCode(e){this._errorCode=e}set status(e){this._status=e}set timestamp(e){this._timestamp=e}};import{DateTime as Se}from"ts-luxon";var H=class extends qe{static{c(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(e){let t=this._readRaw(e);if(this._isSmpCachedValue(t)){if(t.expiry>=Se.now().ts)return t.value;this._removeRaw(e);return}return t}remove(e){this._removeRaw(e)}write(e,t,r){if(isNaN(+r)||+r<=0){this._writeRaw(e,t,r);return}let s=Se.now().ts+r*1e3,o={value:t,expiry:s};this._writeRaw(e,o,r)}_isSmpCachedValue(e){return Xe(e)}};var de=class extends H{static{c(this,"SmpBrowserCache")}_storage;_prefix;constructor(e,t){super(),this._storage=e,this._prefix=t}_flushRaw(){let e=[],t=-1;for(;++t<this._storage.length;){let r=this._storage.key(t);r&&r.startsWith(this._prefix)&&e.push(r)}for(t=-1;++t<e.length;)this._storage.removeItem(e[t])}_readRaw(e){let t=this._storage.getItem(this._prefix+e);try{return t?JSON.parse(t):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+e}`);return}}_removeRaw(e){this._storage.removeItem(this._prefix+e)}_writeRaw(e,t){try{this._storage.setItem(this._prefix+e,JSON.stringify(t))}catch(r){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+e}`,r)}}};var pe=class extends de{static{c(this,"SmpHttpSessionStorageCache")}constructor(){super(sessionStorage,"smp_rest_cache_")}};var ue=class extends H{static{c(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(e){return this._staticSelf._storage.get(e)}_removeRaw(e){this._staticSelf._storage.delete(e)}_writeRaw(e,t){this._staticSelf._storage.set(e,t)}};var et=class{static{c(this,"SmpHttpService")}static _cachePrefix="smp_rest_cache_";static _cacheStrategy=typeof sessionStorage<"u"?new pe:new ue;static _config={cachePrefix:this._cachePrefix,shared:new Map};static _errorClass=D;static _mergeParamsFallbackBaseUrl="https://ts-mapi-core.com";static $http(e){return this._generateAjax(e)}static async _generateAjax(e){if(e.cacheKey){let t=this._cacheRead(e.cacheKey);return t?Promise.resolve(t):this._generateAjaxBase(e).then(r=>(e.cacheKey&&this._cacheWrite(e.cacheKey,r),r))}return this._generateAjaxBase(e)}static async _generateAjaxBase(e){let t=await this._preprocessRequest(e),r={method:t.method,headers:new Headers({"content-type":"application/json",...t.headers}),body:t.body?JSON.stringify(t.body):null};return t.useCredentials&&(r.credentials="include"),t.url=this.mergeQueryParams(t.url,t.queryParams),fetch(t.url,r).then(s=>this._preprocessResponse(e,s)).then(s=>{if(s.ok){if(s.status===204||s.headers.get("content-length")==="0")return null;switch(t.responseType){case"blob":return s.blob();case"arraybuffer":return s.arrayBuffer();case"text":return s.text();case"json":default:return s.json()}}return s.json().then(o=>{let n=o;try{n=this._errorClass.fromPlain(o)}catch(h){console.debug("http: failed to parse error response into ErrorResponse",h)}return Promise.reject({status:s.status,message:s.statusText,body:n})})})}static cacheFlush(){this._cacheStrategy.flush()}static mergeQueryParams(e,t){let r=e.startsWith("http");if(t){let s=new URL(e,globalThis?.location?.origin||this._mergeParamsFallbackBaseUrl),o=Object.fromEntries(s.searchParams.entries());s.search=new URLSearchParams({...o,...Object.fromEntries(Object.entries(t).map(([n,h])=>[n,`${h}`]))}).toString(),e=r?s.href:s.pathname+s.search}return e}static _cacheKey(e){return`${this._config.cachePrefix}${e}`}static _cachePop(e){let t=this._cacheRead(e);return this._cacheRemove(e),t}static _cacheRead(e){return this._cacheStrategy.read(this._cacheKey(e))}static _cacheRemove(e){this._cacheStrategy.remove(this._cacheKey(e))}static _cacheWrite(e,t){this._cacheStrategy.write(this._cacheKey(e),t)}static async _preprocessRequest(e){return e}static async _preprocessResponse(e,t){return t}};var tt=(function(i){return i[i.Continue=100]="Continue",i[i.SwitchingProtocols=101]="SwitchingProtocols",i[i.Processing=102]="Processing",i[i.EarlyHints=103]="EarlyHints",i[i.Ok=200]="Ok",i[i.Created=201]="Created",i[i.Accepted=202]="Accepted",i[i.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",i[i.NoContent=204]="NoContent",i[i.ResetContent=205]="ResetContent",i[i.PartialContent=206]="PartialContent",i[i.MultiStatus=207]="MultiStatus",i[i.AlreadyReported=208]="AlreadyReported",i[i.ImUsed=226]="ImUsed",i[i.MultipleChoices=300]="MultipleChoices",i[i.MovedPermanently=301]="MovedPermanently",i[i.Found=302]="Found",i[i.SeeOther=303]="SeeOther",i[i.NotModified=304]="NotModified",i[i.UseProxy=305]="UseProxy",i[i.Unused=306]="Unused",i[i.TemporaryRedirect=307]="TemporaryRedirect",i[i.PermanentRedirect=308]="PermanentRedirect",i[i.BadRequest=400]="BadRequest",i[i.Unauthorized=401]="Unauthorized",i[i.PaymentRequired=402]="PaymentRequired",i[i.Forbidden=403]="Forbidden",i[i.NotFound=404]="NotFound",i[i.MethodNotAllowed=405]="MethodNotAllowed",i[i.NotAcceptable=406]="NotAcceptable",i[i.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",i[i.RequestTimeout=408]="RequestTimeout",i[i.Conflict=409]="Conflict",i[i.Gone=410]="Gone",i[i.LengthRequired=411]="LengthRequired",i[i.PreconditionFailed=412]="PreconditionFailed",i[i.PayloadTooLarge=413]="PayloadTooLarge",i[i.UriTooLong=414]="UriTooLong",i[i.UnsupportedMediaType=415]="UnsupportedMediaType",i[i.RangeNotSatisfiable=416]="RangeNotSatisfiable",i[i.ExpectationFailed=417]="ExpectationFailed",i[i.ImATeapot=418]="ImATeapot",i[i.MisdirectedRequest=421]="MisdirectedRequest",i[i.UnprocessableEntity=422]="UnprocessableEntity",i[i.Locked=423]="Locked",i[i.FailedDependency=424]="FailedDependency",i[i.TooEarly=425]="TooEarly",i[i.UpgradeRequired=426]="UpgradeRequired",i[i.PreconditionRequired=428]="PreconditionRequired",i[i.TooManyRequests=429]="TooManyRequests",i[i.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",i[i.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",i[i.InternalServerError=500]="InternalServerError",i[i.NotImplemented=501]="NotImplemented",i[i.BadGateway=502]="BadGateway",i[i.ServiceUnavailable=503]="ServiceUnavailable",i[i.GatewayTimeout=504]="GatewayTimeout",i[i.HttpVersionNotSupported=505]="HttpVersionNotSupported",i[i.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",i[i.InsufficientStorage=507]="InsufficientStorage",i[i.LoopDetected=508]="LoopDetected",i[i.NotExtended=510]="NotExtended",i[i.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",i})({});import{SmpLoggerMethods as hr}from"@tonysamperi/logger";var rt=class{static{c(this,"SmpApiCommonUtils")}static _javascriptVariablePattern="[a-zA-Z_$][a-zA-Z_$0-9]*";static _logger=new hr;static _pathParamRegex=new RegExp(`\\{(${this._javascriptVariablePattern})\\}`,"g");static credentialsToBasicAuth(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}static fromBearer(e=""){return e.split(" ")[1]}static getCountryFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[0]?.toUpperCase()}static getLanguageFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[1]}static getLocaleFromReferer(e){return e?.match(/\/([A-Z]{2}-[A-Z]{2})\//i)?.[1]}static interpolateParams(e,t){try{return e.replace(this._pathParamRegex,(r,s)=>{let o=t[s];return o!==void 0?encodeURIComponent(o):r})}catch(r){this._logger.warn(`${this.constructor.name}: couldn't interpolate params`,r)}return e}};var Bs={status:"OK"};var st=(function(i){return i.GET="GET",i.POST="POST",i.PUT="PUT",i.DELETE="DELETE",i.PATCH="PATCH",i})({});var it=class{static{c(this,"SmpBaseJwtToken")}_access_token;_exp;_iss;get access_token(){return this._access_token}get exp(){return this._exp}get iss(){return this._iss}constructor(e,t,r){this._access_token=e,this._exp=t,this._iss=r}serialize(){return{access_token:this._access_token,exp:this._exp,iss:this._iss}}};var ot=class{static{c(this,"SmpBaseJwtTokenPlain")}access_token;exp;iss};var L=class{static{c(this,"Hex")}static parse(e){let t=e.length,r=[];for(let s=0;s<t;s+=2)r[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new g(r,t/2)}static stringify(e){let t=[];for(let r=0;r<e.sigBytes;r++){let s=e.words[r>>>2]>>>24-r%4*8&255;t.push((s>>>4).toString(16)),t.push((s&15).toString(16))}return t.join("")}};var g=class be{static{c(this,"WordArray")}constructor(e,t){this.words=e||[],t!==void 0?this.sigBytes=t:this.sigBytes=this.words.length*4}static random(e){let t=[],r=c(function(s){let o=987654321,n=4294967295;return function(){o=36969*(o&65535)+(o>>16)&n,s=18e3*(s&65535)+(s>>16)&n;let h=(o<<16)+s&n;return h/=4294967296,h+=.5,h*(Math.random()>.5?1:-1)}},"r");for(let s=0,o;s<e;s+=4){let n=r((o||Math.random())*4294967296);o=n()*987654071,t.push(n()*4294967296|0)}return new be(t,e)}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new be(this.words.slice(0),this.sigBytes)}concat(e){if(this.clamp(),this.sigBytes%4)for(let t=0;t<e.sigBytes;t++){let r=e.words[t>>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=r<<24-(this.sigBytes+t)%4*8}else for(let t=0;t<e.sigBytes;t+=4)this.words[this.sigBytes+t>>>2]=e.words[t>>>2];return this.sigBytes+=e.sigBytes,this}toString(e){return(e||L).stringify(this)}};var we=class{static{c(this,"Latin1")}static parse(e){let t=e.length,r=[];for(let s=0;s<t;s++)r[s>>>2]|=(e.charCodeAt(s)&255)<<24-s%4*8;return new g(r,t)}static stringify(e){let t=[];for(let r=0;r<e.sigBytes;r++){let s=e.words[r>>>2]>>>24-r%4*8&255;t.push(String.fromCharCode(s))}return t.join("")}};var R=class{static{c(this,"Utf8")}static parse(e){return we.parse(unescape(encodeURIComponent(e)))}static stringify(e){try{return decodeURIComponent(escape(we.stringify(e)))}catch(t){throw console.error("Malformed UTF-8 data",t),new Error("Malformed UTF-8 data")}}};var ge=class{static{c(this,"BufferedBlockAlgorithm")}constructor(e){this._minBufferSize=0,this.cfg=Object.assign({blockSize:1},e),this._data=new g,this._nDataBytes=0}clone(){let e=this.constructor();for(let t in this)Object.prototype.hasOwnProperty.call(this,t)&&(e[t]=this[t]);return e._data=this._data.clone(),e}reset(){this._data=new g,this._nDataBytes=0}_append(e){typeof e=="string"&&(e=R.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_process(e){if(!this.cfg.blockSize)throw new Error("missing blockSize in config");let t=this.cfg.blockSize*4,r=this._data.sigBytes/t;e?r=Math.ceil(r):r=Math.max((r|0)-this._minBufferSize,0);let s=r*this.cfg.blockSize,o=Math.min(s*4,this._data.sigBytes),n;if(s){for(let h=0;h<s;h+=this.cfg.blockSize)this._doProcessBlock(this._data.words,h);n=this._data.words.splice(0,s),this._data.sigBytes-=o}return new g(n,o)}};var J=class{static{c(this,"CipherParams")}constructor(e){this.ciphertext=e.ciphertext,this.key=e.key,this.iv=e.iv,this.salt=e.salt,this.algorithm=e.algorithm,this.mode=e.mode,this.padding=e.padding,this.blockSize=e.blockSize,this.formatter=e.formatter}extend(e){return e.ciphertext!==void 0&&(this.ciphertext=e.ciphertext),e.key!==void 0&&(this.key=e.key),e.iv!==void 0&&(this.iv=e.iv),e.salt!==void 0&&(this.salt=e.salt),e.algorithm!==void 0&&(this.algorithm=e.algorithm),e.mode!==void 0&&(this.mode=e.mode),e.padding!==void 0&&(this.padding=e.padding),e.blockSize!==void 0&&(this.blockSize=e.blockSize),e.formatter!==void 0&&(this.formatter=e.formatter),this}toString(e){if(e)return e.stringify(this);if(this.formatter)return this.formatter.stringify(this);throw new Error("cipher needs a formatter to be able to convert the result into a string")}};var z=class{static{c(this,"Base64")}static parse(e){let t=e.length;if(this._reverseMap===void 0){this._reverseMap=[];for(let s=0;s<this._map.length;s++)this._reverseMap[this._map.charCodeAt(s)]=s}let r=this._map.charAt(64);if(r){let s=e.indexOf(r);s!==-1&&(t=s)}return this.parseLoop(e,t,this._reverseMap)}static parseLoop(e,t,r){let s=[],o=0;for(let n=0;n<t;n++)if(n%4){let h=r[e.charCodeAt(n-1)]<<n%4*2,a=r[e.charCodeAt(n)]>>>6-n%4*2;s[o>>>2]|=(h|a)<<24-o%4*8,o++}return new g(s,o)}static stringify(e){e.clamp();let t=[];for(let s=0;s<e.sigBytes;s+=3){let o=e.words[s>>>2]>>>24-s%4*8&255,n=e.words[s+1>>>2]>>>24-(s+1)%4*8&255,h=e.words[s+2>>>2]>>>24-(s+2)%4*8&255,a=o<<16|n<<8|h;for(let p=0;p<4&&s+p*.75<e.sigBytes;p++)t.push(this._map.charAt(a>>>6*(3-p)&63))}let r=this._map.charAt(64);if(r)for(;t.length%4;)t.push(r);return t.join("")}};z._map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";z._reverseMap=void 0;var _e=class{static{c(this,"OpenSSL")}static parse(e){let t=z.parse(e),r;return t.words[0]===1398893684&&t.words[1]===1701076831&&(r=new g(t.words.slice(2,4)),t.words.splice(0,4),t.sigBytes-=16),new J({ciphertext:t,salt:r})}static stringify(e){if(!e.ciphertext)throw new Error("missing ciphertext in params");let t=e.ciphertext,r=e.salt,s;if(r){if(typeof r=="string")throw new Error("salt is expected to be a WordArray");s=new g([1398893684,1701076831]).concat(r).concat(t)}else s=t;return s.toString(z)}};var W=class{static{c(this,"SerializableCipher")}static decrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(!o.format)throw new Error("could not determine format");if(t=this._parse(t,o.format),!t.ciphertext)throw new Error("could not determine ciphertext");return e.createDecryptor(r,o).finalize(t.ciphertext)}static encrypt(e,t,r,s){let o=Object.assign({},this.cfg,s),n=e.createEncryptor(r,o),h=n.finalize(t);return new J({ciphertext:h,key:r,iv:n.cfg.iv,algorithm:e,mode:n.cfg.mode,padding:n.cfg.padding,blockSize:n.cfg.blockSize,formatter:o.format})}static _parse(e,t){return typeof e=="string"?t.parse(e):e}};W.cfg={blockSize:4,iv:new g([]),format:_e};var E=class extends ge{static{c(this,"Hasher")}constructor(e){super(Object.assign({blockSize:512/32},e)),this.reset()}static _createHelper(e){function t(r,s){return new e(s).finalize(r)}return c(t,"helper"),t}finalize(e){return e&&this._append(e),this._doFinalize()}update(e){return this._append(e),this._process(),this}};var f=[];for(let i=0;i<64;i++)f[i]=Math.abs(Math.sin(i+1))*4294967296|0;var T=class d extends E{static{c(this,"MD5")}get hash(){return this._hash}static FF(e,t,r,s,o,n,h){let a=e+(t&r|~t&s)+o+h;return(a<<n|a>>>32-n)+t}static GG(e,t,r,s,o,n,h){let a=e+(t&s|r&~s)+o+h;return(a<<n|a>>>32-n)+t}static HH(e,t,r,s,o,n,h){let a=e+(t^r^s)+o+h;return(a<<n|a>>>32-n)+t}static II(e,t,r,s,o,n,h){let a=e+(r^(t|~s))+o+h;return(a<<n|a>>>32-n)+t}reset(){super.reset(),this._hash=new g([1732584193,4023233417,2562383102,271733878])}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;this._data.words[t>>>5]|=128<<24-t%32;let r=Math.floor(e/4294967296),s=e;this._data.words[(t+64>>>9<<4)+15]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360,this._data.words[(t+64>>>9<<4)+14]=(s<<8|s>>>24)&16711935|(s<<24|s>>>8)&4278255360,this._data.sigBytes=(this._data.words.length+1)*4,this._process();for(let o=0;o<4;o++)this._hash.words[o]=(this._hash.words[o]<<8|this._hash.words[o]>>>24)&16711935|(this._hash.words[o]<<24|this._hash.words[o]>>>8)&4278255360;return this._hash}_doProcessBlock(e,t){for(let a=0;a<16;a++){let p=t+a,w=e[p];e[p]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}let r=Array.from({length:16});for(let a=0;a<16;a++)r[a]=e[t+a];let s=this._hash.words[0],o=this._hash.words[1],n=this._hash.words[2],h=this._hash.words[3];s=d.FF(s,o,n,h,r[0],7,f[0]),h=d.FF(h,s,o,n,r[1],12,f[1]),n=d.FF(n,h,s,o,r[2],17,f[2]),o=d.FF(o,n,h,s,r[3],22,f[3]),s=d.FF(s,o,n,h,r[4],7,f[4]),h=d.FF(h,s,o,n,r[5],12,f[5]),n=d.FF(n,h,s,o,r[6],17,f[6]),o=d.FF(o,n,h,s,r[7],22,f[7]),s=d.FF(s,o,n,h,r[8],7,f[8]),h=d.FF(h,s,o,n,r[9],12,f[9]),n=d.FF(n,h,s,o,r[10],17,f[10]),o=d.FF(o,n,h,s,r[11],22,f[11]),s=d.FF(s,o,n,h,r[12],7,f[12]),h=d.FF(h,s,o,n,r[13],12,f[13]),n=d.FF(n,h,s,o,r[14],17,f[14]),o=d.FF(o,n,h,s,r[15],22,f[15]),s=d.GG(s,o,n,h,r[1],5,f[16]),h=d.GG(h,s,o,n,r[6],9,f[17]),n=d.GG(n,h,s,o,r[11],14,f[18]),o=d.GG(o,n,h,s,r[0],20,f[19]),s=d.GG(s,o,n,h,r[5],5,f[20]),h=d.GG(h,s,o,n,r[10],9,f[21]),n=d.GG(n,h,s,o,r[15],14,f[22]),o=d.GG(o,n,h,s,r[4],20,f[23]),s=d.GG(s,o,n,h,r[9],5,f[24]),h=d.GG(h,s,o,n,r[14],9,f[25]),n=d.GG(n,h,s,o,r[3],14,f[26]),o=d.GG(o,n,h,s,r[8],20,f[27]),s=d.GG(s,o,n,h,r[13],5,f[28]),h=d.GG(h,s,o,n,r[2],9,f[29]),n=d.GG(n,h,s,o,r[7],14,f[30]),o=d.GG(o,n,h,s,r[12],20,f[31]),s=d.HH(s,o,n,h,r[5],4,f[32]),h=d.HH(h,s,o,n,r[8],11,f[33]),n=d.HH(n,h,s,o,r[11],16,f[34]),o=d.HH(o,n,h,s,r[14],23,f[35]),s=d.HH(s,o,n,h,r[1],4,f[36]),h=d.HH(h,s,o,n,r[4],11,f[37]),n=d.HH(n,h,s,o,r[7],16,f[38]),o=d.HH(o,n,h,s,r[10],23,f[39]),s=d.HH(s,o,n,h,r[13],4,f[40]),h=d.HH(h,s,o,n,r[0],11,f[41]),n=d.HH(n,h,s,o,r[3],16,f[42]),o=d.HH(o,n,h,s,r[6],23,f[43]),s=d.HH(s,o,n,h,r[9],4,f[44]),h=d.HH(h,s,o,n,r[12],11,f[45]),n=d.HH(n,h,s,o,r[15],16,f[46]),o=d.HH(o,n,h,s,r[2],23,f[47]),s=d.II(s,o,n,h,r[0],6,f[48]),h=d.II(h,s,o,n,r[7],10,f[49]),n=d.II(n,h,s,o,r[14],15,f[50]),o=d.II(o,n,h,s,r[5],21,f[51]),s=d.II(s,o,n,h,r[12],6,f[52]),h=d.II(h,s,o,n,r[3],10,f[53]),n=d.II(n,h,s,o,r[10],15,f[54]),o=d.II(o,n,h,s,r[1],21,f[55]),s=d.II(s,o,n,h,r[8],6,f[56]),h=d.II(h,s,o,n,r[15],10,f[57]),n=d.II(n,h,s,o,r[6],15,f[58]),o=d.II(o,n,h,s,r[13],21,f[59]),s=d.II(s,o,n,h,r[4],6,f[60]),h=d.II(h,s,o,n,r[11],10,f[61]),n=d.II(n,h,s,o,r[2],15,f[62]),o=d.II(o,n,h,s,r[9],21,f[63]),this._hash.words[0]=this._hash.words[0]+s|0,this._hash.words[1]=this._hash.words[1]+o|0,this._hash.words[2]=this._hash.words[2]+n|0,this._hash.words[3]=this._hash.words[3]+h|0}};var Oe=class nt{static{c(this,"EVPKDF")}constructor(e){this.cfg=Object.assign({keySize:128/32,hasher:T,iterations:1},e)}static execute(e,t,r){return new nt(r).compute(e,t)}compute(e,t){let r=new this.cfg.hasher,s=new g,o;for(;s.words.length<this.cfg.keySize;){o&&r.update(o),o=r.update(e).finalize(t),r.reset();for(let n=1;n<this.cfg.iterations;n++)o=r.finalize(o),r.reset();s.concat(o)}return s.sigBytes=this.cfg.keySize*4,s}};var ht=class{static{c(this,"OpenSSLKdf")}static execute(e,t,r,s){s||(s=g.random(64/8));let o=new Oe({keySize:t+r}).compute(e,s),n=new g(o.words.slice(t),r*4);return o.sigBytes=t*4,new J({key:o,iv:n,salt:s})}};var me=class{static{c(this,"PasswordBasedCipher")}static decrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(o.format===void 0)throw new Error("missing format in config");if(t=this._parse(t,o.format),o.kdf===void 0)throw new Error("the key derivation function must be set");let n=o.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv!==void 0&&(o.iv=n.iv),W.decrypt.call(this,e,t,n.key,o)}static encrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(o.kdf===void 0)throw new Error("missing kdf in config");let n=o.kdf.execute(r,e.keySize,e.ivSize);return n.iv!==void 0&&(o.iv=n.iv),W.encrypt.call(this,e,t,n.key,o).extend(n)}static _parse(e,t){return typeof e=="string"?t.parse(e):e}};me.cfg={blockSize:4,iv:new g([]),format:_e,kdf:ht};var ct=class{static{c(this,"CipherHelper")}constructor(e){this._cipher=e}decrypt(e,t,r){return typeof t=="string"?me.decrypt(this._cipher,e,t,r):W.decrypt(this._cipher,e,t,r)}encrypt(e,t,r){return typeof t=="string"?me.encrypt(this._cipher,e,t,r):W.encrypt(this._cipher,e,t,r)}};var Y=class extends ge{static{c(this,"Cipher")}constructor(e,t,r){super(Object.assign({blockSize:1},r)),this._xformMode=e,this._key=t,this.reset()}static _createHelper(e){return new ct(e)}static createDecryptor(e,t){let r=this;return new r(this._DEC_XFORM_MODE,e,t)}static createEncryptor(e,t){return new this(this._ENC_XFORM_MODE,e,t)}finalize(e){return e&&this._append(e),this._doFinalize()}process(e){return this._append(e),this._process()}};Y.ivSize=4;Y.keySize=4;Y._DEC_XFORM_MODE=2;Y._ENC_XFORM_MODE=1;var K=class{static{c(this,"BlockCipherModeAlgorithm")}constructor(e,t){this.init(e,t)}init(e,t){this._cipher=e,this._iv=t}};var ye=class{static{c(this,"BlockCipherMode")}static createDecryptor(e,t){let r=this.Decryptor;return new r(e,t)}static createEncryptor(e,t){let r=this.Encryptor;return new r(e,t)}};ye.Decryptor=K;ye.Encryptor=K;var at=class extends K{static{c(this,"CBCEncryptor")}get prevBlock(){return this._prevBlock}processBlock(e,t){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");this.xorBlock(e,t,this._cipher.cfg.blockSize),this._cipher.encryptBlock(e,t),this._prevBlock=e.slice(t,t+this._cipher.cfg.blockSize)}xorBlock(e,t,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)e[t+o]^=s[o]}};var lt=class extends K{static{c(this,"CBCDecryptor")}get prevBlock(){return this._prevBlock}processBlock(e,t){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");let r=e.slice(t,t+this._cipher.cfg.blockSize);this._cipher.decryptBlock(e,t),this.xorBlock(e,t,this._cipher.cfg.blockSize),this._prevBlock=r}xorBlock(e,t,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)e[t+o]^=s[o]}};var U=class extends ye{static{c(this,"CBC")}};U.Decryptor=lt;U.Encryptor=at;var Q=class{static{c(this,"PKCS7")}static pad(e,t){let r=t*4,s=r-e.sigBytes%r,o=s<<24|s<<16|s<<8|s,n=[];for(let a=0;a<s;a+=4)n.push(o);let h=new g(n,s);e.concat(h)}static unpad(e){let t=e.words[e.sigBytes-1>>>2]&255;e.sigBytes-=t}};var xe=class extends Y{static{c(this,"BlockCipher")}constructor(e,t,r){super(e,t,Object.assign({blockSize:4,mode:U,padding:Q},r))}reset(){if(super.reset(),this.cfg.mode===void 0)throw new Error("missing mode in config");let e;this._xformMode===this.constructor._ENC_XFORM_MODE?e=this.cfg.mode.createEncryptor:(e=this.cfg.mode.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator===e?this._mode.init(this,this.cfg.iv&&this.cfg.iv.words):(this._mode=e.call(this.cfg.mode,this,this.cfg.iv&&this.cfg.iv.words),this._mode.__creator=e)}_doFinalize(){if(this.cfg.padding===void 0)throw new Error("missing padding in config");let e;if(this._xformMode===this.constructor._ENC_XFORM_MODE){if(this.cfg.blockSize===void 0)throw new Error("missing blockSize in config");this.cfg.padding.pad(this._data,this.cfg.blockSize),e=this._process(!0)}else e=this._process(!0),this.cfg.padding.unpad(e);return e}_doProcessBlock(e,t){this._mode.processBlock(e,t)}};var l=class P{static{c(this,"X64Word")}constructor(e,t){this.high=e,this.low=t}add(e){let t=this.low+e.low|0,r=t>>>0<this.low>>>0?1:0,s=this.high+e.high+r|0;return new P(s,t)}and(e){return new P(this.high&e.high,this.low&e.low)}not(){return new P(~this.high,~this.low)}or(e){return new P(this.high|e.high,this.low|e.low)}rotL(e){return this.shiftL(e).or(this.shiftR(64-e))}rotR(e){return this.shiftR(e).or(this.shiftL(64-e))}shiftL(e){return e<32?new P(this.high<<e|this.low>>>32-e,this.low<<e):new P(this.low<<e-32,0)}shiftR(e){return e<32?new P(this.high>>>e,this.low>>>e|this.high<<32-e):new P(0,this.high>>>e-32)}xor(e){return new P(this.high^e.high,this.low^e.low)}};var ft=class ve{static{c(this,"X64WordArray")}constructor(e=[],t){this.words=e,this.sigBytes=t!==void 0?t:e.length*8}static create(e=[],t){return new ve(e,t)}clone(){let e=this.words.map(t=>new l(t.high,t.low));return new ve(e,this.sigBytes)}toX32(){let e=[];for(let t of this.words)e.push(t.high,t.low);return new g(e,this.sigBytes)}};var B=[],dt=[],pt=[],ut=[],wt=[],gt=[],Ie=[],ke=[],Ne=[],Me=[];(function(){let i=[];for(let r=0;r<256;r++)r<128?i[r]=r<<1:i[r]=r<<1^283;let e=0,t=0;for(let r=0;r<256;r++){let s=t^t<<1^t<<2^t<<3^t<<4;s=s>>>8^s&255^99,B[e]=s,dt[s]=e;let o=i[e],n=i[o],h=i[n],a=i[s]*257^s*16843008;pt[e]=a<<24|a>>>8,ut[e]=a<<16|a>>>16,wt[e]=a<<8|a>>>24,gt[e]=a,a=h*16843009^n*65537^o*257^e*16843008,Ie[s]=a<<24|a>>>8,ke[s]=a<<16|a>>>16,Ne[s]=a<<8|a>>>24,Me[s]=a,e?(e=o^i[i[i[h^o]]],t^=i[i[t]]):e=t=1}})();var cr=[0,1,2,4,8,16,32,64,128,27,54],Ee=class extends xe{static{c(this,"AES")}constructor(e,t,r){super(e,t,r),super.reset()}decryptBlock(e,t){let r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,Ie,ke,Ne,Me,dt),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r}encryptBlock(e,t){this._doCryptBlock(e,t,this._keySchedule,pt,ut,wt,gt,B)}reset(){if(super.reset(),this._nRounds&&this._keyPriorReset===this._key)return;let e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,o=((this._nRounds=r+6)+1)*4,n=this._keySchedule=[];for(let h=0;h<o;h++)if(h<r)n[h]=t[h];else{let a=n[h-1];h%r?r>6&&h%r===4&&(a=B[a>>>24]<<24|B[a>>>16&255]<<16|B[a>>>8&255]<<8|B[a&255]):(a=a<<8|a>>>24,a=B[a>>>24]<<24|B[a>>>16&255]<<16|B[a>>>8&255]<<8|B[a&255],a^=cr[h/r|0]<<24),n[h]=n[h-r]^a}this._invKeySchedule=[];for(let h=0;h<o;h++){let a=o-h,p;h%4?p=n[a]:p=n[a-4],h<4||a<=4?this._invKeySchedule[h]=p:this._invKeySchedule[h]=Ie[B[p>>>24]]^ke[B[p>>>16&255]]^Ne[B[p>>>8&255]]^Me[B[p&255]]}}_doCryptBlock(e,t,r,s,o,n,h,a){let p=e[t]^r[0],w=e[t+1]^r[1],u=e[t+2]^r[2],_=e[t+3]^r[3],x=4;for(let A=1;A<this._nRounds;A++){let m=s[p>>>24]^o[w>>>16&255]^n[u>>>8&255]^h[_&255]^r[x++],y=s[w>>>24]^o[u>>>16&255]^n[_>>>8&255]^h[p&255]^r[x++],N=s[u>>>24]^o[_>>>16&255]^n[p>>>8&255]^h[w&255]^r[x++],Be=s[_>>>24]^o[p>>>16&255]^n[w>>>8&255]^h[u&255]^r[x++];p=m,w=y,u=N,_=Be}let b=(a[p>>>24]<<24|a[w>>>16&255]<<16|a[u>>>8&255]<<8|a[_&255])^r[x++],C=(a[w>>>24]<<24|a[u>>>16&255]<<16|a[_>>>8&255]<<8|a[p&255])^r[x++],I=(a[u>>>24]<<24|a[_>>>16&255]<<16|a[p>>>8&255]<<8|a[w&255])^r[x++],k=(a[_>>>24]<<24|a[p>>>16&255]<<16|a[w>>>8&255]<<8|a[u&255])^r[x++];e[t]=b,e[t+1]=C,e[t+2]=I,e[t+3]=k}};Ee.keySize=256/32;var ar=[1732584193,4023233417,2562383102,271733878,3285377520],G=new Array(80),V=class extends E{static{c(this,"SHA1")}get hash(){return this._hash}reset(){super.reset(),this._hash=new g(ar.slice(0))}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;return this._data.words[t>>>5]|=128<<24-t%32,this._data.words[(t+64>>>9<<4)+14]=Math.floor(e/4294967296),this._data.words[(t+64>>>9<<4)+15]=e,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,t){let r=this._hash.words[0],s=this._hash.words[1],o=this._hash.words[2],n=this._hash.words[3],h=this._hash.words[4];for(let a=0;a<80;a++){if(a<16)G[a]=e[t+a]|0;else{let _=G[a-3]^G[a-8]^G[a-14]^G[a-16];G[a]=_<<1|_>>>31}let p,w;a<20?(p=s&o|~s&n,w=1518500249):a<40?(p=s^o^n,w=1859775393):a<60?(p=s&o|s&n|o&n,w=2400959708):(p=s^o^n,w=3395469782);let u=(r<<5|r>>>27)+p+h+w+G[a];h=n,n=o,o=s<<30|s>>>2,s=r,r=u|0}this._hash.words[0]=this._hash.words[0]+r|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+o|0,this._hash.words[3]=this._hash.words[3]+n|0,this._hash.words[4]=this._hash.words[4]+h|0}};var _t=[],mt=[];(function(){function i(s){let o=Math.sqrt(s);for(let n=2;n<=o;n++)if(!(s%n))return!1;return!0}c(i,"isPrime");function e(s){return(s-(s|0))*4294967296|0}c(e,"getFractionalBits");let t=2,r=0;for(;r<64;)i(t)&&(r<8&&(_t[r]=e(Math.pow(t,1/2))),mt[r]=e(Math.pow(t,1/3)),r++),t++})();var q=[],ne=class extends E{static{c(this,"SHA256")}constructor(){super()}reset(){super.reset(),this._hash=new g(_t.slice(0))}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;return this._data.words[t>>>5]|=128<<24-t%32,this._data.words[(t+64>>>9<<4)+14]=Math.floor(e/4294967296),this._data.words[(t+64>>>9<<4)+15]=e,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,t){let r=this._hash.words[0],s=this._hash.words[1],o=this._hash.words[2],n=this._hash.words[3],h=this._hash.words[4],a=this._hash.words[5],p=this._hash.words[6],w=this._hash.words[7];for(let u=0;u<64;u++){if(u<16)q[u]=e[t+u]|0;else{let A=q[u-15],m=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,y=q[u-2],N=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;q[u]=m+q[u-7]+N+q[u-16]}let _=h&a^~h&p,x=r&s^r&o^s&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),C=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),I=w+C+_+mt[u]+q[u],k=b+x;w=p,p=a,a=h,h=n+I|0,n=o,o=s,s=r,r=I+k|0}this._hash.words[0]=this._hash.words[0]+r|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+o|0,this._hash.words[3]=this._hash.words[3]+n|0,this._hash.words[4]=this._hash.words[4]+h|0,this._hash.words[5]=this._hash.words[5]+a|0,this._hash.words[6]=this._hash.words[6]+p|0,this._hash.words[7]=this._hash.words[7]+w|0}};var Ce=[new l(1116352408,3609767458),new l(1899447441,602891725),new l(3049323471,3964484399),new l(3921009573,2173295548),new l(961987163,4081628472),new l(1508970993,3053834265),new l(2453635748,2937671579),new l(2870763221,3664609560),new l(3624381080,2734883394),new l(310598401,1164996542),new l(607225278,1323610764),new l(1426881987,3590304994),new l(1925078388,4068182383),new l(2162078206,991336113),new l(2614888103,633803317),new l(3248222580,3479774868),new l(3835390401,2666613458),new l(4022224774,944711139),new l(264347078,2341262773),new l(604807628,2007800933),new l(770255983,1495990901),new l(1249150122,1856431235),new l(1555081692,3175218132),new l(1996064986,2198950837),new l(2554220882,3999719339),new l(2821834349,766784016),new l(2952996808,2566594879),new l(3210313671,3203337956),new l(3336571891,1034457026),new l(3584528711,2466948901),new l(113926993,3758326383),new l(338241895,168717936),new l(666307205,1188179964),new l(773529912,1546045734),new l(1294757372,1522805485),new l(1396182291,2643833823),new l(1695183700,2343527390),new l(1986661051,1014477480),new l(2177026350,1206759142),new l(2456956037,344077627),new l(2730485921,1290863460),new l(2820302411,3158454273),new l(3259730800,3505952657),new l(3345764771,106217008),new l(3516065817,3606008344),new l(3600352804,1432725776),new l(4094571909,1467031594),new l(275423344,851169720),new l(430227734,3100823752),new l(506948616,1363258195),new l(659060556,3750685593),new l(883997877,3785050280),new l(958139571,3318307427),new l(1322822218,3812723403),new l(1537002063,2003034995),new l(1747873779,3602036899),new l(1955562222,1575990012),new l(2024104815,1125592928),new l(2227730452,2716904306),new l(2361852424,442776044),new l(2428436474,593698344),new l(2756734187,3733110249),new l(3204031479,2999351573),new l(3329325298,3815920427),new l(3391569614,3928383900),new l(3515267271,566280711),new l(3940187606,3454069534),new l(4118630271,4000239992),new l(116418474,1914138554),new l(174292421,2731055270),new l(289380356,3203993006),new l(460393269,320620315),new l(685471733,587496836),new l(852142971,1086792851),new l(1017036298,365543100),new l(1126000580,2618297676),new l(1288033470,3409855158),new l(1501505948,4234509866),new l(1607167915,987167468),new l(1816402316,1246189591)],M=[];(function(){for(let i=0;i<80;i++)M[i]=new l(void 0,void 0)})();var Fe=class extends E{static{c(this,"SHA512")}constructor(){super({blockSize:1024/32})}reset(){super.reset(),this._hash=new ft([new l(1779033703,4089235720),new l(3144134277,2227873595),new l(1013904242,4271175723),new l(2773480762,1595750129),new l(1359893119,2917565137),new l(2600822924,725511199),new l(528734635,4215389547),new l(1541459225,327033209)])}_doFinalize(){let e=this._data,t=e.words,r=this._nDataBytes*8,s=e.sigBytes*8;return t[s>>>5]|=128<<24-s%32,t[(s+128>>>10<<5)+30]=Math.floor(r/4294967296),t[(s+128>>>10<<5)+31]=r,e.sigBytes=t.length*4,this._process(),this._hash.toX32()}_doProcessBlock(e,t){let r=this._hash.words[0].high,s=this._hash.words[0].low,o=this._hash.words[1].high,n=this._hash.words[1].low,h=this._hash.words[2].high,a=this._hash.words[2].low,p=this._hash.words[3].high,w=this._hash.words[3].low,u=this._hash.words[4].high,_=this._hash.words[4].low,x=this._hash.words[5].high,b=this._hash.words[5].low,C=this._hash.words[6].high,I=this._hash.words[6].low,k=this._hash.words[7].high,A=this._hash.words[7].low;for(let m=0;m<80;m++){let y,N;if(m<16)N=M[m].high=e[t+m*2]|0,y=M[m].low=e[t+m*2+1]|0;else{let We=M[m-15],X=We.high,se=We.low,Qt=(X>>>1|se<<31)^(X>>>8|se<<24)^X>>>7,Ke=(se>>>1|X<<31)^(se>>>8|X<<24)^(se>>>7|X<<25),Ge=M[m-2],Z=Ge.high,ie=Ge.low,St=(Z>>>19|ie<<13)^(Z<<3|ie>>>29)^Z>>>6,Ve=(ie>>>19|Z<<13)^(ie<<3|Z>>>29)^(ie>>>6|Z<<26);y=Ke+M[m-7].low,N=Qt+M[m-7].high+(y>>>0<Ke>>>0?1:0),y=y+Ve,N=N+St+(y>>>0<Ve>>>0?1:0),y=y+M[m-16].low,N=N+M[m-16].high+(y>>>0<M[m-16].low>>>0?1:0),M[m].high=N,M[m].low=y}let Be=u&x^~u&C,Le=_&b^~_&I,qt=r&o^r&h^o&h,Xt=s&n^s&a^n&a,Zt=(r>>>28|s<<4)^(r<<30|s>>>2)^(r<<25|s>>>7),Ue=(s>>>28|r<<4)^(s<<30|r>>>2)^(s<<25|r>>>7),Ht=(u>>>14|_<<18)^(u>>>18|_<<14)^(u<<23|_>>>9),Jt=(_>>>14|u<<18)^(_>>>18|u<<14)^(_<<23|u>>>9),O=A+Jt,j=k+Ht+(O>>>0<A>>>0?1:0);O=O+Le,j=j+Be+(O>>>0<Le>>>0?1:0),O=O+Ce[m].low,j=j+Ce[m].high+(O>>>0<Ce[m].low>>>0?1:0),O=O+y,j=j+N+(O>>>0<y>>>0?1:0);let $e=Ue+Xt,Yt=Zt+qt+($e>>>0<Ue>>>0?1:0);k=C,A=I,C=x,I=b,x=u,b=_,_=w+O|0,u=p+j+(_>>>0<w>>>0?1:0)|0,p=h,w=a,h=o,a=n,o=r,n=s,s=O+$e|0,r=j+Yt+(s>>>0<O>>>0?1:0)|0}this._hash.words[0].low=this._hash.words[0].low=this._hash.words[0].low+s,this._hash.words[0].high=this._hash.words[0].high+r+(this._hash.words[0].low>>>0<s>>>0?1:0),this._hash.words[1].low=this._hash.words[1].low=this._hash.words[1].low+n,this._hash.words[1].high=this._hash.words[1].high+o+(this._hash.words[1].low>>>0<n>>>0?1:0),this._hash.words[2].low=this._hash.words[2].low=this._hash.words[2].low+a,this._hash.words[2].high=this._hash.words[2].high+h+(this._hash.words[2].low>>>0<a>>>0?1:0),this._hash.words[3].low=this._hash.words[3].low=this._hash.words[3].low+w,this._hash.words[3].high=this._hash.words[3].high+p+(this._hash.words[3].low>>>0<w>>>0?1:0),this._hash.words[4].low=this._hash.words[4].low=this._hash.words[4].low+_,this._hash.words[4].high=this._hash.words[4].high+u+(this._hash.words[4].low>>>0<_>>>0?1:0),this._hash.words[5].low=this._hash.words[5].low=this._hash.words[5].low+b,this._hash.words[5].high=this._hash.words[5].high+x+(this._hash.words[5].low>>>0<b>>>0?1:0),this._hash.words[6].low=this._hash.words[6].low=this._hash.words[6].low+I,this._hash.words[6].high=this._hash.words[6].high+C+(this._hash.words[6].low>>>0<I>>>0?1:0),this._hash.words[7].low=this._hash.words[7].low=this._hash.words[7].low+A,this._hash.words[7].high=this._hash.words[7].high+k+(this._hash.words[7].low>>>0<A>>>0?1:0)}};var yt=class{static{c(this,"HMAC")}constructor(e,t){this._hasher=new e;let r=typeof t=="string"?R.parse(t):t,s=this._hasher.cfg.blockSize,o=s*4;r.sigBytes>o&&(r=this._hasher.finalize(r)),r.clamp();let n=this._oKey=r.clone(),h=this._iKey=r.clone(),a=n.words,p=h.words;for(let w=0;w<s;w++)a[w]^=1549556828,p[w]^=909522486;n.sigBytes=h.sigBytes=o,this.reset()}finalize(e){let t=this._hasher.finalize(e);return this._hasher.reset(),this._hasher.finalize(this._oKey.clone().concat(t))}reset(){this._hasher.reset(),this._hasher.update(this._iKey)}update(e){return this._hasher.update(e),this}};var Pe=class xt{static{c(this,"PBKDF2")}constructor(e){this.cfg=Object.assign({keySize:128/32,hasher:ne,iterations:25e4},e)}static execute(e,t,r){return new xt(r).compute(e,t)}compute(e,t){let r=this.cfg,s=new yt(r.hasher,e),o=new g,n=new g([1]),h=o.words,a=n.words,p=r.keySize,w=r.iterations;for(;h.length<p;){let u=s.update(t).finalize(n);s.reset();let _=u.words,x=_.length,b=u;for(let C=1;C<w;C++){b=s.finalize(b),s.reset();let I=b.words;for(let k=0;k<x;k++)_[k]^=I[k]}o.concat(u),a[0]++}return o.sigBytes=p*4,o}};var he=xe._createHelper(Ee);var S=E._createHelper(T);var ee=E._createHelper(V);var Re=E._createHelper(ne);var Ae=E._createHelper(Fe);var ce=class{static{c(this,"SmpAesCrypt")}_password;_salt;_initVector;get _iv(){return this._initVector?L.parse(this._initVector):void 0}_mode=U;_padding=Q;constructor(e,t,r){this._password=e,this._salt=t,this._initVector=r}decryptAES(e){return he.decrypt(e,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString(R)}encryptAES(e){return he.encrypt(e,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString()}_buildKey(){return Pe.execute(this._password,L.parse(this._salt),{keySize:256/32,iterations:1e3,hasher:V})}};var De=class{static{c(this,"SmpCrypto")}static base64Decode(e){return R.stringify(z.parse(e))}static base64Encode(e){return z.stringify(R.parse(e))}static md5(e){return S(e).toString()}static sha1(e){return ee(e).toString()}static sha256(e){return Re(e).toString()}static sha512(e){return Ae(e).toString()}};var ze=class{static{c(this,"SmpSecureCode")}_baseCode;get baseCode(){return this._baseCode}get secureCode(){return this._encode()}_crcLength=5;_seed="changeme";constructor(e){this._baseCode=e}static check(e,t){if(new this(e).secureCode!==t)throw D.create({messages:"WRONG_SECURE_CODE",errorCode:"WRONG_SECURE_CODE",status:tt.BadRequest})}_encode(){let e=new T;return e.update(R.parse(this._seed+this._baseCode)),e.finalize().toString(L).substring(0,this._crcLength).toUpperCase()}};import{Expose as fr,instanceToPlain as dr,plainToInstance as pr}from"class-transformer";import{DateTime as Te}from"ts-luxon";var v=(function(i){return i.ACTIVATE="ACTIVATE",i.BLOCK="BLOCK",i.CHECK="CHECK",i.DIGITAL_ACTIVATE="DIGITAL_ACTIVATE",i.FREEZE="FREEZE",i.PURCHASE="PURCHASE",i.RECHARGE="RECHARGE",i.ROLLBACK="ROLLBACK",i.TRANSACTION="TRANSACTION",i.TRANSACTION_DETAIL="TRANSACTION_DETAIL",i.UNFREEZE="UNFREEZE",i.XREFUND="XREFUND",i})({});var te=(function(i){return i.MD5="MD5",i.MD5_HMAC="MD5_HMAC",i.SHA1="SHA1",i.SHA1_HMAC="SHA1_HMAC",i})({});function lr(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(lr,"_ts_decorate");function Et(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(Et,"_ts_metadata");var je=class i{static{c(this,"SmpGiftcardTransaction")}gc;op;ot;static _AES_ENCODER=new ce("changeme","5f6eae61d2428b99","d92fbf214e16a79fd36f9a5185ae733f");static _LOGGER=console;static _OP_CODES={[v.CHECK]:"",[v.TRANSACTION]:"",[v.TRANSACTION_DETAIL]:"",[v.ACTIVATE]:"A",[v.BLOCK]:"B",[v.DIGITAL_ACTIVATE]:"D",[v.FREEZE]:"F",[v.PURCHASE]:"P",[v.RECHARGE]:"G",[v.ROLLBACK]:"R",[v.UNFREEZE]:"U",[v.XREFUND]:"X"};static _SEP="_";get dto(){return this._dto}get hash(){return this._hashStrategy(this.toString()).toString()}get iso(){return this.dto.toUTC().toISO()}get ts(){return this._dto.ts}_dto;_hashStrategies={[te.MD5]:e=>S(e),[te.MD5_HMAC]:e=>{let t=new T;return t.update(R.parse(e)),t.finalize()},[te.SHA1]:e=>ee(e),[te.SHA1_HMAC]:e=>{let t=new V;return t.update(R.parse(e)),t.finalize()}};_hashStrategy=this._hashStrategies[te.MD5];constructor(e="ACTIVATION",t,r,s){this.gc=e,this.op=t,this.ot=r,this._dto=typeof s=="number"&&s>=0?Te.fromMillis(+`${s}000`.slice(0,13)):Te.local()}static build({gc:e,op:t,ot:r,dto:s}){return new this(e,t,r,s?.ts)}static explode(e){let t=this.constructor,r=(e||"").split(t._SEP);if(r.length<4)throw new Error(`INVALID_TRANSACTION "${e}"`);return this.build({gc:r[1],op:t.prefixToOperation(r[2]),dto:Te.fromSeconds(+r[3])})}static isBase64(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)&&e.length%4===0}static parse(e){this._LOGGER.info(`${this.constructor.name}: trying to parse ${e}`);try{if(this.isBase64(e)){let t=this._AES_ENCODER.decryptAES(e),r=JSON.parse(t);return pr(i,r)}else return this.explode(e)}catch(t){throw this._LOGGER.error(`${this.constructor.name}: failed to parse ${e}`,t),new Error(`UNPARSEABLE "${e}"`)}}static prefixToOperation(e){return Object.entries(this._OP_CODES).find(([,r])=>r===e)[0]}serialize(){return dr(this,{excludePrefixes:["_"]})}toString(){let e=JSON.stringify(this.serialize());return this.constructor._AES_ENCODER.encryptAES(e)}};lr([fr(),Et("design:type",Number),Et("design:paramtypes",[])],je.prototype,"ts",null);var Rh=(function(i){return i.ListDetectiveValidator="ListDetectiveValidator",i.MXValidator="MXValidator",i.SyntaxValidator="SyntaxValidator",i})({});function Bh(i,e){e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{r!=="constructor"&&(r in i.prototype||Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)))});try{let r=new t;Object.getOwnPropertyNames(r).forEach(s=>{s in i.prototype||Object.defineProperty(i.prototype,s,Object.getOwnPropertyDescriptor(r,s))})}catch{}Object.getOwnPropertyNames(t).forEach(r=>{r!=="prototype"&&r!=="name"&&r!=="length"&&(r in i||Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r)))})})}c(Bh,"smpApplyMixin");var ur=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Rt(i){return i.match(ur)}c(Rt,"smpAsciiWords");var It="\\ud800-\\udfff",wr="\\u0300-\\u036f",gr="\\ufe20-\\ufe2f",_r="\\u20d0-\\u20ff",mr="\\u1ab0-\\u1aff",yr="\\u1dc0-\\u1dff",xr=wr+gr+_r+mr+yr,kt="\\u2700-\\u27bf",Nt="a-z\\xdf-\\xf6\\xf8-\\xff",Er="\\xac\\xb1\\xd7\\xf7",Rr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ar="\\u2000-\\u206f",Br=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Mt="A-Z\\xc0-\\xd6\\xd8-\\xde",br="\\ufe0e\\ufe0f",Ct=Er+Rr+Ar+Br,Ft="['\u2019]",At=`[${Ct}]`,Or=`[${xr}]`,Pt="\\d",vr=`[${kt}]`,Dt=`[${Nt}]`,zt=`[^${It}${Ct+Pt+kt+Nt+Mt}]`,Ir="\\ud83c[\\udffb-\\udfff]",kr=`(?:${Or}|${Ir})`,Nr=`[^${It}]`,Tt="(?:\\ud83c[\\udde6-\\uddff]){2}",jt="[\\ud800-\\udbff][\\udc00-\\udfff]",re=`[${Mt}]`,Mr="\\u200d",Bt=`(?:${Dt}|${zt})`,Cr=`(?:${re}|${zt})`,bt=`(?:${Ft}(?:d|ll|m|re|s|t|ve))?`,Ot=`(?:${Ft}(?:D|LL|M|RE|S|T|VE))?`,Lt=`${kr}?`,Ut=`[${br}]?`,Fr=`(?:${Mr}(?:${[Nr,Tt,jt].join("|")})${Ut+Lt})*`,Pr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Dr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",zr=Ut+Lt+Fr,vt=`(?:${[vr,Tt,jt].join("|")})${zr}`,ae=class{static{c(this,"SmpUnicodeWords")}static HAS_UNICODE_WORD=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/);static RE_UNICODE_WORDS=RegExp([`${re}?${Dt}+${bt}(?=${[At,re,"$"].join("|")})`,`${Cr}+${Ot}(?=${[At,re+Bt,"$"].join("|")})`,`${re}?${Bt}+${bt}`,`${re}+${Ot}`,Dr,Pr,`${Pt}+`,vt].join("|"),"g");static RS_EMOJI=vt;static unicodeWords(e){return e.match(this.RE_UNICODE_WORDS)}};var $t=class i{static{c(this,"SmpCommonUtils")}static arrayRemove(e,t){let r=[],s=e.filter((o,n)=>t(o,n)&&r.push(n));return r.reverse().forEach(o=>e.splice(o,1)),s}static assertIsArray(e,t){if(!Array.isArray(e))throw new Error(t||`${this.constructor.name} => val was not an array`)}static assertIsBoolean(e,t){if(!this.isBoolean(e))throw new Error(t||`${this.constructor.name} => val was not boolean`)}static assertIsFunction(e,t){if(!this.isFunction(e))throw new Error(t||`${this.constructor.name} => entity was not a function`)}static assertIsInstance(e,t,r){if(!(e instanceof t))throw new Error(r||`${this.constructor.name} => val was not instance of class`)}static assertIsNotEmpty(e,t){if(this.isEmpty(e))throw new Error(t||`${this.constructor.name} => entity was empty`)}static assertIsNumber(e,t){if(typeof e!="number")throw new Error(t||`${this.constructor.name} => val was not numeric`)}static assertIsNumeric(e,t){if(!this.isNumeric(e))throw new Error(t||`${this.constructor.name} => val was not numeric`)}static assertIsObject(e,t){if(!this.isObject(e))throw new Error(t||`${this.constructor.name} => val was not an object`)}static assertIsString(e,t){if(!this.isString(e))throw new Error(t||`${this.constructor.name} => val was not a string`)}static assertIsTruthy(e,t){if(!e)throw new Error(t||`${this.constructor.name} => condition wasn't truthy`)}static buildPath(...e){let t=e.filter(r=>!!r).join("/").replace(/(?<!:)\/\/+/g,"/");return t.startsWith("http")&&!t.endsWith("/")?`${t}/`:t}static downloadBlob(e,t){let r=window.URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.setAttribute("download",t),document.body.appendChild(s),s.click()}static generateRandomHexString(e=12){let t="0123456789abcdef",r="";for(let s=0;s<e;s++){let o=Math.floor(Math.random()*t.length);r+=t[o]}return r}static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}static getDecimalPrecision(e){if(this.assertIsNumeric(e),!isFinite(+e))return 0;let t=1,r=0;for(;Math.round(+e*t)/t!==e;)t*=10,r++;return r}static getType(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}static isBoolean(e){return typeof e=="boolean"}static isColor(e){if(!e||!this.isString(e))return!1;let t=new Option().style;return t.color=e,t.color!==""}static isEmpty(e){return!e&&e!==0}static isEqual(e,t){function r(){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!i.isEqual(e[a],t[a]))return!1;return!0}c(r,"areArraysEqual");function s(){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&!i.isEqual(e[a],t[a]))return!1;return!0}c(s,"areObjectsEqual");function o(){return e.toString()===t.toString()}c(o,"areFunctionsEqual");function n(){return e===t}c(n,"arePrimativesEqual");let h=this.getType(e);return h!==this.getType(t)?!1:h==="array"?r():h==="object"?s():h==="function"?o():n()}static isFormField(e){return/^(?:input|select|textarea|button)$/i.test(e.nodeName)}static isFunction(e){return typeof e==typeof isNaN}static isNotEmpty(e){return!this.isEmpty(e)}static isNumber(e){return typeof e=="number"&&this.isNumeric(e)}static isNumeric(e){return!isNaN(e)}static isObject(e){return!!e&&e===Object(e)&&e.constructor===Object}static isPrimitive(e){let t=this.getType(e);return t!=="function"&&(t!=="object"||!e)}static isString(e){return typeof e=="string"}static isWindows(){return navigator.userAgent.toLowerCase().includes("win")}static mapObject(e,t){if(this.assertIsFunction(t,`CommonUtils => expected type of iteratee to be Function, got ${typeof t}`),this.isObject(e))return Object.entries(e).reduce((r,[s,o])=>(r.push(t(o,s)),r),[]);if(Array.isArray(e))return e.map(t);throw new Error(`CommonUtils => invalid object provided. Expected Object or Array, got ${typeof t}`)}static mapObjectKeys(e,t){return Object.entries(e).reduce((r,[s,o])=>(r[s]=t.call(null,s,o),r),{})}static mapObjectValues(e,t){return this.isObject(e)?Object.entries(e).reduce((r,[s,o])=>(r[s]=t.call(null,o,s),r),{}):{}}static noop(){}static objectHasValue(e,t){return!!~Object.values(e).filter(r=>this.isEqual(r,t))}static omit(e,t){return Object.keys(e).filter(s=>!t.includes(s)).reduce((s,o)=>(s[o]=e[o],s),{})}static parseBoolean(e){return e?/^true$/i.test(e):!1}static parseJsonSafely(e){try{return JSON.parse(e)}catch(t){console.warn(`${this.constructor.name} => couldn't parse json string`,{str:e,error:t});return}}static pick(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}static runSafely(e,t=null,r=[]){if(this.isFunction(e))return e.apply(t,r)}static sleep(e){return new Promise(t=>setTimeout(t,e))}static sprintf(e,...t){return this.isString(e)&&t.length?this.sprintf(e.replace("%s",String(t.shift())),...t):e}static stripComments(e){return typeof e=="string"?e.replace(/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g,""):e}static submitFakeForm({action:e,method:t=st.POST,data:r,target:s}){let o=Object.entries(r||{}).map(([h,a])=>`<input name="${h}" type="hidden" value="${a}" />`),n=document.createElement("form");n.method=t,n.action=e,n.innerHTML=`${o}`,n.target=s||"_self",document.body.append(n),n.submit()}static toCamelCase(e){return this.words(e.replace(/['\u2019]/g,"")).reduce((t,r,s)=>(r=r.toLowerCase(),t+(s?r.charAt(0).toUpperCase()+r.slice(1):r)),"")}static toKebabCase(e){return this.words(e.replace(/['\u2019]/g,"")).join("-").toLowerCase()}static toPascalCase(e){return this.toCamelCase(e).replace(/^(.)/,t=>t.toUpperCase())}static toSnakeCase(e){return this.words(e.replace(/['\u2019]/g,"")).join("_").toLowerCase()}static toUpperSnakeCase(e){return this.toSnakeCase(e).toUpperCase()}static words(e,t){return t===void 0?(ae.HAS_UNICODE_WORD(e)?ae.unicodeWords(e):Rt(e))||[]:e.match(t)||[]}};var Wt=class extends Error{static{c(this,"SmpFilterException")}message;data;constructor(e="Filter Exception",t){super(),this.message=e,this.data=t}};import{DateTime as Kt}from"ts-luxon";var Gt=class i{static{c(this,"SmpSid")}value;expiry;get active(){return this.value.endsWith(this._controlSuffix)}get expired(){return Kt.now().ts>this.expiry}get valid(){return!this.expired}_controlSuffix="$1";constructor(e=`sid-xxxx-${+Kt.now().ts}`,t=0){this.value=e,this.expiry=t}static parse(e){return new i(e.value,e.expiry)}toPlain(){return{value:this.value,expiry:this.expiry}}};import{smpNoop as Kh}from"@tonysamperi/logger";var Vt=class{static{c(this,"SmpRegularExpressions")}static get COUNTRY(){return this._country}static get DOMAIN(){return/^(?!www)(\w)([\w.-])*\.[a-z]{2,6}$/}static get EMAIL(){return/^[^\\|!"£$%&/()='?^€*[\]°#§<>,;:\s]+@[a-z0-9.-]+\.[a-z]{2,6}$/}static get LANGUAGE(){return this._language}static get LATIN_CHARS(){return/^[\u0000-\u024F\u1E00-\u1EFF\u2C60-\u2C7F\uA720-\uA7FF]+/}static get LOCALE(){return new RegExp(`${this._country.source}-${this._language.source}`)}static get NO_EMOJI_NO_PUNCTUATION(){return/[^\p{Emoji_Presentation}|\p{P}]/gu}static get PHONE_NUMBER(){return/^(\+\d{1,4}\s)(\d{4,15})$/}static get PHONE_NUMBER_BY_PREFIX(){return{"+971":{dontStartWithZero:/^(\+\d{3}\s)([1-9])/,typeExactlyNineDigits:/^(\+\d{3}\s)([1-9]\d{8}$)/}}}static get TAXCODE_BY_COUNTRY(){return{ES:{DNI:/^\d{8}[A-Z]$/,NIE:/^[A-Z]\d{7}[A-Z]$/,CIF:/^[A-Z]\d{8}$/}}}static _country=/[a-zA-Z]{2}/;static _language=/[a-z]{2}/};var qh="2.0.0-beta.1";export{Bs as SMP_HEALTHZ,qe as SmpAbstractCacheStrategy,H as SmpAbstractTtlCacheStrategy,ce as SmpAesCrypt,rt as SmpApiCommonUtils,it as SmpBaseJwtToken,ot as SmpBaseJwtTokenPlain,de as SmpBrowserCache,$t as SmpCommonUtils,De as SmpCrypto,D as SmpErrorResponse,Wt as SmpFilterException,Lr as SmpFirebaseErrors,oe as SmpGenericResponse,je as SmpGiftcardTransaction,te as SmpGiftcardTransactionHashStrategies,v as SmpGiftcardTransactionOps,et as SmpHttpService,pe as SmpHttpSessionStorageCache,tt as SmpHttpStatusCodes,ue as SmpInMemoryCache,Rh as SmpMarketingCloudValidators,Vt as SmpRegularExpressions,F as SmpResponseMessage,$ as SmpResponseMessageTypes,st as SmpRestVerbs,ze as SmpSecureCode,Gt as SmpSid,Tr as SmpSocialSignInKeys,jr as SmpSocialSignInUxModes,qh as VERSION,Bh as smpApplyMixin,Xe as smpIsSmpCachedValue,Kh as smpNoop};
|
|
1
|
+
import{a as Tr,b as jr,c as Lr}from"./chunk-DIVAYUSN.js";import{a as qe,b as Xe}from"./chunk-VBEMFJKM.js";import{a as $}from"./chunk-F3OJMKBL.js";import{a as c}from"./chunk-EI7MMDWY.js";import{Expose as Qe,plainToInstance as or}from"class-transformer";import{Expose as tr,instanceToPlain as rr,plainToInstance as sr,Transform as ir}from"class-transformer";import{Expose as He}from"class-transformer";function Ze(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(Ze,"_ts_decorate");function le(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(le,"_ts_metadata");var F=class i{static{c(this,"SmpResponseMessage")}_message;_type;get message(){return this._message}get type(){return this._type}constructor(e,t=$.ERROR){this._message=e,this._type=t}static sanitizeMessages(e){return typeof e=="string"?e.length?[new i(e)]:[]:[e].flat().map(t=>typeof t=="string"?new i(t):t)}};Ze([He(),le("design:type",String),le("design:paramtypes",[])],F.prototype,"message",null);Ze([He(),le("design:type",typeof $>"u"?Object:$),le("design:paramtypes",[])],F.prototype,"type",null);function er(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(er,"_ts_decorate");function Je(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(Je,"_ts_metadata");var oe=class i{static{c(this,"SmpGenericResponse")}_messages;data;set messages(e){this._messages=F.sanitizeMessages(e)}get messages(){return this._messages}constructor(e=[],t){this._messages=e,this.data=t}static buildInfo(e,t){return new i([e].flat().map(r=>new F(r,$.INFO)),t)}static buildSuccess(e,t){return new i([e].flat().map(r=>new F(r,$.SUCCESS)),t)}static fromPlain(e){return sr(i,e)}isError(){return!this.isSuccess()}isSuccess(){return"_errorCode"in this&&this._errorCode!==null&&this._errorCode!==void 0}serialize(){return rr(this,{excludePrefixes:["_"]})}};er([tr(),ir(({value:i})=>i?.length?i:void 0),Je("design:type",Object),Je("design:paramtypes",[])],oe.prototype,"messages",null);function Ye(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(Ye,"_ts_decorate");function fe(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(fe,"_ts_metadata");var D=class i extends oe{static{c(this,"SmpErrorResponse")}_errorCode;_status;static get DEFAULT_MESSAGES(){return[new F("GENERIC_ERROR")]}get errorCode(){return this._errorCode}get status(){return this._status}get timestamp(){return this._timestamp}_timestamp=Date.now();constructor(e=i.DEFAULT_MESSAGES,t="GENERIC_ERROR",r=500,s){super(e,s),this._errorCode=t,this._status=r}static create({messages:e=i.DEFAULT_MESSAGES,...t}={}){return new i(F.sanitizeMessages(e),t.errorCode,t.status,t.data)}static fromPlain(e){let t=or(nr,e,{excludePrefixes:["_"]}),r=new i;return Object.getOwnPropertyNames(t).forEach(s=>{s in r&&(r[s]=t[s])}),r}};Ye([Qe(),fe("design:type",Object),fe("design:paramtypes",[])],D.prototype,"errorCode",null);Ye([Qe(),fe("design:type",Number),fe("design:paramtypes",[])],D.prototype,"timestamp",null);var nr=class extends D{static{c(this,"SmpErrorResponseMutable")}set errorCode(e){this._errorCode=e}set status(e){this._status=e}set timestamp(e){this._timestamp=e}};import{DateTime as Se}from"ts-luxon";var H=class extends qe{static{c(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(e){let t=this._readRaw(e);if(this._isSmpCachedValue(t)){if(t.expiry>=Se.now().ts)return t.value;this._removeRaw(e);return}return t}remove(e){this._removeRaw(e)}write(e,t,r){if(isNaN(+r)||+r<=0){this._writeRaw(e,t,r);return}let s=Se.now().ts+r*1e3,o={value:t,expiry:s};this._writeRaw(e,o,r)}_isSmpCachedValue(e){return Xe(e)}};var de=class extends H{static{c(this,"SmpBrowserCache")}_storage;_prefix;constructor(e,t){super(),this._storage=e,this._prefix=t}_flushRaw(){let e=[],t=-1;for(;++t<this._storage.length;){let r=this._storage.key(t);r&&r.startsWith(this._prefix)&&e.push(r)}for(t=-1;++t<e.length;)this._storage.removeItem(e[t])}_readRaw(e){let t=this._storage.getItem(this._prefix+e);try{return t?JSON.parse(t):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+e}`);return}}_removeRaw(e){this._storage.removeItem(this._prefix+e)}_writeRaw(e,t){try{this._storage.setItem(this._prefix+e,JSON.stringify(t))}catch(r){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+e}`,r)}}};var pe=class extends de{static{c(this,"SmpHttpSessionStorageCache")}constructor(){super(sessionStorage,"smp_rest_cache_")}};var ue=class extends H{static{c(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(e){return this._staticSelf._storage.get(e)}_removeRaw(e){this._staticSelf._storage.delete(e)}_writeRaw(e,t){this._staticSelf._storage.set(e,t)}};var et=class{static{c(this,"SmpHttpService")}static _cachePrefix="smp_rest_cache_";static _cacheStrategy=typeof sessionStorage<"u"?new pe:new ue;static _config={cachePrefix:this._cachePrefix,shared:new Map};static _errorClass=D;static _mergeParamsFallbackBaseUrl="https://ts-mapi-core.com";static $http(e){return this._generateAjax(e)}static async _generateAjax(e){if(e.cacheKey){let t=this._cacheRead(e.cacheKey);return t?Promise.resolve(t):this._generateAjaxBase(e).then(r=>(e.cacheKey&&this._cacheWrite(e.cacheKey,r),r))}return this._generateAjaxBase(e)}static async _generateAjaxBase(e){let t=await this._preprocessRequest(e),r={method:t.method,headers:new Headers({"content-type":"application/json",...t.headers}),body:t.body?JSON.stringify(t.body):null};return t.useCredentials&&(r.credentials="include"),t.url=this.mergeQueryParams(t.url,t.queryParams),fetch(t.url,r).then(s=>this._preprocessResponse(e,s)).then(s=>{if(s.ok){if(s.status===204||s.headers.get("content-length")==="0")return null;switch(t.responseType){case"blob":return s.blob();case"arraybuffer":return s.arrayBuffer();case"text":return s.text();case"json":default:return s.json()}}return s.json().then(o=>{let n=o;try{n=this._errorClass.fromPlain(o)}catch(h){console.debug("http: failed to parse error response into ErrorResponse",h)}return Promise.reject({status:s.status,message:s.statusText,body:n})})})}static cacheFlush(){this._cacheStrategy.flush()}static mergeQueryParams(e,t){let r=e.startsWith("http");if(t){let s=new URL(e,globalThis?.location?.origin||this._mergeParamsFallbackBaseUrl),o=Object.fromEntries(s.searchParams.entries());s.search=new URLSearchParams({...o,...Object.fromEntries(Object.entries(t).map(([n,h])=>[n,`${h}`]))}).toString(),e=r?s.href:s.pathname+s.search}return e}static _cacheKey(e){return`${this._config.cachePrefix}${e}`}static _cachePop(e){let t=this._cacheRead(e);return this._cacheRemove(e),t}static _cacheRead(e){return this._cacheStrategy.read(this._cacheKey(e))}static _cacheRemove(e){this._cacheStrategy.remove(this._cacheKey(e))}static _cacheWrite(e,t){this._cacheStrategy.write(this._cacheKey(e),t)}static async _preprocessRequest(e){return e}static async _preprocessResponse(e,t){return t}};var tt=(function(i){return i[i.Continue=100]="Continue",i[i.SwitchingProtocols=101]="SwitchingProtocols",i[i.Processing=102]="Processing",i[i.EarlyHints=103]="EarlyHints",i[i.Ok=200]="Ok",i[i.Created=201]="Created",i[i.Accepted=202]="Accepted",i[i.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",i[i.NoContent=204]="NoContent",i[i.ResetContent=205]="ResetContent",i[i.PartialContent=206]="PartialContent",i[i.MultiStatus=207]="MultiStatus",i[i.AlreadyReported=208]="AlreadyReported",i[i.ImUsed=226]="ImUsed",i[i.MultipleChoices=300]="MultipleChoices",i[i.MovedPermanently=301]="MovedPermanently",i[i.Found=302]="Found",i[i.SeeOther=303]="SeeOther",i[i.NotModified=304]="NotModified",i[i.UseProxy=305]="UseProxy",i[i.Unused=306]="Unused",i[i.TemporaryRedirect=307]="TemporaryRedirect",i[i.PermanentRedirect=308]="PermanentRedirect",i[i.BadRequest=400]="BadRequest",i[i.Unauthorized=401]="Unauthorized",i[i.PaymentRequired=402]="PaymentRequired",i[i.Forbidden=403]="Forbidden",i[i.NotFound=404]="NotFound",i[i.MethodNotAllowed=405]="MethodNotAllowed",i[i.NotAcceptable=406]="NotAcceptable",i[i.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",i[i.RequestTimeout=408]="RequestTimeout",i[i.Conflict=409]="Conflict",i[i.Gone=410]="Gone",i[i.LengthRequired=411]="LengthRequired",i[i.PreconditionFailed=412]="PreconditionFailed",i[i.PayloadTooLarge=413]="PayloadTooLarge",i[i.UriTooLong=414]="UriTooLong",i[i.UnsupportedMediaType=415]="UnsupportedMediaType",i[i.RangeNotSatisfiable=416]="RangeNotSatisfiable",i[i.ExpectationFailed=417]="ExpectationFailed",i[i.ImATeapot=418]="ImATeapot",i[i.MisdirectedRequest=421]="MisdirectedRequest",i[i.UnprocessableEntity=422]="UnprocessableEntity",i[i.Locked=423]="Locked",i[i.FailedDependency=424]="FailedDependency",i[i.TooEarly=425]="TooEarly",i[i.UpgradeRequired=426]="UpgradeRequired",i[i.PreconditionRequired=428]="PreconditionRequired",i[i.TooManyRequests=429]="TooManyRequests",i[i.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",i[i.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",i[i.InternalServerError=500]="InternalServerError",i[i.NotImplemented=501]="NotImplemented",i[i.BadGateway=502]="BadGateway",i[i.ServiceUnavailable=503]="ServiceUnavailable",i[i.GatewayTimeout=504]="GatewayTimeout",i[i.HttpVersionNotSupported=505]="HttpVersionNotSupported",i[i.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",i[i.InsufficientStorage=507]="InsufficientStorage",i[i.LoopDetected=508]="LoopDetected",i[i.NotExtended=510]="NotExtended",i[i.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",i})({});import{SmpLoggerMethods as hr}from"@tonysamperi/logger";var rt=class{static{c(this,"SmpApiCommonUtils")}static _javascriptVariablePattern="[a-zA-Z_$][a-zA-Z_$0-9]*";static _logger=new hr;static _pathParamRegex=new RegExp(`\\{(${this._javascriptVariablePattern})\\}`,"g");static credentialsToBasicAuth(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}static fromBearer(e=""){return e.split(" ")[1]}static getCountryFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[0]?.toUpperCase()}static getLanguageFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[1]}static getLocaleFromReferer(e){return e?.match(/\/([A-Z]{2}-[A-Z]{2})\//i)?.[1]}static interpolateParams(e,t){try{return e.replace(this._pathParamRegex,(r,s)=>{let o=t[s];return o!==void 0?encodeURIComponent(o):r})}catch(r){this._logger.warn(`${this.constructor.name}: couldn't interpolate params`,r)}return e}};var Bs={status:"OK"};var st=(function(i){return i.GET="GET",i.POST="POST",i.PUT="PUT",i.DELETE="DELETE",i.PATCH="PATCH",i})({});var it=class{static{c(this,"SmpBaseJwtToken")}_access_token;_exp;_iss;get access_token(){return this._access_token}get exp(){return this._exp}get iss(){return this._iss}constructor(e,t,r){this._access_token=e,this._exp=t,this._iss=r}serialize(){return{access_token:this._access_token,exp:this._exp,iss:this._iss}}};var ot=class{static{c(this,"SmpBaseJwtTokenPlain")}access_token;exp;iss};var L=class{static{c(this,"Hex")}static parse(e){let t=e.length,r=[];for(let s=0;s<t;s+=2)r[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new g(r,t/2)}static stringify(e){let t=[];for(let r=0;r<e.sigBytes;r++){let s=e.words[r>>>2]>>>24-r%4*8&255;t.push((s>>>4).toString(16)),t.push((s&15).toString(16))}return t.join("")}};var g=class be{static{c(this,"WordArray")}constructor(e,t){this.words=e||[],t!==void 0?this.sigBytes=t:this.sigBytes=this.words.length*4}static random(e){let t=[],r=c(function(s){let o=987654321,n=4294967295;return function(){o=36969*(o&65535)+(o>>16)&n,s=18e3*(s&65535)+(s>>16)&n;let h=(o<<16)+s&n;return h/=4294967296,h+=.5,h*(Math.random()>.5?1:-1)}},"r");for(let s=0,o;s<e;s+=4){let n=r((o||Math.random())*4294967296);o=n()*987654071,t.push(n()*4294967296|0)}return new be(t,e)}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new be(this.words.slice(0),this.sigBytes)}concat(e){if(this.clamp(),this.sigBytes%4)for(let t=0;t<e.sigBytes;t++){let r=e.words[t>>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=r<<24-(this.sigBytes+t)%4*8}else for(let t=0;t<e.sigBytes;t+=4)this.words[this.sigBytes+t>>>2]=e.words[t>>>2];return this.sigBytes+=e.sigBytes,this}toString(e){return(e||L).stringify(this)}};var we=class{static{c(this,"Latin1")}static parse(e){let t=e.length,r=[];for(let s=0;s<t;s++)r[s>>>2]|=(e.charCodeAt(s)&255)<<24-s%4*8;return new g(r,t)}static stringify(e){let t=[];for(let r=0;r<e.sigBytes;r++){let s=e.words[r>>>2]>>>24-r%4*8&255;t.push(String.fromCharCode(s))}return t.join("")}};var R=class{static{c(this,"Utf8")}static parse(e){return we.parse(unescape(encodeURIComponent(e)))}static stringify(e){try{return decodeURIComponent(escape(we.stringify(e)))}catch(t){throw console.error("Malformed UTF-8 data",t),new Error("Malformed UTF-8 data")}}};var ge=class{static{c(this,"BufferedBlockAlgorithm")}constructor(e){this._minBufferSize=0,this.cfg=Object.assign({blockSize:1},e),this._data=new g,this._nDataBytes=0}clone(){let e=this.constructor();for(let t in this)Object.prototype.hasOwnProperty.call(this,t)&&(e[t]=this[t]);return e._data=this._data.clone(),e}reset(){this._data=new g,this._nDataBytes=0}_append(e){typeof e=="string"&&(e=R.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_process(e){if(!this.cfg.blockSize)throw new Error("missing blockSize in config");let t=this.cfg.blockSize*4,r=this._data.sigBytes/t;e?r=Math.ceil(r):r=Math.max((r|0)-this._minBufferSize,0);let s=r*this.cfg.blockSize,o=Math.min(s*4,this._data.sigBytes),n;if(s){for(let h=0;h<s;h+=this.cfg.blockSize)this._doProcessBlock(this._data.words,h);n=this._data.words.splice(0,s),this._data.sigBytes-=o}return new g(n,o)}};var J=class{static{c(this,"CipherParams")}constructor(e){this.ciphertext=e.ciphertext,this.key=e.key,this.iv=e.iv,this.salt=e.salt,this.algorithm=e.algorithm,this.mode=e.mode,this.padding=e.padding,this.blockSize=e.blockSize,this.formatter=e.formatter}extend(e){return e.ciphertext!==void 0&&(this.ciphertext=e.ciphertext),e.key!==void 0&&(this.key=e.key),e.iv!==void 0&&(this.iv=e.iv),e.salt!==void 0&&(this.salt=e.salt),e.algorithm!==void 0&&(this.algorithm=e.algorithm),e.mode!==void 0&&(this.mode=e.mode),e.padding!==void 0&&(this.padding=e.padding),e.blockSize!==void 0&&(this.blockSize=e.blockSize),e.formatter!==void 0&&(this.formatter=e.formatter),this}toString(e){if(e)return e.stringify(this);if(this.formatter)return this.formatter.stringify(this);throw new Error("cipher needs a formatter to be able to convert the result into a string")}};var z=class{static{c(this,"Base64")}static parse(e){let t=e.length;if(this._reverseMap===void 0){this._reverseMap=[];for(let s=0;s<this._map.length;s++)this._reverseMap[this._map.charCodeAt(s)]=s}let r=this._map.charAt(64);if(r){let s=e.indexOf(r);s!==-1&&(t=s)}return this.parseLoop(e,t,this._reverseMap)}static parseLoop(e,t,r){let s=[],o=0;for(let n=0;n<t;n++)if(n%4){let h=r[e.charCodeAt(n-1)]<<n%4*2,a=r[e.charCodeAt(n)]>>>6-n%4*2;s[o>>>2]|=(h|a)<<24-o%4*8,o++}return new g(s,o)}static stringify(e){e.clamp();let t=[];for(let s=0;s<e.sigBytes;s+=3){let o=e.words[s>>>2]>>>24-s%4*8&255,n=e.words[s+1>>>2]>>>24-(s+1)%4*8&255,h=e.words[s+2>>>2]>>>24-(s+2)%4*8&255,a=o<<16|n<<8|h;for(let p=0;p<4&&s+p*.75<e.sigBytes;p++)t.push(this._map.charAt(a>>>6*(3-p)&63))}let r=this._map.charAt(64);if(r)for(;t.length%4;)t.push(r);return t.join("")}};z._map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";z._reverseMap=void 0;var _e=class{static{c(this,"OpenSSL")}static parse(e){let t=z.parse(e),r;return t.words[0]===1398893684&&t.words[1]===1701076831&&(r=new g(t.words.slice(2,4)),t.words.splice(0,4),t.sigBytes-=16),new J({ciphertext:t,salt:r})}static stringify(e){if(!e.ciphertext)throw new Error("missing ciphertext in params");let t=e.ciphertext,r=e.salt,s;if(r){if(typeof r=="string")throw new Error("salt is expected to be a WordArray");s=new g([1398893684,1701076831]).concat(r).concat(t)}else s=t;return s.toString(z)}};var W=class{static{c(this,"SerializableCipher")}static decrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(!o.format)throw new Error("could not determine format");if(t=this._parse(t,o.format),!t.ciphertext)throw new Error("could not determine ciphertext");return e.createDecryptor(r,o).finalize(t.ciphertext)}static encrypt(e,t,r,s){let o=Object.assign({},this.cfg,s),n=e.createEncryptor(r,o),h=n.finalize(t);return new J({ciphertext:h,key:r,iv:n.cfg.iv,algorithm:e,mode:n.cfg.mode,padding:n.cfg.padding,blockSize:n.cfg.blockSize,formatter:o.format})}static _parse(e,t){return typeof e=="string"?t.parse(e):e}};W.cfg={blockSize:4,iv:new g([]),format:_e};var E=class extends ge{static{c(this,"Hasher")}constructor(e){super(Object.assign({blockSize:512/32},e)),this.reset()}static _createHelper(e){function t(r,s){return new e(s).finalize(r)}return c(t,"helper"),t}finalize(e){return e&&this._append(e),this._doFinalize()}update(e){return this._append(e),this._process(),this}};var f=[];for(let i=0;i<64;i++)f[i]=Math.abs(Math.sin(i+1))*4294967296|0;var T=class d extends E{static{c(this,"MD5")}get hash(){return this._hash}static FF(e,t,r,s,o,n,h){let a=e+(t&r|~t&s)+o+h;return(a<<n|a>>>32-n)+t}static GG(e,t,r,s,o,n,h){let a=e+(t&s|r&~s)+o+h;return(a<<n|a>>>32-n)+t}static HH(e,t,r,s,o,n,h){let a=e+(t^r^s)+o+h;return(a<<n|a>>>32-n)+t}static II(e,t,r,s,o,n,h){let a=e+(r^(t|~s))+o+h;return(a<<n|a>>>32-n)+t}reset(){super.reset(),this._hash=new g([1732584193,4023233417,2562383102,271733878])}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;this._data.words[t>>>5]|=128<<24-t%32;let r=Math.floor(e/4294967296),s=e;this._data.words[(t+64>>>9<<4)+15]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360,this._data.words[(t+64>>>9<<4)+14]=(s<<8|s>>>24)&16711935|(s<<24|s>>>8)&4278255360,this._data.sigBytes=(this._data.words.length+1)*4,this._process();for(let o=0;o<4;o++)this._hash.words[o]=(this._hash.words[o]<<8|this._hash.words[o]>>>24)&16711935|(this._hash.words[o]<<24|this._hash.words[o]>>>8)&4278255360;return this._hash}_doProcessBlock(e,t){for(let a=0;a<16;a++){let p=t+a,w=e[p];e[p]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}let r=Array.from({length:16});for(let a=0;a<16;a++)r[a]=e[t+a];let s=this._hash.words[0],o=this._hash.words[1],n=this._hash.words[2],h=this._hash.words[3];s=d.FF(s,o,n,h,r[0],7,f[0]),h=d.FF(h,s,o,n,r[1],12,f[1]),n=d.FF(n,h,s,o,r[2],17,f[2]),o=d.FF(o,n,h,s,r[3],22,f[3]),s=d.FF(s,o,n,h,r[4],7,f[4]),h=d.FF(h,s,o,n,r[5],12,f[5]),n=d.FF(n,h,s,o,r[6],17,f[6]),o=d.FF(o,n,h,s,r[7],22,f[7]),s=d.FF(s,o,n,h,r[8],7,f[8]),h=d.FF(h,s,o,n,r[9],12,f[9]),n=d.FF(n,h,s,o,r[10],17,f[10]),o=d.FF(o,n,h,s,r[11],22,f[11]),s=d.FF(s,o,n,h,r[12],7,f[12]),h=d.FF(h,s,o,n,r[13],12,f[13]),n=d.FF(n,h,s,o,r[14],17,f[14]),o=d.FF(o,n,h,s,r[15],22,f[15]),s=d.GG(s,o,n,h,r[1],5,f[16]),h=d.GG(h,s,o,n,r[6],9,f[17]),n=d.GG(n,h,s,o,r[11],14,f[18]),o=d.GG(o,n,h,s,r[0],20,f[19]),s=d.GG(s,o,n,h,r[5],5,f[20]),h=d.GG(h,s,o,n,r[10],9,f[21]),n=d.GG(n,h,s,o,r[15],14,f[22]),o=d.GG(o,n,h,s,r[4],20,f[23]),s=d.GG(s,o,n,h,r[9],5,f[24]),h=d.GG(h,s,o,n,r[14],9,f[25]),n=d.GG(n,h,s,o,r[3],14,f[26]),o=d.GG(o,n,h,s,r[8],20,f[27]),s=d.GG(s,o,n,h,r[13],5,f[28]),h=d.GG(h,s,o,n,r[2],9,f[29]),n=d.GG(n,h,s,o,r[7],14,f[30]),o=d.GG(o,n,h,s,r[12],20,f[31]),s=d.HH(s,o,n,h,r[5],4,f[32]),h=d.HH(h,s,o,n,r[8],11,f[33]),n=d.HH(n,h,s,o,r[11],16,f[34]),o=d.HH(o,n,h,s,r[14],23,f[35]),s=d.HH(s,o,n,h,r[1],4,f[36]),h=d.HH(h,s,o,n,r[4],11,f[37]),n=d.HH(n,h,s,o,r[7],16,f[38]),o=d.HH(o,n,h,s,r[10],23,f[39]),s=d.HH(s,o,n,h,r[13],4,f[40]),h=d.HH(h,s,o,n,r[0],11,f[41]),n=d.HH(n,h,s,o,r[3],16,f[42]),o=d.HH(o,n,h,s,r[6],23,f[43]),s=d.HH(s,o,n,h,r[9],4,f[44]),h=d.HH(h,s,o,n,r[12],11,f[45]),n=d.HH(n,h,s,o,r[15],16,f[46]),o=d.HH(o,n,h,s,r[2],23,f[47]),s=d.II(s,o,n,h,r[0],6,f[48]),h=d.II(h,s,o,n,r[7],10,f[49]),n=d.II(n,h,s,o,r[14],15,f[50]),o=d.II(o,n,h,s,r[5],21,f[51]),s=d.II(s,o,n,h,r[12],6,f[52]),h=d.II(h,s,o,n,r[3],10,f[53]),n=d.II(n,h,s,o,r[10],15,f[54]),o=d.II(o,n,h,s,r[1],21,f[55]),s=d.II(s,o,n,h,r[8],6,f[56]),h=d.II(h,s,o,n,r[15],10,f[57]),n=d.II(n,h,s,o,r[6],15,f[58]),o=d.II(o,n,h,s,r[13],21,f[59]),s=d.II(s,o,n,h,r[4],6,f[60]),h=d.II(h,s,o,n,r[11],10,f[61]),n=d.II(n,h,s,o,r[2],15,f[62]),o=d.II(o,n,h,s,r[9],21,f[63]),this._hash.words[0]=this._hash.words[0]+s|0,this._hash.words[1]=this._hash.words[1]+o|0,this._hash.words[2]=this._hash.words[2]+n|0,this._hash.words[3]=this._hash.words[3]+h|0}};var Oe=class nt{static{c(this,"EVPKDF")}constructor(e){this.cfg=Object.assign({keySize:128/32,hasher:T,iterations:1},e)}static execute(e,t,r){return new nt(r).compute(e,t)}compute(e,t){let r=new this.cfg.hasher,s=new g,o;for(;s.words.length<this.cfg.keySize;){o&&r.update(o),o=r.update(e).finalize(t),r.reset();for(let n=1;n<this.cfg.iterations;n++)o=r.finalize(o),r.reset();s.concat(o)}return s.sigBytes=this.cfg.keySize*4,s}};var ht=class{static{c(this,"OpenSSLKdf")}static execute(e,t,r,s){s||(s=g.random(64/8));let o=new Oe({keySize:t+r}).compute(e,s),n=new g(o.words.slice(t),r*4);return o.sigBytes=t*4,new J({key:o,iv:n,salt:s})}};var me=class{static{c(this,"PasswordBasedCipher")}static decrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(o.format===void 0)throw new Error("missing format in config");if(t=this._parse(t,o.format),o.kdf===void 0)throw new Error("the key derivation function must be set");let n=o.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv!==void 0&&(o.iv=n.iv),W.decrypt.call(this,e,t,n.key,o)}static encrypt(e,t,r,s){let o=Object.assign({},this.cfg,s);if(o.kdf===void 0)throw new Error("missing kdf in config");let n=o.kdf.execute(r,e.keySize,e.ivSize);return n.iv!==void 0&&(o.iv=n.iv),W.encrypt.call(this,e,t,n.key,o).extend(n)}static _parse(e,t){return typeof e=="string"?t.parse(e):e}};me.cfg={blockSize:4,iv:new g([]),format:_e,kdf:ht};var ct=class{static{c(this,"CipherHelper")}constructor(e){this._cipher=e}decrypt(e,t,r){return typeof t=="string"?me.decrypt(this._cipher,e,t,r):W.decrypt(this._cipher,e,t,r)}encrypt(e,t,r){return typeof t=="string"?me.encrypt(this._cipher,e,t,r):W.encrypt(this._cipher,e,t,r)}};var Y=class extends ge{static{c(this,"Cipher")}constructor(e,t,r){super(Object.assign({blockSize:1},r)),this._xformMode=e,this._key=t,this.reset()}static _createHelper(e){return new ct(e)}static createDecryptor(e,t){let r=this;return new r(this._DEC_XFORM_MODE,e,t)}static createEncryptor(e,t){return new this(this._ENC_XFORM_MODE,e,t)}finalize(e){return e&&this._append(e),this._doFinalize()}process(e){return this._append(e),this._process()}};Y.ivSize=4;Y.keySize=4;Y._DEC_XFORM_MODE=2;Y._ENC_XFORM_MODE=1;var K=class{static{c(this,"BlockCipherModeAlgorithm")}constructor(e,t){this.init(e,t)}init(e,t){this._cipher=e,this._iv=t}};var ye=class{static{c(this,"BlockCipherMode")}static createDecryptor(e,t){let r=this.Decryptor;return new r(e,t)}static createEncryptor(e,t){let r=this.Encryptor;return new r(e,t)}};ye.Decryptor=K;ye.Encryptor=K;var at=class extends K{static{c(this,"CBCEncryptor")}get prevBlock(){return this._prevBlock}processBlock(e,t){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");this.xorBlock(e,t,this._cipher.cfg.blockSize),this._cipher.encryptBlock(e,t),this._prevBlock=e.slice(t,t+this._cipher.cfg.blockSize)}xorBlock(e,t,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)e[t+o]^=s[o]}};var lt=class extends K{static{c(this,"CBCDecryptor")}get prevBlock(){return this._prevBlock}processBlock(e,t){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");let r=e.slice(t,t+this._cipher.cfg.blockSize);this._cipher.decryptBlock(e,t),this.xorBlock(e,t,this._cipher.cfg.blockSize),this._prevBlock=r}xorBlock(e,t,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)e[t+o]^=s[o]}};var U=class extends ye{static{c(this,"CBC")}};U.Decryptor=lt;U.Encryptor=at;var Q=class{static{c(this,"PKCS7")}static pad(e,t){let r=t*4,s=r-e.sigBytes%r,o=s<<24|s<<16|s<<8|s,n=[];for(let a=0;a<s;a+=4)n.push(o);let h=new g(n,s);e.concat(h)}static unpad(e){let t=e.words[e.sigBytes-1>>>2]&255;e.sigBytes-=t}};var xe=class extends Y{static{c(this,"BlockCipher")}constructor(e,t,r){super(e,t,Object.assign({blockSize:4,mode:U,padding:Q},r))}reset(){if(super.reset(),this.cfg.mode===void 0)throw new Error("missing mode in config");let e;this._xformMode===this.constructor._ENC_XFORM_MODE?e=this.cfg.mode.createEncryptor:(e=this.cfg.mode.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator===e?this._mode.init(this,this.cfg.iv&&this.cfg.iv.words):(this._mode=e.call(this.cfg.mode,this,this.cfg.iv&&this.cfg.iv.words),this._mode.__creator=e)}_doFinalize(){if(this.cfg.padding===void 0)throw new Error("missing padding in config");let e;if(this._xformMode===this.constructor._ENC_XFORM_MODE){if(this.cfg.blockSize===void 0)throw new Error("missing blockSize in config");this.cfg.padding.pad(this._data,this.cfg.blockSize),e=this._process(!0)}else e=this._process(!0),this.cfg.padding.unpad(e);return e}_doProcessBlock(e,t){this._mode.processBlock(e,t)}};var l=class P{static{c(this,"X64Word")}constructor(e,t){this.high=e,this.low=t}add(e){let t=this.low+e.low|0,r=t>>>0<this.low>>>0?1:0,s=this.high+e.high+r|0;return new P(s,t)}and(e){return new P(this.high&e.high,this.low&e.low)}not(){return new P(~this.high,~this.low)}or(e){return new P(this.high|e.high,this.low|e.low)}rotL(e){return this.shiftL(e).or(this.shiftR(64-e))}rotR(e){return this.shiftR(e).or(this.shiftL(64-e))}shiftL(e){return e<32?new P(this.high<<e|this.low>>>32-e,this.low<<e):new P(this.low<<e-32,0)}shiftR(e){return e<32?new P(this.high>>>e,this.low>>>e|this.high<<32-e):new P(0,this.high>>>e-32)}xor(e){return new P(this.high^e.high,this.low^e.low)}};var ft=class ve{static{c(this,"X64WordArray")}constructor(e=[],t){this.words=e,this.sigBytes=t!==void 0?t:e.length*8}static create(e=[],t){return new ve(e,t)}clone(){let e=this.words.map(t=>new l(t.high,t.low));return new ve(e,this.sigBytes)}toX32(){let e=[];for(let t of this.words)e.push(t.high,t.low);return new g(e,this.sigBytes)}};var B=[],dt=[],pt=[],ut=[],wt=[],gt=[],Ie=[],ke=[],Ne=[],Me=[];(function(){let i=[];for(let r=0;r<256;r++)r<128?i[r]=r<<1:i[r]=r<<1^283;let e=0,t=0;for(let r=0;r<256;r++){let s=t^t<<1^t<<2^t<<3^t<<4;s=s>>>8^s&255^99,B[e]=s,dt[s]=e;let o=i[e],n=i[o],h=i[n],a=i[s]*257^s*16843008;pt[e]=a<<24|a>>>8,ut[e]=a<<16|a>>>16,wt[e]=a<<8|a>>>24,gt[e]=a,a=h*16843009^n*65537^o*257^e*16843008,Ie[s]=a<<24|a>>>8,ke[s]=a<<16|a>>>16,Ne[s]=a<<8|a>>>24,Me[s]=a,e?(e=o^i[i[i[h^o]]],t^=i[i[t]]):e=t=1}})();var cr=[0,1,2,4,8,16,32,64,128,27,54],Ee=class extends xe{static{c(this,"AES")}constructor(e,t,r){super(e,t,r),super.reset()}decryptBlock(e,t){let r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,Ie,ke,Ne,Me,dt),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r}encryptBlock(e,t){this._doCryptBlock(e,t,this._keySchedule,pt,ut,wt,gt,B)}reset(){if(super.reset(),this._nRounds&&this._keyPriorReset===this._key)return;let e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,o=((this._nRounds=r+6)+1)*4,n=this._keySchedule=[];for(let h=0;h<o;h++)if(h<r)n[h]=t[h];else{let a=n[h-1];h%r?r>6&&h%r===4&&(a=B[a>>>24]<<24|B[a>>>16&255]<<16|B[a>>>8&255]<<8|B[a&255]):(a=a<<8|a>>>24,a=B[a>>>24]<<24|B[a>>>16&255]<<16|B[a>>>8&255]<<8|B[a&255],a^=cr[h/r|0]<<24),n[h]=n[h-r]^a}this._invKeySchedule=[];for(let h=0;h<o;h++){let a=o-h,p;h%4?p=n[a]:p=n[a-4],h<4||a<=4?this._invKeySchedule[h]=p:this._invKeySchedule[h]=Ie[B[p>>>24]]^ke[B[p>>>16&255]]^Ne[B[p>>>8&255]]^Me[B[p&255]]}}_doCryptBlock(e,t,r,s,o,n,h,a){let p=e[t]^r[0],w=e[t+1]^r[1],u=e[t+2]^r[2],_=e[t+3]^r[3],x=4;for(let A=1;A<this._nRounds;A++){let m=s[p>>>24]^o[w>>>16&255]^n[u>>>8&255]^h[_&255]^r[x++],y=s[w>>>24]^o[u>>>16&255]^n[_>>>8&255]^h[p&255]^r[x++],N=s[u>>>24]^o[_>>>16&255]^n[p>>>8&255]^h[w&255]^r[x++],Be=s[_>>>24]^o[p>>>16&255]^n[w>>>8&255]^h[u&255]^r[x++];p=m,w=y,u=N,_=Be}let b=(a[p>>>24]<<24|a[w>>>16&255]<<16|a[u>>>8&255]<<8|a[_&255])^r[x++],C=(a[w>>>24]<<24|a[u>>>16&255]<<16|a[_>>>8&255]<<8|a[p&255])^r[x++],I=(a[u>>>24]<<24|a[_>>>16&255]<<16|a[p>>>8&255]<<8|a[w&255])^r[x++],k=(a[_>>>24]<<24|a[p>>>16&255]<<16|a[w>>>8&255]<<8|a[u&255])^r[x++];e[t]=b,e[t+1]=C,e[t+2]=I,e[t+3]=k}};Ee.keySize=256/32;var ar=[1732584193,4023233417,2562383102,271733878,3285377520],G=new Array(80),V=class extends E{static{c(this,"SHA1")}get hash(){return this._hash}reset(){super.reset(),this._hash=new g(ar.slice(0))}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;return this._data.words[t>>>5]|=128<<24-t%32,this._data.words[(t+64>>>9<<4)+14]=Math.floor(e/4294967296),this._data.words[(t+64>>>9<<4)+15]=e,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,t){let r=this._hash.words[0],s=this._hash.words[1],o=this._hash.words[2],n=this._hash.words[3],h=this._hash.words[4];for(let a=0;a<80;a++){if(a<16)G[a]=e[t+a]|0;else{let _=G[a-3]^G[a-8]^G[a-14]^G[a-16];G[a]=_<<1|_>>>31}let p,w;a<20?(p=s&o|~s&n,w=1518500249):a<40?(p=s^o^n,w=1859775393):a<60?(p=s&o|s&n|o&n,w=2400959708):(p=s^o^n,w=3395469782);let u=(r<<5|r>>>27)+p+h+w+G[a];h=n,n=o,o=s<<30|s>>>2,s=r,r=u|0}this._hash.words[0]=this._hash.words[0]+r|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+o|0,this._hash.words[3]=this._hash.words[3]+n|0,this._hash.words[4]=this._hash.words[4]+h|0}};var _t=[],mt=[];(function(){function i(s){let o=Math.sqrt(s);for(let n=2;n<=o;n++)if(!(s%n))return!1;return!0}c(i,"isPrime");function e(s){return(s-(s|0))*4294967296|0}c(e,"getFractionalBits");let t=2,r=0;for(;r<64;)i(t)&&(r<8&&(_t[r]=e(Math.pow(t,1/2))),mt[r]=e(Math.pow(t,1/3)),r++),t++})();var q=[],ne=class extends E{static{c(this,"SHA256")}constructor(){super()}reset(){super.reset(),this._hash=new g(_t.slice(0))}_doFinalize(){let e=this._nDataBytes*8,t=this._data.sigBytes*8;return this._data.words[t>>>5]|=128<<24-t%32,this._data.words[(t+64>>>9<<4)+14]=Math.floor(e/4294967296),this._data.words[(t+64>>>9<<4)+15]=e,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,t){let r=this._hash.words[0],s=this._hash.words[1],o=this._hash.words[2],n=this._hash.words[3],h=this._hash.words[4],a=this._hash.words[5],p=this._hash.words[6],w=this._hash.words[7];for(let u=0;u<64;u++){if(u<16)q[u]=e[t+u]|0;else{let A=q[u-15],m=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,y=q[u-2],N=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;q[u]=m+q[u-7]+N+q[u-16]}let _=h&a^~h&p,x=r&s^r&o^s&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),C=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),I=w+C+_+mt[u]+q[u],k=b+x;w=p,p=a,a=h,h=n+I|0,n=o,o=s,s=r,r=I+k|0}this._hash.words[0]=this._hash.words[0]+r|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+o|0,this._hash.words[3]=this._hash.words[3]+n|0,this._hash.words[4]=this._hash.words[4]+h|0,this._hash.words[5]=this._hash.words[5]+a|0,this._hash.words[6]=this._hash.words[6]+p|0,this._hash.words[7]=this._hash.words[7]+w|0}};var Ce=[new l(1116352408,3609767458),new l(1899447441,602891725),new l(3049323471,3964484399),new l(3921009573,2173295548),new l(961987163,4081628472),new l(1508970993,3053834265),new l(2453635748,2937671579),new l(2870763221,3664609560),new l(3624381080,2734883394),new l(310598401,1164996542),new l(607225278,1323610764),new l(1426881987,3590304994),new l(1925078388,4068182383),new l(2162078206,991336113),new l(2614888103,633803317),new l(3248222580,3479774868),new l(3835390401,2666613458),new l(4022224774,944711139),new l(264347078,2341262773),new l(604807628,2007800933),new l(770255983,1495990901),new l(1249150122,1856431235),new l(1555081692,3175218132),new l(1996064986,2198950837),new l(2554220882,3999719339),new l(2821834349,766784016),new l(2952996808,2566594879),new l(3210313671,3203337956),new l(3336571891,1034457026),new l(3584528711,2466948901),new l(113926993,3758326383),new l(338241895,168717936),new l(666307205,1188179964),new l(773529912,1546045734),new l(1294757372,1522805485),new l(1396182291,2643833823),new l(1695183700,2343527390),new l(1986661051,1014477480),new l(2177026350,1206759142),new l(2456956037,344077627),new l(2730485921,1290863460),new l(2820302411,3158454273),new l(3259730800,3505952657),new l(3345764771,106217008),new l(3516065817,3606008344),new l(3600352804,1432725776),new l(4094571909,1467031594),new l(275423344,851169720),new l(430227734,3100823752),new l(506948616,1363258195),new l(659060556,3750685593),new l(883997877,3785050280),new l(958139571,3318307427),new l(1322822218,3812723403),new l(1537002063,2003034995),new l(1747873779,3602036899),new l(1955562222,1575990012),new l(2024104815,1125592928),new l(2227730452,2716904306),new l(2361852424,442776044),new l(2428436474,593698344),new l(2756734187,3733110249),new l(3204031479,2999351573),new l(3329325298,3815920427),new l(3391569614,3928383900),new l(3515267271,566280711),new l(3940187606,3454069534),new l(4118630271,4000239992),new l(116418474,1914138554),new l(174292421,2731055270),new l(289380356,3203993006),new l(460393269,320620315),new l(685471733,587496836),new l(852142971,1086792851),new l(1017036298,365543100),new l(1126000580,2618297676),new l(1288033470,3409855158),new l(1501505948,4234509866),new l(1607167915,987167468),new l(1816402316,1246189591)],M=[];(function(){for(let i=0;i<80;i++)M[i]=new l(void 0,void 0)})();var Fe=class extends E{static{c(this,"SHA512")}constructor(){super({blockSize:1024/32})}reset(){super.reset(),this._hash=new ft([new l(1779033703,4089235720),new l(3144134277,2227873595),new l(1013904242,4271175723),new l(2773480762,1595750129),new l(1359893119,2917565137),new l(2600822924,725511199),new l(528734635,4215389547),new l(1541459225,327033209)])}_doFinalize(){let e=this._data,t=e.words,r=this._nDataBytes*8,s=e.sigBytes*8;return t[s>>>5]|=128<<24-s%32,t[(s+128>>>10<<5)+30]=Math.floor(r/4294967296),t[(s+128>>>10<<5)+31]=r,e.sigBytes=t.length*4,this._process(),this._hash.toX32()}_doProcessBlock(e,t){let r=this._hash.words[0].high,s=this._hash.words[0].low,o=this._hash.words[1].high,n=this._hash.words[1].low,h=this._hash.words[2].high,a=this._hash.words[2].low,p=this._hash.words[3].high,w=this._hash.words[3].low,u=this._hash.words[4].high,_=this._hash.words[4].low,x=this._hash.words[5].high,b=this._hash.words[5].low,C=this._hash.words[6].high,I=this._hash.words[6].low,k=this._hash.words[7].high,A=this._hash.words[7].low;for(let m=0;m<80;m++){let y,N;if(m<16)N=M[m].high=e[t+m*2]|0,y=M[m].low=e[t+m*2+1]|0;else{let We=M[m-15],X=We.high,se=We.low,Qt=(X>>>1|se<<31)^(X>>>8|se<<24)^X>>>7,Ke=(se>>>1|X<<31)^(se>>>8|X<<24)^(se>>>7|X<<25),Ge=M[m-2],Z=Ge.high,ie=Ge.low,St=(Z>>>19|ie<<13)^(Z<<3|ie>>>29)^Z>>>6,Ve=(ie>>>19|Z<<13)^(ie<<3|Z>>>29)^(ie>>>6|Z<<26);y=Ke+M[m-7].low,N=Qt+M[m-7].high+(y>>>0<Ke>>>0?1:0),y=y+Ve,N=N+St+(y>>>0<Ve>>>0?1:0),y=y+M[m-16].low,N=N+M[m-16].high+(y>>>0<M[m-16].low>>>0?1:0),M[m].high=N,M[m].low=y}let Be=u&x^~u&C,Le=_&b^~_&I,qt=r&o^r&h^o&h,Xt=s&n^s&a^n&a,Zt=(r>>>28|s<<4)^(r<<30|s>>>2)^(r<<25|s>>>7),Ue=(s>>>28|r<<4)^(s<<30|r>>>2)^(s<<25|r>>>7),Ht=(u>>>14|_<<18)^(u>>>18|_<<14)^(u<<23|_>>>9),Jt=(_>>>14|u<<18)^(_>>>18|u<<14)^(_<<23|u>>>9),O=A+Jt,j=k+Ht+(O>>>0<A>>>0?1:0);O=O+Le,j=j+Be+(O>>>0<Le>>>0?1:0),O=O+Ce[m].low,j=j+Ce[m].high+(O>>>0<Ce[m].low>>>0?1:0),O=O+y,j=j+N+(O>>>0<y>>>0?1:0);let $e=Ue+Xt,Yt=Zt+qt+($e>>>0<Ue>>>0?1:0);k=C,A=I,C=x,I=b,x=u,b=_,_=w+O|0,u=p+j+(_>>>0<w>>>0?1:0)|0,p=h,w=a,h=o,a=n,o=r,n=s,s=O+$e|0,r=j+Yt+(s>>>0<O>>>0?1:0)|0}this._hash.words[0].low=this._hash.words[0].low=this._hash.words[0].low+s,this._hash.words[0].high=this._hash.words[0].high+r+(this._hash.words[0].low>>>0<s>>>0?1:0),this._hash.words[1].low=this._hash.words[1].low=this._hash.words[1].low+n,this._hash.words[1].high=this._hash.words[1].high+o+(this._hash.words[1].low>>>0<n>>>0?1:0),this._hash.words[2].low=this._hash.words[2].low=this._hash.words[2].low+a,this._hash.words[2].high=this._hash.words[2].high+h+(this._hash.words[2].low>>>0<a>>>0?1:0),this._hash.words[3].low=this._hash.words[3].low=this._hash.words[3].low+w,this._hash.words[3].high=this._hash.words[3].high+p+(this._hash.words[3].low>>>0<w>>>0?1:0),this._hash.words[4].low=this._hash.words[4].low=this._hash.words[4].low+_,this._hash.words[4].high=this._hash.words[4].high+u+(this._hash.words[4].low>>>0<_>>>0?1:0),this._hash.words[5].low=this._hash.words[5].low=this._hash.words[5].low+b,this._hash.words[5].high=this._hash.words[5].high+x+(this._hash.words[5].low>>>0<b>>>0?1:0),this._hash.words[6].low=this._hash.words[6].low=this._hash.words[6].low+I,this._hash.words[6].high=this._hash.words[6].high+C+(this._hash.words[6].low>>>0<I>>>0?1:0),this._hash.words[7].low=this._hash.words[7].low=this._hash.words[7].low+A,this._hash.words[7].high=this._hash.words[7].high+k+(this._hash.words[7].low>>>0<A>>>0?1:0)}};var yt=class{static{c(this,"HMAC")}constructor(e,t){this._hasher=new e;let r=typeof t=="string"?R.parse(t):t,s=this._hasher.cfg.blockSize,o=s*4;r.sigBytes>o&&(r=this._hasher.finalize(r)),r.clamp();let n=this._oKey=r.clone(),h=this._iKey=r.clone(),a=n.words,p=h.words;for(let w=0;w<s;w++)a[w]^=1549556828,p[w]^=909522486;n.sigBytes=h.sigBytes=o,this.reset()}finalize(e){let t=this._hasher.finalize(e);return this._hasher.reset(),this._hasher.finalize(this._oKey.clone().concat(t))}reset(){this._hasher.reset(),this._hasher.update(this._iKey)}update(e){return this._hasher.update(e),this}};var Pe=class xt{static{c(this,"PBKDF2")}constructor(e){this.cfg=Object.assign({keySize:128/32,hasher:ne,iterations:25e4},e)}static execute(e,t,r){return new xt(r).compute(e,t)}compute(e,t){let r=this.cfg,s=new yt(r.hasher,e),o=new g,n=new g([1]),h=o.words,a=n.words,p=r.keySize,w=r.iterations;for(;h.length<p;){let u=s.update(t).finalize(n);s.reset();let _=u.words,x=_.length,b=u;for(let C=1;C<w;C++){b=s.finalize(b),s.reset();let I=b.words;for(let k=0;k<x;k++)_[k]^=I[k]}o.concat(u),a[0]++}return o.sigBytes=p*4,o}};var he=xe._createHelper(Ee);var S=E._createHelper(T);var ee=E._createHelper(V);var Re=E._createHelper(ne);var Ae=E._createHelper(Fe);var ce=class{static{c(this,"SmpAesCrypt")}_password;_salt;_initVector;get _iv(){return this._initVector?L.parse(this._initVector):void 0}_mode=U;_padding=Q;constructor(e,t,r){this._password=e,this._salt=t,this._initVector=r}decryptAES(e){return he.decrypt(e,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString(R)}encryptAES(e){return he.encrypt(e,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString()}_buildKey(){return Pe.execute(this._password,L.parse(this._salt),{keySize:256/32,iterations:1e3,hasher:V})}};var De=class{static{c(this,"SmpCrypto")}static base64Decode(e){return R.stringify(z.parse(e))}static base64Encode(e){return z.stringify(R.parse(e))}static md5(e){return S(e).toString()}static sha1(e){return ee(e).toString()}static sha256(e){return Re(e).toString()}static sha512(e){return Ae(e).toString()}};var ze=class{static{c(this,"SmpSecureCode")}_baseCode;get baseCode(){return this._baseCode}get secureCode(){return this._encode()}_crcLength=5;_seed="changeme";constructor(e){this._baseCode=e}static check(e,t){if(new this(e).secureCode!==t)throw D.create({messages:"WRONG_SECURE_CODE",errorCode:"WRONG_SECURE_CODE",status:tt.BadRequest})}_encode(){let e=new T;return e.update(R.parse(this._seed+this._baseCode)),e.finalize().toString(L).substring(0,this._crcLength).toUpperCase()}};import{Expose as fr,instanceToPlain as dr,plainToInstance as pr}from"class-transformer";import{DateTime as Te}from"ts-luxon";var v=(function(i){return i.ACTIVATE="ACTIVATE",i.BLOCK="BLOCK",i.CHECK="CHECK",i.DIGITAL_ACTIVATE="DIGITAL_ACTIVATE",i.FREEZE="FREEZE",i.PURCHASE="PURCHASE",i.RECHARGE="RECHARGE",i.ROLLBACK="ROLLBACK",i.TRANSACTION="TRANSACTION",i.TRANSACTION_DETAIL="TRANSACTION_DETAIL",i.UNFREEZE="UNFREEZE",i.XREFUND="XREFUND",i})({});var te=(function(i){return i.MD5="MD5",i.MD5_HMAC="MD5_HMAC",i.SHA1="SHA1",i.SHA1_HMAC="SHA1_HMAC",i})({});function lr(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}c(lr,"_ts_decorate");function Et(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}c(Et,"_ts_metadata");var je=class i{static{c(this,"SmpGiftcardTransaction")}gc;op;ot;static _AES_ENCODER=new ce("changeme","5f6eae61d2428b99","d92fbf214e16a79fd36f9a5185ae733f");static _LOGGER=console;static _OP_CODES={[v.CHECK]:"",[v.TRANSACTION]:"",[v.TRANSACTION_DETAIL]:"",[v.ACTIVATE]:"A",[v.BLOCK]:"B",[v.DIGITAL_ACTIVATE]:"D",[v.FREEZE]:"F",[v.PURCHASE]:"P",[v.RECHARGE]:"G",[v.ROLLBACK]:"R",[v.UNFREEZE]:"U",[v.XREFUND]:"X"};static _SEP="_";get dto(){return this._dto}get hash(){return this._hashStrategy(this.toString()).toString()}get iso(){return this.dto.toUTC().toISO()}get ts(){return this._dto.ts}_dto;_hashStrategies={[te.MD5]:e=>S(e),[te.MD5_HMAC]:e=>{let t=new T;return t.update(R.parse(e)),t.finalize()},[te.SHA1]:e=>ee(e),[te.SHA1_HMAC]:e=>{let t=new V;return t.update(R.parse(e)),t.finalize()}};_hashStrategy=this._hashStrategies[te.MD5];constructor(e="ACTIVATION",t,r,s){this.gc=e,this.op=t,this.ot=r,this._dto=typeof s=="number"&&s>=0?Te.fromMillis(+`${s}000`.slice(0,13)):Te.local()}static build({gc:e,op:t,ot:r,dto:s}){return new this(e,t,r,s?.ts)}static explode(e){let t=this.constructor,r=(e||"").split(t._SEP);if(r.length<4)throw new Error(`INVALID_TRANSACTION "${e}"`);return this.build({gc:r[1],op:t.prefixToOperation(r[2]),dto:Te.fromSeconds(+r[3])})}static isBase64(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)&&e.length%4===0}static parse(e){this._LOGGER.info(`${this.constructor.name}: trying to parse ${e}`);try{if(this.isBase64(e)){let t=this._AES_ENCODER.decryptAES(e),r=JSON.parse(t);return pr(i,r)}else return this.explode(e)}catch(t){throw this._LOGGER.error(`${this.constructor.name}: failed to parse ${e}`,t),new Error(`UNPARSEABLE "${e}"`)}}static prefixToOperation(e){return Object.entries(this._OP_CODES).find(([,r])=>r===e)[0]}serialize(){return dr(this,{excludePrefixes:["_"]})}toString(){let e=JSON.stringify(this.serialize());return this.constructor._AES_ENCODER.encryptAES(e)}};lr([fr(),Et("design:type",Number),Et("design:paramtypes",[])],je.prototype,"ts",null);var Rh=(function(i){return i.ListDetectiveValidator="ListDetectiveValidator",i.MXValidator="MXValidator",i.SyntaxValidator="SyntaxValidator",i})({});function Bh(i,e){e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{r!=="constructor"&&(r in i.prototype||Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)))});try{let r=new t;Object.getOwnPropertyNames(r).forEach(s=>{s in i.prototype||Object.defineProperty(i.prototype,s,Object.getOwnPropertyDescriptor(r,s))})}catch{}Object.getOwnPropertyNames(t).forEach(r=>{r!=="prototype"&&r!=="name"&&r!=="length"&&(r in i||Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r)))})})}c(Bh,"smpApplyMixin");var ur=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Rt(i){return i.match(ur)}c(Rt,"smpAsciiWords");var It="\\ud800-\\udfff",wr="\\u0300-\\u036f",gr="\\ufe20-\\ufe2f",_r="\\u20d0-\\u20ff",mr="\\u1ab0-\\u1aff",yr="\\u1dc0-\\u1dff",xr=wr+gr+_r+mr+yr,kt="\\u2700-\\u27bf",Nt="a-z\\xdf-\\xf6\\xf8-\\xff",Er="\\xac\\xb1\\xd7\\xf7",Rr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ar="\\u2000-\\u206f",Br=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Mt="A-Z\\xc0-\\xd6\\xd8-\\xde",br="\\ufe0e\\ufe0f",Ct=Er+Rr+Ar+Br,Ft="['\u2019]",At=`[${Ct}]`,Or=`[${xr}]`,Pt="\\d",vr=`[${kt}]`,Dt=`[${Nt}]`,zt=`[^${It}${Ct+Pt+kt+Nt+Mt}]`,Ir="\\ud83c[\\udffb-\\udfff]",kr=`(?:${Or}|${Ir})`,Nr=`[^${It}]`,Tt="(?:\\ud83c[\\udde6-\\uddff]){2}",jt="[\\ud800-\\udbff][\\udc00-\\udfff]",re=`[${Mt}]`,Mr="\\u200d",Bt=`(?:${Dt}|${zt})`,Cr=`(?:${re}|${zt})`,bt=`(?:${Ft}(?:d|ll|m|re|s|t|ve))?`,Ot=`(?:${Ft}(?:D|LL|M|RE|S|T|VE))?`,Lt=`${kr}?`,Ut=`[${br}]?`,Fr=`(?:${Mr}(?:${[Nr,Tt,jt].join("|")})${Ut+Lt})*`,Pr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Dr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",zr=Ut+Lt+Fr,vt=`(?:${[vr,Tt,jt].join("|")})${zr}`,ae=class{static{c(this,"SmpUnicodeWords")}static HAS_UNICODE_WORD=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/);static RE_UNICODE_WORDS=RegExp([`${re}?${Dt}+${bt}(?=${[At,re,"$"].join("|")})`,`${Cr}+${Ot}(?=${[At,re+Bt,"$"].join("|")})`,`${re}?${Bt}+${bt}`,`${re}+${Ot}`,Dr,Pr,`${Pt}+`,vt].join("|"),"g");static RS_EMOJI=vt;static unicodeWords(e){return e.match(this.RE_UNICODE_WORDS)}};var $t=class i{static{c(this,"SmpCommonUtils")}static arrayRemove(e,t){let r=[],s=e.filter((o,n)=>t(o,n)&&r.push(n));return r.reverse().forEach(o=>e.splice(o,1)),s}static assertIsArray(e,t){if(!Array.isArray(e))throw new Error(t||`${this.constructor.name} => val was not an array`)}static assertIsBoolean(e,t){if(!this.isBoolean(e))throw new Error(t||`${this.constructor.name} => val was not boolean`)}static assertIsFunction(e,t){if(!this.isFunction(e))throw new Error(t||`${this.constructor.name} => entity was not a function`)}static assertIsInstance(e,t,r){if(!(e instanceof t))throw new Error(r||`${this.constructor.name} => val was not instance of class`)}static assertIsNotEmpty(e,t){if(this.isEmpty(e))throw new Error(t||`${this.constructor.name} => entity was empty`)}static assertIsNumber(e,t){if(typeof e!="number")throw new Error(t||`${this.constructor.name} => val was not numeric`)}static assertIsNumeric(e,t){if(!this.isNumeric(e))throw new Error(t||`${this.constructor.name} => val was not numeric`)}static assertIsObject(e,t){if(!this.isObject(e))throw new Error(t||`${this.constructor.name} => val was not an object`)}static assertIsString(e,t){if(!this.isString(e))throw new Error(t||`${this.constructor.name} => val was not a string`)}static assertIsTruthy(e,t){if(!e)throw new Error(t||`${this.constructor.name} => condition wasn't truthy`)}static buildPath(...e){let t=e.filter(r=>!!r).join("/").replace(/(?<!:)\/\/+/g,"/");return t.startsWith("http")&&!t.endsWith("/")?`${t}/`:t}static downloadBlob(e,t){let r=window.URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.setAttribute("download",t),document.body.appendChild(s),s.click()}static generateRandomHexString(e=12){let t="0123456789abcdef",r="";for(let s=0;s<e;s++){let o=Math.floor(Math.random()*t.length);r+=t[o]}return r}static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}static getDecimalPrecision(e){if(this.assertIsNumeric(e),!isFinite(+e))return 0;let t=1,r=0;for(;Math.round(+e*t)/t!==e;)t*=10,r++;return r}static getType(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}static isBoolean(e){return typeof e=="boolean"}static isColor(e){if(!e||!this.isString(e))return!1;let t=new Option().style;return t.color=e,t.color!==""}static isEmpty(e){return!e&&e!==0}static isEqual(e,t){function r(){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!i.isEqual(e[a],t[a]))return!1;return!0}c(r,"areArraysEqual");function s(){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&!i.isEqual(e[a],t[a]))return!1;return!0}c(s,"areObjectsEqual");function o(){return e.toString()===t.toString()}c(o,"areFunctionsEqual");function n(){return e===t}c(n,"arePrimativesEqual");let h=this.getType(e);return h!==this.getType(t)?!1:h==="array"?r():h==="object"?s():h==="function"?o():n()}static isFormField(e){return/^(?:input|select|textarea|button)$/i.test(e.nodeName)}static isFunction(e){return typeof e==typeof isNaN}static isNotEmpty(e){return!this.isEmpty(e)}static isNumber(e){return typeof e=="number"&&this.isNumeric(e)}static isNumeric(e){return!isNaN(e)}static isObject(e){return!!e&&e===Object(e)&&e.constructor===Object}static isPrimitive(e){let t=this.getType(e);return t!=="function"&&(t!=="object"||!e)}static isString(e){return typeof e=="string"}static isWindows(){return navigator.userAgent.toLowerCase().includes("win")}static mapObject(e,t){if(this.assertIsFunction(t,`CommonUtils => expected type of iteratee to be Function, got ${typeof t}`),this.isObject(e))return Object.entries(e).reduce((r,[s,o])=>(r.push(t(o,s)),r),[]);if(Array.isArray(e))return e.map(t);throw new Error(`CommonUtils => invalid object provided. Expected Object or Array, got ${typeof t}`)}static mapObjectKeys(e,t){return Object.entries(e).reduce((r,[s,o])=>(r[s]=t.call(null,s,o),r),{})}static mapObjectValues(e,t){return this.isObject(e)?Object.entries(e).reduce((r,[s,o])=>(r[s]=t.call(null,o,s),r),{}):{}}static noop(){}static objectHasValue(e,t){return!!~Object.values(e).filter(r=>this.isEqual(r,t))}static omit(e,t){return Object.keys(e).filter(s=>!t.includes(s)).reduce((s,o)=>(s[o]=e[o],s),{})}static parseBoolean(e){return e?/^true$/i.test(e):!1}static parseJsonSafely(e){try{return JSON.parse(e)}catch(t){console.warn(`${this.constructor.name} => couldn't parse json string`,{str:e,error:t});return}}static pick(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}static runSafely(e,t=null,r=[]){if(this.isFunction(e))return e.apply(t,r)}static sleep(e){return new Promise(t=>setTimeout(t,e))}static sprintf(e,...t){return this.isString(e)&&t.length?this.sprintf(e.replace("%s",String(t.shift())),...t):e}static stripComments(e){return typeof e=="string"?e.replace(/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g,""):e}static submitFakeForm({action:e,method:t=st.POST,data:r,target:s}){let o=Object.entries(r||{}).map(([h,a])=>`<input name="${h}" type="hidden" value="${a}" />`),n=document.createElement("form");n.method=t,n.action=e,n.innerHTML=`${o}`,n.target=s||"_self",document.body.append(n),n.submit()}static toCamelCase(e){return this.words(e.replace(/['\u2019]/g,"")).reduce((t,r,s)=>(r=r.toLowerCase(),t+(s?r.charAt(0).toUpperCase()+r.slice(1):r)),"")}static toKebabCase(e){return this.words(e.replace(/['\u2019]/g,"")).join("-").toLowerCase()}static toPascalCase(e){return this.toCamelCase(e).replace(/^(.)/,t=>t.toUpperCase())}static toSnakeCase(e){return this.words(e.replace(/['\u2019]/g,"")).join("_").toLowerCase()}static toUpperSnakeCase(e){return this.toSnakeCase(e).toUpperCase()}static words(e,t){return t===void 0?(ae.HAS_UNICODE_WORD(e)?ae.unicodeWords(e):Rt(e))||[]:e.match(t)||[]}};var Wt=class extends Error{static{c(this,"SmpFilterException")}message;data;constructor(e="Filter Exception",t){super(),this.message=e,this.data=t}};import{DateTime as Kt}from"ts-luxon";var Gt=class i{static{c(this,"SmpSid")}value;expiry;get active(){return this.value.endsWith(this._controlSuffix)}get expired(){return Kt.now().ts>this.expiry}get valid(){return!this.expired}_controlSuffix="$1";constructor(e=`sid-xxxx-${+Kt.now().ts}`,t=0){this.value=e,this.expiry=t}static parse(e){return new i(e.value,e.expiry)}toPlain(){return{value:this.value,expiry:this.expiry}}};import{smpNoop as Kh}from"@tonysamperi/logger";var Vt=class{static{c(this,"SmpRegularExpressions")}static get COUNTRY(){return this._country}static get DOMAIN(){return/^(?!www)(\w)([\w.-])*\.[a-z]{2,6}$/}static get EMAIL(){return/^[^\\|!"£$%&/()='?^€*[\]°#§<>,;:\s]+@[a-z0-9.-]+\.[a-z]{2,6}$/}static get LANGUAGE(){return this._language}static get LATIN_CHARS(){return/^[\u0000-\u024F\u1E00-\u1EFF\u2C60-\u2C7F\uA720-\uA7FF]+/}static get LOCALE(){return new RegExp(`${this._country.source}-${this._language.source}`)}static get NO_EMOJI_NO_PUNCTUATION(){return/[^\p{Emoji_Presentation}|\p{P}]/gu}static get PHONE_NUMBER(){return/^(\+\d{1,4}\s)(\d{4,15})$/}static get PHONE_NUMBER_BY_PREFIX(){return{"+971":{dontStartWithZero:/^(\+\d{3}\s)([1-9])/,typeExactlyNineDigits:/^(\+\d{3}\s)([1-9]\d{8}$)/}}}static get TAXCODE_BY_COUNTRY(){return{ES:{DNI:/^\d{8}[A-Z]$/,NIE:/^[A-Z]\d{7}[A-Z]$/,CIF:/^[A-Z]\d{8}$/}}}static _country=/[a-zA-Z]{2}/;static _language=/[a-z]{2}/};var qh="2.0.0-beta.2";export{Bs as SMP_HEALTHZ,qe as SmpAbstractCacheStrategy,H as SmpAbstractTtlCacheStrategy,ce as SmpAesCrypt,rt as SmpApiCommonUtils,it as SmpBaseJwtToken,ot as SmpBaseJwtTokenPlain,de as SmpBrowserCache,$t as SmpCommonUtils,De as SmpCrypto,D as SmpErrorResponse,Wt as SmpFilterException,Lr as SmpFirebaseErrors,oe as SmpGenericResponse,je as SmpGiftcardTransaction,te as SmpGiftcardTransactionHashStrategies,v as SmpGiftcardTransactionOps,et as SmpHttpService,pe as SmpHttpSessionStorageCache,tt as SmpHttpStatusCodes,ue as SmpInMemoryCache,Rh as SmpMarketingCloudValidators,Vt as SmpRegularExpressions,F as SmpResponseMessage,$ as SmpResponseMessageTypes,st as SmpRestVerbs,ze as SmpSecureCode,Gt as SmpSid,Tr as SmpSocialSignInKeys,jr as SmpSocialSignInUxModes,qh as VERSION,Bh as smpApplyMixin,Xe as smpIsSmpCachedValue,Kh as smpNoop};
|
package/dist/esm/rxjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable, ObservableInput, OperatorFunction, ObservedValueOf } from 'rxjs';
|
|
2
|
-
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-
|
|
2
|
+
import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-DoiEsQxI.js';
|
|
3
3
|
|
|
4
4
|
declare abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {
|
|
5
5
|
protected abstract _flushRaw(): Observable<void>;
|
|
@@ -7,9 +7,9 @@ declare abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheS
|
|
|
7
7
|
protected abstract _removeRaw(key: string): Observable<void>;
|
|
8
8
|
protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;
|
|
9
9
|
flush(): Observable<void>;
|
|
10
|
-
read<T =
|
|
10
|
+
read<T = any>(key: string): Observable<T | undefined>;
|
|
11
11
|
remove(key: string): Observable<void>;
|
|
12
|
-
write<T =
|
|
12
|
+
write<T = any>(key: string, value: T, ttl?: number): Observable<void>;
|
|
13
13
|
protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -7,8 +7,8 @@ import { Observable } from 'rxjs';
|
|
|
7
7
|
* For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.
|
|
8
8
|
*/
|
|
9
9
|
declare abstract class SmpAbstractCacheStrategy {
|
|
10
|
-
abstract read<T =
|
|
11
|
-
abstract write<T =
|
|
10
|
+
abstract read<T = any>(key: string): T | undefined | Observable<T | undefined>;
|
|
11
|
+
abstract write<T = any>(key: string, value: T, ttl?: number): void | Observable<void>;
|
|
12
12
|
abstract remove(key: string): void | Observable<void>;
|
|
13
13
|
abstract flush(): void | Observable<void>;
|
|
14
14
|
}
|