@tonysamperi/ts-mapi-core 2.0.0-beta.4 → 2.0.0-beta.5

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/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.0.0
2
+ * Split modules
3
+ * Add toLowerCase to email schema
4
+ * Fix HttpTwoService not encoding "+", rely on manual encoding for more predictable behaviour compared to URLSearchParams / URL
5
+ * Fix signature of kikRxjsThrowOnCondition
6
+ * Switch to lodash-es for KikCommonUtils.isEqual
7
+
1
8
  ## 1.8.0
2
9
  * Made SmpGenericConstructor GENERIC!
3
10
  * Add SmpBaseJwtToken and SmpBaseJwtTokenPlain
@@ -7,7 +14,7 @@
7
14
  ## 1.7.0
8
15
  * Added smpApplyMixin
9
16
  * Added smpRxjsQueue + smpRxjsSequence
10
- * Misc fixes on giftcard stuff
17
+ * Misc fixes on gift card stuff
11
18
 
12
19
  ## 1.6.2
13
20
  * Fix imports
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var u=(r,e)=>d(r,"name",{value:e,configurable:!0});var P=(r,e)=>{for(var i in e)d(r,i,{get:e[i],enumerable:!0})},f=(r,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!E.call(r,s)&&s!==i&&d(r,s,{get:()=>e[s],enumerable:!(o=_(e,s))||o.enumerable});return r};var U=r=>f(d({},"__esModule",{value:!0}),r);var m={};P(m,{SmpFirebaseService:()=>l});module.exports=U(m);var g=require("@tonysamperi/logger"),h=require("firebase/app"),t=require("firebase/auth");var n=(function(r){return r.APPLE="APPLE",r.FACEBOOK="FACEBOOK",r.GOOGLE="GOOGLE",r})({});var a=(function(r){return r.POPUP="POPUP",r.REDIRECT="REDIRECT",r})({});var c=(function(r){return r.DIFFERENT_CREDENTIAL="auth/account-exists-with-different-credential",r.DIFFERENT_CREDENTIAL_APPLE="auth/account-exists-with-different-credential/apple",r.DIFFERENT_CREDENTIAL_FACEBOOK="auth/account-exists-with-different-credential/facebook",r.DIFFERENT_CREDENTIAL_GOOGLE="auth/account-exists-with-different-credential/google",r.EMAIL_EXISTS="auth/email-already-exists",r.INVALID_ACTION_CODE="auth/invalid-action-code",r.POPUP_BLOCKED="auth/popup-blocked",r.POPUP_CLOSED_BY_USER="auth/popup-closed-by-user",r.USER_NOT_FOUND="auth/user-not-found",r.WRONG_PASSWORD="auth/wrong-password",r})({});var l=class r{static{u(this,"SmpFirebaseService")}static get INSTANCE(){if(!(this._instance instanceof r))throw Error(`${this.constructor.name} instance doesn't exist! Call ${this.constructor.name}.init first!`);return this._instance}static _instance;get config(){return this._config}get enabledSocials(){return this._enabledSocials}get loggedUser(){return this._loggedUser||(this._loggedUser=this._readStoredUser()),this._auth.currentUser||this._loggedUser||void 0}get providersRelation(){return{"facebook.com":n.FACEBOOK,"google.com":n.GOOGLE,"apple.com":n.APPLE}}get socialLoginUXMode(){return this._socialLoginUxMode}get storedUserKey(){return"firebaseUser"}get _auth(){return(0,t.getAuth)(this._app)}_app;_config;_enabledSocials=[];_loggedUser;_logger;_popupErrors=0;_popupFallsBackToRedirect;_providers;_socialLoginUxMode=a.POPUP;constructor(e,i){this._config=e,this._enabledSocials=i.enabledSocials||[],this._socialLoginUxMode=i.socialLoginUxMode||a.POPUP,this._popupFallsBackToRedirect=!!i.popupFallsBackToRedirect,this._buildProviders(),this._logger=i.logger||new g.SmpLoggerMethods,this._app=(0,h.getApps)().length?(0,h.getApps)()[0]:(0,h.initializeApp)(e),this._watchAuthState()}static init(e,i){return this._instance||(this._instance=new r(e,i)),this._instance}addAuthStateChangedCallback(e){return this._auth.onAuthStateChanged(i=>{e(i||this.loggedUser||null)})}checkActionCode(e){return(0,t.checkActionCode)(this._auth,e)}confirmPasswordReset(e,i){return(0,t.confirmPasswordReset)(this._auth,e,i)}fetchSignInMethodsForEmail(e){return(0,t.fetchSignInMethodsForEmail)(this._auth,e).then(i=>i.map(o=>this.providersRelation[o]||o))}getRedirectResult(){return(0,t.getRedirectResult)(this._auth).catch(async e=>(await this._expandDifferentCredential(e),Promise.reject(e)))}initAppCheck(){}sendEmailVerification(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return(0,t.sendEmailVerification)(this.loggedUser,e?{url:e}:void 0)}sendPasswordResetEmail(e,i){return(0,t.sendPasswordResetEmail)(this._auth,e,{url:i})}setPersistence(e){return(0,t.setPersistence)(this._auth,e?t.browserLocalPersistence:t.browserSessionPersistence)}signInWithCustomToken(e){return(0,t.signInWithCustomToken)(this._auth,e)}signInWithEmailAndPassword(e,i){return(0,t.signInWithEmailAndPassword)(this._auth,e,i).then(async o=>o.user)}signInWithSocialProvider(e){if(!this._providers[e])throw Error(`Firebase: invalid social key provided! Expected one of ${this.enabledSocials}, got ${e}`);return this._signInWithProvider(this._providers[e])}signOut(){return(0,t.signOut)(this._auth)}updatePassword(e,i){if(!this.loggedUser)throw Error("Firebase: user is not logged!");let o=t.EmailAuthProvider.credential(this.loggedUser.email,e);return(0,t.reauthenticateWithCredential)(this.loggedUser,o).then(()=>(0,t.updatePassword)(this.loggedUser,i))}updateUserProfile(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return(0,t.updateProfile)(this.loggedUser,e)}async verifyIdToken(){return this._auth.currentUser?.getIdTokenResult()}_buildProviders(){this._providers=this._enabledSocials.reduce((e,i)=>(i in e&&(e[i]=e[i]),e),{[n.APPLE]:new t.OAuthProvider("apple.com"),[n.FACEBOOK]:new t.FacebookAuthProvider().setCustomParameters({prompt:"select_account"}),[n.GOOGLE]:new t.GoogleAuthProvider().setCustomParameters({prompt:"select_account"})})}async _expandDifferentCredential(e){if(e?.code===c.DIFFERENT_CREDENTIAL){let i=await this.fetchSignInMethodsForEmail(e.customData.email);throw e.code=c["DIFFERENT_CREDENTIAL_"+i[0]],e}}_readStoredUser(){try{let e=localStorage.getItem(this.storedUserKey);if(e){this._logger?.debug("Firebase: found local user",e);let i=JSON.parse(e);return{...i,getIdToken:u(()=>Promise.resolve(i.stsTokenManager.accessToken),"getIdToken")}}}catch(e){this._logger.debug("Firebase: error while getting stored user",e)}}async _signInWithProvider(e,i=this.socialLoginUXMode){return(i===a.POPUP?t.signInWithPopup:t.signInWithRedirect)(this._auth,e).then(s=>(this._logger.info(`Firebase: signin with provider ${e.providerId} was successful`),s.user)).catch(async s=>s?.code===c.POPUP_BLOCKED&&(this._logger.warn(`Firebase: social signin popup blocked (${++this._popupErrors}`),this._popupFallsBackToRedirect&&this._popupErrors>1)?(this._popupErrors=0,this._signInWithProvider(e,a.REDIRECT)):(this._logger.error(`Firebase: sign in with ${e.providerId} errored`,s),await this._expandDifferentCredential(s),Promise.reject(s)))}_updateLocalUser(e){try{e?localStorage.setItem(this.storedUserKey,JSON.stringify(e)):localStorage.removeItem(this.storedUserKey),this._logger.debug("Firebase: updating local user",e),this._loggedUser=e}catch(i){this._logger.warn("Firebase: couldn't update local user",{user:e,error:i})}}_watchAuthState(){this._auth.onAuthStateChanged(e=>{this._logger.debug("Firebase: firebase detected auth state change",e),this._updateLocalUser(e||void 0)})}};0&&(module.exports={SmpFirebaseService});
1
+ "use strict";var c=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var u=(r,e)=>c(r,"name",{value:e,configurable:!0});var P=(r,e)=>{for(var i in e)c(r,i,{get:e[i],enumerable:!0})},f=(r,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!E.call(r,s)&&s!==i&&c(r,s,{get:()=>e[s],enumerable:!(o=_(e,s))||o.enumerable});return r};var U=r=>f(c({},"__esModule",{value:!0}),r);var m={};P(m,{SmpFirebaseErrors:()=>h,SmpFirebaseService:()=>l});module.exports=U(m);var g=require("@tonysamperi/logger"),d=require("firebase/app"),t=require("firebase/auth");var n=(function(r){return r.APPLE="APPLE",r.FACEBOOK="FACEBOOK",r.GOOGLE="GOOGLE",r})({});var a=(function(r){return r.POPUP="POPUP",r.REDIRECT="REDIRECT",r})({});var h=(function(r){return r.DIFFERENT_CREDENTIAL="auth/account-exists-with-different-credential",r.DIFFERENT_CREDENTIAL_APPLE="auth/account-exists-with-different-credential/apple",r.DIFFERENT_CREDENTIAL_FACEBOOK="auth/account-exists-with-different-credential/facebook",r.DIFFERENT_CREDENTIAL_GOOGLE="auth/account-exists-with-different-credential/google",r.EMAIL_EXISTS="auth/email-already-exists",r.INVALID_ACTION_CODE="auth/invalid-action-code",r.POPUP_BLOCKED="auth/popup-blocked",r.POPUP_CLOSED_BY_USER="auth/popup-closed-by-user",r.USER_NOT_FOUND="auth/user-not-found",r.WRONG_PASSWORD="auth/wrong-password",r})({});var l=class r{static{u(this,"SmpFirebaseService")}static get INSTANCE(){if(!(this._instance instanceof r))throw Error(`${this.constructor.name} instance doesn't exist! Call ${this.constructor.name}.init first!`);return this._instance}static _instance;get config(){return this._config}get enabledSocials(){return this._enabledSocials}get loggedUser(){return this._loggedUser||(this._loggedUser=this._readStoredUser()),this._auth.currentUser||this._loggedUser||void 0}get providersRelation(){return{"facebook.com":n.FACEBOOK,"google.com":n.GOOGLE,"apple.com":n.APPLE}}get socialLoginUXMode(){return this._socialLoginUxMode}get storedUserKey(){return"firebaseUser"}get _auth(){return(0,t.getAuth)(this._app)}_app;_config;_enabledSocials=[];_loggedUser;_logger;_popupErrors=0;_popupFallsBackToRedirect;_providers;_socialLoginUxMode=a.POPUP;constructor(e,i){this._config=e,this._enabledSocials=i.enabledSocials||[],this._socialLoginUxMode=i.socialLoginUxMode||a.POPUP,this._popupFallsBackToRedirect=!!i.popupFallsBackToRedirect,this._buildProviders(),this._logger=i.logger||new g.SmpLoggerMethods,this._app=(0,d.getApps)().length?(0,d.getApps)()[0]:(0,d.initializeApp)(e),this._watchAuthState()}static init(e,i){return this._instance||(this._instance=new r(e,i)),this._instance}addAuthStateChangedCallback(e){return this._auth.onAuthStateChanged(i=>{e(i||this.loggedUser||null)})}checkActionCode(e){return(0,t.checkActionCode)(this._auth,e)}confirmPasswordReset(e,i){return(0,t.confirmPasswordReset)(this._auth,e,i)}fetchSignInMethodsForEmail(e){return(0,t.fetchSignInMethodsForEmail)(this._auth,e).then(i=>i.map(o=>this.providersRelation[o]||o))}getRedirectResult(){return(0,t.getRedirectResult)(this._auth).catch(async e=>(await this._expandDifferentCredential(e),Promise.reject(e)))}initAppCheck(){}sendEmailVerification(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return(0,t.sendEmailVerification)(this.loggedUser,e?{url:e}:void 0)}sendPasswordResetEmail(e,i){return(0,t.sendPasswordResetEmail)(this._auth,e,{url:i})}setPersistence(e){return(0,t.setPersistence)(this._auth,e?t.browserLocalPersistence:t.browserSessionPersistence)}signInWithCustomToken(e){return(0,t.signInWithCustomToken)(this._auth,e)}signInWithEmailAndPassword(e,i){return(0,t.signInWithEmailAndPassword)(this._auth,e,i).then(async o=>o.user)}signInWithSocialProvider(e){if(!this._providers[e])throw Error(`Firebase: invalid social key provided! Expected one of ${this.enabledSocials}, got ${e}`);return this._signInWithProvider(this._providers[e])}signOut(){return(0,t.signOut)(this._auth)}updatePassword(e,i){if(!this.loggedUser)throw Error("Firebase: user is not logged!");let o=t.EmailAuthProvider.credential(this.loggedUser.email,e);return(0,t.reauthenticateWithCredential)(this.loggedUser,o).then(()=>(0,t.updatePassword)(this.loggedUser,i))}updateUserProfile(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return(0,t.updateProfile)(this.loggedUser,e)}async verifyIdToken(){return this._auth.currentUser?.getIdTokenResult()}_buildProviders(){this._providers=this._enabledSocials.reduce((e,i)=>(i in e&&(e[i]=e[i]),e),{[n.APPLE]:new t.OAuthProvider("apple.com"),[n.FACEBOOK]:new t.FacebookAuthProvider().setCustomParameters({prompt:"select_account"}),[n.GOOGLE]:new t.GoogleAuthProvider().setCustomParameters({prompt:"select_account"})})}async _expandDifferentCredential(e){if(e?.code===h.DIFFERENT_CREDENTIAL){let i=await this.fetchSignInMethodsForEmail(e.customData.email);throw e.code=h["DIFFERENT_CREDENTIAL_"+i[0]],e}}_readStoredUser(){try{let e=localStorage.getItem(this.storedUserKey);if(e){this._logger?.debug("Firebase: found local user",e);let i=JSON.parse(e);return{...i,getIdToken:u(()=>Promise.resolve(i.stsTokenManager.accessToken),"getIdToken")}}}catch(e){this._logger.debug("Firebase: error while getting stored user",e)}}async _signInWithProvider(e,i=this.socialLoginUXMode){return(i===a.POPUP?t.signInWithPopup:t.signInWithRedirect)(this._auth,e).then(s=>(this._logger.info(`Firebase: signin with provider ${e.providerId} was successful`),s.user)).catch(async s=>s?.code===h.POPUP_BLOCKED&&(this._logger.warn(`Firebase: social signin popup blocked (${++this._popupErrors}`),this._popupFallsBackToRedirect&&this._popupErrors>1)?(this._popupErrors=0,this._signInWithProvider(e,a.REDIRECT)):(this._logger.error(`Firebase: sign in with ${e.providerId} errored`,s),await this._expandDifferentCredential(s),Promise.reject(s)))}_updateLocalUser(e){try{e?localStorage.setItem(this.storedUserKey,JSON.stringify(e)):localStorage.removeItem(this.storedUserKey),this._logger.debug("Firebase: updating local user",e),this._loggedUser=e}catch(i){this._logger.debug("Firebase: couldn't update local user",{user:e,error:i})}}_watchAuthState(){this._auth.onAuthStateChanged(e=>{this._logger.debug("Firebase: firebase detected auth state change",e),this._updateLocalUser(e||void 0)})}};0&&(module.exports={SmpFirebaseErrors,SmpFirebaseService});
2
2
  //# sourceMappingURL=firebase.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/firebase.ts","../../src/services/firebase/smp-firebase.service.ts","../../src/shared/common/smp-social-sign-in-keys.enum.ts","../../src/shared/common/smp-social-sign-in-ux-modes.enum.ts","../../src/shared/firebase/smp-firebase-errors.enum.ts"],"sourcesContent":["export * from \"./services/firebase/index.js\";\n","import {SmpLoggerMethods} from \"@tonysamperi/logger\";\nimport {FirebaseApp, FirebaseOptions, getApps, initializeApp} from \"firebase/app\";\nimport {\n ActionCodeInfo,\n Auth,\n AuthProvider,\n browserLocalPersistence,\n browserSessionPersistence,\n EmailAuthProvider,\n FacebookAuthProvider,\n GoogleAuthProvider,\n IdTokenResult,\n OAuthProvider,\n User,\n UserCredential,\n //\n checkActionCode,\n confirmPasswordReset,\n fetchSignInMethodsForEmail,\n getAuth,\n getRedirectResult,\n reauthenticateWithCredential,\n sendEmailVerification,\n sendPasswordResetEmail,\n setPersistence,\n signInWithCustomToken,\n signInWithEmailAndPassword,\n signInWithPopup,\n signInWithRedirect,\n signOut,\n updatePassword,\n updateProfile\n} from \"firebase/auth\";\n//\nimport {SmpSocialSignInKeys} from \"../../shared/common/smp-social-sign-in-keys.enum.js\";\nimport {SmpSocialSignInUxModes} from \"../../shared/common/smp-social-sign-in-ux-modes.enum.js\";\nimport {SmpFirebaseErrors} from \"../../shared/firebase/smp-firebase-errors.enum.js\";\nimport {SmpFirebaseServiceConfig} from \"./smp-firebase-service-config.interface.js\";\n\nexport class SmpFirebaseService {\n\n static get INSTANCE(): SmpFirebaseService {\n if (!(this._instance instanceof SmpFirebaseService)) {\n throw Error(`${this.constructor.name} instance doesn't exist! Call ${this.constructor.name}.init first!`);\n }\n\n return this._instance;\n }\n\n protected static _instance?: SmpFirebaseService;\n\n get config(): FirebaseOptions {\n return this._config;\n }\n\n get enabledSocials(): SmpSocialSignInKeys[] {\n return this._enabledSocials;\n }\n\n get loggedUser(): User | void {\n if (!this._loggedUser) {\n this._loggedUser = this._readStoredUser();\n }\n\n return this._auth.currentUser || this._loggedUser || void 0;\n }\n\n get providersRelation(): Record<string, SmpSocialSignInKeys> {\n return {\n \"facebook.com\": SmpSocialSignInKeys.FACEBOOK,\n \"google.com\": SmpSocialSignInKeys.GOOGLE,\n \"apple.com\": SmpSocialSignInKeys.APPLE\n };\n }\n\n get socialLoginUXMode(): SmpSocialSignInUxModes {\n return this._socialLoginUxMode;\n }\n\n get storedUserKey(): string {\n return \"firebaseUser\";\n }\n\n protected get _auth(): Auth {\n return getAuth(this._app);\n }\n\n\n protected readonly _app: FirebaseApp;\n // protected _appCheck?: AppCheck;\n // protected readonly _auth;\n protected readonly _config: FirebaseOptions;\n protected readonly _enabledSocials: SmpSocialSignInKeys[] = [];\n protected _loggedUser?: User | void;\n protected _logger: SmpLoggerMethods;\n protected _popupErrors: number = 0;\n protected _popupFallsBackToRedirect: boolean;\n protected _providers: Record<SmpSocialSignInKeys, AuthProvider>;\n protected _socialLoginUxMode: SmpSocialSignInUxModes = SmpSocialSignInUxModes.POPUP;\n\n constructor(firebaseOptions: FirebaseOptions, config: SmpFirebaseServiceConfig) {\n this._config = firebaseOptions;\n this._enabledSocials = config.enabledSocials || [];\n this._socialLoginUxMode = config.socialLoginUxMode || SmpSocialSignInUxModes.POPUP;\n this._popupFallsBackToRedirect = !!config.popupFallsBackToRedirect;\n this._buildProviders();\n this._logger = config.logger || new SmpLoggerMethods();\n this._app = getApps().length ? getApps()[0] : initializeApp(firebaseOptions);\n // TODO: see how we can activate this\n // this.initAppCheck();\n this._watchAuthState();\n }\n\n // Static\n\n static init(firebaseOptions: FirebaseOptions, config: SmpFirebaseServiceConfig): SmpFirebaseService {\n if (!this._instance) {\n this._instance = new SmpFirebaseService(firebaseOptions, config);\n }\n\n return this._instance;\n }\n\n // Public\n\n addAuthStateChangedCallback(cb: (userOrNull: User | null) => void): () => void {\n return this._auth.onAuthStateChanged((userOrNull: User | null) => {\n cb(userOrNull || this.loggedUser || null);\n });\n }\n\n checkActionCode(code: string): Promise<ActionCodeInfo> {\n return checkActionCode(this._auth, code);\n }\n\n confirmPasswordReset(code: string, newPassword: string): Promise<void> {\n return confirmPasswordReset(this._auth, code, newPassword);\n }\n\n fetchSignInMethodsForEmail(email: string): Promise<SmpSocialSignInKeys[] | \"password\"> {\n return fetchSignInMethodsForEmail(this._auth, email).then((list: string[]) =>\n list.map((method: string) => this.providersRelation[method] || method)\n );\n }\n\n getRedirectResult() {\n return getRedirectResult(this._auth).catch(async (err: any) => {\n await this._expandDifferentCredential(err);\n\n return Promise.reject(err);\n });\n }\n\n // Made public to see if we can call this from a useEffect or something\n initAppCheck(): void {\n // this._appCheck = initializeAppCheck(this._app, {\n // provider: new ReCaptchaV3Provider(process.env.NEXT_PUBLIC_RECAPTCHA_KEY as string),\n // isTokenAutoRefreshEnabled: true\n // } as AppCheckOptions);\n }\n\n sendEmailVerification(url?: string): Promise<void> | never {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n\n return sendEmailVerification(this.loggedUser, url ? {url} : void 0);\n }\n\n sendPasswordResetEmail(email: string, continueUrl: string): Promise<void> {\n return sendPasswordResetEmail(this._auth, email, {\n url: continueUrl\n });\n }\n\n setPersistence(rememberMe: boolean): Promise<void> {\n return setPersistence(this._auth, rememberMe ? browserLocalPersistence : browserSessionPersistence);\n }\n\n signInWithCustomToken(customToken: string): Promise<UserCredential> {\n return signInWithCustomToken(this._auth, customToken);\n }\n\n signInWithEmailAndPassword(email: string, password: string): Promise<User> {\n return signInWithEmailAndPassword(this._auth, email, password).then(async (userCredential) => userCredential.user);\n }\n\n signInWithSocialProvider(key: SmpSocialSignInKeys): Promise<User | void> {\n if (!this._providers[key]) {\n throw Error(`Firebase: invalid social key provided! Expected one of ${this.enabledSocials}, got ${key}`);\n }\n\n return this._signInWithProvider(this._providers[key]!);\n }\n\n signOut(): Promise<void> {\n return signOut(this._auth);\n }\n\n updatePassword(oldPassword: string, newPassword: string) {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n const credentials = EmailAuthProvider.credential(this.loggedUser.email!, oldPassword);\n\n return reauthenticateWithCredential(this.loggedUser, credentials).then(() =>\n updatePassword(this.loggedUser!, newPassword)\n );\n }\n\n updateUserProfile(params: { displayName?: string | null; photoURL?: string | null }): Promise<void> {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n\n return updateProfile(this.loggedUser, params);\n }\n\n async verifyIdToken(): Promise<IdTokenResult | void> {\n return this._auth.currentUser?.getIdTokenResult();\n }\n\n // protected\n\n protected _buildProviders(): void {\n this._providers = this._enabledSocials.reduce((acc, key) => {\n if (key in acc) {\n // eslint-disable-next-line no-self-assign\n acc[key] = acc[key];\n }\n return acc;\n }, {\n [SmpSocialSignInKeys.APPLE]: new OAuthProvider(\"apple.com\"),\n [SmpSocialSignInKeys.FACEBOOK]: new FacebookAuthProvider().setCustomParameters({\n prompt: \"select_account\"\n }),\n [SmpSocialSignInKeys.GOOGLE]: new GoogleAuthProvider().setCustomParameters({\n prompt: \"select_account\"\n })\n } as Record<SmpSocialSignInKeys, OAuthProvider>);\n }\n\n protected async _expandDifferentCredential(err: any): Promise<void> {\n if (err?.code === SmpFirebaseErrors.DIFFERENT_CREDENTIAL) {\n const preferredCredentials = await this.fetchSignInMethodsForEmail(err.customData.email);\n err.code = SmpFirebaseErrors[(\"DIFFERENT_CREDENTIAL_\" + preferredCredentials[0]) as keyof typeof SmpFirebaseErrors];\n\n throw err;\n }\n }\n\n protected _readStoredUser(): User | void {\n try {\n const storedUser = localStorage.getItem(this.storedUserKey);\n if (!!storedUser) {\n this._logger?.debug(\"Firebase: found local user\", storedUser);\n const parsedUser = JSON.parse(storedUser);\n\n return {\n ...parsedUser,\n getIdToken: () => Promise.resolve(parsedUser.stsTokenManager.accessToken)\n };\n }\n }\n catch (e: any) {\n this._logger.debug(\"Firebase: error while getting stored user\", e);\n }\n\n return;\n }\n\n protected async _signInWithProvider<T extends AuthProvider = AuthProvider>(\n provider: T,\n uxMode: SmpSocialSignInUxModes = this.socialLoginUXMode\n ): Promise<User | void> {\n const method = uxMode === SmpSocialSignInUxModes.POPUP ? signInWithPopup : signInWithRedirect;\n\n return method(this._auth, provider)\n .then((userCredential: UserCredential) => {\n this._logger.info(`Firebase: signin with provider ${provider.providerId} was successful`);\n\n return userCredential.user;\n })\n .catch(async (err: any) => {\n if (err?.code === SmpFirebaseErrors.POPUP_BLOCKED) {\n this._logger.warn(`Firebase: social signin popup blocked (${++this._popupErrors}`);\n if (this._popupFallsBackToRedirect && this._popupErrors > 1) {\n this._popupErrors = 0; // Cooldown\n return this._signInWithProvider(provider, SmpSocialSignInUxModes.REDIRECT);\n }\n }\n this._logger.error(`Firebase: sign in with ${provider.providerId} errored`, err);\n await this._expandDifferentCredential(err);\n\n return Promise.reject(err);\n });\n }\n\n protected _updateLocalUser(user: User | void): void {\n try {\n if (user) {\n localStorage.setItem(this.storedUserKey, JSON.stringify(user));\n }\n else {\n localStorage.removeItem(this.storedUserKey);\n }\n this._logger.debug(\"Firebase: updating local user\", user);\n this._loggedUser = user;\n }\n catch (error) {\n this._logger.warn(\"Firebase: couldn't update local user\", {\n user,\n error\n });\n }\n }\n\n protected _watchAuthState(): void {\n this._auth.onAuthStateChanged((user: User | null) => {\n this._logger.debug(\"Firebase: firebase detected auth state change\", user);\n this._updateLocalUser(user || void 0);\n });\n }\n}\n","export enum SmpSocialSignInKeys {\n APPLE = \"APPLE\",\n FACEBOOK = \"FACEBOOK\",\n GOOGLE = \"GOOGLE\",\n}\n","export enum SmpSocialSignInUxModes {\n POPUP = \"POPUP\",\n REDIRECT = \"REDIRECT\",\n}\n","export enum SmpFirebaseErrors {\n DIFFERENT_CREDENTIAL = \"auth/account-exists-with-different-credential\",\n // DIFFERENT_CREDENTIALS_{SmpSocialSignInKeys}: dynamic key for social provider error\n DIFFERENT_CREDENTIAL_APPLE = \"auth/account-exists-with-different-credential/apple\",\n DIFFERENT_CREDENTIAL_FACEBOOK = \"auth/account-exists-with-different-credential/facebook\",\n DIFFERENT_CREDENTIAL_GOOGLE = \"auth/account-exists-with-different-credential/google\",\n EMAIL_EXISTS = \"auth/email-already-exists\",\n INVALID_ACTION_CODE = \"auth/invalid-action-code\",\n POPUP_BLOCKED = \"auth/popup-blocked\",\n POPUP_CLOSED_BY_USER = \"auth/popup-closed-by-user\",\n USER_NOT_FOUND = \"auth/user-not-found\",\n WRONG_PASSWORD = \"auth/wrong-password\",\n}\n"],"mappings":"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","names":["firebase_exports","__export","SmpFirebaseService","__toCommonJS","import_logger","import_app","import_auth","SmpSocialSignInKeys","SmpSocialSignInUxModes","SmpFirebaseErrors","SmpFirebaseService","INSTANCE","_instance","Error","name","config","_config","enabledSocials","_enabledSocials","loggedUser","_loggedUser","_readStoredUser","_auth","currentUser","providersRelation","SmpSocialSignInKeys","FACEBOOK","GOOGLE","APPLE","socialLoginUXMode","_socialLoginUxMode","storedUserKey","getAuth","_app","_logger","_popupErrors","_popupFallsBackToRedirect","_providers","SmpSocialSignInUxModes","POPUP","firebaseOptions","socialLoginUxMode","popupFallsBackToRedirect","_buildProviders","logger","SmpLoggerMethods","getApps","length","initializeApp","_watchAuthState","init","addAuthStateChangedCallback","cb","onAuthStateChanged","userOrNull","checkActionCode","code","confirmPasswordReset","newPassword","fetchSignInMethodsForEmail","email","then","list","map","method","getRedirectResult","catch","err","_expandDifferentCredential","Promise","reject","initAppCheck","sendEmailVerification","url","sendPasswordResetEmail","continueUrl","setPersistence","rememberMe","browserLocalPersistence","browserSessionPersistence","signInWithCustomToken","customToken","signInWithEmailAndPassword","password","userCredential","user","signInWithSocialProvider","key","_signInWithProvider","signOut","updatePassword","oldPassword","credentials","EmailAuthProvider","credential","reauthenticateWithCredential","updateUserProfile","params","updateProfile","verifyIdToken","getIdTokenResult","reduce","acc","OAuthProvider","FacebookAuthProvider","setCustomParameters","prompt","GoogleAuthProvider","SmpFirebaseErrors","DIFFERENT_CREDENTIAL","preferredCredentials","customData","storedUser","localStorage","getItem","debug","parsedUser","JSON","parse","getIdToken","__name","resolve","stsTokenManager","accessToken","e","provider","uxMode","signInWithPopup","signInWithRedirect","info","providerId","POPUP_BLOCKED","warn","REDIRECT","error","_updateLocalUser","setItem","stringify","removeItem"]}
1
+ {"version":3,"sources":["../../src/firebase.ts","../../src/services/firebase/smp-firebase.service.ts","../../src/shared/common/smp-social-sign-in-keys.enum.ts","../../src/shared/common/smp-social-sign-in-ux-modes.enum.ts","../../src/shared/firebase/smp-firebase-errors.enum.ts"],"sourcesContent":["export * from \"./services/firebase/index.js\";\nexport * from \"./shared/firebase/index.js\";\n","import {SmpLoggerMethods} from \"@tonysamperi/logger\";\nimport {FirebaseApp, FirebaseOptions, getApps, initializeApp} from \"firebase/app\";\nimport {\n ActionCodeInfo,\n Auth,\n AuthProvider,\n browserLocalPersistence,\n browserSessionPersistence,\n EmailAuthProvider,\n FacebookAuthProvider,\n GoogleAuthProvider,\n IdTokenResult,\n OAuthProvider,\n User,\n UserCredential,\n //\n checkActionCode,\n confirmPasswordReset,\n fetchSignInMethodsForEmail,\n getAuth,\n getRedirectResult,\n reauthenticateWithCredential,\n sendEmailVerification,\n sendPasswordResetEmail,\n setPersistence,\n signInWithCustomToken,\n signInWithEmailAndPassword,\n signInWithPopup,\n signInWithRedirect,\n signOut,\n updatePassword,\n updateProfile\n} from \"firebase/auth\";\n//\nimport {SmpSocialSignInKeys} from \"../../shared/common/smp-social-sign-in-keys.enum.js\";\nimport {SmpSocialSignInUxModes} from \"../../shared/common/smp-social-sign-in-ux-modes.enum.js\";\nimport {SmpFirebaseErrors} from \"../../shared/firebase/smp-firebase-errors.enum.js\";\nimport {SmpFirebaseServiceConfig} from \"./smp-firebase-service-config.interface.js\";\n\nexport class SmpFirebaseService {\n\n static get INSTANCE(): SmpFirebaseService {\n if (!(this._instance instanceof SmpFirebaseService)) {\n throw Error(`${this.constructor.name} instance doesn't exist! Call ${this.constructor.name}.init first!`);\n }\n\n return this._instance;\n }\n\n protected static _instance?: SmpFirebaseService;\n\n get config(): FirebaseOptions {\n return this._config;\n }\n\n get enabledSocials(): SmpSocialSignInKeys[] {\n return this._enabledSocials;\n }\n\n get loggedUser(): User | void {\n if (!this._loggedUser) {\n this._loggedUser = this._readStoredUser();\n }\n\n return this._auth.currentUser || this._loggedUser || void 0;\n }\n\n get providersRelation(): Record<string, SmpSocialSignInKeys> {\n return {\n \"facebook.com\": SmpSocialSignInKeys.FACEBOOK,\n \"google.com\": SmpSocialSignInKeys.GOOGLE,\n \"apple.com\": SmpSocialSignInKeys.APPLE\n };\n }\n\n get socialLoginUXMode(): SmpSocialSignInUxModes {\n return this._socialLoginUxMode;\n }\n\n get storedUserKey(): string {\n return \"firebaseUser\";\n }\n\n protected get _auth(): Auth {\n return getAuth(this._app);\n }\n\n\n protected readonly _app: FirebaseApp;\n // protected _appCheck?: AppCheck;\n // protected readonly _auth;\n protected readonly _config: FirebaseOptions;\n protected readonly _enabledSocials: SmpSocialSignInKeys[] = [];\n protected _loggedUser?: User | void;\n protected _logger: SmpLoggerMethods;\n protected _popupErrors: number = 0;\n protected _popupFallsBackToRedirect: boolean;\n protected _providers: Record<SmpSocialSignInKeys, AuthProvider>;\n protected _socialLoginUxMode: SmpSocialSignInUxModes = SmpSocialSignInUxModes.POPUP;\n\n constructor(firebaseOptions: FirebaseOptions, config: SmpFirebaseServiceConfig) {\n this._config = firebaseOptions;\n this._enabledSocials = config.enabledSocials || [];\n this._socialLoginUxMode = config.socialLoginUxMode || SmpSocialSignInUxModes.POPUP;\n this._popupFallsBackToRedirect = !!config.popupFallsBackToRedirect;\n this._buildProviders();\n this._logger = config.logger || new SmpLoggerMethods();\n this._app = getApps().length ? getApps()[0] : initializeApp(firebaseOptions);\n // TODO: see how we can activate this\n // this.initAppCheck();\n this._watchAuthState();\n }\n\n // Static\n\n static init(firebaseOptions: FirebaseOptions, config: SmpFirebaseServiceConfig): SmpFirebaseService {\n if (!this._instance) {\n this._instance = new SmpFirebaseService(firebaseOptions, config);\n }\n\n return this._instance;\n }\n\n // Public\n\n addAuthStateChangedCallback(cb: (userOrNull: User | null) => void): () => void {\n return this._auth.onAuthStateChanged((userOrNull: User | null) => {\n cb(userOrNull || this.loggedUser || null);\n });\n }\n\n checkActionCode(code: string): Promise<ActionCodeInfo> {\n return checkActionCode(this._auth, code);\n }\n\n confirmPasswordReset(code: string, newPassword: string): Promise<void> {\n return confirmPasswordReset(this._auth, code, newPassword);\n }\n\n fetchSignInMethodsForEmail(email: string): Promise<SmpSocialSignInKeys[] | \"password\"> {\n return fetchSignInMethodsForEmail(this._auth, email).then((list: string[]) =>\n list.map((method: string) => this.providersRelation[method] || method)\n );\n }\n\n getRedirectResult() {\n return getRedirectResult(this._auth).catch(async (err: any) => {\n await this._expandDifferentCredential(err);\n\n return Promise.reject(err);\n });\n }\n\n // Made public to see if we can call this from a useEffect or something\n initAppCheck(): void {\n // this._appCheck = initializeAppCheck(this._app, {\n // provider: new ReCaptchaV3Provider(process.env.NEXT_PUBLIC_RECAPTCHA_KEY as string),\n // isTokenAutoRefreshEnabled: true\n // } as AppCheckOptions);\n }\n\n sendEmailVerification(url?: string): Promise<void> | never {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n\n return sendEmailVerification(this.loggedUser, url ? {url} : void 0);\n }\n\n sendPasswordResetEmail(email: string, continueUrl: string): Promise<void> {\n return sendPasswordResetEmail(this._auth, email, {\n url: continueUrl\n });\n }\n\n setPersistence(rememberMe: boolean): Promise<void> {\n return setPersistence(this._auth, rememberMe ? browserLocalPersistence : browserSessionPersistence);\n }\n\n signInWithCustomToken(customToken: string): Promise<UserCredential> {\n return signInWithCustomToken(this._auth, customToken);\n }\n\n signInWithEmailAndPassword(email: string, password: string): Promise<User> {\n return signInWithEmailAndPassword(this._auth, email, password).then(async (userCredential) => userCredential.user);\n }\n\n signInWithSocialProvider(key: SmpSocialSignInKeys): Promise<User | void> {\n if (!this._providers[key]) {\n throw Error(`Firebase: invalid social key provided! Expected one of ${this.enabledSocials}, got ${key}`);\n }\n\n return this._signInWithProvider(this._providers[key]!);\n }\n\n signOut(): Promise<void> {\n return signOut(this._auth);\n }\n\n updatePassword(oldPassword: string, newPassword: string) {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n const credentials = EmailAuthProvider.credential(this.loggedUser.email!, oldPassword);\n\n return reauthenticateWithCredential(this.loggedUser, credentials).then(() =>\n updatePassword(this.loggedUser!, newPassword)\n );\n }\n\n updateUserProfile(params: { displayName?: string | null; photoURL?: string | null }): Promise<void> {\n if (!this.loggedUser) {\n throw Error(\"Firebase: user is not logged!\");\n }\n\n return updateProfile(this.loggedUser, params);\n }\n\n async verifyIdToken(): Promise<IdTokenResult | void> {\n return this._auth.currentUser?.getIdTokenResult();\n }\n\n // protected\n\n protected _buildProviders(): void {\n this._providers = this._enabledSocials.reduce((acc, key) => {\n if (key in acc) {\n // eslint-disable-next-line no-self-assign\n acc[key] = acc[key];\n }\n return acc;\n }, {\n [SmpSocialSignInKeys.APPLE]: new OAuthProvider(\"apple.com\"),\n [SmpSocialSignInKeys.FACEBOOK]: new FacebookAuthProvider().setCustomParameters({\n prompt: \"select_account\"\n }),\n [SmpSocialSignInKeys.GOOGLE]: new GoogleAuthProvider().setCustomParameters({\n prompt: \"select_account\"\n })\n } as Record<SmpSocialSignInKeys, OAuthProvider>);\n }\n\n protected async _expandDifferentCredential(err: any): Promise<void> {\n if (err?.code === SmpFirebaseErrors.DIFFERENT_CREDENTIAL) {\n const preferredCredentials = await this.fetchSignInMethodsForEmail(err.customData.email);\n err.code = SmpFirebaseErrors[(\"DIFFERENT_CREDENTIAL_\" + preferredCredentials[0]) as keyof typeof SmpFirebaseErrors];\n\n throw err;\n }\n }\n\n protected _readStoredUser(): User | void {\n try {\n const storedUser = localStorage.getItem(this.storedUserKey);\n if (!!storedUser) {\n this._logger?.debug(\"Firebase: found local user\", storedUser);\n const parsedUser = JSON.parse(storedUser);\n\n return {\n ...parsedUser,\n getIdToken: () => Promise.resolve(parsedUser.stsTokenManager.accessToken)\n };\n }\n }\n catch (e: any) {\n this._logger.debug(\"Firebase: error while getting stored user\", e);\n }\n\n return;\n }\n\n protected async _signInWithProvider<T extends AuthProvider = AuthProvider>(\n provider: T,\n uxMode: SmpSocialSignInUxModes = this.socialLoginUXMode\n ): Promise<User | void> {\n const method = uxMode === SmpSocialSignInUxModes.POPUP ? signInWithPopup : signInWithRedirect;\n\n return method(this._auth, provider)\n .then((userCredential: UserCredential) => {\n this._logger.info(`Firebase: signin with provider ${provider.providerId} was successful`);\n\n return userCredential.user;\n })\n .catch(async (err: any) => {\n if (err?.code === SmpFirebaseErrors.POPUP_BLOCKED) {\n this._logger.warn(`Firebase: social signin popup blocked (${++this._popupErrors}`);\n if (this._popupFallsBackToRedirect && this._popupErrors > 1) {\n this._popupErrors = 0; // Cooldown\n return this._signInWithProvider(provider, SmpSocialSignInUxModes.REDIRECT);\n }\n }\n this._logger.error(`Firebase: sign in with ${provider.providerId} errored`, err);\n await this._expandDifferentCredential(err);\n\n return Promise.reject(err);\n });\n }\n\n protected _updateLocalUser(user: User | void): void {\n try {\n if (user) {\n localStorage.setItem(this.storedUserKey, JSON.stringify(user));\n }\n else {\n localStorage.removeItem(this.storedUserKey);\n }\n this._logger.debug(\"Firebase: updating local user\", user);\n this._loggedUser = user;\n }\n catch (error) {\n this._logger.debug(\"Firebase: couldn't update local user\", {\n user,\n error\n });\n }\n }\n\n protected _watchAuthState(): void {\n this._auth.onAuthStateChanged((user: User | null) => {\n this._logger.debug(\"Firebase: firebase detected auth state change\", user);\n this._updateLocalUser(user || void 0);\n });\n }\n}\n","export enum SmpSocialSignInKeys {\n APPLE = \"APPLE\",\n FACEBOOK = \"FACEBOOK\",\n GOOGLE = \"GOOGLE\",\n}\n","export enum SmpSocialSignInUxModes {\n POPUP = \"POPUP\",\n REDIRECT = \"REDIRECT\",\n}\n","export enum SmpFirebaseErrors {\n DIFFERENT_CREDENTIAL = \"auth/account-exists-with-different-credential\",\n // DIFFERENT_CREDENTIALS_{SmpSocialSignInKeys}: dynamic key for social provider error\n DIFFERENT_CREDENTIAL_APPLE = \"auth/account-exists-with-different-credential/apple\",\n DIFFERENT_CREDENTIAL_FACEBOOK = \"auth/account-exists-with-different-credential/facebook\",\n DIFFERENT_CREDENTIAL_GOOGLE = \"auth/account-exists-with-different-credential/google\",\n EMAIL_EXISTS = \"auth/email-already-exists\",\n INVALID_ACTION_CODE = \"auth/invalid-action-code\",\n POPUP_BLOCKED = \"auth/popup-blocked\",\n POPUP_CLOSED_BY_USER = \"auth/popup-closed-by-user\",\n USER_NOT_FOUND = \"auth/user-not-found\",\n WRONG_PASSWORD = \"auth/wrong-password\",\n}\n"],"mappings":"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","names":["firebase_exports","__export","SmpFirebaseErrors","SmpFirebaseService","__toCommonJS","import_logger","import_app","import_auth","SmpSocialSignInKeys","SmpSocialSignInUxModes","SmpFirebaseErrors","SmpFirebaseService","INSTANCE","_instance","Error","name","config","_config","enabledSocials","_enabledSocials","loggedUser","_loggedUser","_readStoredUser","_auth","currentUser","providersRelation","SmpSocialSignInKeys","FACEBOOK","GOOGLE","APPLE","socialLoginUXMode","_socialLoginUxMode","storedUserKey","getAuth","_app","_logger","_popupErrors","_popupFallsBackToRedirect","_providers","SmpSocialSignInUxModes","POPUP","firebaseOptions","socialLoginUxMode","popupFallsBackToRedirect","_buildProviders","logger","SmpLoggerMethods","getApps","length","initializeApp","_watchAuthState","init","addAuthStateChangedCallback","cb","onAuthStateChanged","userOrNull","checkActionCode","code","confirmPasswordReset","newPassword","fetchSignInMethodsForEmail","email","then","list","map","method","getRedirectResult","catch","err","_expandDifferentCredential","Promise","reject","initAppCheck","sendEmailVerification","url","sendPasswordResetEmail","continueUrl","setPersistence","rememberMe","browserLocalPersistence","browserSessionPersistence","signInWithCustomToken","customToken","signInWithEmailAndPassword","password","userCredential","user","signInWithSocialProvider","key","_signInWithProvider","signOut","updatePassword","oldPassword","credentials","EmailAuthProvider","credential","reauthenticateWithCredential","updateUserProfile","params","updateProfile","verifyIdToken","getIdTokenResult","reduce","acc","OAuthProvider","FacebookAuthProvider","setCustomParameters","prompt","GoogleAuthProvider","SmpFirebaseErrors","DIFFERENT_CREDENTIAL","preferredCredentials","customData","storedUser","localStorage","getItem","debug","parsedUser","JSON","parse","getIdToken","__name","resolve","stsTokenManager","accessToken","e","provider","uxMode","signInWithPopup","signInWithRedirect","info","providerId","POPUP_BLOCKED","warn","REDIRECT","error","_updateLocalUser","setItem","stringify","removeItem"]}
@@ -1,7 +1,8 @@
1
1
  import { SmpLoggerMethods } from '@tonysamperi/logger';
2
2
  import { FirebaseOptions, FirebaseApp } from 'firebase/app';
3
3
  import { User, Auth, AuthProvider, ActionCodeInfo, UserCredential, IdTokenResult } from 'firebase/auth';
4
- import { S as SmpSocialSignInKeys, a as SmpSocialSignInUxModes } from './smp-social-sign-in-ux-modes.enum-Cw9H3EqT.cjs';
4
+ import { S as SmpSocialSignInKeys, a as SmpSocialSignInUxModes } from './smp-firebase-errors.enum-BlzgwNdc.cjs';
5
+ export { b as SmpFirebaseErrors } from './smp-firebase-errors.enum-BlzgwNdc.cjs';
5
6
 
6
7
  interface SmpFirebaseServiceConfig {
7
8
  enabledSocials?: SmpSocialSignInKeys[];
@@ -1,2 +1,2 @@
1
- "use strict";var gt=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var hr=Object.prototype.hasOwnProperty;var c=(i,t)=>gt(i,"name",{value:t,configurable:!0});var cr=(i,t)=>{for(var e in t)gt(i,e,{get:t[e],enumerable:!0})},ar=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of nr(t))!hr.call(i,s)&&s!==e&&gt(i,s,{get:()=>t[s],enumerable:!(r=or(t,s))||r.enumerable});return i};var lr=i=>ar(gt({},"__esModule",{value:!0}),i);var qr={};cr(qr,{SMP_HEALTHZ:()=>pr,SmpAbstractCacheStrategy:()=>lt,SmpAbstractTtlCacheStrategy:()=>G,SmpAesCrypt:()=>it,SmpApiCommonUtils:()=>Ut,SmpBaseJwtToken:()=>$t,SmpBaseJwtTokenPlain:()=>Wt,SmpBrowserCache:()=>ft,SmpCommonUtils:()=>St,SmpCrypto:()=>Nt,SmpErrorResponse:()=>F,SmpFilterException:()=>te,SmpFirebaseErrors:()=>mr,SmpGenericResponse:()=>Q,SmpGiftcardTransaction:()=>Dt,SmpGiftcardTransactionHashStrategies:()=>H,SmpGiftcardTransactionOps:()=>O,SmpHttpService:()=>Lt,SmpHttpSessionStorageCache:()=>dt,SmpHttpStatusCodes:()=>zt,SmpInMemoryCache:()=>pt,SmpMarketingCloudValidators:()=>xr,SmpRegularExpressions:()=>se,SmpResponseMessage:()=>C,SmpResponseMessageTypes:()=>U,SmpRestVerbs:()=>jt,SmpSecureCode:()=>Pt,SmpSid:()=>re,SmpSocialSignInKeys:()=>ur,SmpSocialSignInUxModes:()=>wr,VERSION:()=>Vr,smpApplyMixin:()=>Er,smpIsSmpCachedValue:()=>Mt,smpNoop:()=>Je.smpNoop});module.exports=lr(qr);var at=require("class-transformer");var j=require("class-transformer");var Ft=require("class-transformer");var U=(function(i){return i.INFO="INFO",i.SUCCESS="SUCCESS",i.WARNING="WARNING",i.ERROR="ERROR",i})({});function fe(i,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}c(fe,"_ts_decorate");function mt(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}c(mt,"_ts_metadata");var C=class i{static{c(this,"SmpResponseMessage")}_message;_type;get message(){return this._message}get type(){return this._type}constructor(t,e=U.ERROR){this._message=t,this._type=e}static sanitizeMessages(t){return typeof t=="string"?t.length?[new i(t)]:[]:[t].flat().map(e=>typeof e=="string"?new i(e):e)}};fe([(0,Ft.Expose)(),mt("design:type",String),mt("design:paramtypes",[])],C.prototype,"message",null);fe([(0,Ft.Expose)(),mt("design:type",typeof U>"u"?Object:U),mt("design:paramtypes",[])],C.prototype,"type",null);function fr(i,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}c(fr,"_ts_decorate");function de(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}c(de,"_ts_metadata");var Q=class i{static{c(this,"SmpGenericResponse")}_messages;data;set messages(t){this._messages=C.sanitizeMessages(t)}get messages(){return this._messages}constructor(t=[],e){this._messages=t,this.data=e}static buildInfo(t,e){return new i([t].flat().map(r=>new C(r,U.INFO)),e)}static buildSuccess(t,e){return new i([t].flat().map(r=>new C(r,U.SUCCESS)),e)}static fromPlain(t){return(0,j.plainToInstance)(i,t)}isError(){return!this.isSuccess()}isSuccess(){return"_errorCode"in this&&this._errorCode!==null&&this._errorCode!==void 0}serialize(){return(0,j.instanceToPlain)(this,{excludePrefixes:["_"]})}};fr([(0,j.Expose)(),(0,j.Transform)(({value:i})=>i?.length?i:void 0),de("design:type",Object),de("design:paramtypes",[])],Q.prototype,"messages",null);function pe(i,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}c(pe,"_ts_decorate");function yt(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}c(yt,"_ts_metadata");var F=class i extends Q{static{c(this,"SmpErrorResponse")}_errorCode;_status;static get DEFAULT_MESSAGES(){return[new C("GENERIC_ERROR")]}get errorCode(){return this._errorCode}get status(){return this._status}get timestamp(){return this._timestamp}_timestamp=Date.now();constructor(t=i.DEFAULT_MESSAGES,e="GENERIC_ERROR",r=500,s){super(t,s),this._errorCode=e,this._status=r}static create({messages:t=i.DEFAULT_MESSAGES,...e}={}){return new i(C.sanitizeMessages(t),e.errorCode,e.status,e.data)}static fromPlain(t){let e=(0,at.plainToInstance)(dr,t,{excludePrefixes:["_"]}),r=new i;return Object.getOwnPropertyNames(e).forEach(s=>{s in r&&(r[s]=e[s])}),r}};pe([(0,at.Expose)(),yt("design:type",Object),yt("design:paramtypes",[])],F.prototype,"errorCode",null);pe([(0,at.Expose)(),yt("design:type",Number),yt("design:paramtypes",[])],F.prototype,"timestamp",null);var dr=class extends F{static{c(this,"SmpErrorResponseMutable")}set errorCode(t){this._errorCode=t}set status(t){this._status=t}set timestamp(t){this._timestamp=t}};var Tt=require("ts-luxon");var lt=class{static{c(this,"SmpAbstractCacheStrategy")}};function Mt(i){return typeof i=="object"&&i!==null&&"value"in i&&"expiry"in i&&typeof i.expiry=="number"}c(Mt,"smpIsSmpCachedValue");var G=class extends lt{static{c(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(t){let e=this._readRaw(t);if(this._isSmpCachedValue(e)){if(e.expiry>=Tt.DateTime.now().ts)return e.value;this._removeRaw(t);return}return e}remove(t){this._removeRaw(t)}write(t,e,r){if(isNaN(+r)||+r<=0){this._writeRaw(t,e,r);return}let s=Tt.DateTime.now().ts+r*1e3,o={value:e,expiry:s};this._writeRaw(t,o,r)}_isSmpCachedValue(t){return Mt(t)}};var ft=class extends G{static{c(this,"SmpBrowserCache")}_storage;_prefix;constructor(t,e){super(),this._storage=t,this._prefix=e}_flushRaw(){let t=[],e=-1;for(;++e<this._storage.length;){let r=this._storage.key(e);r&&r.startsWith(this._prefix)&&t.push(r)}for(e=-1;++e<t.length;)this._storage.removeItem(t[e])}_readRaw(t){let e=this._storage.getItem(this._prefix+t);try{return e?JSON.parse(e):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+t}`);return}}_removeRaw(t){this._storage.removeItem(this._prefix+t)}_writeRaw(t,e){try{this._storage.setItem(this._prefix+t,JSON.stringify(e))}catch(r){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+t}`,r)}}};var dt=class extends ft{static{c(this,"SmpHttpSessionStorageCache")}constructor(){super(sessionStorage,"smp_rest_cache_")}};var pt=class extends G{static{c(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(t){return this._staticSelf._storage.get(t)}_removeRaw(t){this._staticSelf._storage.delete(t)}_writeRaw(t,e){this._staticSelf._storage.set(t,e)}};var Lt=class{static{c(this,"SmpHttpService")}static _cachePrefix="smp_rest_cache_";static _cacheStrategy=typeof sessionStorage<"u"?new dt:new pt;static _config={cachePrefix:this._cachePrefix,shared:new Map};static _errorClass=F;static _mergeParamsFallbackBaseUrl="https://ts-mapi-core.com";static $http(t){return this._generateAjax(t)}static async _generateAjax(t){if(t.cacheKey){let e=this._cacheRead(t.cacheKey);return e?Promise.resolve(e):this._generateAjaxBase(t).then(r=>(t.cacheKey&&this._cacheWrite(t.cacheKey,r),r))}return this._generateAjaxBase(t)}static async _generateAjaxBase(t){let e=await this._preprocessRequest(t),r={method:e.method,headers:new Headers({"content-type":"application/json",...e.headers}),body:e.body?JSON.stringify(e.body):null};return e.useCredentials&&(r.credentials="include"),e.url=this.mergeQueryParams(e.url,e.queryParams),fetch(e.url,r).then(s=>this._preprocessResponse(t,s)).then(s=>{if(s.ok){if(s.status===204||s.headers.get("content-length")==="0")return null;switch(e.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(t,e){let r=t.startsWith("http");if(e){let s=new URL(t,globalThis?.location?.origin||this._mergeParamsFallbackBaseUrl),o=Object.fromEntries(s.searchParams.entries());s.search=new URLSearchParams({...o,...Object.fromEntries(Object.entries(e).map(([n,h])=>[n,`${h}`]))}).toString(),t=r?s.href:s.pathname+s.search}return t}static _cacheKey(t){return`${this._config.cachePrefix}${t}`}static _cachePop(t){let e=this._cacheRead(t);return this._cacheRemove(t),e}static _cacheRead(t){return this._cacheStrategy.read(this._cacheKey(t))}static _cacheRemove(t){this._cacheStrategy.remove(this._cacheKey(t))}static _cacheWrite(t,e){this._cacheStrategy.write(this._cacheKey(t),e)}static async _preprocessRequest(t){return t}static async _preprocessResponse(t,e){return e}};var zt=(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})({});var ue=require("@tonysamperi/logger");var Ut=class{static{c(this,"SmpApiCommonUtils")}static _javascriptVariablePattern="[a-zA-Z_$][a-zA-Z_$0-9]*";static _logger=new ue.SmpLoggerMethods;static _pathParamRegex=new RegExp(`\\{(${this._javascriptVariablePattern})\\}`,"g");static credentialsToBasicAuth(t,e){return`Basic ${Buffer.from(`${t}:${e}`).toString("base64")}`}static fromBearer(t=""){return t.split(" ")[1]}static getCountryFromReferer(t){return this.getLocaleFromReferer(t)?.split("-")[0]?.toUpperCase()}static getLanguageFromReferer(t){return this.getLocaleFromReferer(t)?.split("-")[1]}static getLocaleFromReferer(t){return t?.match(/\/([A-Z]{2}-[A-Z]{2})\//i)?.[1]}static interpolateParams(t,e){try{return t.replace(this._pathParamRegex,(r,s)=>{let o=e[s];return o!==void 0?encodeURIComponent(o):r})}catch(r){this._logger.warn(`${this.constructor.name}: couldn't interpolate params`,r)}return t}};var pr={status:"OK"};var jt=(function(i){return i.GET="GET",i.POST="POST",i.PUT="PUT",i.DELETE="DELETE",i.PATCH="PATCH",i})({});var $t=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(t,e,r){this._access_token=t,this._exp=e,this._iss=r}serialize(){return{access_token:this._access_token,exp:this._exp,iss:this._iss}}};var Wt=class{static{c(this,"SmpBaseJwtTokenPlain")}access_token;exp;iss};var ur=(function(i){return i.APPLE="APPLE",i.FACEBOOK="FACEBOOK",i.GOOGLE="GOOGLE",i})({});var wr=(function(i){return i.POPUP="POPUP",i.REDIRECT="REDIRECT",i})({});var $=class{static{c(this,"Hex")}static parse(t){let e=t.length,r=[];for(let s=0;s<e;s+=2)r[s>>>3]|=parseInt(t.substr(s,2),16)<<24-s%8*4;return new _(r,e/2)}static stringify(t){let e=[];for(let r=0;r<t.sigBytes;r++){let s=t.words[r>>>2]>>>24-r%4*8&255;e.push((s>>>4).toString(16)),e.push((s&15).toString(16))}return e.join("")}};var _=class Gt{static{c(this,"WordArray")}constructor(t,e){this.words=t||[],e!==void 0?this.sigBytes=e:this.sigBytes=this.words.length*4}static random(t){let e=[],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<t;s+=4){let n=r((o||Math.random())*4294967296);o=n()*987654071,e.push(n()*4294967296|0)}return new Gt(e,t)}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new Gt(this.words.slice(0),this.sigBytes)}concat(t){if(this.clamp(),this.sigBytes%4)for(let e=0;e<t.sigBytes;e++){let r=t.words[e>>>2]>>>24-e%4*8&255;this.words[this.sigBytes+e>>>2]|=r<<24-(this.sigBytes+e)%4*8}else for(let e=0;e<t.sigBytes;e+=4)this.words[this.sigBytes+e>>>2]=t.words[e>>>2];return this.sigBytes+=t.sigBytes,this}toString(t){return(t||$).stringify(this)}};var xt=class{static{c(this,"Latin1")}static parse(t){let e=t.length,r=[];for(let s=0;s<e;s++)r[s>>>2]|=(t.charCodeAt(s)&255)<<24-s%4*8;return new _(r,e)}static stringify(t){let e=[];for(let r=0;r<t.sigBytes;r++){let s=t.words[r>>>2]>>>24-r%4*8&255;e.push(String.fromCharCode(s))}return e.join("")}};var R=class{static{c(this,"Utf8")}static parse(t){return xt.parse(unescape(encodeURIComponent(t)))}static stringify(t){try{return decodeURIComponent(escape(xt.stringify(t)))}catch(e){throw console.error("Malformed UTF-8 data",e),new Error("Malformed UTF-8 data")}}};var Et=class{static{c(this,"BufferedBlockAlgorithm")}constructor(t){this._minBufferSize=0,this.cfg=Object.assign({blockSize:1},t),this._data=new _,this._nDataBytes=0}clone(){let t=this.constructor();for(let e in this)Object.prototype.hasOwnProperty.call(this,e)&&(t[e]=this[e]);return t._data=this._data.clone(),t}reset(){this._data=new _,this._nDataBytes=0}_append(t){typeof t=="string"&&(t=R.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}_process(t){if(!this.cfg.blockSize)throw new Error("missing blockSize in config");let e=this.cfg.blockSize*4,r=this._data.sigBytes/e;t?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 _(n,o)}};var S=class{static{c(this,"CipherParams")}constructor(t){this.ciphertext=t.ciphertext,this.key=t.key,this.iv=t.iv,this.salt=t.salt,this.algorithm=t.algorithm,this.mode=t.mode,this.padding=t.padding,this.blockSize=t.blockSize,this.formatter=t.formatter}extend(t){return t.ciphertext!==void 0&&(this.ciphertext=t.ciphertext),t.key!==void 0&&(this.key=t.key),t.iv!==void 0&&(this.iv=t.iv),t.salt!==void 0&&(this.salt=t.salt),t.algorithm!==void 0&&(this.algorithm=t.algorithm),t.mode!==void 0&&(this.mode=t.mode),t.padding!==void 0&&(this.padding=t.padding),t.blockSize!==void 0&&(this.blockSize=t.blockSize),t.formatter!==void 0&&(this.formatter=t.formatter),this}toString(t){if(t)return t.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 T=class{static{c(this,"Base64")}static parse(t){let e=t.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=t.indexOf(r);s!==-1&&(e=s)}return this.parseLoop(t,e,this._reverseMap)}static parseLoop(t,e,r){let s=[],o=0;for(let n=0;n<e;n++)if(n%4){let h=r[t.charCodeAt(n-1)]<<n%4*2,a=r[t.charCodeAt(n)]>>>6-n%4*2;s[o>>>2]|=(h|a)<<24-o%4*8,o++}return new _(s,o)}static stringify(t){t.clamp();let e=[];for(let s=0;s<t.sigBytes;s+=3){let o=t.words[s>>>2]>>>24-s%4*8&255,n=t.words[s+1>>>2]>>>24-(s+1)%4*8&255,h=t.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<t.sigBytes;p++)e.push(this._map.charAt(a>>>6*(3-p)&63))}let r=this._map.charAt(64);if(r)for(;e.length%4;)e.push(r);return e.join("")}};T._map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";T._reverseMap=void 0;var Rt=class{static{c(this,"OpenSSL")}static parse(t){let e=T.parse(t),r;return e.words[0]===1398893684&&e.words[1]===1701076831&&(r=new _(e.words.slice(2,4)),e.words.splice(0,4),e.sigBytes-=16),new S({ciphertext:e,salt:r})}static stringify(t){if(!t.ciphertext)throw new Error("missing ciphertext in params");let e=t.ciphertext,r=t.salt,s;if(r){if(typeof r=="string")throw new Error("salt is expected to be a WordArray");s=new _([1398893684,1701076831]).concat(r).concat(e)}else s=e;return s.toString(T)}};var K=class{static{c(this,"SerializableCipher")}static decrypt(t,e,r,s){let o=Object.assign({},this.cfg,s);if(!o.format)throw new Error("could not determine format");if(e=this._parse(e,o.format),!e.ciphertext)throw new Error("could not determine ciphertext");return t.createDecryptor(r,o).finalize(e.ciphertext)}static encrypt(t,e,r,s){let o=Object.assign({},this.cfg,s),n=t.createEncryptor(r,o),h=n.finalize(e);return new S({ciphertext:h,key:r,iv:n.cfg.iv,algorithm:t,mode:n.cfg.mode,padding:n.cfg.padding,blockSize:n.cfg.blockSize,formatter:o.format})}static _parse(t,e){return typeof t=="string"?e.parse(t):t}};K.cfg={blockSize:4,iv:new _([]),format:Rt};var E=class extends Et{static{c(this,"Hasher")}constructor(t){super(Object.assign({blockSize:512/32},t)),this.reset()}static _createHelper(t){function e(r,s){return new t(s).finalize(r)}return c(e,"helper"),e}finalize(t){return t&&this._append(t),this._doFinalize()}update(t){return this._append(t),this._process(),this}};var f=[];for(let i=0;i<64;i++)f[i]=Math.abs(Math.sin(i+1))*4294967296|0;var L=class d extends E{static{c(this,"MD5")}get hash(){return this._hash}static FF(t,e,r,s,o,n,h){let a=t+(e&r|~e&s)+o+h;return(a<<n|a>>>32-n)+e}static GG(t,e,r,s,o,n,h){let a=t+(e&s|r&~s)+o+h;return(a<<n|a>>>32-n)+e}static HH(t,e,r,s,o,n,h){let a=t+(e^r^s)+o+h;return(a<<n|a>>>32-n)+e}static II(t,e,r,s,o,n,h){let a=t+(r^(e|~s))+o+h;return(a<<n|a>>>32-n)+e}reset(){super.reset(),this._hash=new _([1732584193,4023233417,2562383102,271733878])}_doFinalize(){let t=this._nDataBytes*8,e=this._data.sigBytes*8;this._data.words[e>>>5]|=128<<24-e%32;let r=Math.floor(t/4294967296),s=t;this._data.words[(e+64>>>9<<4)+15]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360,this._data.words[(e+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(t,e){for(let a=0;a<16;a++){let p=e+a,w=t[p];t[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]=t[e+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 Kt=class we{static{c(this,"EVPKDF")}constructor(t){this.cfg=Object.assign({keySize:128/32,hasher:L,iterations:1},t)}static execute(t,e,r){return new we(r).compute(t,e)}compute(t,e){let r=new this.cfg.hasher,s=new _,o;for(;s.words.length<this.cfg.keySize;){o&&r.update(o),o=r.update(t).finalize(e),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 _e=class{static{c(this,"OpenSSLKdf")}static execute(t,e,r,s){s||(s=_.random(64/8));let o=new Kt({keySize:e+r}).compute(t,s),n=new _(o.words.slice(e),r*4);return o.sigBytes=e*4,new S({key:o,iv:n,salt:s})}};var At=class{static{c(this,"PasswordBasedCipher")}static decrypt(t,e,r,s){let o=Object.assign({},this.cfg,s);if(o.format===void 0)throw new Error("missing format in config");if(e=this._parse(e,o.format),o.kdf===void 0)throw new Error("the key derivation function must be set");let n=o.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv!==void 0&&(o.iv=n.iv),K.decrypt.call(this,t,e,n.key,o)}static encrypt(t,e,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,t.keySize,t.ivSize);return n.iv!==void 0&&(o.iv=n.iv),K.encrypt.call(this,t,e,n.key,o).extend(n)}static _parse(t,e){return typeof t=="string"?e.parse(t):t}};At.cfg={blockSize:4,iv:new _([]),format:Rt,kdf:_e};var ge=class{static{c(this,"CipherHelper")}constructor(t){this._cipher=t}decrypt(t,e,r){return typeof e=="string"?At.decrypt(this._cipher,t,e,r):K.decrypt(this._cipher,t,e,r)}encrypt(t,e,r){return typeof e=="string"?At.encrypt(this._cipher,t,e,r):K.encrypt(this._cipher,t,e,r)}};var tt=class extends Et{static{c(this,"Cipher")}constructor(t,e,r){super(Object.assign({blockSize:1},r)),this._xformMode=t,this._key=e,this.reset()}static _createHelper(t){return new ge(t)}static createDecryptor(t,e){let r=this;return new r(this._DEC_XFORM_MODE,t,e)}static createEncryptor(t,e){return new this(this._ENC_XFORM_MODE,t,e)}finalize(t){return t&&this._append(t),this._doFinalize()}process(t){return this._append(t),this._process()}};tt.ivSize=4;tt.keySize=4;tt._DEC_XFORM_MODE=2;tt._ENC_XFORM_MODE=1;var V=class{static{c(this,"BlockCipherModeAlgorithm")}constructor(t,e){this.init(t,e)}init(t,e){this._cipher=t,this._iv=e}};var Bt=class{static{c(this,"BlockCipherMode")}static createDecryptor(t,e){let r=this.Decryptor;return new r(t,e)}static createEncryptor(t,e){let r=this.Encryptor;return new r(t,e)}};Bt.Decryptor=V;Bt.Encryptor=V;var me=class extends V{static{c(this,"CBCEncryptor")}get prevBlock(){return this._prevBlock}processBlock(t,e){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");this.xorBlock(t,e,this._cipher.cfg.blockSize),this._cipher.encryptBlock(t,e),this._prevBlock=t.slice(e,e+this._cipher.cfg.blockSize)}xorBlock(t,e,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)t[e+o]^=s[o]}};var ye=class extends V{static{c(this,"CBCDecryptor")}get prevBlock(){return this._prevBlock}processBlock(t,e){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");let r=t.slice(e,e+this._cipher.cfg.blockSize);this._cipher.decryptBlock(t,e),this.xorBlock(t,e,this._cipher.cfg.blockSize),this._prevBlock=r}xorBlock(t,e,r){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let o=0;o<r;o++)t[e+o]^=s[o]}};var W=class extends Bt{static{c(this,"CBC")}};W.Decryptor=ye;W.Encryptor=me;var et=class{static{c(this,"PKCS7")}static pad(t,e){let r=e*4,s=r-t.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 _(n,s);t.concat(h)}static unpad(t){let e=t.words[t.sigBytes-1>>>2]&255;t.sigBytes-=e}};var Ot=class extends tt{static{c(this,"BlockCipher")}constructor(t,e,r){super(t,e,Object.assign({blockSize:4,mode:W,padding:et},r))}reset(){if(super.reset(),this.cfg.mode===void 0)throw new Error("missing mode in config");let t;this._xformMode===this.constructor._ENC_XFORM_MODE?t=this.cfg.mode.createEncryptor:(t=this.cfg.mode.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator===t?this._mode.init(this,this.cfg.iv&&this.cfg.iv.words):(this._mode=t.call(this.cfg.mode,this,this.cfg.iv&&this.cfg.iv.words),this._mode.__creator=t)}_doFinalize(){if(this.cfg.padding===void 0)throw new Error("missing padding in config");let t;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),t=this._process(!0)}else t=this._process(!0),this.cfg.padding.unpad(t);return t}_doProcessBlock(t,e){this._mode.processBlock(t,e)}};var l=class M{static{c(this,"X64Word")}constructor(t,e){this.high=t,this.low=e}add(t){let e=this.low+t.low|0,r=e>>>0<this.low>>>0?1:0,s=this.high+t.high+r|0;return new M(s,e)}and(t){return new M(this.high&t.high,this.low&t.low)}not(){return new M(~this.high,~this.low)}or(t){return new M(this.high|t.high,this.low|t.low)}rotL(t){return this.shiftL(t).or(this.shiftR(64-t))}rotR(t){return this.shiftR(t).or(this.shiftL(64-t))}shiftL(t){return t<32?new M(this.high<<t|this.low>>>32-t,this.low<<t):new M(this.low<<t-32,0)}shiftR(t){return t<32?new M(this.high>>>t,this.low>>>t|this.high<<32-t):new M(0,this.high>>>t-32)}xor(t){return new M(this.high^t.high,this.low^t.low)}};var xe=class Vt{static{c(this,"X64WordArray")}constructor(t=[],e){this.words=t,this.sigBytes=e!==void 0?e:t.length*8}static create(t=[],e){return new Vt(t,e)}clone(){let t=this.words.map(e=>new l(e.high,e.low));return new Vt(t,this.sigBytes)}toX32(){let t=[];for(let e of this.words)t.push(e.high,e.low);return new _(t,this.sigBytes)}};var B=[],Ee=[],Re=[],Ae=[],Be=[],Oe=[],qt=[],Xt=[],Zt=[],Ht=[];(function(){let i=[];for(let r=0;r<256;r++)r<128?i[r]=r<<1:i[r]=r<<1^283;let t=0,e=0;for(let r=0;r<256;r++){let s=e^e<<1^e<<2^e<<3^e<<4;s=s>>>8^s&255^99,B[t]=s,Ee[s]=t;let o=i[t],n=i[o],h=i[n],a=i[s]*257^s*16843008;Re[t]=a<<24|a>>>8,Ae[t]=a<<16|a>>>16,Be[t]=a<<8|a>>>24,Oe[t]=a,a=h*16843009^n*65537^o*257^t*16843008,qt[s]=a<<24|a>>>8,Xt[s]=a<<16|a>>>16,Zt[s]=a<<8|a>>>24,Ht[s]=a,t?(t=o^i[i[i[h^o]]],e^=i[i[e]]):t=e=1}})();var _r=[0,1,2,4,8,16,32,64,128,27,54],bt=class extends Ot{static{c(this,"AES")}constructor(t,e,r){super(t,e,r),super.reset()}decryptBlock(t,e){let r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,qt,Xt,Zt,Ht,Ee),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r}encryptBlock(t,e){this._doCryptBlock(t,e,this._keySchedule,Re,Ae,Be,Oe,B)}reset(){if(super.reset(),this._nRounds&&this._keyPriorReset===this._key)return;let t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,o=((this._nRounds=r+6)+1)*4,n=this._keySchedule=[];for(let h=0;h<o;h++)if(h<r)n[h]=e[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^=_r[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]=qt[B[p>>>24]]^Xt[B[p>>>16&255]]^Zt[B[p>>>8&255]]^Ht[B[p&255]]}}_doCryptBlock(t,e,r,s,o,n,h,a){let p=t[e]^r[0],w=t[e+1]^r[1],u=t[e+2]^r[2],g=t[e+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[g&255]^r[x++],y=s[w>>>24]^o[u>>>16&255]^n[g>>>8&255]^h[p&255]^r[x++],P=s[u>>>24]^o[g>>>16&255]^n[p>>>8&255]^h[w&255]^r[x++],kt=s[g>>>24]^o[p>>>16&255]^n[w>>>8&255]^h[u&255]^r[x++];p=m,w=y,u=P,g=kt}let b=(a[p>>>24]<<24|a[w>>>16&255]<<16|a[u>>>8&255]<<8|a[g&255])^r[x++],k=(a[w>>>24]<<24|a[u>>>16&255]<<16|a[g>>>8&255]<<8|a[p&255])^r[x++],v=(a[u>>>24]<<24|a[g>>>16&255]<<16|a[p>>>8&255]<<8|a[w&255])^r[x++],N=(a[g>>>24]<<24|a[p>>>16&255]<<16|a[w>>>8&255]<<8|a[u&255])^r[x++];t[e]=b,t[e+1]=k,t[e+2]=v,t[e+3]=N}};bt.keySize=256/32;var gr=[1732584193,4023233417,2562383102,271733878,3285377520],q=new Array(80),X=class extends E{static{c(this,"SHA1")}get hash(){return this._hash}reset(){super.reset(),this._hash=new _(gr.slice(0))}_doFinalize(){let t=this._nDataBytes*8,e=this._data.sigBytes*8;return this._data.words[e>>>5]|=128<<24-e%32,this._data.words[(e+64>>>9<<4)+14]=Math.floor(t/4294967296),this._data.words[(e+64>>>9<<4)+15]=t,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(t,e){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)q[a]=t[e+a]|0;else{let g=q[a-3]^q[a-8]^q[a-14]^q[a-16];q[a]=g<<1|g>>>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+q[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 be=[],Ie=[];(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 t(s){return(s-(s|0))*4294967296|0}c(t,"getFractionalBits");let e=2,r=0;for(;r<64;)i(e)&&(r<8&&(be[r]=t(Math.pow(e,1/2))),Ie[r]=t(Math.pow(e,1/3)),r++),e++})();var Z=[],ut=class extends E{static{c(this,"SHA256")}constructor(){super()}reset(){super.reset(),this._hash=new _(be.slice(0))}_doFinalize(){let t=this._nDataBytes*8,e=this._data.sigBytes*8;return this._data.words[e>>>5]|=128<<24-e%32,this._data.words[(e+64>>>9<<4)+14]=Math.floor(t/4294967296),this._data.words[(e+64>>>9<<4)+15]=t,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(t,e){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)Z[u]=t[e+u]|0;else{let A=Z[u-15],m=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,y=Z[u-2],P=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;Z[u]=m+Z[u-7]+P+Z[u-16]}let g=h&a^~h&p,x=r&s^r&o^s&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),k=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),v=w+k+g+Ie[u]+Z[u],N=b+x;w=p,p=a,a=h,h=n+v|0,n=o,o=s,s=r,r=v+N|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 Jt=[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)],D=[];(function(){for(let i=0;i<80;i++)D[i]=new l(void 0,void 0)})();var Yt=class extends E{static{c(this,"SHA512")}constructor(){super({blockSize:1024/32})}reset(){super.reset(),this._hash=new xe([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 t=this._data,e=t.words,r=this._nDataBytes*8,s=t.sigBytes*8;return e[s>>>5]|=128<<24-s%32,e[(s+128>>>10<<5)+30]=Math.floor(r/4294967296),e[(s+128>>>10<<5)+31]=r,t.sigBytes=e.length*4,this._process(),this._hash.toX32()}_doProcessBlock(t,e){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,g=this._hash.words[4].low,x=this._hash.words[5].high,b=this._hash.words[5].low,k=this._hash.words[6].high,v=this._hash.words[6].low,N=this._hash.words[7].high,A=this._hash.words[7].low;for(let m=0;m<80;m++){let y,P;if(m<16)P=D[m].high=t[e+m*2]|0,y=D[m].low=t[e+m*2+1]|0;else{let he=D[m-15],J=he.high,ht=he.low,sr=(J>>>1|ht<<31)^(J>>>8|ht<<24)^J>>>7,ce=(ht>>>1|J<<31)^(ht>>>8|J<<24)^(ht>>>7|J<<25),ae=D[m-2],Y=ae.high,ct=ae.low,ir=(Y>>>19|ct<<13)^(Y<<3|ct>>>29)^Y>>>6,le=(ct>>>19|Y<<13)^(ct<<3|Y>>>29)^(ct>>>6|Y<<26);y=ce+D[m-7].low,P=sr+D[m-7].high+(y>>>0<ce>>>0?1:0),y=y+le,P=P+ir+(y>>>0<le>>>0?1:0),y=y+D[m-16].low,P=P+D[m-16].high+(y>>>0<D[m-16].low>>>0?1:0),D[m].high=P,D[m].low=y}let kt=u&x^~u&k,ie=g&b^~g&v,Ye=r&o^r&h^o&h,Qe=s&n^s&a^n&a,Se=(r>>>28|s<<4)^(r<<30|s>>>2)^(r<<25|s>>>7),oe=(s>>>28|r<<4)^(s<<30|r>>>2)^(s<<25|r>>>7),tr=(u>>>14|g<<18)^(u>>>18|g<<14)^(u<<23|g>>>9),er=(g>>>14|u<<18)^(g>>>18|u<<14)^(g<<23|u>>>9),I=A+er,z=N+tr+(I>>>0<A>>>0?1:0);I=I+ie,z=z+kt+(I>>>0<ie>>>0?1:0),I=I+Jt[m].low,z=z+Jt[m].high+(I>>>0<Jt[m].low>>>0?1:0),I=I+y,z=z+P+(I>>>0<y>>>0?1:0);let ne=oe+Qe,rr=Se+Ye+(ne>>>0<oe>>>0?1:0);N=k,A=v,k=x,v=b,x=u,b=g,g=w+I|0,u=p+z+(g>>>0<w>>>0?1:0)|0,p=h,w=a,h=o,a=n,o=r,n=s,s=I+ne|0,r=z+rr+(s>>>0<I>>>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+g,this._hash.words[4].high=this._hash.words[4].high+u+(this._hash.words[4].low>>>0<g>>>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+v,this._hash.words[6].high=this._hash.words[6].high+k+(this._hash.words[6].low>>>0<v>>>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+N+(this._hash.words[7].low>>>0<A>>>0?1:0)}};var ve=class{static{c(this,"HMAC")}constructor(t,e){this._hasher=new t;let r=typeof e=="string"?R.parse(e):e,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(t){let e=this._hasher.finalize(t);return this._hasher.reset(),this._hasher.finalize(this._oKey.clone().concat(e))}reset(){this._hasher.reset(),this._hasher.update(this._iKey)}update(t){return this._hasher.update(t),this}};var Qt=class Ne{static{c(this,"PBKDF2")}constructor(t){this.cfg=Object.assign({keySize:128/32,hasher:ut,iterations:25e4},t)}static execute(t,e,r){return new Ne(r).compute(t,e)}compute(t,e){let r=this.cfg,s=new ve(r.hasher,t),o=new _,n=new _([1]),h=o.words,a=n.words,p=r.keySize,w=r.iterations;for(;h.length<p;){let u=s.update(e).finalize(n);s.reset();let g=u.words,x=g.length,b=u;for(let k=1;k<w;k++){b=s.finalize(b),s.reset();let v=b.words;for(let N=0;N<x;N++)g[N]^=v[N]}o.concat(u),a[0]++}return o.sigBytes=p*4,o}};var wt=Ot._createHelper(bt);var rt=E._createHelper(L);var st=E._createHelper(X);var It=E._createHelper(ut);var vt=E._createHelper(Yt);var it=class{static{c(this,"SmpAesCrypt")}_password;_salt;_initVector;get _iv(){return this._initVector?$.parse(this._initVector):void 0}_mode=W;_padding=et;constructor(t,e,r){this._password=t,this._salt=e,this._initVector=r}decryptAES(t){return wt.decrypt(t,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString(R)}encryptAES(t){return wt.encrypt(t,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString()}_buildKey(){return Qt.execute(this._password,$.parse(this._salt),{keySize:256/32,iterations:1e3,hasher:X})}};var Nt=class{static{c(this,"SmpCrypto")}static base64Decode(t){return R.stringify(T.parse(t))}static base64Encode(t){return T.stringify(R.parse(t))}static md5(t){return rt(t).toString()}static sha1(t){return st(t).toString()}static sha256(t){return It(t).toString()}static sha512(t){return vt(t).toString()}};var Pt=class{static{c(this,"SmpSecureCode")}_baseCode;get baseCode(){return this._baseCode}get secureCode(){return this._encode()}_crcLength=5;_seed="changeme";constructor(t){this._baseCode=t}static check(t,e){if(new this(t).secureCode!==e)throw F.create({messages:"WRONG_SECURE_CODE",errorCode:"WRONG_SECURE_CODE",status:zt.BadRequest})}_encode(){let t=new L;return t.update(R.parse(this._seed+this._baseCode)),t.finalize().toString($).substring(0,this._crcLength).toUpperCase()}};var mr=(function(i){return i.DIFFERENT_CREDENTIAL="auth/account-exists-with-different-credential",i.DIFFERENT_CREDENTIAL_APPLE="auth/account-exists-with-different-credential/apple",i.DIFFERENT_CREDENTIAL_FACEBOOK="auth/account-exists-with-different-credential/facebook",i.DIFFERENT_CREDENTIAL_GOOGLE="auth/account-exists-with-different-credential/google",i.EMAIL_EXISTS="auth/email-already-exists",i.INVALID_ACTION_CODE="auth/invalid-action-code",i.POPUP_BLOCKED="auth/popup-blocked",i.POPUP_CLOSED_BY_USER="auth/popup-closed-by-user",i.USER_NOT_FOUND="auth/user-not-found",i.WRONG_PASSWORD="auth/wrong-password",i})({});var ot=require("class-transformer"),Ct=require("ts-luxon");var O=(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 H=(function(i){return i.MD5="MD5",i.MD5_HMAC="MD5_HMAC",i.SHA1="SHA1",i.SHA1_HMAC="SHA1_HMAC",i})({});function yr(i,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var h=i.length-1;h>=0;h--)(n=i[h])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}c(yr,"_ts_decorate");function Pe(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}c(Pe,"_ts_metadata");var Dt=class i{static{c(this,"SmpGiftcardTransaction")}gc;op;ot;static _AES_ENCODER=new it("changeme","5f6eae61d2428b99","d92fbf214e16a79fd36f9a5185ae733f");static _LOGGER=console;static _OP_CODES={[O.CHECK]:"",[O.TRANSACTION]:"",[O.TRANSACTION_DETAIL]:"",[O.ACTIVATE]:"A",[O.BLOCK]:"B",[O.DIGITAL_ACTIVATE]:"D",[O.FREEZE]:"F",[O.PURCHASE]:"P",[O.RECHARGE]:"G",[O.ROLLBACK]:"R",[O.UNFREEZE]:"U",[O.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={[H.MD5]:t=>rt(t),[H.MD5_HMAC]:t=>{let e=new L;return e.update(R.parse(t)),e.finalize()},[H.SHA1]:t=>st(t),[H.SHA1_HMAC]:t=>{let e=new X;return e.update(R.parse(t)),e.finalize()}};_hashStrategy=this._hashStrategies[H.MD5];constructor(t="ACTIVATION",e,r,s){this.gc=t,this.op=e,this.ot=r,this._dto=typeof s=="number"&&s>=0?Ct.DateTime.fromMillis(+`${s}000`.slice(0,13)):Ct.DateTime.local()}static build({gc:t,op:e,ot:r,dto:s}){return new this(t,e,r,s?.ts)}static explode(t){let e=this.constructor,r=(t||"").split(e._SEP);if(r.length<4)throw new Error(`INVALID_TRANSACTION "${t}"`);return this.build({gc:r[1],op:e.prefixToOperation(r[2]),dto:Ct.DateTime.fromSeconds(+r[3])})}static isBase64(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)&&t.length%4===0}static parse(t){this._LOGGER.info(`${this.constructor.name}: trying to parse ${t}`);try{if(this.isBase64(t)){let e=this._AES_ENCODER.decryptAES(t),r=JSON.parse(e);return(0,ot.plainToInstance)(i,r)}else return this.explode(t)}catch(e){throw this._LOGGER.error(`${this.constructor.name}: failed to parse ${t}`,e),new Error(`UNPARSEABLE "${t}"`)}}static prefixToOperation(t){return Object.entries(this._OP_CODES).find(([,r])=>r===t)[0]}serialize(){return(0,ot.instanceToPlain)(this,{excludePrefixes:["_"]})}toString(){let t=JSON.stringify(this.serialize());return this.constructor._AES_ENCODER.encryptAES(t)}};yr([(0,ot.Expose)(),Pe("design:type",Number),Pe("design:paramtypes",[])],Dt.prototype,"ts",null);var xr=(function(i){return i.ListDetectiveValidator="ListDetectiveValidator",i.MXValidator="MXValidator",i.SyntaxValidator="SyntaxValidator",i})({});function Er(i,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&(r in i.prototype||Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)))});try{let r=new e;Object.getOwnPropertyNames(r).forEach(s=>{s in i.prototype||Object.defineProperty(i.prototype,s,Object.getOwnPropertyDescriptor(r,s))})}catch{}Object.getOwnPropertyNames(e).forEach(r=>{r!=="prototype"&&r!=="name"&&r!=="length"&&(r in i||Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r)))})})}c(Er,"smpApplyMixin");var Rr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ce(i){return i.match(Rr)}c(Ce,"smpAsciiWords");var Le="\\ud800-\\udfff",Ar="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",Or="\\u20d0-\\u20ff",br="\\u1ab0-\\u1aff",Ir="\\u1dc0-\\u1dff",vr=Ar+Br+Or+br+Ir,ze="\\u2700-\\u27bf",Ue="a-z\\xdf-\\xf6\\xf8-\\xff",Nr="\\xac\\xb1\\xd7\\xf7",Pr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Cr="\\u2000-\\u206f",Dr=" \\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",je="A-Z\\xc0-\\xd6\\xd8-\\xde",kr="\\ufe0e\\ufe0f",$e=Nr+Pr+Cr+Dr,We="['\u2019]",De=`[${$e}]`,Fr=`[${vr}]`,Ge="\\d",Mr=`[${ze}]`,Ke=`[${Ue}]`,Ve=`[^${Le}${$e+Ge+ze+Ue+je}]`,Tr="\\ud83c[\\udffb-\\udfff]",Lr=`(?:${Fr}|${Tr})`,zr=`[^${Le}]`,qe="(?:\\ud83c[\\udde6-\\uddff]){2}",Xe="[\\ud800-\\udbff][\\udc00-\\udfff]",nt=`[${je}]`,Ur="\\u200d",ke=`(?:${Ke}|${Ve})`,jr=`(?:${nt}|${Ve})`,Fe=`(?:${We}(?:d|ll|m|re|s|t|ve))?`,Me=`(?:${We}(?:D|LL|M|RE|S|T|VE))?`,Ze=`${Lr}?`,He=`[${kr}]?`,$r=`(?:${Ur}(?:${[zr,qe,Xe].join("|")})${He+Ze})*`,Wr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Gr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Kr=He+Ze+$r,Te=`(?:${[Mr,qe,Xe].join("|")})${Kr}`,_t=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([`${nt}?${Ke}+${Fe}(?=${[De,nt,"$"].join("|")})`,`${jr}+${Me}(?=${[De,nt+ke,"$"].join("|")})`,`${nt}?${ke}+${Fe}`,`${nt}+${Me}`,Gr,Wr,`${Ge}+`,Te].join("|"),"g");static RS_EMOJI=Te;static unicodeWords(t){return t.match(this.RE_UNICODE_WORDS)}};var St=class i{static{c(this,"SmpCommonUtils")}static arrayRemove(t,e){let r=[],s=t.filter((o,n)=>e(o,n)&&r.push(n));return r.reverse().forEach(o=>t.splice(o,1)),s}static assertIsArray(t,e){if(!Array.isArray(t))throw new Error(e||`${this.constructor.name} => val was not an array`)}static assertIsBoolean(t,e){if(!this.isBoolean(t))throw new Error(e||`${this.constructor.name} => val was not boolean`)}static assertIsFunction(t,e){if(!this.isFunction(t))throw new Error(e||`${this.constructor.name} => entity was not a function`)}static assertIsInstance(t,e,r){if(!(t instanceof e))throw new Error(r||`${this.constructor.name} => val was not instance of class`)}static assertIsNotEmpty(t,e){if(this.isEmpty(t))throw new Error(e||`${this.constructor.name} => entity was empty`)}static assertIsNumber(t,e){if(typeof t!="number")throw new Error(e||`${this.constructor.name} => val was not numeric`)}static assertIsNumeric(t,e){if(!this.isNumeric(t))throw new Error(e||`${this.constructor.name} => val was not numeric`)}static assertIsObject(t,e){if(!this.isObject(t))throw new Error(e||`${this.constructor.name} => val was not an object`)}static assertIsString(t,e){if(!this.isString(t))throw new Error(e||`${this.constructor.name} => val was not a string`)}static assertIsTruthy(t,e){if(!t)throw new Error(e||`${this.constructor.name} => condition wasn't truthy`)}static buildPath(...t){let e=t.filter(r=>!!r).join("/").replace(/(?<!:)\/\/+/g,"/");return e.startsWith("http")&&!e.endsWith("/")?`${e}/`:e}static downloadBlob(t,e){let r=window.URL.createObjectURL(t),s=document.createElement("a");s.href=r,s.setAttribute("download",e),document.body.appendChild(s),s.click()}static generateRandomHexString(t=12){let e="0123456789abcdef",r="";for(let s=0;s<t;s++){let o=Math.floor(Math.random()*e.length);r+=e[o]}return r}static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}static getDecimalPrecision(t){if(this.assertIsNumeric(t),!isFinite(+t))return 0;let e=1,r=0;for(;Math.round(+t*e)/e!==t;)e*=10,r++;return r}static getType(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}static isBoolean(t){return typeof t=="boolean"}static isColor(t){if(!t||!this.isString(t))return!1;let e=new Option().style;return e.color=t,e.color!==""}static isEmpty(t){return!t&&t!==0}static isEqual(t,e){function r(){if(t.length!==e.length)return!1;for(let a=0;a<t.length;a++)if(!i.isEqual(t[a],e[a]))return!1;return!0}c(r,"areArraysEqual");function s(){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)&&!i.isEqual(t[a],e[a]))return!1;return!0}c(s,"areObjectsEqual");function o(){return t.toString()===e.toString()}c(o,"areFunctionsEqual");function n(){return t===e}c(n,"arePrimativesEqual");let h=this.getType(t);return h!==this.getType(e)?!1:h==="array"?r():h==="object"?s():h==="function"?o():n()}static isFormField(t){return/^(?:input|select|textarea|button)$/i.test(t.nodeName)}static isFunction(t){return typeof t==typeof isNaN}static isNotEmpty(t){return!this.isEmpty(t)}static isNumber(t){return typeof t=="number"&&this.isNumeric(t)}static isNumeric(t){return!isNaN(t)}static isObject(t){return!!t&&t===Object(t)&&t.constructor===Object}static isPrimitive(t){let e=this.getType(t);return e!=="function"&&(e!=="object"||!t)}static isString(t){return typeof t=="string"}static isWindows(){return navigator.userAgent.toLowerCase().includes("win")}static mapObject(t,e){if(this.assertIsFunction(e,`CommonUtils => expected type of iteratee to be Function, got ${typeof e}`),this.isObject(t))return Object.entries(t).reduce((r,[s,o])=>(r.push(e(o,s)),r),[]);if(Array.isArray(t))return t.map(e);throw new Error(`CommonUtils => invalid object provided. Expected Object or Array, got ${typeof e}`)}static mapObjectKeys(t,e){return Object.entries(t).reduce((r,[s,o])=>(r[s]=e.call(null,s,o),r),{})}static mapObjectValues(t,e){return this.isObject(t)?Object.entries(t).reduce((r,[s,o])=>(r[s]=e.call(null,o,s),r),{}):{}}static noop(){}static objectHasValue(t,e){return!!~Object.values(t).filter(r=>this.isEqual(r,e))}static omit(t,e){return Object.keys(t).filter(s=>!e.includes(s)).reduce((s,o)=>(s[o]=t[o],s),{})}static parseBoolean(t){return t?/^true$/i.test(t):!1}static parseJsonSafely(t){try{return JSON.parse(t)}catch(e){console.warn(`${this.constructor.name} => couldn't parse json string`,{str:t,error:e});return}}static pick(t,e){return e.reduce((r,s)=>(s in t&&(r[s]=t[s]),r),{})}static runSafely(t,e=null,r=[]){if(this.isFunction(t))return t.apply(e,r)}static sleep(t){return new Promise(e=>setTimeout(e,t))}static sprintf(t,...e){return this.isString(t)&&e.length?this.sprintf(t.replace("%s",String(e.shift())),...e):t}static stripComments(t){return typeof t=="string"?t.replace(/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g,""):t}static submitFakeForm({action:t,method:e=jt.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=e,n.action=t,n.innerHTML=`${o}`,n.target=s||"_self",document.body.append(n),n.submit()}static toCamelCase(t){return this.words(t.replace(/['\u2019]/g,"")).reduce((e,r,s)=>(r=r.toLowerCase(),e+(s?r.charAt(0).toUpperCase()+r.slice(1):r)),"")}static toKebabCase(t){return this.words(t.replace(/['\u2019]/g,"")).join("-").toLowerCase()}static toPascalCase(t){return this.toCamelCase(t).replace(/^(.)/,e=>e.toUpperCase())}static toSnakeCase(t){return this.words(t.replace(/['\u2019]/g,"")).join("_").toLowerCase()}static toUpperSnakeCase(t){return this.toSnakeCase(t).toUpperCase()}static words(t,e){return e===void 0?(_t.HAS_UNICODE_WORD(t)?_t.unicodeWords(t):Ce(t))||[]:t.match(e)||[]}};var te=class extends Error{static{c(this,"SmpFilterException")}message;data;constructor(t="Filter Exception",e){super(),this.message=t,this.data=e}};var ee=require("ts-luxon");var re=class i{static{c(this,"SmpSid")}value;expiry;get active(){return this.value.endsWith(this._controlSuffix)}get expired(){return ee.DateTime.now().ts>this.expiry}get valid(){return!this.expired}_controlSuffix="$1";constructor(t=`sid-xxxx-${+ee.DateTime.now().ts}`,e=0){this.value=t,this.expiry=e}static parse(t){return new i(t.value,t.expiry)}toPlain(){return{value:this.value,expiry:this.expiry}}};var Je=require("@tonysamperi/logger");var se=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 Vr="2.0.0-beta.4";0&&(module.exports={SMP_HEALTHZ,SmpAbstractCacheStrategy,SmpAbstractTtlCacheStrategy,SmpAesCrypt,SmpApiCommonUtils,SmpBaseJwtToken,SmpBaseJwtTokenPlain,SmpBrowserCache,SmpCommonUtils,SmpCrypto,SmpErrorResponse,SmpFilterException,SmpFirebaseErrors,SmpGenericResponse,SmpGiftcardTransaction,SmpGiftcardTransactionHashStrategies,SmpGiftcardTransactionOps,SmpHttpService,SmpHttpSessionStorageCache,SmpHttpStatusCodes,SmpInMemoryCache,SmpMarketingCloudValidators,SmpRegularExpressions,SmpResponseMessage,SmpResponseMessageTypes,SmpRestVerbs,SmpSecureCode,SmpSid,SmpSocialSignInKeys,SmpSocialSignInUxModes,VERSION,smpApplyMixin,smpIsSmpCachedValue,smpNoop});
1
+ "use strict";var zt=Object.defineProperty;var ys=Object.getOwnPropertyDescriptor;var xs=Object.getOwnPropertyNames;var bs=Object.prototype.hasOwnProperty;var n=(e,t)=>zt(e,"name",{value:t,configurable:!0});var As=(e,t)=>{for(var r in t)zt(e,r,{get:t[r],enumerable:!0})},Es=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xs(t))!bs.call(e,s)&&s!==r&&zt(e,s,{get:()=>t[s],enumerable:!(o=ys(t,s))||o.enumerable});return e};var vs=e=>Es(zt({},"__esModule",{value:!0}),e);var Ec={};As(Ec,{SMP_HEALTHZ:()=>Cs,SmpAbstractCacheStrategy:()=>Tt,SmpAbstractTtlCacheStrategy:()=>tt,SmpAesCrypt:()=>yt,SmpApiCommonUtils:()=>je,SmpBaseJwtToken:()=>Ne,SmpBaseJwtTokenPlain:()=>Me,SmpBrowserCache:()=>Ct,SmpCommonUtils:()=>Ke,SmpCrypto:()=>at,SmpErrorResponse:()=>L,SmpFilterException:()=>qe,SmpFirebaseErrors:()=>js,SmpGenericResponse:()=>ut,SmpGiftcardTransaction:()=>Qt,SmpGiftcardTransactionHashStrategies:()=>ct,SmpGiftcardTransactionOps:()=>j,SmpHttpSessionStorageCache:()=>It,SmpHttpStatusCodes:()=>ye,SmpHttpTwoService:()=>Pe,SmpInMemoryCache:()=>Nt,SmpMarketingCloudValidators:()=>Ns,SmpRegularExpressions:()=>Ve,SmpResponseMessage:()=>N,SmpResponseMessageTypes:()=>et,SmpRestVerbs:()=>De,SmpSecureCode:()=>Jt,SmpSid:()=>He,SmpSocialSignInKeys:()=>Is,SmpSocialSignInUxModes:()=>Ps,VERSION:()=>Ac,smpApplyMixin:()=>Ms,smpIsSmpCachedValue:()=>_e,smpNoop:()=>ls.smpNoop});module.exports=vs(Ec);var we=require("ts-luxon");var Tt=class{static{n(this,"SmpAbstractCacheStrategy")}};function _e(e){return typeof e=="object"&&e!==null&&"value"in e&&"expiry"in e&&typeof e.expiry=="number"}n(_e,"smpIsSmpCachedValue");var tt=class extends Tt{static{n(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(t){let r=this._readRaw(t);if(this._isSmpCachedValue(r)){if(r.expiry>=we.DateTime.now().ts)return r.value;this._removeRaw(t);return}return r}remove(t){this._removeRaw(t)}write(t,r,o){if(isNaN(+o)||+o<=0){this._writeRaw(t,r,o);return}let s=we.DateTime.now().ts+o*1e3,i={value:r,expiry:s};this._writeRaw(t,i,o)}_isSmpCachedValue(t){return _e(t)}};var Ct=class extends tt{static{n(this,"SmpBrowserCache")}_storage;_prefix;constructor(t,r){super(),this._storage=t,this._prefix=r}_flushRaw(){let t=[],r=-1;for(;++r<this._storage.length;){let o=this._storage.key(r);o&&o.startsWith(this._prefix)&&t.push(o)}for(r=-1;++r<t.length;)this._storage.removeItem(t[r])}_readRaw(t){let r=this._storage.getItem(this._prefix+t);try{return r?JSON.parse(r):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+t}`);return}}_removeRaw(t){this._storage.removeItem(this._prefix+t)}_writeRaw(t,r){try{this._storage.setItem(this._prefix+t,JSON.stringify(r))}catch(o){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+t}`,o)}}};var It=class extends Ct{static{n(this,"SmpHttpSessionStorageCache")}constructor(){super(sessionStorage,"smp_rest_cache_")}};var ye=(function(e){return e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.Unused=306]="Unused",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e})({});var Pt=require("class-transformer");var H=require("class-transformer");var xe=require("class-transformer");var et=(function(e){return e.INFO="INFO",e.SUCCESS="SUCCESS",e.WARNING="WARNING",e.ERROR="ERROR",e})({});function rr(e,t,r,o){var s=arguments.length,i=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(s<3?a(i):s>3?a(t,r,i):a(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}n(rr,"_ts_decorate");function $t(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}n($t,"_ts_metadata");var N=class e{static{n(this,"SmpResponseMessage")}_message;_type;get message(){return this._message}get type(){return this._type}constructor(t,r=et.ERROR){this._message=t,this._type=r}static sanitizeMessages(t){return typeof t=="string"?t.length?[new e(t)]:[]:[t].flat().map(r=>typeof r=="string"?new e(r):r)}};rr([(0,xe.Expose)(),$t("design:type",String),$t("design:paramtypes",[])],N.prototype,"message",null);rr([(0,xe.Expose)(),$t("design:type",typeof et>"u"?Object:et),$t("design:paramtypes",[])],N.prototype,"type",null);function Os(e,t,r,o){var s=arguments.length,i=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(s<3?a(i):s>3?a(t,r,i):a(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}n(Os,"_ts_decorate");function or(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}n(or,"_ts_metadata");var ut=class e{static{n(this,"SmpGenericResponse")}_messages;data;set messages(t){this._messages=N.sanitizeMessages(t)}get messages(){return this._messages}constructor(t=[],r){this._messages=t,this.data=r}static create(t){return new e([t.messages||[]].flat().map(r=>r instanceof N?r:new N(r,t.type||et.SUCCESS)),t.data)}static fromPlain(t){return(0,H.plainToInstance)(e,t)}isError(){return!this.isSuccess()}isSuccess(){return typeof this._errorCode=="number"}serialize(){return(0,H.instanceToPlain)(this,{excludePrefixes:["_"]})}};Os([(0,H.Expose)(),(0,H.Transform)(({value:e})=>e?.length?e:void 0),or("design:type",Object),or("design:paramtypes",[])],ut.prototype,"messages",null);function sr(e,t,r,o){var s=arguments.length,i=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(s<3?a(i):s>3?a(t,r,i):a(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}n(sr,"_ts_decorate");function kt(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}n(kt,"_ts_metadata");var L=class e extends ut{static{n(this,"SmpErrorResponse")}_errorCode;_status;static get DEFAULT_MESSAGES(){return[new N("GENERIC_ERROR")]}set errorCode(t){this._errorCode=t}get errorCode(){return this._errorCode}get status(){return this._status}set timestamp(t){this._timestamp=t}get timestamp(){return this._timestamp}_timestamp=Date.now();constructor(t=e.DEFAULT_MESSAGES,r="GENERIC_ERROR",o=500,s){super(t,s),this._errorCode=r,this._status=o}static create({messages:t=e.DEFAULT_MESSAGES,...r}={}){return new e(N.sanitizeMessages(t),r.errorCode,r.status,r.data)}static fromPlain(t){let r=(0,Pt.plainToInstance)(Rs,t,{excludePrefixes:["_"]}),o=new e;return Object.getOwnPropertyNames(r).forEach(s=>{s in o&&(o[s]=r[s])}),o}};sr([(0,Pt.Expose)(),kt("design:type",Object),kt("design:paramtypes",[])],L.prototype,"errorCode",null);sr([(0,Pt.Expose)(),kt("design:type",Number),kt("design:paramtypes",[])],L.prototype,"timestamp",null);var Rs=class extends L{static{n(this,"SmpErrorResponseMutable")}set errorCode(t){this._errorCode=t}set status(t){this._status=t}set timestamp(t){this._timestamp=t}};var V=class{static{n(this,"Hex")}static parse(t){let r=t.length,o=[];for(let s=0;s<r;s+=2)o[s>>>3]|=parseInt(t.substr(s,2),16)<<24-s%8*4;return new _(o,r/2)}static stringify(t){let r=[];for(let o=0;o<t.sigBytes;o++){let s=t.words[o>>>2]>>>24-o%4*8&255;r.push((s>>>4).toString(16)),r.push((s&15).toString(16))}return r.join("")}};var _=class be{static{n(this,"WordArray")}constructor(t,r){this.words=t||[],r!==void 0?this.sigBytes=r:this.sigBytes=this.words.length*4}static random(t){let r=[],o=n(function(s){let i=987654321,a=4294967295;return function(){i=36969*(i&65535)+(i>>16)&a,s=18e3*(s&65535)+(s>>16)&a;let c=(i<<16)+s&a;return c/=4294967296,c+=.5,c*(Math.random()>.5?1:-1)}},"r");for(let s=0,i;s<t;s+=4){let a=o((i||Math.random())*4294967296);i=a()*987654071,r.push(a()*4294967296|0)}return new be(r,t)}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(t){if(this.clamp(),this.sigBytes%4)for(let r=0;r<t.sigBytes;r++){let o=t.words[r>>>2]>>>24-r%4*8&255;this.words[this.sigBytes+r>>>2]|=o<<24-(this.sigBytes+r)%4*8}else for(let r=0;r<t.sigBytes;r+=4)this.words[this.sigBytes+r>>>2]=t.words[r>>>2];return this.sigBytes+=t.sigBytes,this}toString(t){return(t||V).stringify(this)}};var Gt=class{static{n(this,"Latin1")}static parse(t){let r=t.length,o=[];for(let s=0;s<r;s++)o[s>>>2]|=(t.charCodeAt(s)&255)<<24-s%4*8;return new _(o,r)}static stringify(t){let r=[];for(let o=0;o<t.sigBytes;o++){let s=t.words[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(s))}return r.join("")}};var I=class{static{n(this,"Utf8")}static parse(t){return Gt.parse(unescape(encodeURIComponent(t)))}static stringify(t){try{return decodeURIComponent(escape(Gt.stringify(t)))}catch(r){throw console.error("Malformed UTF-8 data",r),new Error("Malformed UTF-8 data")}}};var Wt=class{static{n(this,"BufferedBlockAlgorithm")}constructor(t){this._minBufferSize=0,this.cfg=Object.assign({blockSize:1},t),this._data=new _,this._nDataBytes=0}clone(){let t=this.constructor();for(let r in this)Object.prototype.hasOwnProperty.call(this,r)&&(t[r]=this[r]);return t._data=this._data.clone(),t}reset(){this._data=new _,this._nDataBytes=0}_append(t){typeof t=="string"&&(t=I.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}_process(t){if(!this.cfg.blockSize)throw new Error("missing blockSize in config");let r=this.cfg.blockSize*4,o=this._data.sigBytes/r;t?o=Math.ceil(o):o=Math.max((o|0)-this._minBufferSize,0);let s=o*this.cfg.blockSize,i=Math.min(s*4,this._data.sigBytes),a;if(s){for(let c=0;c<s;c+=this.cfg.blockSize)this._doProcessBlock(this._data.words,c);a=this._data.words.splice(0,s),this._data.sigBytes-=i}return new _(a,i)}};var dt=class{static{n(this,"CipherParams")}constructor(t){this.ciphertext=t.ciphertext,this.key=t.key,this.iv=t.iv,this.salt=t.salt,this.algorithm=t.algorithm,this.mode=t.mode,this.padding=t.padding,this.blockSize=t.blockSize,this.formatter=t.formatter}extend(t){return t.ciphertext!==void 0&&(this.ciphertext=t.ciphertext),t.key!==void 0&&(this.key=t.key),t.iv!==void 0&&(this.iv=t.iv),t.salt!==void 0&&(this.salt=t.salt),t.algorithm!==void 0&&(this.algorithm=t.algorithm),t.mode!==void 0&&(this.mode=t.mode),t.padding!==void 0&&(this.padding=t.padding),t.blockSize!==void 0&&(this.blockSize=t.blockSize),t.formatter!==void 0&&(this.formatter=t.formatter),this}toString(t){if(t)return t.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{n(this,"Base64")}static parse(t){let r=t.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 o=this._map.charAt(64);if(o){let s=t.indexOf(o);s!==-1&&(r=s)}return this.parseLoop(t,r,this._reverseMap)}static parseLoop(t,r,o){let s=[],i=0;for(let a=0;a<r;a++)if(a%4){let c=o[t.charCodeAt(a-1)]<<a%4*2,h=o[t.charCodeAt(a)]>>>6-a%4*2;s[i>>>2]|=(c|h)<<24-i%4*8,i++}return new _(s,i)}static stringify(t){t.clamp();let r=[];for(let s=0;s<t.sigBytes;s+=3){let i=t.words[s>>>2]>>>24-s%4*8&255,a=t.words[s+1>>>2]>>>24-(s+1)%4*8&255,c=t.words[s+2>>>2]>>>24-(s+2)%4*8&255,h=i<<16|a<<8|c;for(let f=0;f<4&&s+f*.75<t.sigBytes;f++)r.push(this._map.charAt(h>>>6*(3-f)&63))}let o=this._map.charAt(64);if(o)for(;r.length%4;)r.push(o);return r.join("")}};z._map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";z._reverseMap=void 0;var Kt=class{static{n(this,"OpenSSL")}static parse(t){let r=z.parse(t),o;return r.words[0]===1398893684&&r.words[1]===1701076831&&(o=new _(r.words.slice(2,4)),r.words.splice(0,4),r.sigBytes-=16),new dt({ciphertext:r,salt:o})}static stringify(t){if(!t.ciphertext)throw new Error("missing ciphertext in params");let r=t.ciphertext,o=t.salt,s;if(o){if(typeof o=="string")throw new Error("salt is expected to be a WordArray");s=new _([1398893684,1701076831]).concat(o).concat(r)}else s=r;return s.toString(z)}};var rt=class{static{n(this,"SerializableCipher")}static decrypt(t,r,o,s){let i=Object.assign({},this.cfg,s);if(!i.format)throw new Error("could not determine format");if(r=this._parse(r,i.format),!r.ciphertext)throw new Error("could not determine ciphertext");return t.createDecryptor(o,i).finalize(r.ciphertext)}static encrypt(t,r,o,s){let i=Object.assign({},this.cfg,s),a=t.createEncryptor(o,i),c=a.finalize(r);return new dt({ciphertext:c,key:o,iv:a.cfg.iv,algorithm:t,mode:a.cfg.mode,padding:a.cfg.padding,blockSize:a.cfg.blockSize,formatter:i.format})}static _parse(t,r){return typeof t=="string"?r.parse(t):t}};rt.cfg={blockSize:4,iv:new _([]),format:Kt};var C=class extends Wt{static{n(this,"Hasher")}constructor(t){super(Object.assign({blockSize:512/32},t)),this.reset()}static _createHelper(t){function r(o,s){return new t(s).finalize(o)}return n(r,"helper"),r}finalize(t){return t&&this._append(t),this._doFinalize()}update(t){return this._append(t),this._process(),this}};var p=[];for(let e=0;e<64;e++)p[e]=Math.abs(Math.sin(e+1))*4294967296|0;var $=class u extends C{static{n(this,"MD5")}get hash(){return this._hash}static FF(t,r,o,s,i,a,c){let h=t+(r&o|~r&s)+i+c;return(h<<a|h>>>32-a)+r}static GG(t,r,o,s,i,a,c){let h=t+(r&s|o&~s)+i+c;return(h<<a|h>>>32-a)+r}static HH(t,r,o,s,i,a,c){let h=t+(r^o^s)+i+c;return(h<<a|h>>>32-a)+r}static II(t,r,o,s,i,a,c){let h=t+(o^(r|~s))+i+c;return(h<<a|h>>>32-a)+r}reset(){super.reset(),this._hash=new _([1732584193,4023233417,2562383102,271733878])}_doFinalize(){let t=this._nDataBytes*8,r=this._data.sigBytes*8;this._data.words[r>>>5]|=128<<24-r%32;let o=Math.floor(t/4294967296),s=t;this._data.words[(r+64>>>9<<4)+15]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,this._data.words[(r+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 i=0;i<4;i++)this._hash.words[i]=(this._hash.words[i]<<8|this._hash.words[i]>>>24)&16711935|(this._hash.words[i]<<24|this._hash.words[i]>>>8)&4278255360;return this._hash}_doProcessBlock(t,r){for(let h=0;h<16;h++){let f=r+h,g=t[f];t[f]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}let o=Array.from({length:16});for(let h=0;h<16;h++)o[h]=t[r+h];let s=this._hash.words[0],i=this._hash.words[1],a=this._hash.words[2],c=this._hash.words[3];s=u.FF(s,i,a,c,o[0],7,p[0]),c=u.FF(c,s,i,a,o[1],12,p[1]),a=u.FF(a,c,s,i,o[2],17,p[2]),i=u.FF(i,a,c,s,o[3],22,p[3]),s=u.FF(s,i,a,c,o[4],7,p[4]),c=u.FF(c,s,i,a,o[5],12,p[5]),a=u.FF(a,c,s,i,o[6],17,p[6]),i=u.FF(i,a,c,s,o[7],22,p[7]),s=u.FF(s,i,a,c,o[8],7,p[8]),c=u.FF(c,s,i,a,o[9],12,p[9]),a=u.FF(a,c,s,i,o[10],17,p[10]),i=u.FF(i,a,c,s,o[11],22,p[11]),s=u.FF(s,i,a,c,o[12],7,p[12]),c=u.FF(c,s,i,a,o[13],12,p[13]),a=u.FF(a,c,s,i,o[14],17,p[14]),i=u.FF(i,a,c,s,o[15],22,p[15]),s=u.GG(s,i,a,c,o[1],5,p[16]),c=u.GG(c,s,i,a,o[6],9,p[17]),a=u.GG(a,c,s,i,o[11],14,p[18]),i=u.GG(i,a,c,s,o[0],20,p[19]),s=u.GG(s,i,a,c,o[5],5,p[20]),c=u.GG(c,s,i,a,o[10],9,p[21]),a=u.GG(a,c,s,i,o[15],14,p[22]),i=u.GG(i,a,c,s,o[4],20,p[23]),s=u.GG(s,i,a,c,o[9],5,p[24]),c=u.GG(c,s,i,a,o[14],9,p[25]),a=u.GG(a,c,s,i,o[3],14,p[26]),i=u.GG(i,a,c,s,o[8],20,p[27]),s=u.GG(s,i,a,c,o[13],5,p[28]),c=u.GG(c,s,i,a,o[2],9,p[29]),a=u.GG(a,c,s,i,o[7],14,p[30]),i=u.GG(i,a,c,s,o[12],20,p[31]),s=u.HH(s,i,a,c,o[5],4,p[32]),c=u.HH(c,s,i,a,o[8],11,p[33]),a=u.HH(a,c,s,i,o[11],16,p[34]),i=u.HH(i,a,c,s,o[14],23,p[35]),s=u.HH(s,i,a,c,o[1],4,p[36]),c=u.HH(c,s,i,a,o[4],11,p[37]),a=u.HH(a,c,s,i,o[7],16,p[38]),i=u.HH(i,a,c,s,o[10],23,p[39]),s=u.HH(s,i,a,c,o[13],4,p[40]),c=u.HH(c,s,i,a,o[0],11,p[41]),a=u.HH(a,c,s,i,o[3],16,p[42]),i=u.HH(i,a,c,s,o[6],23,p[43]),s=u.HH(s,i,a,c,o[9],4,p[44]),c=u.HH(c,s,i,a,o[12],11,p[45]),a=u.HH(a,c,s,i,o[15],16,p[46]),i=u.HH(i,a,c,s,o[2],23,p[47]),s=u.II(s,i,a,c,o[0],6,p[48]),c=u.II(c,s,i,a,o[7],10,p[49]),a=u.II(a,c,s,i,o[14],15,p[50]),i=u.II(i,a,c,s,o[5],21,p[51]),s=u.II(s,i,a,c,o[12],6,p[52]),c=u.II(c,s,i,a,o[3],10,p[53]),a=u.II(a,c,s,i,o[10],15,p[54]),i=u.II(i,a,c,s,o[1],21,p[55]),s=u.II(s,i,a,c,o[8],6,p[56]),c=u.II(c,s,i,a,o[15],10,p[57]),a=u.II(a,c,s,i,o[6],15,p[58]),i=u.II(i,a,c,s,o[13],21,p[59]),s=u.II(s,i,a,c,o[4],6,p[60]),c=u.II(c,s,i,a,o[11],10,p[61]),a=u.II(a,c,s,i,o[2],15,p[62]),i=u.II(i,a,c,s,o[9],21,p[63]),this._hash.words[0]=this._hash.words[0]+s|0,this._hash.words[1]=this._hash.words[1]+i|0,this._hash.words[2]=this._hash.words[2]+a|0,this._hash.words[3]=this._hash.words[3]+c|0}};var Ae=class ir{static{n(this,"EVPKDF")}constructor(t){this.cfg=Object.assign({keySize:128/32,hasher:$,iterations:1},t)}static execute(t,r,o){return new ir(o).compute(t,r)}compute(t,r){let o=new this.cfg.hasher,s=new _,i;for(;s.words.length<this.cfg.keySize;){i&&o.update(i),i=o.update(t).finalize(r),o.reset();for(let a=1;a<this.cfg.iterations;a++)i=o.finalize(i),o.reset();s.concat(i)}return s.sigBytes=this.cfg.keySize*4,s}};var nr=class{static{n(this,"OpenSSLKdf")}static execute(t,r,o,s){s||(s=_.random(64/8));let i=new Ae({keySize:r+o}).compute(t,s),a=new _(i.words.slice(r),o*4);return i.sigBytes=r*4,new dt({key:i,iv:a,salt:s})}};var qt=class{static{n(this,"PasswordBasedCipher")}static decrypt(t,r,o,s){let i=Object.assign({},this.cfg,s);if(i.format===void 0)throw new Error("missing format in config");if(r=this._parse(r,i.format),i.kdf===void 0)throw new Error("the key derivation function must be set");let a=i.kdf.execute(o,t.keySize,t.ivSize,r.salt);return a.iv!==void 0&&(i.iv=a.iv),rt.decrypt.call(this,t,r,a.key,i)}static encrypt(t,r,o,s){let i=Object.assign({},this.cfg,s);if(i.kdf===void 0)throw new Error("missing kdf in config");let a=i.kdf.execute(o,t.keySize,t.ivSize);return a.iv!==void 0&&(i.iv=a.iv),rt.encrypt.call(this,t,r,a.key,i).extend(a)}static _parse(t,r){return typeof t=="string"?r.parse(t):t}};qt.cfg={blockSize:4,iv:new _([]),format:Kt,kdf:nr};var ar=class{static{n(this,"CipherHelper")}constructor(t){this._cipher=t}decrypt(t,r,o){return typeof r=="string"?qt.decrypt(this._cipher,t,r,o):rt.decrypt(this._cipher,t,r,o)}encrypt(t,r,o){return typeof r=="string"?qt.encrypt(this._cipher,t,r,o):rt.encrypt(this._cipher,t,r,o)}};var mt=class extends Wt{static{n(this,"Cipher")}constructor(t,r,o){super(Object.assign({blockSize:1},o)),this._xformMode=t,this._key=r,this.reset()}static _createHelper(t){return new ar(t)}static createDecryptor(t,r){let o=this;return new o(this._DEC_XFORM_MODE,t,r)}static createEncryptor(t,r){return new this(this._ENC_XFORM_MODE,t,r)}finalize(t){return t&&this._append(t),this._doFinalize()}process(t){return this._append(t),this._process()}};mt.ivSize=4;mt.keySize=4;mt._DEC_XFORM_MODE=2;mt._ENC_XFORM_MODE=1;var ot=class{static{n(this,"BlockCipherModeAlgorithm")}constructor(t,r){this.init(t,r)}init(t,r){this._cipher=t,this._iv=r}};var St=class{static{n(this,"BlockCipherMode")}static createDecryptor(t,r){let o=this.Decryptor;return new o(t,r)}static createEncryptor(t,r){let o=this.Encryptor;return new o(t,r)}};St.Decryptor=ot;St.Encryptor=ot;var cr=class extends ot{static{n(this,"CBCEncryptor")}get prevBlock(){return this._prevBlock}processBlock(t,r){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");this.xorBlock(t,r,this._cipher.cfg.blockSize),this._cipher.encryptBlock(t,r),this._prevBlock=t.slice(r,r+this._cipher.cfg.blockSize)}xorBlock(t,r,o){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let i=0;i<o;i++)t[r+i]^=s[i]}};var hr=class extends ot{static{n(this,"CBCDecryptor")}get prevBlock(){return this._prevBlock}processBlock(t,r){if(this._cipher.cfg.blockSize===void 0)throw new Error("missing blockSize in cipher config");let o=t.slice(r,r+this._cipher.cfg.blockSize);this._cipher.decryptBlock(t,r),this.xorBlock(t,r,this._cipher.cfg.blockSize),this._prevBlock=o}xorBlock(t,r,o){let s;this._iv?(s=this._iv,this._iv=void 0):s=this._prevBlock;for(let i=0;i<o;i++)t[r+i]^=s[i]}};var X=class extends St{static{n(this,"CBC")}};X.Decryptor=hr;X.Encryptor=cr;var gt=class{static{n(this,"PKCS7")}static pad(t,r){let o=r*4,s=o-t.sigBytes%o,i=s<<24|s<<16|s<<8|s,a=[];for(let h=0;h<s;h+=4)a.push(i);let c=new _(a,s);t.concat(c)}static unpad(t){let r=t.words[t.sigBytes-1>>>2]&255;t.sigBytes-=r}};var Ht=class extends mt{static{n(this,"BlockCipher")}constructor(t,r,o){super(t,r,Object.assign({blockSize:4,mode:X,padding:gt},o))}reset(){if(super.reset(),this.cfg.mode===void 0)throw new Error("missing mode in config");let t;this._xformMode===this.constructor._ENC_XFORM_MODE?t=this.cfg.mode.createEncryptor:(t=this.cfg.mode.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator===t?this._mode.init(this,this.cfg.iv&&this.cfg.iv.words):(this._mode=t.call(this.cfg.mode,this,this.cfg.iv&&this.cfg.iv.words),this._mode.__creator=t)}_doFinalize(){if(this.cfg.padding===void 0)throw new Error("missing padding in config");let t;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),t=this._process(!0)}else t=this._process(!0),this.cfg.padding.unpad(t);return t}_doProcessBlock(t,r){this._mode.processBlock(t,r)}};var l=class U{static{n(this,"X64Word")}constructor(t,r){this.high=t,this.low=r}add(t){let r=this.low+t.low|0,o=r>>>0<this.low>>>0?1:0,s=this.high+t.high+o|0;return new U(s,r)}and(t){return new U(this.high&t.high,this.low&t.low)}not(){return new U(~this.high,~this.low)}or(t){return new U(this.high|t.high,this.low|t.low)}rotL(t){return this.shiftL(t).or(this.shiftR(64-t))}rotR(t){return this.shiftR(t).or(this.shiftL(64-t))}shiftL(t){return t<32?new U(this.high<<t|this.low>>>32-t,this.low<<t):new U(this.low<<t-32,0)}shiftR(t){return t<32?new U(this.high>>>t,this.low>>>t|this.high<<32-t):new U(0,this.high>>>t-32)}xor(t){return new U(this.high^t.high,this.low^t.low)}};var lr=class Ee{static{n(this,"X64WordArray")}constructor(t=[],r){this.words=t,this.sigBytes=r!==void 0?r:t.length*8}static create(t=[],r){return new Ee(t,r)}clone(){let t=this.words.map(r=>new l(r.high,r.low));return new Ee(t,this.sigBytes)}toX32(){let t=[];for(let r of this.words)t.push(r.high,r.low);return new _(t,this.sigBytes)}};var P=[],fr=[],pr=[],ur=[],dr=[],mr=[],ve=[],Oe=[],Re=[],Be=[];(function(){let e=[];for(let o=0;o<256;o++)o<128?e[o]=o<<1:e[o]=o<<1^283;let t=0,r=0;for(let o=0;o<256;o++){let s=r^r<<1^r<<2^r<<3^r<<4;s=s>>>8^s&255^99,P[t]=s,fr[s]=t;let i=e[t],a=e[i],c=e[a],h=e[s]*257^s*16843008;pr[t]=h<<24|h>>>8,ur[t]=h<<16|h>>>16,dr[t]=h<<8|h>>>24,mr[t]=h,h=c*16843009^a*65537^i*257^t*16843008,ve[s]=h<<24|h>>>8,Oe[s]=h<<16|h>>>16,Re[s]=h<<8|h>>>24,Be[s]=h,t?(t=i^e[e[e[c^i]]],r^=e[e[r]]):t=r=1}})();var Bs=[0,1,2,4,8,16,32,64,128,27,54],Vt=class extends Ht{static{n(this,"AES")}constructor(t,r,o){super(t,r,o),super.reset()}decryptBlock(t,r){let o=t[r+1];t[r+1]=t[r+3],t[r+3]=o,this._doCryptBlock(t,r,this._invKeySchedule,ve,Oe,Re,Be,fr),o=t[r+1],t[r+1]=t[r+3],t[r+3]=o}encryptBlock(t,r){this._doCryptBlock(t,r,this._keySchedule,pr,ur,dr,mr,P)}reset(){if(super.reset(),this._nRounds&&this._keyPriorReset===this._key)return;let t=this._keyPriorReset=this._key,r=t.words,o=t.sigBytes/4,i=((this._nRounds=o+6)+1)*4,a=this._keySchedule=[];for(let c=0;c<i;c++)if(c<o)a[c]=r[c];else{let h=a[c-1];c%o?o>6&&c%o===4&&(h=P[h>>>24]<<24|P[h>>>16&255]<<16|P[h>>>8&255]<<8|P[h&255]):(h=h<<8|h>>>24,h=P[h>>>24]<<24|P[h>>>16&255]<<16|P[h>>>8&255]<<8|P[h&255],h^=Bs[c/o|0]<<24),a[c]=a[c-o]^h}this._invKeySchedule=[];for(let c=0;c<i;c++){let h=i-c,f;c%4?f=a[h]:f=a[h-4],c<4||h<=4?this._invKeySchedule[c]=f:this._invKeySchedule[c]=ve[P[f>>>24]]^Oe[P[f>>>16&255]]^Re[P[f>>>8&255]]^Be[P[f&255]]}}_doCryptBlock(t,r,o,s,i,a,c,h){let f=t[r]^o[0],g=t[r+1]^o[1],d=t[r+2]^o[2],m=t[r+3]^o[3],w=4;for(let v=1;v<this._nRounds;v++){let x=s[f>>>24]^i[g>>>16&255]^a[d>>>8&255]^c[m&255]^o[w++],b=s[g>>>24]^i[d>>>16&255]^a[m>>>8&255]^c[f&255]^o[w++],T=s[d>>>24]^i[m>>>16&255]^a[f>>>8&255]^c[g&255]^o[w++],ge=s[m>>>24]^i[f>>>16&255]^a[g>>>8&255]^c[d&255]^o[w++];f=x,g=b,d=T,m=ge}let y=(h[f>>>24]<<24|h[g>>>16&255]<<16|h[d>>>8&255]<<8|h[m&255])^o[w++],E=(h[g>>>24]<<24|h[d>>>16&255]<<16|h[m>>>8&255]<<8|h[f&255])^o[w++],O=(h[d>>>24]<<24|h[m>>>16&255]<<16|h[f>>>8&255]<<8|h[g&255])^o[w++],R=(h[m>>>24]<<24|h[f>>>16&255]<<16|h[g>>>8&255]<<8|h[d&255])^o[w++];t[r]=y,t[r+1]=E,t[r+2]=O,t[r+3]=R}};Vt.keySize=256/32;var Ts=[1732584193,4023233417,2562383102,271733878,3285377520],st=new Array(80),it=class extends C{static{n(this,"SHA1")}get hash(){return this._hash}reset(){super.reset(),this._hash=new _(Ts.slice(0))}_doFinalize(){let t=this._nDataBytes*8,r=this._data.sigBytes*8;return this._data.words[r>>>5]|=128<<24-r%32,this._data.words[(r+64>>>9<<4)+14]=Math.floor(t/4294967296),this._data.words[(r+64>>>9<<4)+15]=t,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(t,r){let o=this._hash.words[0],s=this._hash.words[1],i=this._hash.words[2],a=this._hash.words[3],c=this._hash.words[4];for(let h=0;h<80;h++){if(h<16)st[h]=t[r+h]|0;else{let m=st[h-3]^st[h-8]^st[h-14]^st[h-16];st[h]=m<<1|m>>>31}let f,g;h<20?(f=s&i|~s&a,g=1518500249):h<40?(f=s^i^a,g=1859775393):h<60?(f=s&i|s&a|i&a,g=2400959708):(f=s^i^a,g=3395469782);let d=(o<<5|o>>>27)+f+c+g+st[h];c=a,a=i,i=s<<30|s>>>2,s=o,o=d|0}this._hash.words[0]=this._hash.words[0]+o|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+i|0,this._hash.words[3]=this._hash.words[3]+a|0,this._hash.words[4]=this._hash.words[4]+c|0}};var gr=[],_r=[];(function(){function e(s){let i=Math.sqrt(s);for(let a=2;a<=i;a++)if(!(s%a))return!1;return!0}n(e,"isPrime");function t(s){return(s-(s|0))*4294967296|0}n(t,"getFractionalBits");let r=2,o=0;for(;o<64;)e(r)&&(o<8&&(gr[o]=t(Math.pow(r,1/2))),_r[o]=t(Math.pow(r,1/3)),o++),r++})();var nt=[],jt=class extends C{static{n(this,"SHA256")}constructor(){super()}reset(){super.reset(),this._hash=new _(gr.slice(0))}_doFinalize(){let t=this._nDataBytes*8,r=this._data.sigBytes*8;return this._data.words[r>>>5]|=128<<24-r%32,this._data.words[(r+64>>>9<<4)+14]=Math.floor(t/4294967296),this._data.words[(r+64>>>9<<4)+15]=t,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(t,r){let o=this._hash.words[0],s=this._hash.words[1],i=this._hash.words[2],a=this._hash.words[3],c=this._hash.words[4],h=this._hash.words[5],f=this._hash.words[6],g=this._hash.words[7];for(let d=0;d<64;d++){if(d<16)nt[d]=t[r+d]|0;else{let v=nt[d-15],x=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,b=nt[d-2],T=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;nt[d]=x+nt[d-7]+T+nt[d-16]}let m=c&h^~c&f,w=o&s^o&i^s&i,y=(o<<30|o>>>2)^(o<<19|o>>>13)^(o<<10|o>>>22),E=(c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25),O=g+E+m+_r[d]+nt[d],R=y+w;g=f,f=h,h=c,c=a+O|0,a=i,i=s,s=o,o=O+R|0}this._hash.words[0]=this._hash.words[0]+o|0,this._hash.words[1]=this._hash.words[1]+s|0,this._hash.words[2]=this._hash.words[2]+i|0,this._hash.words[3]=this._hash.words[3]+a|0,this._hash.words[4]=this._hash.words[4]+c|0,this._hash.words[5]=this._hash.words[5]+h|0,this._hash.words[6]=this._hash.words[6]+f|0,this._hash.words[7]=this._hash.words[7]+g|0}};var Te=[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 e=0;e<80;e++)M[e]=new l(void 0,void 0)})();var Ce=class extends C{static{n(this,"SHA512")}constructor(){super({blockSize:1024/32})}reset(){super.reset(),this._hash=new lr([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 t=this._data,r=t.words,o=this._nDataBytes*8,s=t.sigBytes*8;return r[s>>>5]|=128<<24-s%32,r[(s+128>>>10<<5)+30]=Math.floor(o/4294967296),r[(s+128>>>10<<5)+31]=o,t.sigBytes=r.length*4,this._process(),this._hash.toX32()}_doProcessBlock(t,r){let o=this._hash.words[0].high,s=this._hash.words[0].low,i=this._hash.words[1].high,a=this._hash.words[1].low,c=this._hash.words[2].high,h=this._hash.words[2].low,f=this._hash.words[3].high,g=this._hash.words[3].low,d=this._hash.words[4].high,m=this._hash.words[4].low,w=this._hash.words[5].high,y=this._hash.words[5].low,E=this._hash.words[6].high,O=this._hash.words[6].low,R=this._hash.words[7].high,v=this._hash.words[7].low;for(let x=0;x<80;x++){let b,T;if(x<16)T=M[x].high=t[r+x*2]|0,b=M[x].low=t[r+x*2+1]|0;else{let Ye=M[x-15],ft=Ye.high,Rt=Ye.low,_s=(ft>>>1|Rt<<31)^(ft>>>8|Rt<<24)^ft>>>7,Qe=(Rt>>>1|ft<<31)^(Rt>>>8|ft<<24)^(Rt>>>7|ft<<25),tr=M[x-2],pt=tr.high,Bt=tr.low,ws=(pt>>>19|Bt<<13)^(pt<<3|Bt>>>29)^pt>>>6,er=(Bt>>>19|pt<<13)^(Bt<<3|pt>>>29)^(Bt>>>6|pt<<26);b=Qe+M[x-7].low,T=_s+M[x-7].high+(b>>>0<Qe>>>0?1:0),b=b+er,T=T+ws+(b>>>0<er>>>0?1:0),b=b+M[x-16].low,T=T+M[x-16].high+(b>>>0<M[x-16].low>>>0?1:0),M[x].high=T,M[x].low=b}let ge=d&w^~d&E,Xe=m&y^~m&O,fs=o&i^o&c^i&c,ps=s&a^s&h^a&h,us=(o>>>28|s<<4)^(o<<30|s>>>2)^(o<<25|s>>>7),Ze=(s>>>28|o<<4)^(s<<30|o>>>2)^(s<<25|o>>>7),ds=(d>>>14|m<<18)^(d>>>18|m<<14)^(d<<23|m>>>9),ms=(m>>>14|d<<18)^(m>>>18|d<<14)^(m<<23|d>>>9),D=v+ms,S=R+ds+(D>>>0<v>>>0?1:0);D=D+Xe,S=S+ge+(D>>>0<Xe>>>0?1:0),D=D+Te[x].low,S=S+Te[x].high+(D>>>0<Te[x].low>>>0?1:0),D=D+b,S=S+T+(D>>>0<b>>>0?1:0);let Je=Ze+ps,gs=us+fs+(Je>>>0<Ze>>>0?1:0);R=E,v=O,E=w,O=y,w=d,y=m,m=g+D|0,d=f+S+(m>>>0<g>>>0?1:0)|0,f=c,g=h,c=i,h=a,i=o,a=s,s=D+Je|0,o=S+gs+(s>>>0<D>>>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+o+(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+a,this._hash.words[1].high=this._hash.words[1].high+i+(this._hash.words[1].low>>>0<a>>>0?1:0),this._hash.words[2].low=this._hash.words[2].low=this._hash.words[2].low+h,this._hash.words[2].high=this._hash.words[2].high+c+(this._hash.words[2].low>>>0<h>>>0?1:0),this._hash.words[3].low=this._hash.words[3].low=this._hash.words[3].low+g,this._hash.words[3].high=this._hash.words[3].high+f+(this._hash.words[3].low>>>0<g>>>0?1:0),this._hash.words[4].low=this._hash.words[4].low=this._hash.words[4].low+m,this._hash.words[4].high=this._hash.words[4].high+d+(this._hash.words[4].low>>>0<m>>>0?1:0),this._hash.words[5].low=this._hash.words[5].low=this._hash.words[5].low+y,this._hash.words[5].high=this._hash.words[5].high+w+(this._hash.words[5].low>>>0<y>>>0?1:0),this._hash.words[6].low=this._hash.words[6].low=this._hash.words[6].low+O,this._hash.words[6].high=this._hash.words[6].high+E+(this._hash.words[6].low>>>0<O>>>0?1:0),this._hash.words[7].low=this._hash.words[7].low=this._hash.words[7].low+v,this._hash.words[7].high=this._hash.words[7].high+R+(this._hash.words[7].low>>>0<v>>>0?1:0)}};var wr=class{static{n(this,"HMAC")}constructor(t,r){this._hasher=new t;let o=typeof r=="string"?I.parse(r):r,s=this._hasher.cfg.blockSize,i=s*4;o.sigBytes>i&&(o=this._hasher.finalize(o)),o.clamp();let a=this._oKey=o.clone(),c=this._iKey=o.clone(),h=a.words,f=c.words;for(let g=0;g<s;g++)h[g]^=1549556828,f[g]^=909522486;a.sigBytes=c.sigBytes=i,this.reset()}finalize(t){let r=this._hasher.finalize(t);return this._hasher.reset(),this._hasher.finalize(this._oKey.clone().concat(r))}reset(){this._hasher.reset(),this._hasher.update(this._iKey)}update(t){return this._hasher.update(t),this}};var Ie=class yr{static{n(this,"PBKDF2")}constructor(t){this.cfg=Object.assign({keySize:128/32,hasher:jt,iterations:25e4},t)}static execute(t,r,o){return new yr(o).compute(t,r)}compute(t,r){let o=this.cfg,s=new wr(o.hasher,t),i=new _,a=new _([1]),c=i.words,h=a.words,f=o.keySize,g=o.iterations;for(;c.length<f;){let d=s.update(r).finalize(a);s.reset();let m=d.words,w=m.length,y=d;for(let E=1;E<g;E++){y=s.finalize(y),s.reset();let O=y.words;for(let R=0;R<w;R++)m[R]^=O[R]}i.concat(d),h[0]++}return i.sigBytes=f*4,i}};var Dt=Ht._createHelper(Vt);var _t=C._createHelper($);var wt=C._createHelper(it);var Xt=C._createHelper(jt);var Zt=C._createHelper(Ce);var at=class{static{n(this,"SmpCrypto")}static base64Decode(t){return I.stringify(z.parse(t))}static base64Encode(t){return z.stringify(I.parse(t))}static md5(t){return _t(t).toString()}static sha1(t){return wt(t).toString()}static sha256(t){return Xt(t).toString()}static sha512(t){return Zt(t).toString()}};var Nt=class extends tt{static{n(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(t){return this._staticSelf._storage.get(t)}_removeRaw(t){this._staticSelf._storage.delete(t)}_writeRaw(t,r){this._staticSelf._storage.set(t,r)}};var Pe=class{static{n(this,"SmpHttpTwoService")}static _cacheStrategy=typeof sessionStorage<"u"?new It:new Nt;static _errorClass=L;static _mergeParamsFallbackBaseUrl="https://uc-api-nest-common-fe";static _running=new Map;static $http(t){return this._generateAjax(t)}static async _generateAjax(t){let r=this._generateCacheKey(t),o=+(t.ttl||0)>0;if(o){let a=this._cacheStrategy.read(r);if(a)return Promise.resolve(a)}let s=this._running.get(r);if(s)return s;let i=this._generateAjaxBase(t).then(a=>(o&&this._cacheStrategy.write(r,a,t.ttl),a)).finally(()=>{this._running.delete(r)});return this._running.set(r,i),i}static async _generateAjaxBase(t){let r=await this._preprocessRequest(t),o={method:r.method,headers:new Headers({"content-type":"application/json",...r.headers}),body:r.body?JSON.stringify(r.body):null};return r.useCredentials&&(o.credentials="include"),r.url=this.mergeQueryParams(r.url,r.queryParams),fetch(r.url,o).then(s=>this._preprocessResponse(t,s)).then(s=>{if(s.ok){if(s.status===204||s.headers.get("content-length")==="0")return null;switch(r.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(i=>{let a=i;try{a=this._errorClass.fromPlain(i)}catch(c){console.debug("http: failed to parse error response into ErrorResponse",c)}return Promise.reject({status:s.status,message:s.statusText,body:a})})})}static cacheFlush(){this._cacheStrategy.flush()}static mergeQueryParams(t,r){if(!r||Object.keys(r).length===0)return t;let o=t.startsWith("http"),s=new URL(t,globalThis?.location?.origin||this._mergeParamsFallbackBaseUrl),a={...Object.fromEntries(new URLSearchParams(s.search).entries()),...r},c=[];for(let[d,m]of Object.entries(a))if(m!=null)if(Array.isArray(m))for(let w of m)c.push(`${encodeURIComponent(d)}=${encodeURIComponent(String(w))}`);else c.push(`${encodeURIComponent(d)}=${encodeURIComponent(String(m))}`);let h=c.length?`?${c.join("&")}`:"",g=s.origin+s.pathname+h;return o?g:g.replace(s.origin,"")}static _generateCacheKey(t){let r=`${t.method}:${t.url}`;return t.queryParams&&Object.keys(t.queryParams).length>0&&(r+=`:${at.md5(JSON.stringify(t.queryParams))}`),t.body&&Object.keys(t.body).length>0?`${r}:${at.md5(JSON.stringify(t.body))}`:r}static async _preprocessRequest(t){return t}static async _preprocessResponse(t,r){return r}};var xr=require("@tonysamperi/logger");var je=class{static{n(this,"SmpApiCommonUtils")}static _javascriptVariablePattern="[a-zA-Z_$][a-zA-Z_$0-9]*";static _logger=new xr.SmpLoggerMethods;static _pathParamRegex=new RegExp(`\\{(${this._javascriptVariablePattern})\\}`,"g");static credentialsToBasicAuth(t,r){return`Basic ${Buffer.from(`${t}:${r}`).toString("base64")}`}static fromBearer(t=""){return t.split(" ")[1]}static getCountryFromReferer(t){return this.getLocaleFromReferer(t)?.split("-")[0]?.toUpperCase()}static getLanguageFromReferer(t){return this.getLocaleFromReferer(t)?.split("-")[1]}static getLocaleFromReferer(t){return t?.match(/\/([A-Z]{2}-[A-Z]{2})\//i)?.[1]}static interpolateParams(t,r){try{return t.replace(this._pathParamRegex,(o,s)=>{let i=r[s];return i!==void 0?encodeURIComponent(i):o})}catch(o){this._logger.warn(`${this.constructor.name}: couldn't interpolate params`,o)}return t}};var Cs={status:"OK"};var De=(function(e){return e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e})({});var Ne=class{static{n(this,"SmpBaseJwtToken")}_access_token;_exp;_iss;get access_token(){return this._access_token}get exp(){return this._exp}get iss(){return this._iss}constructor(t,r,o){this._access_token=t,this._exp=r,this._iss=o}serialize(){return{access_token:this._access_token,exp:this._exp,iss:this._iss}}};var Me=class{static{n(this,"SmpBaseJwtTokenPlain")}access_token;exp;iss};var Is=(function(e){return e.APPLE="APPLE",e.FACEBOOK="FACEBOOK",e.GOOGLE="GOOGLE",e})({});var Ps=(function(e){return e.POPUP="POPUP",e.REDIRECT="REDIRECT",e})({});var yt=class{static{n(this,"SmpAesCrypt")}_password;_salt;_initVector;get _iv(){return this._initVector?V.parse(this._initVector):void 0}_mode=X;_padding=gt;constructor(t,r,o){this._password=t,this._salt=r,this._initVector=o}decryptAES(t){return Dt.decrypt(t,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString(I)}encryptAES(t){return Dt.encrypt(t,this._buildKey(),{iv:this._iv,mode:this._mode,padding:this._padding}).toString()}_buildKey(){return Ie.execute(this._password,V.parse(this._salt),{keySize:256/32,iterations:1e3,hasher:it})}};var Jt=class{static{n(this,"SmpSecureCode")}_baseCode;get baseCode(){return this._baseCode}get secureCode(){return this._encode()}_crcLength=5;_seed="changeme";constructor(t){this._baseCode=t}static check(t,r){if(new this(t).secureCode!==r)throw L.create({messages:"WRONG_SECURE_CODE",errorCode:"WRONG_SECURE_CODE",status:ye.BadRequest})}_encode(){let t=new $;return t.update(I.parse(this._seed+this._baseCode)),t.finalize().toString(V).substring(0,this._crcLength).toUpperCase()}};var js=(function(e){return e.DIFFERENT_CREDENTIAL="auth/account-exists-with-different-credential",e.DIFFERENT_CREDENTIAL_APPLE="auth/account-exists-with-different-credential/apple",e.DIFFERENT_CREDENTIAL_FACEBOOK="auth/account-exists-with-different-credential/facebook",e.DIFFERENT_CREDENTIAL_GOOGLE="auth/account-exists-with-different-credential/google",e.EMAIL_EXISTS="auth/email-already-exists",e.INVALID_ACTION_CODE="auth/invalid-action-code",e.POPUP_BLOCKED="auth/popup-blocked",e.POPUP_CLOSED_BY_USER="auth/popup-closed-by-user",e.USER_NOT_FOUND="auth/user-not-found",e.WRONG_PASSWORD="auth/wrong-password",e})({});var xt=require("class-transformer"),Yt=require("ts-luxon");var j=(function(e){return e.ACTIVATE="ACTIVATE",e.BLOCK="BLOCK",e.CHECK="CHECK",e.DIGITAL_ACTIVATE="DIGITAL_ACTIVATE",e.FREEZE="FREEZE",e.PURCHASE="PURCHASE",e.RECHARGE="RECHARGE",e.ROLLBACK="ROLLBACK",e.TRANSACTION="TRANSACTION",e.TRANSACTION_DETAIL="TRANSACTION_DETAIL",e.UNFREEZE="UNFREEZE",e.XREFUND="XREFUND",e})({});var ct=(function(e){return e.MD5="MD5",e.MD5_HMAC="MD5_HMAC",e.SHA1="SHA1",e.SHA1_HMAC="SHA1_HMAC",e})({});function Ds(e,t,r,o){var s=arguments.length,i=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(s<3?a(i):s>3?a(t,r,i):a(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}n(Ds,"_ts_decorate");function br(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}n(br,"_ts_metadata");var Qt=class e{static{n(this,"SmpGiftcardTransaction")}gc;op;ot;static _AES_ENCODER=new yt("changeme","5f6eae61d2428b99","d92fbf214e16a79fd36f9a5185ae733f");static _OP_CODES={[j.CHECK]:"",[j.TRANSACTION]:"",[j.TRANSACTION_DETAIL]:"",[j.ACTIVATE]:"A",[j.BLOCK]:"B",[j.DIGITAL_ACTIVATE]:"D",[j.FREEZE]:"F",[j.PURCHASE]:"P",[j.RECHARGE]:"G",[j.ROLLBACK]:"R",[j.UNFREEZE]:"U",[j.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={[ct.MD5]:t=>_t(t),[ct.MD5_HMAC]:t=>{let r=new $;return r.update(I.parse(t)),r.finalize()},[ct.SHA1]:t=>wt(t),[ct.SHA1_HMAC]:t=>{let r=new it;return r.update(I.parse(t)),r.finalize()}};_hashStrategy=this._hashStrategies[ct.MD5];constructor(t="ACTIVATION",r,o,s){this.gc=t,this.op=r,this.ot=o,this._dto=typeof s=="number"&&s>=0?Yt.DateTime.fromMillis(+`${s}000`.slice(0,13)):Yt.DateTime.local()}static build({gc:t,op:r,ot:o,dto:s}){return new this(t,r,o,s?.ts)}static explode(t){let r=this.constructor,o=(t||"").split(r._SEP);if(o.length<4)throw new Error(`${this.constructor.name}::explode: invalid transactionId provided => "${t}"`);return this.build({gc:o[1],op:r.prefixToOperation(o[2]),dto:Yt.DateTime.fromSeconds(+o[3])})}static isBase64(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)&&t.length%4===0}static parse(t){console.info(`${this.constructor.name}::parse: trying to parse ${t}`);try{if(this.isBase64(t)){let r=this._AES_ENCODER.decryptAES(t),o=JSON.parse(r);return(0,xt.plainToInstance)(e,o)}else return this.explode(t)}catch(r){throw console.error(`${this.constructor.name}::parse: failed to parse ${t}`,r),new Error(`${this.constructor.name}::parse: could not parse transactionId ${t}`)}}static prefixToOperation(t){return Object.entries(this._OP_CODES).find(([,o])=>o===t)[0]}serialize(){return(0,xt.instanceToPlain)(this,{excludePrefixes:["_"]})}toString(){let t=JSON.stringify(this.serialize());return this.constructor._AES_ENCODER.encryptAES(t)}};Ds([(0,xt.Expose)(),br("design:type",Number),br("design:paramtypes",[])],Qt.prototype,"ts",null);var Ns=(function(e){return e.ListDetectiveValidator="ListDetectiveValidator",e.MXValidator="MXValidator",e.SyntaxValidator="SyntaxValidator",e})({});function Ms(e,t){t.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(o=>{o!=="constructor"&&(o in e.prototype||Object.defineProperty(e.prototype,o,Object.getOwnPropertyDescriptor(r.prototype,o)))});try{let o=new r;Object.getOwnPropertyNames(o).forEach(s=>{s in e.prototype||Object.defineProperty(e.prototype,s,Object.getOwnPropertyDescriptor(o,s))})}catch{}Object.getOwnPropertyNames(r).forEach(o=>{o!=="prototype"&&o!=="name"&&o!=="length"&&(o in e||Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o)))})})}n(Ms,"smpApplyMixin");function Fs(){this.__data__=[],this.size=0}n(Fs,"listCacheClear");var Ar=Fs;function Ls(e,t){return e===t||e!==e&&t!==t}n(Ls,"eq");var te=Ls;function Us(e,t){for(var r=e.length;r--;)if(te(e[r][0],t))return r;return-1}n(Us,"assocIndexOf");var Z=Us;var zs=Array.prototype,$s=zs.splice;function ks(e){var t=this.__data__,r=Z(t,e);if(r<0)return!1;var o=t.length-1;return r==o?t.pop():$s.call(t,r,1),--this.size,!0}n(ks,"listCacheDelete");var Er=ks;function Gs(e){var t=this.__data__,r=Z(t,e);return r<0?void 0:t[r][1]}n(Gs,"listCacheGet");var vr=Gs;function Ws(e){return Z(this.__data__,e)>-1}n(Ws,"listCacheHas");var Or=Ws;function Ks(e,t){var r=this.__data__,o=Z(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}n(Ks,"listCacheSet");var Rr=Ks;function bt(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}n(bt,"ListCache");bt.prototype.clear=Ar;bt.prototype.delete=Er;bt.prototype.get=vr;bt.prototype.has=Or;bt.prototype.set=Rr;var J=bt;function qs(){this.__data__=new J,this.size=0}n(qs,"stackClear");var Br=qs;function Ss(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}n(Ss,"stackDelete");var Tr=Ss;function Hs(e){return this.__data__.get(e)}n(Hs,"stackGet");var Cr=Hs;function Vs(e){return this.__data__.has(e)}n(Vs,"stackHas");var Ir=Vs;var Xs=typeof global=="object"&&global&&global.Object===Object&&global,ee=Xs;var Zs=typeof self=="object"&&self&&self.Object===Object&&self,Js=ee||Zs||Function("return this")(),B=Js;var Ys=B.Symbol,k=Ys;var Pr=Object.prototype,Qs=Pr.hasOwnProperty,ti=Pr.toString,Mt=k?k.toStringTag:void 0;function ei(e){var t=Qs.call(e,Mt),r=e[Mt];try{e[Mt]=void 0;var o=!0}catch{}var s=ti.call(e);return o&&(t?e[Mt]=r:delete e[Mt]),s}n(ei,"getRawTag");var jr=ei;var ri=Object.prototype,oi=ri.toString;function si(e){return oi.call(e)}n(si,"objectToString");var Dr=si;var ii="[object Null]",ni="[object Undefined]",Nr=k?k.toStringTag:void 0;function ai(e){return e==null?e===void 0?ni:ii:Nr&&Nr in Object(e)?jr(e):Dr(e)}n(ai,"baseGetTag");var G=ai;function ci(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}n(ci,"isObject");var re=ci;var hi="[object AsyncFunction]",li="[object Function]",fi="[object GeneratorFunction]",pi="[object Proxy]";function ui(e){if(!re(e))return!1;var t=G(e);return t==li||t==fi||t==hi||t==pi}n(ui,"isFunction");var oe=ui;var di=B["__core-js_shared__"],se=di;var Mr=(function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function mi(e){return!!Mr&&Mr in e}n(mi,"isMasked");var Fr=mi;var gi=Function.prototype,_i=gi.toString;function wi(e){if(e!=null){try{return _i.call(e)}catch{}try{return e+""}catch{}}return""}n(wi,"toSource");var W=wi;var yi=/[\\^$.*+?()[\]{}|]/g,xi=/^\[object .+?Constructor\]$/,bi=Function.prototype,Ai=Object.prototype,Ei=bi.toString,vi=Ai.hasOwnProperty,Oi=RegExp("^"+Ei.call(vi).replace(yi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ri(e){if(!re(e)||Fr(e))return!1;var t=oe(e)?Oi:xi;return t.test(W(e))}n(Ri,"baseIsNative");var Lr=Ri;function Bi(e,t){return e?.[t]}n(Bi,"getValue");var Ur=Bi;function Ti(e,t){var r=Ur(e,t);return Lr(r)?r:void 0}n(Ti,"getNative");var F=Ti;var Ci=F(B,"Map"),Y=Ci;var Ii=F(Object,"create"),K=Ii;function Pi(){this.__data__=K?K(null):{},this.size=0}n(Pi,"hashClear");var zr=Pi;function ji(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}n(ji,"hashDelete");var $r=ji;var Di="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Fi(e){var t=this.__data__;if(K){var r=t[e];return r===Di?void 0:r}return Mi.call(t,e)?t[e]:void 0}n(Fi,"hashGet");var kr=Fi;var Li=Object.prototype,Ui=Li.hasOwnProperty;function zi(e){var t=this.__data__;return K?t[e]!==void 0:Ui.call(t,e)}n(zi,"hashHas");var Gr=zi;var $i="__lodash_hash_undefined__";function ki(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=K&&t===void 0?$i:t,this}n(ki,"hashSet");var Wr=ki;function At(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}n(At,"Hash");At.prototype.clear=zr;At.prototype.delete=$r;At.prototype.get=kr;At.prototype.has=Gr;At.prototype.set=Wr;var Fe=At;function Gi(){this.size=0,this.__data__={hash:new Fe,map:new(Y||J),string:new Fe}}n(Gi,"mapCacheClear");var Kr=Gi;function Wi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}n(Wi,"isKeyable");var qr=Wi;function Ki(e,t){var r=e.__data__;return qr(t)?r[typeof t=="string"?"string":"hash"]:r.map}n(Ki,"getMapData");var Q=Ki;function qi(e){var t=Q(this,e).delete(e);return this.size-=t?1:0,t}n(qi,"mapCacheDelete");var Sr=qi;function Si(e){return Q(this,e).get(e)}n(Si,"mapCacheGet");var Hr=Si;function Hi(e){return Q(this,e).has(e)}n(Hi,"mapCacheHas");var Vr=Hi;function Vi(e,t){var r=Q(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}n(Vi,"mapCacheSet");var Xr=Vi;function Et(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}n(Et,"MapCache");Et.prototype.clear=Kr;Et.prototype.delete=Sr;Et.prototype.get=Hr;Et.prototype.has=Vr;Et.prototype.set=Xr;var ie=Et;var Xi=200;function Zi(e,t){var r=this.__data__;if(r instanceof J){var o=r.__data__;if(!Y||o.length<Xi-1)return o.push([e,t]),this.size=++r.size,this;r=this.__data__=new ie(o)}return r.set(e,t),this.size=r.size,this}n(Zi,"stackSet");var Zr=Zi;function vt(e){var t=this.__data__=new J(e);this.size=t.size}n(vt,"Stack");vt.prototype.clear=Br;vt.prototype.delete=Tr;vt.prototype.get=Cr;vt.prototype.has=Ir;vt.prototype.set=Zr;var ne=vt;var Ji="__lodash_hash_undefined__";function Yi(e){return this.__data__.set(e,Ji),this}n(Yi,"setCacheAdd");var Jr=Yi;function Qi(e){return this.__data__.has(e)}n(Qi,"setCacheHas");var Yr=Qi;function ae(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new ie;++t<r;)this.add(e[t])}n(ae,"SetCache");ae.prototype.add=ae.prototype.push=Jr;ae.prototype.has=Yr;var Qr=ae;function tn(e,t){for(var r=-1,o=e==null?0:e.length;++r<o;)if(t(e[r],r,e))return!0;return!1}n(tn,"arraySome");var to=tn;function en(e,t){return e.has(t)}n(en,"cacheHas");var eo=en;var rn=1,on=2;function sn(e,t,r,o,s,i){var a=r&rn,c=e.length,h=t.length;if(c!=h&&!(a&&h>c))return!1;var f=i.get(e),g=i.get(t);if(f&&g)return f==t&&g==e;var d=-1,m=!0,w=r&on?new Qr:void 0;for(i.set(e,t),i.set(t,e);++d<c;){var y=e[d],E=t[d];if(o)var O=a?o(E,y,d,t,e,i):o(y,E,d,e,t,i);if(O!==void 0){if(O)continue;m=!1;break}if(w){if(!to(t,function(R,v){if(!eo(w,v)&&(y===R||s(y,R,r,o,i)))return w.push(v)})){m=!1;break}}else if(!(y===E||s(y,E,r,o,i))){m=!1;break}}return i.delete(e),i.delete(t),m}n(sn,"equalArrays");var ce=sn;var nn=B.Uint8Array,Le=nn;function an(e){var t=-1,r=Array(e.size);return e.forEach(function(o,s){r[++t]=[s,o]}),r}n(an,"mapToArray");var ro=an;function cn(e){var t=-1,r=Array(e.size);return e.forEach(function(o){r[++t]=o}),r}n(cn,"setToArray");var oo=cn;var hn=1,ln=2,fn="[object Boolean]",pn="[object Date]",un="[object Error]",dn="[object Map]",mn="[object Number]",gn="[object RegExp]",_n="[object Set]",wn="[object String]",yn="[object Symbol]",xn="[object ArrayBuffer]",bn="[object DataView]",so=k?k.prototype:void 0,Ue=so?so.valueOf:void 0;function An(e,t,r,o,s,i,a){switch(r){case bn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case xn:return!(e.byteLength!=t.byteLength||!i(new Le(e),new Le(t)));case fn:case pn:case mn:return te(+e,+t);case un:return e.name==t.name&&e.message==t.message;case gn:case wn:return e==t+"";case dn:var c=ro;case _n:var h=o&hn;if(c||(c=oo),e.size!=t.size&&!h)return!1;var f=a.get(e);if(f)return f==t;o|=ln,a.set(e,t);var g=ce(c(e),c(t),o,s,i,a);return a.delete(e),g;case yn:if(Ue)return Ue.call(e)==Ue.call(t)}return!1}n(An,"equalByTag");var io=An;function En(e,t){for(var r=-1,o=t.length,s=e.length;++r<o;)e[s+r]=t[r];return e}n(En,"arrayPush");var no=En;var vn=Array.isArray,ht=vn;function On(e,t,r){var o=t(e);return ht(e)?o:no(o,r(e))}n(On,"baseGetAllKeys");var ao=On;function Rn(e,t){for(var r=-1,o=e==null?0:e.length,s=0,i=[];++r<o;){var a=e[r];t(a,r,e)&&(i[s++]=a)}return i}n(Rn,"arrayFilter");var co=Rn;function Bn(){return[]}n(Bn,"stubArray");var ho=Bn;var Tn=Object.prototype,Cn=Tn.propertyIsEnumerable,lo=Object.getOwnPropertySymbols,In=lo?function(e){return e==null?[]:(e=Object(e),co(lo(e),function(t){return Cn.call(e,t)}))}:ho,fo=In;function Pn(e,t){for(var r=-1,o=Array(e);++r<e;)o[r]=t(r);return o}n(Pn,"baseTimes");var po=Pn;function jn(e){return e!=null&&typeof e=="object"}n(jn,"isObjectLike");var q=jn;var Dn="[object Arguments]";function Nn(e){return q(e)&&G(e)==Dn}n(Nn,"baseIsArguments");var ze=Nn;var uo=Object.prototype,Mn=uo.hasOwnProperty,Fn=uo.propertyIsEnumerable,Ln=ze((function(){return arguments})())?ze:function(e){return q(e)&&Mn.call(e,"callee")&&!Fn.call(e,"callee")},mo=Ln;function Un(){return!1}n(Un,"stubFalse");var go=Un;var yo=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_o=yo&&typeof module=="object"&&module&&!module.nodeType&&module,zn=_o&&_o.exports===yo,wo=zn?B.Buffer:void 0,$n=wo?wo.isBuffer:void 0,kn=$n||go,Ft=kn;var Gn=9007199254740991,Wn=/^(?:0|[1-9]\d*)$/;function Kn(e,t){var r=typeof e;return t=t??Gn,!!t&&(r=="number"||r!="symbol"&&Wn.test(e))&&e>-1&&e%1==0&&e<t}n(Kn,"isIndex");var xo=Kn;var qn=9007199254740991;function Sn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=qn}n(Sn,"isLength");var he=Sn;var Hn="[object Arguments]",Vn="[object Array]",Xn="[object Boolean]",Zn="[object Date]",Jn="[object Error]",Yn="[object Function]",Qn="[object Map]",ta="[object Number]",ea="[object Object]",ra="[object RegExp]",oa="[object Set]",sa="[object String]",ia="[object WeakMap]",na="[object ArrayBuffer]",aa="[object DataView]",ca="[object Float32Array]",ha="[object Float64Array]",la="[object Int8Array]",fa="[object Int16Array]",pa="[object Int32Array]",ua="[object Uint8Array]",da="[object Uint8ClampedArray]",ma="[object Uint16Array]",ga="[object Uint32Array]",A={};A[ca]=A[ha]=A[la]=A[fa]=A[pa]=A[ua]=A[da]=A[ma]=A[ga]=!0;A[Hn]=A[Vn]=A[na]=A[Xn]=A[aa]=A[Zn]=A[Jn]=A[Yn]=A[Qn]=A[ta]=A[ea]=A[ra]=A[oa]=A[sa]=A[ia]=!1;function _a(e){return q(e)&&he(e.length)&&!!A[G(e)]}n(_a,"baseIsTypedArray");var bo=_a;function wa(e){return function(t){return e(t)}}n(wa,"baseUnary");var Ao=wa;var Eo=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lt=Eo&&typeof module=="object"&&module&&!module.nodeType&&module,ya=Lt&&Lt.exports===Eo,$e=ya&&ee.process,xa=(function(){try{var e=Lt&&Lt.require&&Lt.require("util").types;return e||$e&&$e.binding&&$e.binding("util")}catch{}})(),ke=xa;var vo=ke&&ke.isTypedArray,ba=vo?Ao(vo):bo,le=ba;var Aa=Object.prototype,Ea=Aa.hasOwnProperty;function va(e,t){var r=ht(e),o=!r&&mo(e),s=!r&&!o&&Ft(e),i=!r&&!o&&!s&&le(e),a=r||o||s||i,c=a?po(e.length,String):[],h=c.length;for(var f in e)(t||Ea.call(e,f))&&!(a&&(f=="length"||s&&(f=="offset"||f=="parent")||i&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||xo(f,h)))&&c.push(f);return c}n(va,"arrayLikeKeys");var Oo=va;var Oa=Object.prototype;function Ra(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Oa;return e===r}n(Ra,"isPrototype");var Ro=Ra;function Ba(e,t){return function(r){return e(t(r))}}n(Ba,"overArg");var Bo=Ba;var Ta=Bo(Object.keys,Object),To=Ta;var Ca=Object.prototype,Ia=Ca.hasOwnProperty;function Pa(e){if(!Ro(e))return To(e);var t=[];for(var r in Object(e))Ia.call(e,r)&&r!="constructor"&&t.push(r);return t}n(Pa,"baseKeys");var Co=Pa;function ja(e){return e!=null&&he(e.length)&&!oe(e)}n(ja,"isArrayLike");var Io=ja;function Da(e){return Io(e)?Oo(e):Co(e)}n(Da,"keys");var Po=Da;function Na(e){return ao(e,Po,fo)}n(Na,"getAllKeys");var Ge=Na;var Ma=1,Fa=Object.prototype,La=Fa.hasOwnProperty;function Ua(e,t,r,o,s,i){var a=r&Ma,c=Ge(e),h=c.length,f=Ge(t),g=f.length;if(h!=g&&!a)return!1;for(var d=h;d--;){var m=c[d];if(!(a?m in t:La.call(t,m)))return!1}var w=i.get(e),y=i.get(t);if(w&&y)return w==t&&y==e;var E=!0;i.set(e,t),i.set(t,e);for(var O=a;++d<h;){m=c[d];var R=e[m],v=t[m];if(o)var x=a?o(v,R,m,t,e,i):o(R,v,m,e,t,i);if(!(x===void 0?R===v||s(R,v,r,o,i):x)){E=!1;break}O||(O=m=="constructor")}if(E&&!O){var b=e.constructor,T=t.constructor;b!=T&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof T=="function"&&T instanceof T)&&(E=!1)}return i.delete(e),i.delete(t),E}n(Ua,"equalObjects");var jo=Ua;var za=F(B,"DataView"),fe=za;var $a=F(B,"Promise"),pe=$a;var ka=F(B,"Set"),ue=ka;var Ga=F(B,"WeakMap"),de=Ga;var Do="[object Map]",Wa="[object Object]",No="[object Promise]",Mo="[object Set]",Fo="[object WeakMap]",Lo="[object DataView]",Ka=W(fe),qa=W(Y),Sa=W(pe),Ha=W(ue),Va=W(de),lt=G;(fe&&lt(new fe(new ArrayBuffer(1)))!=Lo||Y&&lt(new Y)!=Do||pe&&lt(pe.resolve())!=No||ue&&lt(new ue)!=Mo||de&&lt(new de)!=Fo)&&(lt=n(function(e){var t=G(e),r=t==Wa?e.constructor:void 0,o=r?W(r):"";if(o)switch(o){case Ka:return Lo;case qa:return Do;case Sa:return No;case Ha:return Mo;case Va:return Fo}return t},"getTag"));var We=lt;var Xa=1,Uo="[object Arguments]",zo="[object Array]",me="[object Object]",Za=Object.prototype,$o=Za.hasOwnProperty;function Ja(e,t,r,o,s,i){var a=ht(e),c=ht(t),h=a?zo:We(e),f=c?zo:We(t);h=h==Uo?me:h,f=f==Uo?me:f;var g=h==me,d=f==me,m=h==f;if(m&&Ft(e)){if(!Ft(t))return!1;a=!0,g=!1}if(m&&!g)return i||(i=new ne),a||le(e)?ce(e,t,r,o,s,i):io(e,t,h,r,o,s,i);if(!(r&Xa)){var w=g&&$o.call(e,"__wrapped__"),y=d&&$o.call(t,"__wrapped__");if(w||y){var E=w?e.value():e,O=y?t.value():t;return i||(i=new ne),s(E,O,r,o,i)}}return m?(i||(i=new ne),jo(e,t,r,o,s,i)):!1}n(Ja,"baseIsEqualDeep");var ko=Ja;function Go(e,t,r,o,s){return e===t?!0:e==null||t==null||!q(e)&&!q(t)?e!==e&&t!==t:ko(e,t,r,o,Go,s)}n(Go,"baseIsEqual");var Wo=Go;function Ya(e,t){return Wo(e,t)}n(Ya,"isEqual");var Ko=Ya;var Qa=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function qo(e){return e.match(Qa)}n(qo,"smpAsciiWords");var Jo="\\ud800-\\udfff",tc="\\u0300-\\u036f",ec="\\ufe20-\\ufe2f",rc="\\u20d0-\\u20ff",oc="\\u1ab0-\\u1aff",sc="\\u1dc0-\\u1dff",ic=tc+ec+rc+oc+sc,Yo="\\u2700-\\u27bf",Qo="a-z\\xdf-\\xf6\\xf8-\\xff",nc="\\xac\\xb1\\xd7\\xf7",ac="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",cc="\\u2000-\\u206f",hc=" \\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",ts="A-Z\\xc0-\\xd6\\xd8-\\xde",lc="\\ufe0e\\ufe0f",es=nc+ac+cc+hc,rs="['\u2019]",So=`[${es}]`,fc=`[${ic}]`,os="\\d",pc=`[${Yo}]`,ss=`[${Qo}]`,is=`[^${Jo}${es+os+Yo+Qo+ts}]`,uc="\\ud83c[\\udffb-\\udfff]",dc=`(?:${fc}|${uc})`,mc=`[^${Jo}]`,ns="(?:\\ud83c[\\udde6-\\uddff]){2}",as="[\\ud800-\\udbff][\\udc00-\\udfff]",Ot=`[${ts}]`,gc="\\u200d",Ho=`(?:${ss}|${is})`,_c=`(?:${Ot}|${is})`,Vo=`(?:${rs}(?:d|ll|m|re|s|t|ve))?`,Xo=`(?:${rs}(?:D|LL|M|RE|S|T|VE))?`,cs=`${dc}?`,hs=`[${lc}]?`,wc=`(?:${gc}(?:${[mc,ns,as].join("|")})${hs+cs})*`,yc="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",xc="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",bc=hs+cs+wc,Zo=`(?:${[pc,ns,as].join("|")})${bc}`,Ut=class{static{n(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([`${Ot}?${ss}+${Vo}(?=${[So,Ot,"$"].join("|")})`,`${_c}+${Xo}(?=${[So,Ot+Ho,"$"].join("|")})`,`${Ot}?${Ho}+${Vo}`,`${Ot}+${Xo}`,xc,yc,`${os}+`,Zo].join("|"),"g");static RS_EMOJI=Zo;static unicodeWords(t){return t.match(this.RE_UNICODE_WORDS)}};var Ke=class{static{n(this,"SmpCommonUtils")}static arrayRemove(t,r){let o=[],s=t.filter((i,a)=>r(i,a)&&o.push(a));return o.reverse().forEach(i=>t.splice(i,1)),s}static assertIsArray(t,r){if(!Array.isArray(t))throw new Error(r||`${this.constructor.name} => val was not an array`)}static assertIsBoolean(t,r){if(!this.isBoolean(t))throw new Error(r||`${this.constructor.name} => val was not boolean`)}static assertIsFunction(t,r){if(!this.isFunction(t))throw new Error(r||`${this.constructor.name} => entity was not a function`)}static assertIsInstance(t,r,o){if(!(t instanceof r))throw new Error(o||`${this.constructor.name} => val was not instance of class`)}static assertIsNotEmpty(t,r){if(this.isEmpty(t))throw new Error(r||`${this.constructor.name} => entity was empty`)}static assertIsNumber(t,r){if(typeof t!="number")throw new Error(r||`${this.constructor.name} => val was not numeric`)}static assertIsNumeric(t,r){if(!this.isNumeric(t))throw new Error(r||`${this.constructor.name} => val was not numeric`)}static assertIsObject(t,r){if(!this.isObject(t))throw new Error(r||`${this.constructor.name} => val was not an object`)}static assertIsString(t,r){if(!this.isString(t))throw new Error(r||`${this.constructor.name} => val was not a string`)}static assertIsTruthy(t,r){if(!t)throw new Error(r||`${this.constructor.name} => condition wasn't truthy`)}static buildPath(...t){let r=t.filter(o=>!!o).join("/").replace(/(?<!:)\/\/+/g,"/");return r.startsWith("http")&&!r.endsWith("/")?`${r}/`:r}static downloadBlob(t,r){let o=window.URL.createObjectURL(t),s=document.createElement("a");s.href=o,s.setAttribute("download",r),document.body.appendChild(s),s.click()}static generateRandomHexString(t=12){let r="0123456789abcdef",o="";for(let s=0;s<t;s++){let i=Math.floor(Math.random()*r.length);o+=r[i]}return o}static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t==="x"?r:r&3|8).toString(16)})}static getDecimalPrecision(t){if(this.assertIsNumeric(t),!isFinite(+t))return 0;let r=1,o=0;for(;Math.round(+t*r)/r!==t;)r*=10,o++;return o}static getType(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}static isBoolean(t){return typeof t=="boolean"}static isColor(t){if(!t||!this.isString(t))return!1;let r=new Option().style;return r.color=t,r.color!==""}static isEmpty(t){return!t&&t!==0}static isEqual(t,r){return Ko(t,r)}static isFormField(t){return/^(?:input|select|textarea|button)$/i.test(t.nodeName)}static isFunction(t){return typeof t==typeof isNaN}static isNotEmpty(t){return!this.isEmpty(t)}static isNumber(t){return typeof t=="number"&&this.isNumeric(t)}static isNumeric(t){return!isNaN(t)}static isObject(t){return!!t&&t===Object(t)&&t.constructor===Object}static isPrimitive(t){let r=this.getType(t);return r!=="function"&&(r!=="object"||!t)}static isString(t){return typeof t=="string"}static isWindows(){return navigator.userAgent.toLowerCase().includes("win")}static mapObject(t,r){if(this.assertIsFunction(r,`CommonUtils => expected type of iteratee to be Function, got ${typeof r}`),this.isObject(t))return Object.entries(t).reduce((o,[s,i])=>(o.push(r(i,s)),o),[]);if(Array.isArray(t))return t.map(r);throw new Error(`CommonUtils => invalid object provided. Expected Object or Array, got ${typeof r}`)}static mapObjectKeys(t,r){return this.isObject(t)?Object.entries(t).reduce((o,[s,i])=>{let a=r(s,i);return o[a]=i,o},{}):{}}static mapObjectValues(t,r){return this.isObject(t)?Object.entries(t).reduce((o,[s,i])=>(o[s]=r.call(null,i,s),o),{}):{}}static noop(){}static objectHasValue(t,r){return!!~Object.values(t).filter(o=>this.isEqual(o,r))}static omit(t,r){return Object.keys(t).filter(s=>!r.includes(s)).reduce((s,i)=>(s[i]=t[i],s),{})}static parseBoolean(t){return t?/^true$/i.test(t):!1}static parseJsonSafely(t){try{return JSON.parse(t)}catch(r){console.warn(`${this.constructor.name} => couldn't parse json string`,{str:t,error:r});return}}static pick(t,r){return r.reduce((o,s)=>(s in t&&(o[s]=t[s]),o),{})}static runSafely(t,r=null,o=[]){if(this.isFunction(t))return t.apply(r,o)}static sleep(t){return new Promise(r=>setTimeout(r,t))}static sprintf(t,...r){return this.isString(t)&&r.length?this.sprintf(t.replace("%s",String(r.shift())),...r):t}static stripComments(t){return typeof t=="string"?t.replace(/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g,""):t}static submitFakeForm({action:t,method:r=De.POST,data:o,target:s}){let i=Object.entries(o||{}).map(([c,h])=>`<input name="${c}" type="hidden" value="${h}" />`),a=document.createElement("form");a.method=r,a.action=t,a.innerHTML=`${i}`,a.target=s||"_self",document.body.append(a),a.submit()}static toCamelCase(t){return this.words(t.replace(/['\u2019]/g,"")).reduce((r,o,s)=>(o=o.toLowerCase(),r+(s?o.charAt(0).toUpperCase()+o.slice(1):o)),"")}static toKebabCase(t){return this.words(t.replace(/['\u2019]/g,"")).join("-").toLowerCase()}static toPascalCase(t){return this.toCamelCase(t).replace(/^(.)/,r=>r.toUpperCase())}static toSnakeCase(t){return this.words(t.replace(/['\u2019]/g,"")).join("_").toLowerCase()}static toUpperSnakeCase(t){return this.toSnakeCase(t).toUpperCase()}static words(t,r){return r===void 0?(Ut.HAS_UNICODE_WORD(t)?Ut.unicodeWords(t):qo(t))||[]:t.match(r)||[]}};var qe=class extends Error{static{n(this,"SmpFilterException")}message;data;constructor(t="Filter Exception",r){super(),this.message=t,this.data=r}};var Se=require("ts-luxon");var He=class e{static{n(this,"SmpSid")}value;expiry;get active(){return this.value.endsWith(this._controlSuffix)}get expired(){return Se.DateTime.now().ts>this.expiry}get valid(){return!this.expired}_controlSuffix="$1";constructor(t=`sid-xxxx-${+Se.DateTime.now().ts}`,r=0){this.value=t,this.expiry=r}static parse(t){return new e(t.value,t.expiry)}toPlain(){return{value:this.value,expiry:this.expiry}}};var ls=require("@tonysamperi/logger");var Ve=class{static{n(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 Ac="2.0.0-beta.5";0&&(module.exports={SMP_HEALTHZ,SmpAbstractCacheStrategy,SmpAbstractTtlCacheStrategy,SmpAesCrypt,SmpApiCommonUtils,SmpBaseJwtToken,SmpBaseJwtTokenPlain,SmpBrowserCache,SmpCommonUtils,SmpCrypto,SmpErrorResponse,SmpFilterException,SmpFirebaseErrors,SmpGenericResponse,SmpGiftcardTransaction,SmpGiftcardTransactionHashStrategies,SmpGiftcardTransactionOps,SmpHttpSessionStorageCache,SmpHttpStatusCodes,SmpHttpTwoService,SmpInMemoryCache,SmpMarketingCloudValidators,SmpRegularExpressions,SmpResponseMessage,SmpResponseMessageTypes,SmpRestVerbs,SmpSecureCode,SmpSid,SmpSocialSignInKeys,SmpSocialSignInUxModes,VERSION,smpApplyMixin,smpIsSmpCachedValue,smpNoop});
2
2
  //# sourceMappingURL=index.cjs.map