@adapty/core 4.1.2 → 4.2.0-dev.71df1163b29bba8bf2f2aa673d5faeaa38c717f1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["level: LogLevel","consoleLogSink: LogSink","version: string","message: string","funcName: string","config: LoggerConfig","sink: LogSink","id: string","logLevel: LogLevel","message: LazyMessage","params?: LazyParams","event: LogEvent","args: LogScopeConstructor","args: LogArgs","step: Scope","args: ScopeArgs","message: string","method: ScopeArgs","sdkName: string","sdkVersion: string","error: (typeof ErrorCode)[ErrorCode]","code: ErrorCode","input: AdaptyErrorInput","callback: (error: AdaptyError) => void","message: string","error: unknown","platform: IPlatformAdapter","data: CodableModel","data: Serializable","value: unknown","type: StrType<any>","obj: Record<string, any>","key: string","obj: T","value: any","currentObj: Partial<T>","data: Model","properties: Properties<Model, Serializable>","result: Partial<Serializable>","platform?: 'ios' | 'android'","result: Partial<Model>","input: string","value: Date","platform: IPlatformAdapter","sdkMetadata: ISdkMetadataAdapter","apiKey: string","params: Model","config: Serializable","coderFactory: () => Converter<Model, Serializable>","input: Serializable[]","value: Model[]","data: Serializable","data: Model","json: SerializableLayout","model: AdaptyFlowUiSchemaLayout","json: SerializableGrid","model: AdaptyFlowUiSchemaGrid","json: Serializable","model: Model","input: Serialized","value: Model","data: Serializable","data: Model","data: Serializable","data: Model","platform: IPlatformAdapter","params?: Model","result: Serializable","model: AdaptyInstallationDetails","result: Def['AdaptyInstallationDetails']","json: Def['AdaptyInstallationDetails']","model: AdaptyInstallationStatus","details: Def['AdaptyInstallationDetails']","json: Def['AdaptyInstallationStatus']","details: AdaptyInstallationDetails","data: Model","data: Serializable","data: Model","data: Serializable","data: Serializable","data: Serializable","data: Serializable","coder: T | null","input: Record<string, unknown>","result: Record<string, any>","value: Record<string, any>","result: Record<string, unknown>","platform: IPlatformAdapter","data: Model","purchaseParams: Serializable","data: Serializable","data: Model","data: CreateOnboardingViewParamsInput","result: Serializable","date: Date","num: number","digits: number","value: number","input: string","asset: { relativeAssetPath: string } | { fileLocation: FileLocation }","platformOS: PlatformOS","platform: IPlatformAdapter","data: Model","result: Serializable","timers: Record<string, Date>","result: Record<string, string>","assets: Record<string, AdaptyCustomAsset>","asset: { relativeAssetPath: string } | { fileLocation: FileLocation }","value: string","color: string","params: CreateFlowViewParamsInput['productPurchaseParams']","data: Serializable","data: OnboardingStateUpdatedAction","data: Model","deps: CoderDependencies","coderFactory: () => Converter<Model, Serializable>","coder: T | null","GLOBAL_EVENT_TO_NATIVE_EVENT: GlobalEventMap","NATIVE_EVENT_RESOLVER: Record<\n FlowEventIdType,\n (event: ParsedFlowEvent) => EventName | null\n>","actionMap: Record<string, EventName>","HANDLER_TO_NATIVE_EVENT: Record<EventName, FlowEventIdType>","handlerName: T","event: ParsedFlowEvent","ONBOARDING_EVENT_MAPPINGS: UiEventMapping","HANDLER_TO_EVENT_CONFIG: Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n>","NATIVE_EVENT_TO_HANDLERS: Record<string, EventName[]>","_handlerName: T","event: ParsedOnboardingEvent","factory: CoderFactory","input: string","resultType: AdaptyType","ctx?: LogContext","obj: AdaptyResult<unknown>","event: string","obj: Record<string, unknown>","type: AdaptyType","factory: CoderFactory","input: string","ctx?: LogContext","obj: Record<string, unknown>","view: FlowEventView","actionObj: Record<string, unknown>","type: FlowCoderType","_ctx?: LogContext","factory: CoderFactory","input: string","ctx?: LogContext","obj: Record<string, unknown>","view: OnboardingEventView","type: OnboardingCoderType","_ctx?: LogContext","obj: T","obj: T","fn: (value: T[keyof T], key: keyof T) => any","value: unknown","target: unknown","source: unknown","result: Record<string, unknown>","options: unknown","defaults: unknown","callback: T","handlerName: string","source: string"],"sources":["../src/types/inputs.ts","../src/logger/console-sink.ts","../src/logger/log.ts","../src/logger/log-scope.ts","../src/logger/log-context.ts","../src/adapters/defaults.ts","../src/types/error.ts","../src/adapty-error.ts","../src/coders/coder.ts","../src/coders/date.ts","../src/coders/adapty-access-level.ts","../src/coders/adapty-ui-media-cache.ts","../src/coders/adapty-configuration.ts","../src/coders/adapty-subscription-period.ts","../src/coders/adapty-price.ts","../src/coders/adapty-discount-phase.ts","../src/coders/product-reference.ts","../src/coders/array.ts","../src/coders/adapty-placement.ts","../src/coders/adapty-flow-paywall.ts","../src/coders/adapty-flow-ui-schema.ts","../src/coders/json.ts","../src/coders/adapty-remote-config.ts","../src/coders/adapty-flow.ts","../src/coders/adapty-identify-params.ts","../src/coders/adapty-installation-details.ts","../src/coders/adapty-installation-status.ts","../src/coders/adapty-native-error.ts","../src/coders/adapty-non-subscription.ts","../src/coders/adapty-onboarding-builder.ts","../src/coders/adapty-onboarding.ts","../src/coders/adapty-subscription-offer-identifier.ts","../src/coders/adapty-subscription-offer.ts","../src/coders/adapty-subscription-details.ts","../src/coders/adapty-paywall-product.ts","../src/coders/adapty-promoted-product.ts","../src/coders/adapty-profile-parameters.ts","../src/coders/adapty-subscription.ts","../src/coders/hashmap.ts","../src/coders/adapty-profile.ts","../src/coders/adapty-purchase-params.ts","../src/coders/adapty-purchase-result.ts","../src/coders/adapty-ui-dialog-config.ts","../src/coders/adapty-ui-create-onboarding-view-params.ts","../src/coders/utils.ts","../src/coders/adapty-ui-create-flow-view-params.ts","../src/coders/adapty-ui-onboarding-meta.ts","../src/coders/adapty-ui-onboarding-state-params.ts","../src/coders/adapty-ui-onboarding-state-updated-action.ts","../src/coders/bridge-error.ts","../src/coders/factory.ts","../src/types/index.ts","../src/types/bridge.ts","../src/types/flow-events.ts","../src/types/onboarding-events.ts","../src/ui-builder/flow-event-mapping.ts","../src/ui-builder/onboarding-event-mapping.ts","../src/ui-builder/types.ts","../src/coders/parse.ts","../src/coders/parse-flow.ts","../src/coders/parse-onboarding.ts","../src/utils/generate-id.ts","../src/utils/compact-object.ts","../src/utils/map-values.ts","../src/utils/merge-options.ts","../src/utils/with-error-context.ts"],"sourcesContent":["import { AdaptyUiMediaCache } from '@/ui-builder/types';\nimport type { AdaptyMockConfig } from '@/mock/types';\n/**\n * Log levels for the SDK\n *\n * @remarks\n * Logging is performed on a native side.\n * So you are expected to watch logs in Xcode or Android Studio.\n */\nexport const LogLevel = Object.freeze({\n /**\n * Logs any additional information that may be useful during debugging,\n * such as function calls, API queries, etc.\n */\n VERBOSE: 'verbose',\n /**\n * Logs only errors\n */\n ERROR: 'error',\n /**\n * Logs messages from the SDK\n * that do not cause critical errors,\n * but are worth paying attention to\n */\n WARN: 'warn',\n /**\n * Logs various information messages,\n * such as those that log the lifecycle of various modules\n */\n INFO: 'info',\n});\n\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];\n\nexport const FetchPolicy = Object.freeze({\n ReloadRevalidatingCacheData: 'reload_revalidating_cache_data',\n ReturnCacheDataElseLoad: 'return_cache_data_else_load',\n ReturnCacheDataIfNotExpiredElseLoad:\n 'return_cache_data_if_not_expired_else_load',\n});\nexport type FetchPolicy = (typeof FetchPolicy)[keyof typeof FetchPolicy];\n\nexport type GetPlacementParamsInput =\n GetPlacementForDefaultAudienceParamsInput & {\n /**\n * This value limits the timeout (in milliseconds) for this method.\n *\n * @remarks\n * If the timeout is reached, cached data or local fallback will be returned.\n */\n loadTimeoutMs?: number;\n };\n\nexport type GetPlacementForDefaultAudienceParamsInput =\n | {\n /**\n * Fetch policy\n *\n * @remarks\n * By default SDK will try to load data from server and will return cached data in case of failure.\n * Otherwise use `'return_cache_data_else_load'` to return cached data if it exists.\n */\n fetchPolicy?: Exclude<\n FetchPolicy,\n 'return_cache_data_if_not_expired_else_load'\n >;\n }\n | {\n /**\n * Fetch policy\n *\n * @remarks\n * By default SDK will try to load data from server and will return cached data in case of failure.\n * Otherwise use `'return_cache_data_else_load'` to return cached data if it exists.\n */\n fetchPolicy: Extract<\n FetchPolicy,\n 'return_cache_data_if_not_expired_else_load'\n >;\n /**\n * Max age for cached data.\n *\n * @remarks\n * Max time (in seconds) the cache is valid in case of `'return_cache_data_if_not_expired_else_load'` fetch policy.\n */\n maxAgeSeconds: number;\n };\n\n/**\n * Describes optional parameters for the {@link activate} method.\n */\nexport interface ActivateParamsInput {\n /**\n * Observer mode. Turn it on when your app handles purchases and subscription\n * status itself (through your own purchase code or a third-party SDK) and\n * uses Adapty only for sending subscription events and analytics.\n *\n * @remarks\n * This also enables using Adapty Flow (paywall) views in observer mode: the\n * paywall is still rendered by Adapty, but when the user taps buy/restore the\n * SDK does NOT make the purchase — it notifies your app through the\n * `onObserverPurchaseInitiated` / `onObserverRestoreInitiated` flow event\n * handlers. Report completed purchases back to Adapty (e.g. via\n * `reportTransaction`) so they still flow into events and analytics.\n *\n * @defaultValue `false`\n */\n observerMode?: boolean;\n /**\n * User identifier in your system\n *\n * @remarks\n * If none of the parameters are passed, the SDK will generate an ID\n * and use it for a current device.\n * Use your own ID:\n * 1. If you want to support a cross-device experience\n * 2. If you have your own authentication system,\n * and you want to associate adapty profile with your user\n */\n customerUserId?: string;\n /**\n * Log level for the SDK\n *\n * @remarks\n * Logging is performed on a native side.\n * So you are expected to watch logs in Xcode or Android Studio.\n */\n logLevel?: LogLevel;\n\n serverCluster?: 'default' | 'eu' | 'cn';\n backendProxyHost?: string;\n backendProxyPort?: number;\n activateUi?: boolean;\n mediaCache?: AdaptyUiMediaCache;\n\n /**\n * Does not activate SDK until any other method is called\n * Fixes annoying iOS simulator auhtentication\n */\n __debugDeferActivation?: boolean;\n /**\n * Ignores multiple activation attempts on fast refresh.\n * If true, skips activation if SDK is already activated.\n */\n __ignoreActivationOnFastRefresh?: boolean;\n /**\n * Enables mock mode for web platform\n * @remarks\n * When enabled, SDK will use mock implementations instead of native modules.\n * Useful for Expo Web and testing.\n * @defaultValue `false`\n */\n enableMock?: boolean;\n /**\n * Configuration for mock mode\n * @remarks\n * Allows customization of mock data returned by the SDK.\n */\n mockConfig?: AdaptyMockConfig;\n /**\n * Disables IP address collection\n * @defaultValue `false`\n */\n ipAddressCollectionDisabled?: boolean;\n /**\n * Enables the Adapty Attribution service.\n *\n * @remarks\n * When enabled, the SDK registers the install with Adapty Attribution so\n * acquisition data can be attributed without a third-party attribution SDK.\n *\n * @defaultValue `false`\n */\n adaptyAttributionEnabled?: boolean;\n ios?: {\n /**\n * Disables IDFA collection\n * @default false\n */\n idfaCollectionDisabled?: boolean;\n appAccountToken?: string;\n /**\n * Controls whether the SDK will create a new profile when the app is restored from an iCloud backup\n * @defaultValue `false`\n */\n clearDataOnBackup?: boolean;\n };\n android?: {\n /**\n * Disables Google AdvertisingID collection\n * @default false\n */\n adIdCollectionDisabled?: boolean;\n pendingPrepaidPlansEnabled?: boolean;\n localAccessLevelAllowed?: boolean;\n obfuscatedAccountId?: string;\n };\n}\n\nexport interface IdentifyParamsInput {\n ios?: {\n appAccountToken?: string;\n };\n android?: {\n obfuscatedAccountId?: string;\n };\n}\n\nexport interface GetPaywallProductsParamsInput {}\n\nexport const AdaptyAndroidSubscriptionUpdateReplacementMode = Object.freeze({\n ChargeFullPrice: 'charge_full_price',\n Deferred: 'deferred',\n WithoutProration: 'without_proration',\n ChargeProratedPrice: 'charge_prorated_price',\n WithTimeProration: 'with_time_proration',\n});\n// satisfies Record<\n// string,\n// Schema['Input.AdaptyAndroidSubscriptionUpdateParameters']['replacement_mode']\n// >;\n\nexport type AdaptyAndroidSubscriptionUpdateReplacementMode =\n (typeof AdaptyAndroidSubscriptionUpdateReplacementMode)[keyof typeof AdaptyAndroidSubscriptionUpdateReplacementMode];\n\n/**\n * Android purchase parameters structure\n * @public\n */\nexport interface AdaptyAndroidPurchaseParams {\n /**\n * Android subscription update parameters\n * @platform android\n */\n subscriptionUpdateParams?: {\n oldSubVendorProductId: string;\n prorationMode: AdaptyAndroidSubscriptionUpdateReplacementMode;\n };\n /**\n * Whether the offer is personalized\n * @platform android\n * @see {@link https://developer.android.com/google/play/billing/integrate#personalized-price}\n */\n isOfferPersonalized?: boolean;\n}\n\nexport type MakePurchaseParamsInput = {\n /**\n * Android purchase parameters\n * @platform android\n */\n android?: AdaptyAndroidPurchaseParams;\n};\n\nexport type FileLocation = {\n ios: {\n fileName: string;\n };\n android:\n | {\n relativeAssetPath: string;\n }\n | {\n rawResName: string;\n };\n};\n","import type { LogSink } from './types';\nimport type { LogLevel } from '../types/inputs';\n\nfunction getConsoleForLevel(\n level: LogLevel,\n): (message?: any, ...optionalParams: any[]) => void {\n /* eslint-disable no-console */\n switch (level) {\n case 'error':\n return console.error;\n case 'warn':\n return console.warn;\n case 'verbose':\n return console.debug;\n case 'info':\n default:\n return console.info;\n }\n /* eslint-enable no-console */\n}\n\nexport const consoleLogSink: LogSink = {\n id: 'console',\n handle: event => {\n const logger = getConsoleForLevel(event.level);\n logger(event.formatted, event.params);\n },\n};\n","import { LogLevel } from '../types/inputs';\nimport type { LogEvent, LogSink, LoggerConfig } from './types';\nimport { consoleLogSink } from './console-sink';\n\n// Type for lazy evaluation functions\ntype LazyMessage = () => string;\ntype LazyParams = () => Record<string, unknown>;\n\nexport class Log {\n public static logLevel: LogLevel | null = null;\n private static sinks: LogSink[] = [consoleLogSink];\n private static defaultMeta?: LoggerConfig['defaultMeta'];\n private static _version: string = 'unknown';\n\n /**\n * Override the version shown in log messages\n * @internal\n */\n public static setVersion(version: string): void {\n this._version = version;\n }\n\n // Formats a message for logging\n private static formatMessage(message: string, funcName: string): string {\n const now = new Date().toISOString();\n\n return `[${now}] [adapty@${this._version}] \"${funcName}\": ${message}`;\n }\n\n /** Configure JS logger: replace sinks and/or set default metadata */\n public static configure(config: LoggerConfig): void {\n if (config.sinks) {\n for (const sink of this.sinks) sink.destroy?.();\n this.sinks = config.sinks.slice();\n }\n this.defaultMeta = config.defaultMeta;\n }\n\n /** Register additional sink */\n public static addSink(sink: LogSink): void {\n this.sinks.push(sink);\n }\n\n /** Remove sink by id and call its destroy if present */\n public static removeSink(id: string): void {\n const sink = this.sinks.find(sink => sink.id === id);\n this.sinks = this.sinks.filter(sink => sink.id !== id);\n sink?.destroy?.();\n }\n\n /** Clear all sinks and destroy them */\n public static clearSinks(): void {\n const prev = this.sinks;\n this.sinks = [];\n for (const sink of prev) sink.destroy?.();\n }\n\n /**\n * Gets the appropriate log level integer for a log level.\n * @internal\n */\n private static getLogLevelInt(logLevel: LogLevel): number {\n switch (logLevel) {\n case LogLevel.ERROR:\n return 0;\n case LogLevel.WARN:\n return 1;\n case LogLevel.INFO:\n return 2;\n case LogLevel.VERBOSE:\n return 3;\n }\n }\n\n /**\n * Logs a message to the console if the log level is appropriate.\n * Uses lazy evaluation to avoid unnecessary computations.\n * @internal\n */\n public static log(\n logLevel: LogLevel,\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n if (!Log.logLevel) {\n return;\n }\n\n const currentLevel = Log.getLogLevelInt(Log.logLevel);\n const messageLevel = Log.getLogLevelInt(logLevel);\n\n if (messageLevel <= currentLevel) {\n // Lazy evaluation: only compute once per entry\n const resolvedMessage = message();\n const resolvedParams = params ? params() : undefined;\n const mergedParams = this.defaultMeta\n ? {\n ...(this.defaultMeta as Record<string, unknown>),\n ...(resolvedParams ?? {}),\n }\n : resolvedParams;\n\n const formatted = Log.formatMessage(resolvedMessage, funcName);\n const event: LogEvent = {\n timestamp: new Date().toISOString(),\n version: this._version,\n level: logLevel,\n funcName,\n message: resolvedMessage,\n params: mergedParams,\n formatted,\n };\n\n for (const sink of this.sinks) {\n if (sink.levels && !sink.levels.includes(logLevel)) continue;\n try {\n sink.handle(event);\n } catch {\n // ignore sink errors\n }\n }\n }\n }\n\n public static info(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.INFO, funcName, message, params);\n }\n\n public static warn(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.WARN, funcName, message, params);\n }\n\n public static error(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.ERROR, funcName, message, params);\n }\n\n public static verbose(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.VERBOSE, funcName, message, params);\n }\n}\n","import type { LogArgs } from '@/adapters/interfaces';\nimport { ScopeArgs } from './log-context';\n\nexport type { LogArgs };\ntype LogCallback = (LazyParams: LogArgs) => void;\n\ninterface LogScopeConstructor extends ScopeArgs {\n onStart: LogCallback;\n onSuccess: LogCallback;\n onFailed: LogCallback;\n onWait: LogCallback;\n onWaitComplete: LogCallback;\n}\n\nexport class LogScope {\n public methodName: string;\n private onStart: LogCallback;\n private onSuccess: LogCallback;\n private onFailed: LogCallback;\n private onWait: LogCallback;\n private onWaitComplete: LogCallback;\n\n constructor(args: LogScopeConstructor) {\n this.methodName = args.methodName;\n this.onStart = args.onStart;\n this.onSuccess = args.onSuccess;\n this.onFailed = args.onFailed;\n this.onWait = args.onWait;\n this.onWaitComplete = args.onWaitComplete;\n }\n\n public start(args: LogArgs) {\n this.onStart(args);\n }\n public wait(args: LogArgs) {\n this.onWait(args);\n }\n public waitComplete(args: LogArgs) {\n this.onWaitComplete(args);\n }\n public success(args: LogArgs) {\n this.onSuccess(args);\n }\n public failed(args: LogArgs) {\n this.onFailed(args);\n }\n}\n","import { Log } from './log';\nimport { LogScope } from './log-scope';\nimport type { LogArgs } from './log-scope';\nexport interface ScopeArgs {\n methodName: string;\n}\n\n// Scope of a single stack trace record\ntype Scope = 'EVENT' | 'CALL' | 'ENCODE' | 'BRIDGE' | 'DECODE';\n\n// Displays an interface for a single stack trace record\ninterface Trace {\n action: Scope;\n fn: string;\n payload: LogArgs;\n error?: boolean;\n done?: boolean;\n}\n\n// LogContext instance is a logger context for a single call to a native SDK method\n// It accumulates logs for each step of the call\nexport class LogContext {\n public stack: Trace[] = [];\n\n private createScope(step: Scope, args: ScopeArgs, message: string): LogScope {\n return new LogScope({\n ...args,\n onStart: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n\n Log.verbose(\n args.methodName,\n () => `${message}...`,\n () => payload(),\n );\n },\n onSuccess: payload => {\n this.stack.push({\n action: step,\n fn: args.methodName,\n payload,\n done: true,\n });\n\n Log.verbose(\n args.methodName,\n () => `${message}: OK`,\n () => payload(),\n );\n },\n onFailed: payload => {\n this.stack.push({\n action: step,\n fn: args.methodName,\n payload,\n error: true,\n });\n\n const resolvedStack = this.stack.map(s => ({\n ...s,\n payload: s.payload(),\n }));\n const p = payload() as Record<string, any>;\n p['__stack__'] = resolvedStack;\n Log.error(\n args.methodName,\n () => `${message}: FAILED`,\n () => p,\n );\n },\n onWait: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n Log.verbose(\n args.methodName,\n () => `<HOLD> ${message}`,\n () => payload(),\n );\n },\n onWaitComplete: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n Log.verbose(\n args.methodName,\n () => `<UNLOCKED> ${message}`,\n () => payload(),\n );\n },\n });\n }\n\n // Creates a scope for a event listener\n public event(method: ScopeArgs): LogScope {\n return this.createScope(\n 'EVENT',\n method,\n `Receiving event \"${method.methodName}\"`,\n );\n }\n // Create a scope for a public call\n public call(args: ScopeArgs): LogScope {\n return this.createScope('CALL', args, 'Calling method');\n }\n // Creates a scope for encoding an object\n public encode(args: ScopeArgs): LogScope {\n return this.createScope('ENCODE', args, 'Encoding object');\n }\n // Creates a scope for calling a bridge function\n public bridge(args: ScopeArgs): LogScope {\n return this.createScope('BRIDGE', args, 'Calling bridge function');\n }\n // Creates a scope for decoding a string\n public decode(args: ScopeArgs): LogScope {\n return this.createScope('DECODE', args, 'Decoding string');\n }\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n ILoggerAdapter,\n ILogContext,\n PlatformOS,\n} from './interfaces';\nimport { LogContext } from '@/logger';\n\n/**\n * Default platform adapter with unknown OS\n */\nexport class DefaultPlatformAdapter implements IPlatformAdapter {\n readonly OS: PlatformOS = 'unknown';\n}\n\n/**\n * Default SDK metadata adapter\n */\nexport class DefaultSdkMetadataAdapter implements ISdkMetadataAdapter {\n constructor(\n public readonly sdkName: string = 'unknown',\n public readonly sdkVersion: string = '0.0.0',\n ) {}\n}\n\n/**\n * Default logger adapter using the real LogContext implementation\n */\nexport class DefaultLoggerAdapter implements ILoggerAdapter {\n createContext(): ILogContext {\n return new LogContext();\n }\n}\n","// import SDK type to link to methods in docs.\n// import { AdaptyError } from '../sdk2/error';\n\nconst ErrorCodeMapping = Object.freeze({\n /**\n * System StoreKit codes\n */\n 0: 'unknown',\n /**\n * Client is not allowed to make a request, etc.\n */\n 1: 'clientInvalid',\n /**\n * Invalid purchase identifier, etc.\n */\n 3: 'paymentInvalid',\n /**\n * This device is not allowed to make the payment.\n */\n 4: 'paymentNotAllowed',\n /**\n * Product is not available in the current storefront.\n */\n 5: 'storeProductNotAvailable',\n\n /**\n * User has not allowed access to cloud service information.\n */\n 6: 'cloudServicePermissionDenied',\n\n /**\n * The device could not connect to the network.\n */\n 7: 'cloudServiceNetworkConnectionFailed',\n\n /**\n * User has revoked permission to use this cloud service.\n */\n 8: 'cloudServiceRevoked',\n\n /**\n * The user needs to acknowledge Apple's privacy policy.\n */\n 9: 'privacyAcknowledgementRequired',\n\n /**\n * The app is attempting to use SKPayment's requestData property,\n * but does not have the appropriate entitlement.\n */\n 10: 'unauthorizedRequestData',\n\n /**\n * The specified subscription offer identifier is not valid.\n */\n 11: 'invalidOfferIdentifier',\n\n /**\n * The cryptographic signature provided is not valid.\n */\n 12: 'invalidSignature',\n\n /**\n * One or more parameters from SKPaymentDiscount is missing.\n */\n 13: 'missingOfferParams',\n\n 14: 'invalidOfferPrice',\n\n /**\n * Custom Android codes.\n */\n 20: 'adaptyNotInitialized',\n 22: 'productNotFound',\n 24: 'currentSubscriptionToUpdateNotFoundInHistory',\n 97: 'billingServiceTimeout',\n 98: 'featureNotSupported',\n 99: 'billingServiceDisconnected',\n 102: 'billingServiceUnavailable',\n 103: 'billingUnavailable',\n 105: 'developerError',\n 106: 'billingError',\n 107: 'itemAlreadyOwned',\n 108: 'itemNotOwned',\n 112: 'billingNetworkError',\n\n 1000: 'noProductIDsFound',\n 1002: 'productRequestFailed',\n\n /**\n * In-App Purchases are not allowed on this device.\n */\n 1003: 'cantMakePayments',\n 1004: 'noPurchasesToRestore',\n 1005: 'cantReadReceipt',\n 1006: 'productPurchaseFailed',\n 1010: 'refreshReceiptFailed',\n 1011: 'receiveRestoredTransactionsFailed',\n\n /**\n * You need to be authenticated to perform requests.\n */\n 2002: 'notActivated',\n 2003: 'badRequest',\n 2004: 'serverError',\n 2005: 'networkFailed',\n 2006: 'decodingFailed',\n 2009: 'encodingFailed',\n\n 3000: 'analyticsDisabled',\n /**\n * Wrong parameter was passed.\n */\n 3001: 'wrongParam',\n /**\n * It is not possible to call `.activate` method more than once.\n */\n 3005: 'activateOnceError',\n /**\n * The user profile was changed during the operation.\n */\n 3006: 'profileWasChanged',\n 3007: 'unsupportedData',\n 3100: 'persistingDataError',\n 3101: 'fetchTimeoutError',\n 9000: 'operationInterrupted',\n});\n\nexport const ErrorCode = ErrorCodeMapping;\nexport type ErrorCode = keyof typeof ErrorCodeMapping;\n\nexport const ErrorCodeName = Object.freeze({\n unknown: 0,\n clientInvalid: 1,\n paymentInvalid: 3,\n paymentNotAllowed: 4,\n storeProductNotAvailable: 5,\n cloudServicePermissionDenied: 6,\n cloudServiceNetworkConnectionFailed: 7,\n cloudServiceRevoked: 8,\n privacyAcknowledgementRequired: 9,\n unauthorizedRequestData: 10,\n invalidOfferIdentifier: 11,\n invalidSignature: 12,\n missingOfferParams: 13,\n invalidOfferPrice: 14,\n adaptyNotInitialized: 20,\n productNotFound: 22,\n currentSubscriptionToUpdateNotFoundInHistory: 24,\n billingServiceTimeout: 97,\n featureNotSupported: 98,\n billingServiceDisconnected: 99,\n billingServiceUnavailable: 102,\n billingUnavailable: 103,\n developerError: 105,\n billingError: 106,\n itemAlreadyOwned: 107,\n itemNotOwned: 108,\n billingNetworkError: 112,\n noProductIDsFound: 1000,\n productRequestFailed: 1002,\n cantMakePayments: 1003,\n noPurchasesToRestore: 1004,\n cantReadReceipt: 1005,\n productPurchaseFailed: 1006,\n refreshReceiptFailed: 1010,\n receiveRestoredTransactionsFailed: 1011,\n notActivated: 2002,\n badRequest: 2003,\n serverError: 2004,\n networkFailed: 2005,\n decodingFailed: 2006,\n encodingFailed: 2009,\n analyticsDisabled: 3000,\n wrongParam: 3001,\n activateOnceError: 3005,\n profileWasChanged: 3006,\n unsupportedData: 3007,\n persistingDataError: 3100,\n fetchTimeoutError: 3101,\n operationInterrupted: 9000,\n} as const);\nexport type ErrorCodeName = keyof typeof ErrorCodeName;\n\nexport function getErrorCode(\n error: (typeof ErrorCode)[ErrorCode],\n): ErrorCode | undefined {\n const errorCode = Object.keys(ErrorCode).find(keyStr => {\n const key = Number(keyStr) as ErrorCode;\n return ErrorCode[key] === error;\n });\n\n if (!errorCode) {\n return undefined;\n }\n\n return Number(errorCode) as ErrorCode;\n}\n\nexport function getErrorPrompt(code: ErrorCode): (typeof ErrorCode)[ErrorCode] {\n const prompt = ErrorCode[code];\n\n if (!prompt) {\n return `Unknown code: ${code}` as (typeof ErrorCode)[ErrorCode];\n }\n\n return prompt;\n}\n","import { ErrorCode } from '@/types/error';\n\nexport interface AdaptyErrorInput {\n adaptyCode: ErrorCode;\n message: string;\n detail?: string | undefined;\n}\n\nexport class AdaptyError extends Error {\n // Custom prefix to be shown before log message\n public static prefix = '';\n static middleware?: (error: AdaptyError) => void;\n\n // For example `2` for cancelled payment\n public adaptyCode: ErrorCode;\n // Message that is safe to show to a user\n public localizedDescription: string;\n public detail: string | undefined;\n\n constructor(input: AdaptyErrorInput) {\n super(AdaptyError.getMessage(input));\n\n this.adaptyCode = input.adaptyCode;\n this.localizedDescription = input.message;\n this.detail = input.detail;\n\n if (AdaptyError.middleware) {\n AdaptyError.middleware(this);\n }\n }\n\n public static set onError(callback: (error: AdaptyError) => void) {\n AdaptyError.middleware = callback;\n }\n\n public static failedToDecodeNativeError(\n message: string,\n error: unknown,\n ): AdaptyError {\n return new AdaptyError({\n adaptyCode: 0,\n message: message,\n detail: JSON.stringify(error),\n });\n }\n\n public static failedToEncode(message: string): AdaptyError {\n return new AdaptyError({\n adaptyCode: 2009,\n message: message,\n });\n }\n\n public static failedToDecode(message: string): AdaptyError {\n return new AdaptyError({\n adaptyCode: 2006,\n message: message,\n });\n }\n\n private static getMessage(input: AdaptyErrorInput): string {\n const code = input.adaptyCode;\n const codeText = ErrorCode[code];\n\n let message = `#${code} (${codeText}): ${input.message}`;\n\n if (AdaptyError.prefix) {\n message = `${AdaptyError.prefix} ${message}`;\n }\n\n return message;\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { DefaultPlatformAdapter } from '@/adapters/defaults';\nimport type { IPlatformAdapter } from '@/adapters/interfaces';\nimport { Converter, Properties, StrType } from './types';\n\nexport abstract class Coder<\n Model extends Record<string, any>,\n CodableModel extends Partial<Model>,\n Serializable extends Record<string, any> = Record<string, any>,\n> implements Converter<CodableModel, Serializable> {\n protected readonly platform: IPlatformAdapter;\n protected abstract properties: Properties<CodableModel, Serializable>;\n\n constructor(platform: IPlatformAdapter = new DefaultPlatformAdapter()) {\n this.platform = platform;\n }\n\n encode(data: CodableModel): Serializable {\n return this.encodeWithProperties(data, this.properties);\n }\n // From vendor_product_id to productId\n decode(data: Serializable): CodableModel {\n return this.decodeWithProperties(data, this.properties);\n }\n\n protected isType(value: unknown, type: StrType<any>): boolean {\n switch (type) {\n case 'string':\n case 'boolean':\n case 'number':\n return typeof value === type;\n case 'object':\n return value !== null && typeof value === 'object';\n case 'array':\n return Array.isArray(value);\n }\n }\n\n private getNestedValue(obj: Record<string, any>, key: string): any {\n const keys = key.split('.');\n let current;\n if (typeof obj === 'string') {\n try {\n current = JSON.parse(obj);\n } catch (error) {\n return undefined;\n }\n } else {\n current = obj;\n }\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!;\n\n if (current[key] !== undefined) {\n current = current[key];\n } else {\n return undefined;\n }\n }\n\n return current;\n }\n\n private assignNestedValue<T extends Record<string, any>>(\n obj: T,\n key: string,\n value: any,\n ): T {\n const keys = String(key).split('.');\n let currentObj: Partial<T> = obj;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i] as keyof Partial<T>;\n\n if (currentObj[key] === undefined) {\n currentObj[key] = {} as any;\n }\n\n currentObj = currentObj[key] as any;\n }\n\n currentObj[keys[keys.length - 1] as keyof Partial<T>] = value;\n return obj;\n }\n\n private encodeWithProperties<Model extends Record<string, any>, Serializable>(\n data: Model,\n properties: Properties<Model, Serializable>,\n ): Serializable {\n const result: Partial<Serializable> = {};\n\n for (const key in data) {\n if (key === 'ios' || key === 'android') {\n // Read properties from ios/android platform keys and flatten them\n const platformResult = this.encodeWithProperties(\n data[key],\n (properties as Record<string, any>)[key],\n ) as any;\n\n Object.assign(result, platformResult);\n continue;\n }\n\n const property = properties[key as string];\n if (!property) {\n throw AdaptyError.failedToEncode(\n `Failed to find encoder for property \"${key}\"`,\n );\n }\n\n const converter = property.converter;\n\n this.assignNestedValue(\n result,\n property.key as string,\n converter ? converter.encode(data[key]) : data[key as keyof Model],\n );\n }\n\n return result as Serializable;\n }\n\n private decodeWithProperties<Serializable, Model extends Record<string, any>>(\n data: Serializable,\n properties: Properties<Model, Serializable>,\n platform?: 'ios' | 'android',\n ): Model {\n const result: Partial<Model> = {};\n\n for (const key in properties) {\n if (key === 'android' || key === 'ios') {\n // Add ios/android property and fill platform data there\n result[key as unknown as keyof typeof result] =\n this.decodeWithProperties(\n data,\n (properties as Record<string, any>)[key],\n key,\n ) as any;\n continue;\n }\n\n const property = properties[key];\n if (!property) {\n throw AdaptyError.failedToDecode(\n `Failed to find decoder for property \"${key}\"`,\n );\n }\n\n const value = this.getNestedValue(\n data as Record<string, any>,\n property.key as string,\n );\n\n if (\n property.required &&\n value === undefined &&\n (!platform || platform == this.platform.OS)\n ) {\n throw AdaptyError.failedToDecode(\n `Failed to decode native response, because it is missing required property \"${key}\"`,\n );\n }\n\n // If value is null or undefined and property is not required, continue\n if (value == null) continue;\n\n if (!this.isType(value, property.type)) {\n throw AdaptyError.failedToDecode(\n `Failed to decode native response, because its property \"${key}\" has invalid type. Expected type: ${\n property.type\n }. Received type: ${typeof value}`,\n );\n }\n\n // If a converter is provided, use it to convert the value\n result[key as keyof Model] = property.converter\n ? property.converter.decode(value)\n : (value as any);\n }\n\n return result as Model;\n }\n}\n\nexport abstract class SimpleCoder<\n Model extends Record<string, any>,\n Serializable extends Record<string, any> = Record<string, any>,\n> extends Coder<Model, Model, Serializable> {}\n","import { AdaptyError } from '@/adapty-error';\nimport type { Converter } from './types';\n\n/**\n * Format: yyyy-MM-dd'T'HH:mm:ss.SSSZ\n * OpenAPI: Output.Date\n */\nexport class DateCoder implements Converter<Date, string> {\n decode(input: string): Date {\n let pureValue = input;\n\n if (!input.endsWith('Z')) {\n // React Native seems to have an inconsistent behaviour\n // with dates with timezone offset\n // It is not handled with custom libs like dayjs\n // So we just remove the timezone offset if possible\n\n // Android SDK returns the following format,\n // that resulted in an invalid date for some customers\n // `2023-02-24T07:16:28.000000+0000`\n // solution is:\n // 1. Replace \"+0000\" with \"Z\"\n // 2. Replace microsecs with 0 millisecs\n\n // with the timezone offset removed\n const dateParts = input.split(/[-T:.Z]/);\n const date = new Date(\n Date.UTC(\n parseInt(dateParts[0] ?? '0', 10),\n parseInt(dateParts[1] ?? '0', 10) - 1,\n parseInt(dateParts[2] ?? '0', 10),\n parseInt(dateParts[3] ?? '0', 10),\n parseInt(dateParts[4] ?? '0', 10),\n parseInt(dateParts[5] ?? '0', 10),\n ),\n );\n pureValue = date.toISOString();\n }\n\n const parsedValue = Date.parse(pureValue);\n if (isNaN(parsedValue)) {\n throw AdaptyError.failedToDecode(\n `Failed to decode a date string into JS Date. String value: ${pureValue}`,\n );\n }\n\n return new Date(parsedValue);\n }\n\n encode(value: Date): string {\n return value.toISOString();\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { AdaptyAccessLevel } from '../types';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptyAccessLevel;\ntype Serializable = Def['AdaptyProfile.AccessLevel'];\n\nexport class AdaptyAccessLevelCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n activatedAt: {\n key: 'activated_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n activeIntroductoryOfferType: {\n key: 'active_introductory_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferId: {\n key: 'active_promotional_offer_id',\n required: false,\n type: 'string',\n },\n activePromotionalOfferType: {\n key: 'active_promotional_offer_type',\n required: false,\n type: 'string',\n },\n billingIssueDetectedAt: {\n key: 'billing_issue_detected_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n cancellationReason: {\n key: 'cancellation_reason',\n required: false,\n type: 'string',\n },\n expiresAt: {\n key: 'expires_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n id: {\n key: 'id',\n required: true,\n type: 'string',\n },\n isActive: {\n key: 'is_active',\n required: true,\n type: 'boolean',\n },\n isInGracePeriod: {\n key: 'is_in_grace_period',\n required: true,\n type: 'boolean',\n },\n isLifetime: {\n key: 'is_lifetime',\n required: true,\n type: 'boolean',\n },\n isRefund: {\n key: 'is_refund',\n required: true,\n type: 'boolean',\n },\n renewedAt: {\n key: 'renewed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n startsAt: {\n key: 'starts_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n store: {\n key: 'store',\n required: true,\n type: 'string',\n },\n unsubscribedAt: {\n key: 'unsubscribed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n willRenew: {\n key: 'will_renew',\n required: true,\n type: 'boolean',\n },\n android: {\n offerId: {\n key: 'offer_id',\n required: false,\n type: 'string',\n },\n },\n };\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiMediaCache } from '@/ui-builder/types';\n\ntype Model = AdaptyUiMediaCache;\ntype Serializable = Required<Def['AdaptyConfiguration']>['media_cache'];\n\nexport class AdaptyUiMediaCacheCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n memoryStorageTotalCostLimit: {\n key: 'memory_storage_total_cost_limit',\n required: false,\n type: 'number',\n },\n memoryStorageCountLimit: {\n key: 'memory_storage_count_limit',\n required: false,\n type: 'number',\n },\n diskStorageSizeLimit: {\n key: 'disk_storage_size_limit',\n required: false,\n type: 'number',\n },\n };\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n} from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\nimport type { Def } from '@/types/schema';\nimport { AdaptyUiMediaCacheCoder } from '@/coders/adapty-ui-media-cache';\n\ntype Model = Input.ActivateParamsInput;\ntype Serializable = Def['AdaptyConfiguration'];\n\nexport class AdaptyConfigurationCoder {\n constructor(\n private readonly platform: IPlatformAdapter,\n private readonly sdkMetadata: ISdkMetadataAdapter,\n ) {}\n\n encode(apiKey: string, params: Model): Serializable {\n const config: Serializable = {\n api_key: apiKey,\n cross_platform_sdk_name: this.sdkMetadata.sdkName,\n cross_platform_sdk_version: this.sdkMetadata.sdkVersion,\n };\n\n if (params.customerUserId) {\n config['customer_user_id'] = params.customerUserId;\n }\n\n config['observer_mode'] = params.observerMode ?? false;\n config['ip_address_collection_disabled'] =\n params.ipAddressCollectionDisabled ?? false;\n config['adapty_attribution_enabled'] =\n params.adaptyAttributionEnabled ?? false;\n\n if (params.logLevel) {\n config['log_level'] = params.logLevel;\n }\n\n config['server_cluster'] = params.serverCluster ?? 'default';\n\n if (params.backendProxyHost) {\n config['backend_proxy_host'] = params.backendProxyHost;\n }\n\n if (params.backendProxyPort) {\n config['backend_proxy_port'] = params.backendProxyPort;\n }\n\n config['activate_ui'] = params.activateUi ?? true;\n\n const mediaCacheCoder = new AdaptyUiMediaCacheCoder();\n config['media_cache'] = mediaCacheCoder.encode(\n params.mediaCache ?? {\n memoryStorageTotalCostLimit: 100 * 1024 * 1024,\n memoryStorageCountLimit: 2147483647,\n diskStorageSizeLimit: 100 * 1024 * 1024,\n },\n );\n\n if (this.platform.OS === 'ios') {\n config['apple_idfa_collection_disabled'] =\n params.ios?.idfaCollectionDisabled ?? false;\n if (params.ios?.appAccountToken) {\n config['customer_identity_parameters'] = {\n app_account_token: params.ios.appAccountToken,\n };\n }\n if (params.ios?.clearDataOnBackup !== undefined) {\n config['clear_data_on_backup'] = params.ios.clearDataOnBackup;\n }\n }\n\n if (this.platform.OS === 'android') {\n config['google_adid_collection_disabled'] =\n params.android?.adIdCollectionDisabled ?? false;\n config['google_enable_pending_prepaid_plans'] =\n params.android?.pendingPrepaidPlansEnabled ?? false;\n config['google_local_access_level_allowed'] =\n params.android?.localAccessLevelAllowed ?? false;\n if (params.android?.obfuscatedAccountId) {\n config['customer_identity_parameters'] = {\n obfuscated_account_id: params.android.obfuscatedAccountId,\n };\n }\n }\n\n return config;\n }\n}\n","import type { AdaptySubscriptionPeriod } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptySubscriptionPeriod;\ntype Serializable = Def['AdaptySubscriptionPeriod'];\n\nexport class AdaptySubscriptionPeriodCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n unit: { key: 'unit', required: true, type: 'string' },\n numberOfUnits: { key: 'number_of_units', required: true, type: 'number' },\n };\n}\n","import type { AdaptyPrice } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyPrice;\ntype Serializable = Def['AdaptyPrice'];\n\nexport class AdaptyPriceCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n amount: {\n key: 'amount',\n required: true,\n type: 'number',\n },\n currencyCode: {\n key: 'currency_code',\n required: false,\n type: 'string',\n },\n currencySymbol: {\n key: 'currency_symbol',\n required: false,\n type: 'string',\n },\n localizedString: {\n key: 'localized_string',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptyDiscountPhase } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptyPriceCoder } from './adapty-price';\n\ntype Model = AdaptyDiscountPhase;\ntype Serializable = Def['AdaptySubscriptionOffer.Phase'];\n\nexport class AdaptyDiscountPhaseCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n localizedNumberOfPeriods: {\n key: 'localized_number_of_periods',\n required: false,\n type: 'string',\n },\n localizedSubscriptionPeriod: {\n key: 'localized_subscription_period',\n required: false,\n type: 'string',\n },\n numberOfPeriods: {\n key: 'number_of_periods',\n required: true,\n type: 'number',\n },\n paymentMode: { key: 'payment_mode', required: true, type: 'string' },\n price: {\n key: 'price',\n required: true,\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n subscriptionPeriod: {\n key: 'subscription_period',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionPeriodCoder(),\n },\n };\n}\n","import type { Properties } from './types';\nimport type { ProductReference } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { SimpleCoder } from './coder';\n\ntype Model = ProductReference;\ntype Serializable = Def['AdaptyFlowPaywall.ProductReference'];\n\nexport class ProductReferenceCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n flowProductId: {\n key: 'flow_product_id',\n required: false,\n type: 'string',\n },\n vendorId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n adaptyId: {\n key: 'adapty_product_id',\n required: true,\n type: 'string',\n },\n accessLevelId: {\n key: 'access_level_id',\n required: true,\n type: 'string',\n },\n productType: {\n key: 'product_type',\n required: true,\n type: 'string',\n },\n ios: {\n promotionalOfferId: {\n key: 'promotional_offer_id',\n required: false,\n type: 'string',\n },\n winBackOfferId: {\n key: 'win_back_offer_id',\n required: false,\n type: 'string',\n },\n },\n android: {\n basePlanId: {\n key: 'base_plan_id',\n required: false,\n type: 'string',\n },\n offerId: {\n key: 'offer_id',\n required: false,\n type: 'string',\n },\n },\n };\n}\n","import { Converter } from './types';\n\n// Coder for Array<T>\n// Uses factory function to create coder instances (supports dependency injection)\nexport class ArrayCoder<Model, Serializable> implements Converter<\n Model[],\n Serializable[]\n> {\n constructor(\n private readonly coderFactory: () => Converter<Model, Serializable>,\n ) {}\n\n decode(input: Serializable[]): Model[] {\n const coder = this.coderFactory();\n return input.map(item => coder.decode(item));\n }\n\n encode(value: Model[]): Serializable[] {\n const coder = this.coderFactory();\n return value.map(item => coder.encode(item));\n }\n}\n","import type { AdaptyPlacement } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyPlacement;\ntype Serializable = Def['AdaptyPlacement'];\n\nexport class AdaptyPlacementCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n abTestName: { key: 'ab_test_name', required: true, type: 'string' },\n audienceName: { key: 'audience_name', required: true, type: 'string' },\n id: { key: 'developer_id', required: true, type: 'string' },\n revision: { key: 'revision', required: true, type: 'number' },\n audienceVersionId: {\n key: 'placement_audience_version_id',\n required: true,\n type: 'string',\n },\n isTrackingPurchases: {\n key: 'is_tracking_purchases',\n required: false,\n type: 'boolean',\n },\n };\n}\n","import type { AdaptyFlowPaywall, ProductReference } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { ProductReferenceCoder } from './product-reference';\nimport { ArrayCoder } from './array';\nimport { Coder } from './coder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\n\ntype Model = AdaptyFlowPaywall;\n// `products` is an internal wire-only field: it is the source for deriving\n// `productIdentifiers` on decode and is required by the native wire schema on\n// encode. It is intentionally NOT part of the public `AdaptyFlowPaywall` type,\n// but it is carried on the runtime object so encode round-trips preserve it.\ntype CodableModel = Omit<Model, 'productIdentifiers'> & {\n products?: ProductReference[];\n};\ntype Serializable = Def['AdaptyFlowPaywall'];\n\n// Wire-level properties including the internal `products` field.\n// The `as unknown as` cast is intentional: `products` is required on the wire\n// but optional in CodableModel (so that Model extends CodableModel for\n// override compatibility). The cast bridges the required/optional mismatch.\nconst PROPERTIES = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'paywall_id', required: true, type: 'string' },\n name: { key: 'paywall_name', required: true, type: 'string' },\n products: {\n key: 'products',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new ProductReferenceCoder()),\n },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n webPurchaseUrl: {\n key: 'web_purchase_url',\n required: false,\n type: 'string',\n },\n} as unknown as Properties<CodableModel, Serializable>;\n\nexport class AdaptyFlowPaywallCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = PROPERTIES;\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n // Keep `products` on the runtime object (for encode round-trip) while\n // exposing only `productIdentifiers` on the public type.\n // products is always present on the wire (required: true in PROPERTIES).\n return {\n ...codablePart,\n productIdentifiers: codablePart.products!.map(product => ({\n vendorProductId: product.vendorId,\n adaptyProductId: product.adaptyId,\n basePlanId: product.android?.basePlanId,\n })),\n } as Model;\n }\n\n override encode(data: Model): Serializable {\n // `products` is carried at runtime even though it is not on the public type.\n const { productIdentifiers, ...codablePart } = data as CodableModel &\n Pick<Model, 'productIdentifiers'>;\n return super.encode(codablePart);\n }\n}\n","import type {\n AdaptyFlowUiSchema,\n AdaptyFlowUiSchemaGrid,\n AdaptyFlowUiSchemaLayout,\n} from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Converter } from './types';\n\ntype Model = AdaptyFlowUiSchema;\ntype Serializable = NonNullable<Def['AdaptyFlow']['ui_schema']>;\ntype SerializableGrid = NonNullable<Serializable['grids'][number]>;\ntype SerializableLayout = NonNullable<Serializable['layouts'][number]>;\n\nfunction decodeLayout(json: SerializableLayout): AdaptyFlowUiSchemaLayout {\n return { flowLayoutId: json.flow_layout_id };\n}\n\nfunction encodeLayout(model: AdaptyFlowUiSchemaLayout): SerializableLayout {\n return { flow_layout_id: model.flowLayoutId };\n}\n\nfunction decodeGrid(json: SerializableGrid): AdaptyFlowUiSchemaGrid {\n return {\n ...(json.platforms !== undefined && { platforms: json.platforms }),\n ...(json.devices !== undefined && { devices: json.devices }),\n ...(json.custom_id !== undefined && { customId: json.custom_id }),\n ...(json.h_breakpoints !== undefined && {\n hBreakpoints: json.h_breakpoints,\n }),\n ...(json.v_breakpoints !== undefined && {\n vBreakpoints: json.v_breakpoints,\n }),\n cells: json.cells,\n };\n}\n\nfunction encodeGrid(model: AdaptyFlowUiSchemaGrid): SerializableGrid {\n return {\n ...(model.platforms !== undefined && { platforms: model.platforms }),\n ...(model.devices !== undefined && { devices: model.devices }),\n ...(model.customId !== undefined && { custom_id: model.customId }),\n ...(model.hBreakpoints !== undefined && {\n h_breakpoints: model.hBreakpoints,\n }),\n ...(model.vBreakpoints !== undefined && {\n v_breakpoints: model.vBreakpoints,\n }),\n cells: model.cells,\n };\n}\n\n/**\n * `ui_schema` is written by hand rather than declared through `Properties`,\n * because `platforms` and `devices` are unions of an `'all'` literal and an\n * array, and `PropertyMeta` can only carry a single runtime type per property.\n *\n * The flow is passed back to the native side (e.g. `adapty_ui_create_flow_view`),\n * so this schema has to survive a decode/encode round trip unchanged.\n */\nexport class AdaptyFlowUiSchemaCoder implements Converter<Model, Serializable> {\n decode(json: Serializable): Model {\n return {\n layouts: json.layouts.map(decodeLayout),\n grids: json.grids.map(decodeGrid),\n };\n }\n\n encode(model: Model): Serializable {\n return {\n layouts: model.layouts.map(encodeLayout),\n grids: model.grids.map(encodeGrid),\n };\n }\n}\n","import { Converter } from './types';\n\ntype Model = Record<string, unknown>;\ntype Serialized = string;\n\nexport class JSONCoder implements Converter<Model, Serialized> {\n decode(input: Serialized): Model {\n if (!input) {\n return {};\n }\n\n return JSON.parse(input) as Model;\n }\n encode(value: Model): Serialized {\n if (Object.keys(value).length === 0) {\n return '';\n }\n return JSON.stringify(value);\n }\n}\n","import type { AdaptyRemoteConfig } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { Coder } from './coder';\nimport { JSONCoder } from './json';\n\ntype Model = AdaptyRemoteConfig;\ntype CodableModel = Omit<Model, 'dataString'>;\ntype Serializable = Def['AdaptyRemoteConfig'];\n\nexport class AdaptyRemoteConfigCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = {\n data: {\n key: 'data',\n required: true,\n type: 'string' as any,\n converter: new JSONCoder(),\n },\n lang: {\n key: 'lang',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n const dataString = JSON.stringify(codablePart.data);\n return {\n ...codablePart,\n dataString: dataString.length < 4 ? '' : dataString,\n };\n }\n\n override encode(data: Model): Serializable {\n const { dataString, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import type { AdaptyFlow } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { ArrayCoder } from './array';\nimport { Coder } from './coder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptyFlowPaywallCoder } from './adapty-flow-paywall';\nimport { AdaptyFlowUiSchemaCoder } from './adapty-flow-ui-schema';\n\ntype Model = AdaptyFlow;\n// `hasViewConfiguration` is derived on decode and is not part of the wire\n// schema, so it must be stripped before encoding the flow back to native.\ntype CodableModel = Omit<Model, 'hasViewConfiguration'>;\ntype Serializable = Def['AdaptyFlow'];\n\nexport class AdaptyFlowCoder extends Coder<Model, CodableModel, Serializable> {\n protected properties: Properties<CodableModel, Serializable> = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'flow_id', required: true, type: 'string' },\n name: { key: 'flow_name', required: true, type: 'string' },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n remoteConfigs: {\n key: 'remote_configs',\n required: false,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyRemoteConfigCoder()),\n },\n flowVersionId: {\n key: 'flow_version_id',\n required: false,\n type: 'string',\n },\n paywalls: {\n key: 'variations',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyFlowPaywallCoder()),\n },\n uiSchema: {\n key: 'ui_schema',\n required: false,\n type: 'object',\n converter: new AdaptyFlowUiSchemaCoder(),\n },\n responseCreatedAt: {\n key: 'response_created_at',\n required: true,\n type: 'number',\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n\n return {\n ...codablePart,\n hasViewConfiguration:\n codablePart.flowVersionId !== undefined &&\n codablePart.uiSchema !== undefined,\n };\n }\n\n override encode(data: Model): Serializable {\n const { hasViewConfiguration, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\n\ntype Model = Input.IdentifyParamsInput;\ntype Serializable = {\n app_account_token?: string;\n obfuscated_account_id?: string;\n obfuscated_profile_id?: string;\n};\n\nexport class AdaptyIdentifyParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(params?: Model): Serializable | undefined {\n if (!params) {\n return undefined;\n }\n\n const result: Serializable = {};\n\n if (this.platform.OS === 'ios' && params.ios?.appAccountToken) {\n result.app_account_token = params.ios.appAccountToken;\n }\n\n if (this.platform.OS === 'android' && params.android?.obfuscatedAccountId) {\n result.obfuscated_account_id = params.android.obfuscatedAccountId;\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n }\n}\n","import { AdaptyInstallationDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { Converter } from './types';\nimport { DateCoder } from './date';\n\nexport class AdaptyInstallationDetailsCoder implements Converter<\n AdaptyInstallationDetails,\n Def['AdaptyInstallationDetails']\n> {\n encode(model: AdaptyInstallationDetails): Def['AdaptyInstallationDetails'] {\n const result: Def['AdaptyInstallationDetails'] = {\n install_time: new DateCoder().encode(model.installTime),\n app_launch_count: model.appLaunchCount,\n };\n\n if (model.installId) {\n result.install_id = model.installId;\n }\n\n if (model.payload) {\n result.payload = model.payload;\n }\n\n return result;\n }\n\n decode(json: Def['AdaptyInstallationDetails']): AdaptyInstallationDetails {\n return {\n installTime: new DateCoder().decode(json.install_time),\n appLaunchCount: json.app_launch_count,\n installId: json.install_id,\n payload: json.payload,\n };\n }\n}\n","import { AdaptyInstallationStatus, AdaptyInstallationDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { Converter } from './types';\nimport { DateCoder } from './date';\n\nexport class AdaptyInstallationStatusCoder implements Converter<\n AdaptyInstallationStatus,\n Def['AdaptyInstallationStatus']\n> {\n encode(model: AdaptyInstallationStatus): Def['AdaptyInstallationStatus'] {\n if (model.status === 'determined') {\n const details: Def['AdaptyInstallationDetails'] = {\n install_time: new DateCoder().encode(model.details.installTime),\n app_launch_count: model.details.appLaunchCount,\n };\n\n if (model.details.installId) {\n details.install_id = model.details.installId;\n }\n\n if (model.details.payload) {\n details.payload = model.details.payload;\n }\n\n return {\n status: 'determined',\n details,\n };\n }\n\n return {\n status: model.status,\n };\n }\n\n decode(json: Def['AdaptyInstallationStatus']): AdaptyInstallationStatus {\n if (json.status === 'determined') {\n const details: AdaptyInstallationDetails = {\n installTime: new DateCoder().decode(json.details.install_time),\n appLaunchCount: json.details.app_launch_count,\n installId: json.details.install_id,\n payload: json.details.payload,\n };\n\n return {\n status: 'determined',\n details,\n };\n }\n\n return {\n status: json.status,\n };\n }\n}\n","import type { AdaptyNativeError } from '@/types/bridge';\nimport type { ErrorConverter } from './error-coder';\nimport type { Properties } from './types';\nimport type { Def } from '@/types/schema';\nimport { SimpleCoder } from './coder';\nimport { AdaptyError } from '@/adapty-error';\n\ntype Model = AdaptyNativeError;\ntype Serializable = Def['AdaptyError'];\n\nexport class AdaptyNativeErrorCoder\n extends SimpleCoder<Model, Serializable>\n implements ErrorConverter<Model>\n{\n public type: 'error' = 'error';\n\n protected properties: Properties<Model, Serializable> = {\n adaptyCode: { key: 'adapty_code', required: true, type: 'number' },\n message: { key: 'message', required: true, type: 'string' },\n detail: { key: 'detail', required: false, type: 'string' },\n };\n\n public getError(data: Model): AdaptyError {\n return new AdaptyError({\n adaptyCode: data.adaptyCode as AdaptyError['adaptyCode'],\n message: data.message,\n detail: data.detail,\n });\n }\n}\n","import type { AdaptyNonSubscription } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptyNonSubscription;\ntype Serializable = Def['AdaptyProfile.NonSubscription'];\n\nexport class AdaptyNonSubscriptionCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n isConsumable: { key: 'is_consumable', required: true, type: 'boolean' },\n isRefund: { key: 'is_refund', required: true, type: 'boolean' },\n isSandbox: { key: 'is_sandbox', required: true, type: 'boolean' },\n purchasedAt: {\n key: 'purchased_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n purchaseId: { key: 'purchase_id', required: true, type: 'string' },\n store: { key: 'store', required: true, type: 'string' },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n vendorTransactionId: {\n key: 'vendor_transaction_id',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptyOnboardingBuilder } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyOnboardingBuilder;\ntype Serializable = Required<Def['AdaptyOnboarding']>['onboarding_builder'];\n\nexport class AdaptyOnboardingBuilderCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n url: {\n key: 'config_url',\n required: true,\n type: 'string',\n },\n };\n}\n","import type { AdaptyOnboarding } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { Coder } from './coder';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptyOnboardingBuilderCoder } from './adapty-onboarding-builder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\n\ntype Model = AdaptyOnboarding;\ntype CodableModel = Omit<Model, 'hasViewConfiguration'>;\ntype Serializable = Def['AdaptyOnboarding'];\n\nexport class AdaptyOnboardingCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'onboarding_id', required: true, type: 'string' },\n name: { key: 'onboarding_name', required: true, type: 'string' },\n remoteConfig: {\n key: 'remote_config',\n required: false,\n type: 'object',\n converter: new AdaptyRemoteConfigCoder(),\n },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n version: { key: 'response_created_at', required: false, type: 'number' },\n onboardingBuilder: {\n key: 'onboarding_builder',\n required: true,\n type: 'object',\n converter: new AdaptyOnboardingBuilderCoder(),\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n requestLocale: { key: 'request_locale', required: true, type: 'string' },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n return {\n ...codablePart,\n hasViewConfiguration: codablePart.onboardingBuilder !== undefined,\n };\n }\n\n override encode(data: Model): Serializable {\n const { hasViewConfiguration, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import { AdaptySubscriptionOfferId } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptySubscriptionOfferId;\ntype Serializable = Def['AdaptySubscriptionOffer.Identifier'];\n\nexport class AdaptySubscriptionOfferIdCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n type: {\n key: 'type',\n required: true,\n type: 'string',\n },\n id: {\n key: 'id',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptySubscriptionOffer } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionOfferIdCoder } from '@/coders/adapty-subscription-offer-identifier';\nimport { ArrayCoder } from '@/coders/array';\nimport { AdaptyDiscountPhaseCoder } from '@/coders/adapty-discount-phase';\n\ntype Model = AdaptySubscriptionOffer;\ntype Serializable = Def['AdaptySubscriptionOffer'];\n\nexport class AdaptySubscriptionOfferCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n identifier: {\n key: 'offer_identifier',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionOfferIdCoder(),\n },\n phases: {\n key: 'phases',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyDiscountPhaseCoder()),\n },\n android: {\n offerTags: {\n key: 'offer_tags',\n required: false,\n type: 'array',\n },\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n if (!data.offer_tags) {\n const { android, ...partialData } = baseResult;\n return partialData;\n }\n return baseResult;\n }\n}\n","import type { AdaptySubscriptionDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptySubscriptionOfferCoder } from '@/coders/adapty-subscription-offer';\n\ntype Model = AdaptySubscriptionDetails;\ntype Serializable = Def['AdaptyProduct.Subscription'];\n\nexport class AdaptySubscriptionDetailsCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n subscriptionPeriod: {\n key: 'period',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionPeriodCoder(),\n },\n localizedSubscriptionPeriod: {\n key: 'localized_period',\n required: false,\n type: 'string',\n },\n offer: {\n key: 'offer',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionOfferCoder(),\n },\n ios: {\n subscriptionGroupIdentifier: {\n key: 'group_identifier',\n required: false,\n type: 'string',\n },\n },\n android: {\n basePlanId: {\n key: 'base_plan_id',\n required: true,\n type: 'string',\n },\n renewalType: {\n key: 'renewal_type',\n required: false,\n type: 'string',\n },\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n const propToRemove = data.base_plan_id ? 'ios' : 'android';\n const { [propToRemove]: _, ...partialData } = baseResult;\n return partialData;\n }\n}\n","import type { AdaptyPaywallProduct } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\n\ntype Model = AdaptyPaywallProduct;\ntype Serializable = Def['AdaptyPaywallProduct.Response'];\n\nexport class AdaptyPaywallProductCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n adaptyId: {\n key: 'adapty_product_id',\n required: true,\n type: 'string',\n },\n paywallProductIndex: {\n key: 'paywall_product_index',\n required: true,\n type: 'number',\n },\n localizedDescription: {\n key: 'localized_description',\n required: true,\n type: 'string',\n },\n localizedTitle: { key: 'localized_title', required: true, type: 'string' },\n regionCode: { key: 'region_code', required: false, type: 'string' },\n variationId: {\n key: 'paywall_variation_id',\n required: true,\n type: 'string',\n },\n paywallABTestName: {\n key: 'paywall_ab_test_name',\n required: true,\n type: 'string',\n },\n paywallName: { key: 'paywall_name', required: true, type: 'string' },\n accessLevelId: { key: 'access_level_id', required: true, type: 'string' },\n productType: { key: 'product_type', required: true, type: 'string' },\n price: {\n key: 'price',\n required: false, // Native SDKs require this\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n webPurchaseUrl: {\n key: 'web_purchase_url',\n required: false,\n type: 'string',\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n subscription: {\n key: 'subscription',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionDetailsCoder(),\n },\n ios: {\n isFamilyShareable: {\n key: 'is_family_shareable',\n required: true,\n type: 'boolean',\n },\n },\n };\n\n public getInput(data: Serializable): Def['AdaptyPaywallProduct.Request'] {\n return {\n adapty_product_id: data.adapty_product_id,\n access_level_id: data.access_level_id,\n product_type: data.product_type,\n paywall_product_index: data.paywall_product_index,\n paywall_ab_test_name: data.paywall_ab_test_name,\n payload_data: data.payload_data,\n paywall_name: data.paywall_name,\n paywall_variation_id: data.paywall_variation_id,\n subscription: data.subscription?.offer\n ? {\n offer: {\n offer_identifier: data.subscription.offer.offer_identifier,\n },\n }\n : undefined,\n vendor_product_id: data.vendor_product_id,\n };\n }\n}\n","import type { AdaptyPromotedProduct } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\n\ntype Model = AdaptyPromotedProduct;\ntype Serializable = Def['AdaptyPromotedProduct.Response'];\n\nexport class AdaptyPromotedProductCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n localizedDescription: {\n key: 'localized_description',\n required: true,\n type: 'string',\n },\n localizedTitle: { key: 'localized_title', required: true, type: 'string' },\n regionCode: { key: 'region_code', required: false, type: 'string' },\n price: {\n key: 'price',\n required: false, // Native SDKs require this\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n subscription: {\n key: 'subscription',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionDetailsCoder(),\n },\n ios: {\n isFamilyShareable: {\n key: 'is_family_shareable',\n required: true,\n type: 'boolean',\n },\n },\n };\n\n public getInput(data: Serializable): Def['AdaptyPromotedProduct.Request'] {\n return {\n vendor_product_id: data.vendor_product_id,\n payload_data: data.payload_data,\n subscription: data.subscription?.offer\n ? {\n offer: {\n offer_identifier: data.subscription.offer.offer_identifier,\n },\n }\n : undefined,\n };\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport type { AdaptyProfileParameters } from '@/types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyProfileParameters;\ntype Serializable = Def['AdaptyProfileParameters'];\n\nexport class AdaptyProfileParametersCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n firstName: { key: 'first_name', required: false, type: 'string' },\n lastName: { key: 'last_name', required: false, type: 'string' },\n gender: { key: 'gender', required: false, type: 'string' },\n birthday: { key: 'birthday', required: false, type: 'string' },\n email: { key: 'email', required: false, type: 'string' },\n phoneNumber: { key: 'phone_number', required: false, type: 'string' },\n appTrackingTransparencyStatus: {\n key: 'att_status',\n required: false,\n type: 'number',\n },\n codableCustomAttributes: {\n key: 'custom_attributes',\n required: false,\n type: 'object',\n },\n analyticsDisabled: {\n key: 'analytics_disabled',\n required: false,\n type: 'boolean',\n },\n };\n}\n","import type { AdaptySubscription } from '../types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptySubscription;\ntype Serializable = Def['AdaptyProfile.Subscription'];\n\nexport class AdaptySubscriptionCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n isActive: {\n key: 'is_active',\n required: true,\n type: 'boolean',\n },\n isLifetime: {\n key: 'is_lifetime',\n required: true,\n type: 'boolean',\n },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n store: {\n key: 'store',\n required: true,\n type: 'string',\n },\n vendorTransactionId: {\n key: 'vendor_transaction_id',\n required: true,\n type: 'string',\n },\n vendorOriginalTransactionId: {\n key: 'vendor_original_transaction_id',\n required: true,\n type: 'string',\n },\n activatedAt: {\n key: 'activated_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n willRenew: {\n key: 'will_renew',\n required: true,\n type: 'boolean',\n },\n isInGracePeriod: {\n key: 'is_in_grace_period',\n required: true,\n type: 'boolean',\n },\n isRefund: {\n key: 'is_refund',\n required: true,\n type: 'boolean',\n },\n isSandbox: {\n key: 'is_sandbox',\n required: true,\n type: 'boolean',\n },\n renewedAt: {\n key: 'renewed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n expiresAt: {\n key: 'expires_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n startsAt: {\n key: 'starts_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n unsubscribedAt: {\n key: 'unsubscribed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n billingIssueDetectedAt: {\n key: 'billing_issue_detected_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n activeIntroductoryOfferType: {\n key: 'active_introductory_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferType: {\n key: 'active_promotional_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferId: {\n key: 'active_promotional_offer_id',\n required: false,\n type: 'string',\n },\n cancellationReason: {\n key: 'cancellation_reason',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { Converter } from './types';\n\n// Coder for Record<string, T>\nexport class HashmapCoder<T extends Converter<any, any>> implements Converter<\n Record<string, ReturnType<T['decode']>>,\n Record<string, any>\n> {\n private coder: T | null;\n\n constructor(coder: T | null) {\n this.coder = coder;\n }\n\n decode(\n input: Record<string, unknown>,\n ): Record<string, ReturnType<T['decode']>> {\n const result: Record<string, any> = {};\n\n Object.keys(input).forEach(key => {\n const property = input[key as string];\n\n result[key] = this.coder?.decode(property) ?? property;\n });\n\n return result;\n }\n\n encode(value: Record<string, any>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n const property = value[key as string];\n result[key] = this.coder?.encode(property) ?? property;\n });\n\n return result;\n }\n}\n","import type { AdaptyProfile } from '../types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyAccessLevelCoder } from './adapty-access-level';\nimport { AdaptyNonSubscriptionCoder } from './adapty-non-subscription';\nimport { AdaptySubscriptionCoder } from './adapty-subscription';\nimport { HashmapCoder } from './hashmap';\nimport { ArrayCoder } from './array';\n\ntype Model = AdaptyProfile;\ntype Serializable = Def['AdaptyProfile'];\n\nexport class AdaptyProfileCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n accessLevels: {\n key: 'paid_access_levels',\n required: false,\n type: 'object',\n converter: new HashmapCoder(new AdaptyAccessLevelCoder()),\n },\n appliedExternalAttributionProviders: {\n key: 'applied_attribution_sources',\n required: false,\n type: 'array',\n },\n customAttributes: {\n key: 'custom_attributes',\n required: false,\n type: 'object',\n },\n customerUserId: {\n key: 'customer_user_id',\n required: false,\n type: 'string',\n },\n nonSubscriptions: {\n key: 'non_subscriptions',\n required: false,\n type: 'object',\n converter: new HashmapCoder(\n new ArrayCoder(() => new AdaptyNonSubscriptionCoder()),\n ),\n },\n profileId: {\n key: 'profile_id',\n required: true,\n type: 'string',\n },\n subscriptions: {\n key: 'subscriptions',\n required: false,\n type: 'object',\n converter: new HashmapCoder(new AdaptySubscriptionCoder()),\n },\n };\n}\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\n\ntype Model = Input.MakePurchaseParamsInput;\ntype Serializable = Record<string, unknown>;\n\nexport class AdaptyPurchaseParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(data: Model): Serializable {\n if (this.platform.OS !== 'android') {\n return {};\n }\n\n const purchaseParams: Serializable = {};\n\n if (data.android) {\n if (data.android.subscriptionUpdateParams) {\n purchaseParams['subscription_update_params'] = {\n replacement_mode: data.android.subscriptionUpdateParams.prorationMode,\n old_sub_vendor_product_id:\n data.android.subscriptionUpdateParams.oldSubVendorProductId,\n };\n }\n\n if (data.android.isOfferPersonalized !== undefined) {\n purchaseParams['is_offer_personalized'] =\n data.android.isOfferPersonalized;\n }\n }\n\n return purchaseParams;\n }\n}\n","import type { AdaptyPurchaseResult } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { AdaptyProfileCoder } from '@/coders/adapty-profile';\nimport { SimpleCoder } from './coder';\nimport type { Properties } from './types';\n\ntype Model = AdaptyPurchaseResult;\ntype Serializable = Def['AdaptyPurchaseResult'];\n\nexport class AdaptyPurchaseResultCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n type: {\n key: 'type',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n if (baseResult.type === 'success') {\n if (!data.profile) {\n throw new Error(\n 'Profile is required for success type of purchase result',\n );\n }\n return {\n ...baseResult,\n profile: new AdaptyProfileCoder(this.platform).decode(data.profile),\n ...(this.platform.OS === 'ios' && data.apple_jws_transaction\n ? { ios: { jwsTransaction: data.apple_jws_transaction } }\n : {}),\n ...(this.platform.OS === 'android' && data.google_purchase_token\n ? { android: { purchaseToken: data.google_purchase_token } }\n : {}),\n };\n }\n return baseResult;\n }\n\n override encode(data: Model): Serializable {\n const { type } = data;\n\n if (type === 'success') {\n if (!('profile' in data)) {\n throw new Error(\n 'Profile is required for success type of purchase result',\n );\n }\n\n return {\n type: 'success',\n profile: new AdaptyProfileCoder(this.platform).encode(data.profile),\n ...(this.platform.OS === 'ios' && data.ios?.jwsTransaction\n ? { apple_jws_transaction: data.ios.jwsTransaction }\n : {}),\n ...(this.platform.OS === 'android' && data.android?.purchaseToken\n ? { google_purchase_token: data.android.purchaseToken }\n : {}),\n };\n }\n\n return super.encode({ type });\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiDialogConfig } from '@/ui-builder/types';\n\ntype Model = AdaptyUiDialogConfig;\ntype Serializable = Def['AdaptyUI.DialogConfiguration'];\n\nexport class AdaptyUiDialogConfigCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n primaryActionTitle: {\n key: 'default_action_title',\n required: true,\n type: 'string',\n },\n secondaryActionTitle: {\n key: 'secondary_action_title',\n required: false,\n type: 'string',\n },\n title: {\n key: 'title',\n required: false,\n type: 'string',\n },\n content: {\n key: 'content',\n required: false,\n type: 'string',\n },\n };\n}\n","import { CreateOnboardingViewParamsInput } from '@/ui-builder/types';\nimport { Req } from '@/types/schema';\n\ntype Serializable = Pick<\n Req['AdaptyUICreateOnboardingView.Request'],\n 'external_urls_presentation'\n>;\n\nexport class AdaptyUICreateOnboardingViewParamsCoder {\n encode(data: CreateOnboardingViewParamsInput): Serializable {\n const result: Serializable = {};\n\n if (data.externalUrlsPresentation) {\n result.external_urls_presentation = data.externalUrlsPresentation;\n }\n\n return result;\n }\n}\n","export const formatDateUTC = (date: Date): string => {\n const pad = (num: number, digits: number = 2): string => {\n const str = num.toString();\n const paddingLength = digits - str.length;\n return paddingLength > 0 ? '0'.repeat(paddingLength) + str : str;\n };\n\n const year = date.getUTCFullYear();\n const month = pad(date.getUTCMonth() + 1);\n const day = pad(date.getUTCDate());\n const hours = pad(date.getUTCHours());\n const minutes = pad(date.getUTCMinutes());\n const seconds = pad(date.getUTCSeconds());\n const millis = pad(date.getUTCMilliseconds(), 3);\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${millis}Z`;\n};\n\nexport const colorToHex = {\n fromARGB(value: number): string {\n const hex = value.toString(16).padStart(8, '0');\n return `#${hex.slice(2)}${hex.slice(0, 2)}`;\n },\n fromRGBA(value: number): string {\n return `#${value.toString(16).padStart(8, '0')}`;\n },\n fromRGB(value: number): string {\n return `#${value.toString(16).padStart(6, '0')}ff`;\n },\n};\n\nexport const extractBase64Data = (input: string): string => {\n const commaIndex = input.indexOf(',');\n if (input.startsWith('data:') && commaIndex !== -1) {\n return input.slice(commaIndex + 1);\n }\n return input;\n};\n\nimport type { FileLocation } from '@/types/inputs';\nimport type { PlatformOS } from '@/adapters/interfaces';\n\nexport const resolveAssetId = (\n asset: { relativeAssetPath: string } | { fileLocation: FileLocation },\n platformOS: PlatformOS,\n): string => {\n if ('relativeAssetPath' in asset) {\n return platformOS === 'android'\n ? `${asset.relativeAssetPath}a`\n : asset.relativeAssetPath;\n }\n\n const fileLocation = asset.fileLocation;\n if (platformOS === 'android') {\n return 'relativeAssetPath' in fileLocation.android\n ? `${fileLocation.android.relativeAssetPath}a`\n : `${(fileLocation.android as { rawResName: string }).rawResName}r`;\n }\n\n return fileLocation.ios.fileName;\n};\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport type {\n CreateFlowViewParamsInput,\n AdaptyCustomAsset,\n} from '@/ui-builder/types';\nimport type { FileLocation } from '@/types/inputs';\nimport type { Def } from '@/types/schema';\nimport { AdaptyPurchaseParamsCoder } from './adapty-purchase-params';\nimport {\n colorToHex,\n extractBase64Data,\n formatDateUTC,\n resolveAssetId,\n} from './utils';\n\ntype Model = CreateFlowViewParamsInput;\ntype Serializable = {\n locale?: Def['AdaptyLocale'];\n custom_layout_id?: string;\n preload_products?: boolean;\n load_timeout?: number;\n custom_tags?: Def['AdaptyUI.CustomTagsValues'];\n custom_timers?: Def['AdaptyUI.CustomTimersValues'];\n custom_assets?: Def['AdaptyUI.CustomAssets'];\n product_purchase_parameters?: Def['AdaptyUI.ProductPurchaseParameters'];\n enable_safe_area_paddings?: boolean;\n};\n\nexport class AdaptyUICreateFlowViewParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(data: Model): Serializable {\n const result: Serializable = {};\n\n if (data.locale !== undefined) {\n result.locale = data.locale;\n }\n\n if (data.customLayoutId !== undefined) {\n result.custom_layout_id = data.customLayoutId;\n }\n\n if (data.prefetchProducts !== undefined) {\n result.preload_products = data.prefetchProducts;\n }\n\n if (data.android?.enableSafeArea !== undefined) {\n result.enable_safe_area_paddings = data.android.enableSafeArea;\n }\n\n if (data.loadTimeoutMs !== undefined) {\n result.load_timeout = data.loadTimeoutMs / 1000;\n }\n\n if (data.customTags) {\n result.custom_tags = data.customTags;\n }\n\n if (data.customTimers) {\n result.custom_timers = this.encodeCustomTimers(data.customTimers);\n }\n\n if (data.customAssets) {\n result.custom_assets = this.encodeCustomAssets(data.customAssets);\n }\n\n if (data.productPurchaseParams) {\n result.product_purchase_parameters = this.encodeProductPurchaseParams(\n data.productPurchaseParams,\n );\n }\n\n return result;\n }\n\n private encodeCustomTimers(\n timers: Record<string, Date>,\n ): Def['AdaptyUI.CustomTimersValues'] {\n const result: Record<string, string> = {};\n for (const key in timers) {\n if (timers.hasOwnProperty(key)) {\n const date = timers[key];\n if (date instanceof Date) {\n result[key] = formatDateUTC(date);\n }\n }\n }\n return result;\n }\n\n private encodeCustomAssets(\n assets: Record<string, AdaptyCustomAsset>,\n ): Def['AdaptyUI.CustomAssets'] {\n const getAssetId = (\n asset: { relativeAssetPath: string } | { fileLocation: FileLocation },\n ): string => {\n return resolveAssetId(asset, this.platform.OS) || '';\n };\n\n return Object.entries(assets)\n .map(([id, asset]): Def['AdaptyUI.CustomAssets'][number] | undefined => {\n switch (asset.type) {\n case 'image':\n return 'base64' in asset\n ? {\n id,\n type: 'image',\n value: extractBase64Data(asset.base64),\n }\n : {\n id,\n type: 'image',\n asset_id: getAssetId(asset),\n };\n\n case 'video':\n return {\n id,\n type: 'video',\n asset_id: getAssetId(asset),\n };\n\n case 'color':\n let value: string;\n\n if ('argb' in asset) {\n value = colorToHex.fromARGB(asset.argb);\n } else if ('rgba' in asset) {\n value = colorToHex.fromRGBA(asset.rgba);\n } else if ('rgb' in asset) {\n value = colorToHex.fromRGB(asset.rgb);\n } else {\n return undefined;\n }\n\n return {\n id,\n type: 'color',\n value,\n };\n\n case 'linear-gradient':\n const { values, points = {} } = asset;\n const { x0 = 0, y0 = 0, x1 = 1, y1 = 0 } = points;\n\n const colorStops = values\n .map(({ p, ...colorInput }) => {\n let color: string;\n\n if ('argb' in colorInput) {\n color = colorToHex.fromARGB(colorInput.argb);\n } else if ('rgba' in colorInput) {\n color = colorToHex.fromRGBA(colorInput.rgba);\n } else if ('rgb' in colorInput) {\n color = colorToHex.fromRGB(colorInput.rgb);\n } else {\n return undefined;\n }\n\n return { color, p };\n })\n .filter(\n (v): v is { color: string; p: number } => v !== undefined,\n );\n\n if (colorStops.length !== values.length) return undefined;\n\n return {\n id,\n type: 'linear-gradient',\n values: colorStops,\n points: { x0, y0, x1, y1 },\n };\n\n default:\n return undefined;\n }\n })\n .filter(\n (item): item is Def['AdaptyUI.CustomAssets'][number] =>\n item !== undefined,\n );\n }\n\n private encodeProductPurchaseParams(\n params: CreateFlowViewParamsInput['productPurchaseParams'],\n ): Def['AdaptyUI.ProductPurchaseParameters'] {\n if (!params) return {};\n\n const purchaseParamsCoder = new AdaptyPurchaseParamsCoder(this.platform);\n return Object.fromEntries(\n params.map(({ productId, params }) => [\n productId.adaptyProductId,\n purchaseParamsCoder.encode(params),\n ]),\n );\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiOnboardingMeta } from '@/ui-builder/types';\n\ntype Model = AdaptyUiOnboardingMeta;\ntype Serializable = Def['AdaptyUI.OnboardingMeta'];\n\nexport class AdaptyUiOnboardingMetaCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n onboardingId: {\n key: 'onboarding_id',\n required: true,\n type: 'string',\n },\n screenClientId: {\n key: 'screen_cid',\n required: true,\n type: 'string',\n },\n screenIndex: {\n key: 'screen_index',\n required: true,\n type: 'number',\n },\n totalScreens: {\n key: 'total_screens',\n required: true,\n type: 'number',\n },\n };\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiOnboardingStateParams } from '@/ui-builder/types';\n\ntype Model = AdaptyUiOnboardingStateParams;\ntype Serializable = Def['AdaptyUI.OnboardingsStateParams'];\n\nexport class AdaptyUiOnboardingStateParamsCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n id: {\n key: 'id',\n required: true,\n type: 'string',\n },\n value: {\n key: 'value',\n required: true,\n type: 'string',\n },\n label: {\n key: 'label',\n required: true,\n type: 'string',\n },\n };\n}\n","import type { Def, Event } from '@/types/schema';\nimport type { OnboardingStateUpdatedAction } from '@/ui-builder/types';\nimport { SimpleCoder } from './coder';\nimport type { Properties } from './types';\nimport { AdaptyUiOnboardingStateParamsCoder } from './adapty-ui-onboarding-state-params';\n\ntype Model = OnboardingStateUpdatedAction;\ntype BaseModel = Omit<Model, 'value'>;\ntype Serializable = Event['OnboardingViewEvent.OnStateUpdatedAction']['action'];\ntype SerializableStateParam = Def['AdaptyUI.OnboardingsStateParams'];\n\nexport class AdaptyUiOnboardingStateUpdatedActionCoder extends SimpleCoder<\n BaseModel,\n Serializable\n> {\n private readonly paramCoder = new AdaptyUiOnboardingStateParamsCoder();\n\n protected properties: Properties<BaseModel, Serializable> = {\n elementId: {\n key: 'element_id',\n required: true,\n type: 'string',\n },\n elementType: {\n key: 'element_type',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): OnboardingStateUpdatedAction {\n const base = super.decode(data);\n const { elementType } = base;\n\n switch (elementType) {\n case 'select':\n return {\n ...base,\n elementType: 'select',\n value: this.paramCoder.decode(data.value as SerializableStateParam),\n };\n case 'multi_select':\n return {\n ...base,\n elementType: 'multi_select',\n value: Array.isArray(data.value)\n ? data.value.map(v => this.paramCoder.decode(v))\n : [],\n };\n case 'input':\n return {\n ...base,\n elementType: 'input',\n value: data.value as\n | { type: 'text' | 'email'; value: string }\n | { type: 'number'; value: number },\n };\n case 'date_picker':\n return {\n ...base,\n elementType: 'date_picker',\n value: data.value as { day?: number; month?: number; year?: number },\n };\n default:\n throw new Error(`Unknown element_type: ${elementType}`);\n }\n }\n\n override encode(data: OnboardingStateUpdatedAction): Serializable {\n const base = super.encode(data);\n const { elementType } = data;\n switch (elementType) {\n case 'select':\n return {\n ...base,\n element_type: 'select',\n value: this.paramCoder.encode(data.value),\n };\n case 'multi_select':\n return {\n ...base,\n element_type: 'multi_select',\n value: data.value.map(v => this.paramCoder.encode(v)),\n };\n case 'input':\n return {\n ...base,\n element_type: 'input',\n value: data.value,\n };\n case 'date_picker':\n return {\n ...base,\n element_type: 'date_picker',\n value: data.value,\n };\n default:\n throw new Error(`Unknown elementType: ${elementType}`);\n }\n }\n}\n","import { AdaptyBridgeError } from '@/types/bridge';\nimport { SimpleCoder } from './coder';\nimport { Properties } from './types';\nimport { ErrorConverter } from './error-coder';\nimport { AdaptyError } from '@/adapty-error';\n\ntype Model = AdaptyBridgeError;\ntype Serializable = Record<string, any>;\n\nexport class BridgeErrorCoder\n extends SimpleCoder<Model, Serializable>\n implements ErrorConverter<Model>\n{\n public type: 'error' = 'error';\n\n protected properties: Properties<Model, Serializable> = {\n errorType: {\n key: 'error_type',\n required: true,\n type: 'string',\n },\n name: {\n key: 'name',\n required: false,\n type: 'string',\n },\n type: {\n key: 'type',\n required: false,\n type: 'string',\n },\n underlyingError: {\n key: 'parent_error',\n required: false,\n type: 'string',\n },\n description: {\n key: 'description',\n required: false,\n type: 'string',\n },\n };\n\n public getError(data: Model): AdaptyError {\n switch (data.errorType) {\n case 'missingRequiredArgument':\n return new AdaptyError({\n adaptyCode: 3001,\n message: `Required parameter \"${data.name} was not passed to a native module\"`,\n });\n case 'typeMismatch':\n return new AdaptyError({\n adaptyCode: 3001,\n message: `Passed parameter \"${data.name}\" has invalid type. Expected type: ${data.type}\"`,\n });\n case 'encodingFailed':\n return new AdaptyError({\n adaptyCode: 2009,\n message: `Bridge layer failed to encode response. Bridge error: ${JSON.stringify(\n data.underlyingError ?? {},\n )}\"`,\n });\n case 'wrongParam':\n case 'WRONG_PARAMETER':\n return new AdaptyError({\n adaptyCode: 3001,\n message:\n data.name ??\n `Wrong parameter. Bridge error: ${JSON.stringify(\n data.underlyingError ?? {},\n )}\"`,\n });\n case 'methodNotImplemented':\n return new AdaptyError({\n adaptyCode: 2003,\n message: 'Requested bridge handle not found',\n });\n case 'unsupportedIosVersion':\n return new AdaptyError({\n adaptyCode: 2003,\n message: 'Unsupported iOS version',\n });\n case 'unexpectedError':\n default:\n return new AdaptyError({\n adaptyCode: 0,\n message: `Unexpected error occurred: ${JSON.stringify(\n data.underlyingError ?? {},\n )}`,\n });\n }\n }\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n ILoggerAdapter,\n} from '@/adapters/interfaces';\nimport { AdaptyAccessLevelCoder } from './adapty-access-level';\nimport { AdaptyConfigurationCoder } from './adapty-configuration';\nimport { AdaptyDiscountPhaseCoder } from './adapty-discount-phase';\nimport { AdaptyFlowPaywallCoder } from './adapty-flow-paywall';\nimport { AdaptyFlowUiSchemaCoder } from './adapty-flow-ui-schema';\nimport { AdaptyFlowCoder } from './adapty-flow';\nimport { AdaptyIdentifyParamsCoder } from './adapty-identify-params';\nimport { AdaptyInstallationDetailsCoder } from './adapty-installation-details';\nimport { AdaptyInstallationStatusCoder } from './adapty-installation-status';\nimport { AdaptyNativeErrorCoder } from './adapty-native-error';\nimport { AdaptyNonSubscriptionCoder } from './adapty-non-subscription';\nimport { AdaptyOnboardingBuilderCoder } from './adapty-onboarding-builder';\nimport { AdaptyOnboardingCoder } from './adapty-onboarding';\nimport { AdaptyPaywallProductCoder } from './adapty-paywall-product';\nimport { AdaptyPlacementCoder } from './adapty-placement';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptyPromotedProductCoder } from './adapty-promoted-product';\nimport { AdaptyProfileParametersCoder } from './adapty-profile-parameters';\nimport { AdaptyProfileCoder } from './adapty-profile';\nimport { AdaptyPurchaseParamsCoder } from './adapty-purchase-params';\nimport { AdaptyPurchaseResultCoder } from './adapty-purchase-result';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\nimport { AdaptySubscriptionOfferIdCoder } from './adapty-subscription-offer-identifier';\nimport { AdaptySubscriptionOfferCoder } from './adapty-subscription-offer';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptySubscriptionCoder } from './adapty-subscription';\nimport { AdaptyUiDialogConfigCoder } from './adapty-ui-dialog-config';\nimport { AdaptyUICreateOnboardingViewParamsCoder } from './adapty-ui-create-onboarding-view-params';\nimport { AdaptyUICreateFlowViewParamsCoder } from './adapty-ui-create-flow-view-params';\nimport { AdaptyUiMediaCacheCoder } from './adapty-ui-media-cache';\nimport { AdaptyUiOnboardingMetaCoder } from './adapty-ui-onboarding-meta';\nimport { AdaptyUiOnboardingStateParamsCoder } from './adapty-ui-onboarding-state-params';\nimport { AdaptyUiOnboardingStateUpdatedActionCoder } from './adapty-ui-onboarding-state-updated-action';\nimport { ArrayCoder } from './array';\nimport { BridgeErrorCoder } from './bridge-error';\nimport { DateCoder } from './date';\nimport { HashmapCoder } from './hashmap';\nimport { JSONCoder } from './json';\nimport { ProductReferenceCoder } from './product-reference';\nimport type { Converter } from './types';\n\n/**\n * Dependencies container for coders\n */\nexport interface CoderDependencies {\n platform: IPlatformAdapter;\n sdkMetadata: ISdkMetadataAdapter;\n logger?: ILoggerAdapter;\n}\n\n/**\n * Factory for creating coders with injected dependencies\n */\nexport class CoderFactory {\n constructor(private readonly deps: CoderDependencies) {}\n\n createAccessLevelCoder(): AdaptyAccessLevelCoder {\n return new AdaptyAccessLevelCoder(this.deps.platform);\n }\n\n createConfigurationCoder(): AdaptyConfigurationCoder {\n return new AdaptyConfigurationCoder(\n this.deps.platform,\n this.deps.sdkMetadata,\n );\n }\n\n createDateCoder(): DateCoder {\n return new DateCoder();\n }\n\n createDiscountPhaseCoder(): AdaptyDiscountPhaseCoder {\n return new AdaptyDiscountPhaseCoder(this.deps.platform);\n }\n\n createPurchaseParamsCoder(): AdaptyPurchaseParamsCoder {\n return new AdaptyPurchaseParamsCoder(this.deps.platform);\n }\n\n createPurchaseResultCoder(): AdaptyPurchaseResultCoder {\n return new AdaptyPurchaseResultCoder(this.deps.platform);\n }\n\n createIdentifyParamsCoder(): AdaptyIdentifyParamsCoder {\n return new AdaptyIdentifyParamsCoder(this.deps.platform);\n }\n\n createInstallationDetailsCoder(): AdaptyInstallationDetailsCoder {\n return new AdaptyInstallationDetailsCoder();\n }\n\n createInstallationStatusCoder(): AdaptyInstallationStatusCoder {\n return new AdaptyInstallationStatusCoder();\n }\n\n createJsonCoder(): JSONCoder {\n return new JSONCoder();\n }\n\n createNativeErrorCoder(): AdaptyNativeErrorCoder {\n return new AdaptyNativeErrorCoder(this.deps.platform);\n }\n\n createNonSubscriptionCoder(): AdaptyNonSubscriptionCoder {\n return new AdaptyNonSubscriptionCoder(this.deps.platform);\n }\n\n createOnboardingBuilderCoder(): AdaptyOnboardingBuilderCoder {\n return new AdaptyOnboardingBuilderCoder(this.deps.platform);\n }\n\n createOnboardingCoder(): AdaptyOnboardingCoder {\n return new AdaptyOnboardingCoder(this.deps.platform);\n }\n\n createFlowCoder(): AdaptyFlowCoder {\n return new AdaptyFlowCoder(this.deps.platform);\n }\n\n createFlowPaywallCoder(): AdaptyFlowPaywallCoder {\n return new AdaptyFlowPaywallCoder(this.deps.platform);\n }\n\n createFlowUiSchemaCoder(): AdaptyFlowUiSchemaCoder {\n return new AdaptyFlowUiSchemaCoder();\n }\n\n createPaywallProductCoder(): AdaptyPaywallProductCoder {\n return new AdaptyPaywallProductCoder(this.deps.platform);\n }\n\n createPlacementCoder(): AdaptyPlacementCoder {\n return new AdaptyPlacementCoder(this.deps.platform);\n }\n\n createPriceCoder(): AdaptyPriceCoder {\n return new AdaptyPriceCoder(this.deps.platform);\n }\n\n createProductReferenceCoder(): ProductReferenceCoder {\n return new ProductReferenceCoder(this.deps.platform);\n }\n\n createProfileCoder(): AdaptyProfileCoder {\n return new AdaptyProfileCoder(this.deps.platform);\n }\n\n createProfileParametersCoder(): AdaptyProfileParametersCoder {\n return new AdaptyProfileParametersCoder(this.deps.platform);\n }\n\n createPromotedProductCoder(): AdaptyPromotedProductCoder {\n return new AdaptyPromotedProductCoder(this.deps.platform);\n }\n\n createRemoteConfigCoder(): AdaptyRemoteConfigCoder {\n return new AdaptyRemoteConfigCoder(this.deps.platform);\n }\n\n createSubscriptionCoder(): AdaptySubscriptionCoder {\n return new AdaptySubscriptionCoder(this.deps.platform);\n }\n\n createSubscriptionDetailsCoder(): AdaptySubscriptionDetailsCoder {\n return new AdaptySubscriptionDetailsCoder(this.deps.platform);\n }\n\n createSubscriptionOfferCoder(): AdaptySubscriptionOfferCoder {\n return new AdaptySubscriptionOfferCoder(this.deps.platform);\n }\n\n createSubscriptionOfferIdCoder(): AdaptySubscriptionOfferIdCoder {\n return new AdaptySubscriptionOfferIdCoder(this.deps.platform);\n }\n\n createSubscriptionPeriodCoder(): AdaptySubscriptionPeriodCoder {\n return new AdaptySubscriptionPeriodCoder(this.deps.platform);\n }\n\n createUiCreateOnboardingViewParamsCoder(): AdaptyUICreateOnboardingViewParamsCoder {\n return new AdaptyUICreateOnboardingViewParamsCoder();\n }\n\n createUiCreateFlowViewParamsCoder(): AdaptyUICreateFlowViewParamsCoder {\n return new AdaptyUICreateFlowViewParamsCoder(this.deps.platform);\n }\n\n createUiDialogConfigCoder(): AdaptyUiDialogConfigCoder {\n return new AdaptyUiDialogConfigCoder(this.deps.platform);\n }\n\n createUiMediaCacheCoder(): AdaptyUiMediaCacheCoder {\n return new AdaptyUiMediaCacheCoder(this.deps.platform);\n }\n\n createUiOnboardingMetaCoder(): AdaptyUiOnboardingMetaCoder {\n return new AdaptyUiOnboardingMetaCoder(this.deps.platform);\n }\n\n createUiOnboardingStateParamsCoder(): AdaptyUiOnboardingStateParamsCoder {\n return new AdaptyUiOnboardingStateParamsCoder(this.deps.platform);\n }\n\n createUiOnboardingStateUpdatedActionCoder(): AdaptyUiOnboardingStateUpdatedActionCoder {\n return new AdaptyUiOnboardingStateUpdatedActionCoder(this.deps.platform);\n }\n\n createBridgeErrorCoder(): BridgeErrorCoder {\n return new BridgeErrorCoder(this.deps.platform);\n }\n\n createArrayCoder<Model, Serializable>(\n coderFactory: () => Converter<Model, Serializable>,\n ): ArrayCoder<Model, Serializable> {\n return new ArrayCoder(coderFactory);\n }\n\n createPaywallProductArrayCoder(): ArrayCoder<any, any> {\n return new ArrayCoder(() => this.createPaywallProductCoder());\n }\n\n createHashmapCoder<T extends Converter<any, any>>(\n coder: T | null,\n ): HashmapCoder<T> {\n return new HashmapCoder(coder);\n }\n}\n","// import SDK type to link to methods in docs.\nimport type { Adapty } from '@/adapty-handler';\n\nexport const VendorStore = Object.freeze({\n AppStore: 'app_store',\n PlayStore: 'play_store',\n Adapty: 'adapty',\n});\nexport type VendorStore = (typeof VendorStore)[keyof typeof VendorStore];\n\nexport const OfferType = Object.freeze({\n FreeTrial: 'free_trial',\n PayAsYouGo: 'pay_as_you_go',\n PayUpFront: 'pay_up_front',\n});\nexport type OfferType = (typeof OfferType)[keyof typeof OfferType];\n\nexport const CancellationReason = Object.freeze({\n VolountarilyCancelled: 'voluntarily_cancelled',\n BillingError: 'billing_error',\n Refund: 'refund',\n PriceIncrease: 'price_increase',\n ProductWasNotAvailable: 'product_was_not_available',\n Unknown: 'unknown',\n});\nexport type CancellationReason =\n (typeof CancellationReason)[keyof typeof CancellationReason];\n\nexport const Gender = Object.freeze({\n Female: 'f',\n Male: 'm',\n Other: 'o',\n});\nexport type Gender = (typeof Gender)[keyof typeof Gender];\n\nexport const AppTrackingTransparencyStatus = Object.freeze({\n NotDetermined: 0,\n Restricted: 1,\n Denied: 2,\n Authorized: 3,\n Unknown: 4,\n});\nexport type AppTrackingTransparencyStatus =\n (typeof AppTrackingTransparencyStatus)[keyof typeof AppTrackingTransparencyStatus];\n\nexport const ProductPeriod = Object.freeze({\n Day: 'day',\n Week: 'week',\n Month: 'month',\n Year: 'year',\n});\nexport type ProductPeriod = (typeof ProductPeriod)[keyof typeof ProductPeriod];\n\nexport interface AdaptyPrice {\n /**\n * Price as number\n */\n amount: number;\n /**\n * The currency code of the locale\n * used to format the price of the product.\n * The ISO 4217 (USD, EUR).\n */\n currencyCode?: string;\n /**\n * The currency symbol of the locale\n * used to format the price of the product.\n * ($, €).\n */\n currencySymbol?: string;\n /**\n * A price’s language is determined\n * by the preferred language set on the device.\n * On Android, the formatted price from Google Play as is.\n */\n localizedString?: string;\n}\n\n/**\n * Describes a single paywall variation inside a flow.\n * @public\n */\nexport interface AdaptyFlowPaywall {\n readonly placement: AdaptyPlacement;\n\n /**\n * A paywall name.\n * @readonly\n */\n readonly name: string;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this paywall.\n * @readonly\n */\n readonly variationId: string;\n /**\n * Array of product identifiers for this paywall\n * @readonly\n */\n readonly productIdentifiers: AdaptyProductIdentifier[];\n\n id: string;\n webPurchaseUrl?: string;\n}\n\n/**\n * Describes a single layout of a flow UI schema.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchemaLayout {\n readonly flowLayoutId: string;\n}\n\n/**\n * Describes a single grid of a flow UI schema.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchemaGrid {\n /**\n * Platforms this grid applies to, or `'all'` for every platform.\n * @readonly\n */\n readonly platforms?: 'all' | ('ios' | 'android')[];\n /**\n * Device classes this grid applies to, or `'all'` for every device class.\n * @readonly\n */\n readonly devices?: 'all' | ('phone' | 'tab')[];\n readonly customId?: string;\n readonly hBreakpoints?: number[];\n readonly vBreakpoints?: number[];\n readonly cells: number[];\n}\n\n/**\n * Layout schema used by the Adapty UI builder to render a flow.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchema {\n readonly layouts: AdaptyFlowUiSchemaLayout[];\n readonly grids: AdaptyFlowUiSchemaGrid[];\n}\n\n/**\n * Describes an object that represents a flow,\n * fetched for a placement.\n * @public\n */\nexport interface AdaptyFlow {\n readonly placement: AdaptyPlacement;\n\n /**\n * If `true`, it is possible to fetch the view object\n * and use it with AdaptyUI library.\n *\n * @remarks\n * Derived on decode: `true` only when the flow has both a\n * `flowVersionId` and a `uiSchema`.\n * @readonly\n */\n readonly hasViewConfiguration: boolean;\n\n /**\n * A flow name.\n * @readonly\n */\n readonly name: string;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this flow.\n * @readonly\n */\n readonly variationId: string;\n /**\n * Remote configs configured in Adapty Dashboard for this flow.\n * @readonly\n */\n readonly remoteConfigs?: AdaptyRemoteConfig[];\n /**\n * Paywall variations contained in this flow.\n * @readonly\n */\n readonly paywalls: AdaptyFlowPaywall[];\n /**\n * Layout schema used by the Adapty UI builder to render this flow.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n * @readonly\n */\n readonly uiSchema?: AdaptyFlowUiSchema;\n\n id: string;\n /**\n * Renderer-internal version of the flow's view configuration.\n *\n * @remarks\n * Opaque to the app: carried only so a flow handed back to the native side\n * keeps it. Use {@link AdaptyFlow.hasViewConfiguration} to tell whether the\n * flow can be rendered.\n * @internal\n */\n flowVersionId?: string;\n /** Server response creation timestamp in milliseconds. */\n responseCreatedAt: number;\n payloadData?: string;\n}\n\nexport interface AdaptyOnboarding {\n readonly placement: AdaptyPlacement;\n /**\n * If `true`, it is possible to fetch the view object\n * and use it with AdaptyUI library.\n * @readonly\n */\n readonly hasViewConfiguration: boolean;\n\n /**\n * A paywall name.\n * @readonly\n */\n readonly name: string;\n /**\n * A remote config configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly remoteConfig?: AdaptyRemoteConfig;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this paywall.\n * @readonly\n */\n readonly variationId: string;\n\n id: string;\n version?: number;\n payloadData?: string;\n requestLocale: string;\n onboardingBuilder: AdaptyOnboardingBuilder;\n}\n\nexport interface AdaptyPlacement {\n /**\n * Parent A/B test name.\n * @readonly\n */\n readonly abTestName: string;\n\n /**\n * A name of an audience to which the paywall belongs.\n * @readonly\n */\n readonly audienceName: string;\n /**\n * ID of a placement configured in Adapty Dashboard.\n * @readonly\n */\n readonly id: string;\n /**\n * Current revision (version) of a paywall.\n * Every change within a paywall creates a new revision.\n * @readonly\n */\n readonly revision: number;\n\n isTrackingPurchases?: boolean;\n audienceVersionId: string;\n}\n\n/**\n * Describes an object that represents a remote config of a paywall.\n * @public\n */\nexport interface AdaptyRemoteConfig {\n /**\n * Identifier of a paywall locale.\n * @readonly\n */\n readonly lang: string;\n /**\n * A custom dictionary configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly data: Record<string, any>;\n /**\n * A custom JSON string configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly dataString: string;\n}\n\nexport interface AdaptyOnboardingBuilder {\n readonly url: string;\n}\n\nexport type AdaptyPurchaseResult =\n | {\n type: 'pending' | 'user_cancelled';\n }\n | {\n type: 'success';\n profile: AdaptyProfile;\n ios?: {\n jwsTransaction?: string;\n };\n android?: {\n purchaseToken?: string;\n };\n };\n\n/**\n * Identifiers of attribution providers applied to the profile.\n *\n * Other identifiers may be emitted in future versions, so any string is accepted\n * @public\n */\nexport type AdaptyExternalAttributionProvider =\n | 'apple_search_ads'\n | 'adjust'\n | 'appsflyer'\n | 'branch'\n | 'tenjin'\n | 'custom'\n | (string & {});\n\n/**\n * Interface representing a user profile in Adapty,\n * including details about the user's subscriptions and consumable products.\n * @public\n */\nexport interface AdaptyProfile {\n /**\n * Object that maps access level identifiers (configured by you in Adapty Dashboard)\n * to the corresponding access level details. The value can be `null`\n * if the user does not have any access levels.\n * @readonly\n */\n readonly accessLevels?: Record<string, AdaptyAccessLevel>;\n\n /**\n * Identifiers of attribution providers applied to the profile.\n * @readonly\n */\n readonly appliedExternalAttributionProviders?: AdaptyExternalAttributionProvider[];\n\n /**\n * Object representing custom attributes set for the user using\n * the {@link Adapty.updateProfile} method.\n * @readonly\n */\n readonly customAttributes?: Record<string, any>;\n\n /**\n * The identifier for a user in your system.\n * @readonly\n */\n readonly customerUserId?: string;\n\n /**\n * Object that maps product ids from the store to an array of\n * information about the user's non-subscription purchases.\n * The value can be `null` if the user does not have any purchases.\n * @readonly\n */\n readonly nonSubscriptions?: Record<string, AdaptyNonSubscription[]>;\n\n /**\n * The identifier for a user in Adapty.\n */\n readonly profileId: string;\n\n /**\n * Object that maps product ids from a store to\n * information about the user's subscriptions.\n * The value can be `null` if the user does not have any subscriptions.\n * @readonly\n */\n readonly subscriptions?: Record<string, AdaptySubscription>;\n}\n\n/**\n * Interface representing access level details of a user.\n * @public\n */\nexport interface AdaptyAccessLevel {\n /**\n * The date and time when the access level was activated.\n * @readonly\n */\n readonly activatedAt: Date;\n\n /**\n * Type of active introductory offer, if any.\n * @readonly\n */\n readonly activeIntroductoryOfferType?: OfferType;\n\n /**\n * Identifier of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferId?: string;\n\n /**\n * Type of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferType?: OfferType;\n\n /**\n * The date and time when a billing issue was detected.\n * @readonly\n */\n readonly billingIssueDetectedAt?: Date;\n\n /**\n * The reason for the cancellation of the subscription.\n * @readonly\n */\n readonly cancellationReason?: CancellationReason;\n\n /**\n * The expiration date of the access level, if applicable.\n * @readonly\n */\n readonly expiresAt?: Date;\n\n /**\n * Unique identifier of the access level\n * configured by you in Adapty Dashboard.\n * @readonly\n */\n readonly id: string;\n\n /**\n * Flag indicating whether the access level is currently active.\n * @readonly\n */\n readonly isActive: boolean;\n\n /**\n * Flag indicating whether this auto-renewable subscription is in the grace period.\n * @readonly\n */\n readonly isInGracePeriod: boolean;\n\n /**\n * Flag indicating whether this access level is active for a lifetime.\n * @readonly\n */\n readonly isLifetime: boolean;\n\n /**\n * Flag indicating whether this purchase was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * The date and time when the access level was renewed.\n * @readonly\n */\n readonly renewedAt?: Date;\n\n /**\n * The start date of this access level.\n * @readonly\n */\n readonly startsAt?: Date;\n\n /**\n * The store where the purchase that unlocked this access level was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * The date and time when the auto-renewable subscription was cancelled.\n * @readonly\n */\n readonly unsubscribedAt?: Date;\n\n /**\n * The identifier of the product in the store that unlocked this access level.\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * Flag indicating whether this auto-renewable subscription is set to renew.\n * @readonly\n */\n readonly willRenew: boolean;\n\n android?: {\n offerId?: string;\n };\n}\n\n/**\n * Interface representing a consumable or non-subscription purchase made by the user.\n * @public\n */\nexport interface AdaptyNonSubscription {\n /**\n * Flag indicating whether the product is consumable.\n * @readonly\n */\n readonly isConsumable: boolean;\n\n /**\n * Flag indicating whether the purchase was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * Flag indicating whether the product was purchased in a sandbox environment.\n * @readonly\n */\n readonly isSandbox: boolean;\n\n /**\n * The date and time when the purchase was made.\n * @readonly\n */\n readonly purchasedAt: Date;\n\n /**\n * The identifier of the product in the store that was purchased.\n * @readonly\n */\n readonly vendorProductId: string;\n /**\n * The identifier of the product in the store that was purchased.\n * @readonly\n */\n readonly vendorTransactionId?: string;\n\n /**\n * The store where the purchase was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * An identifier of the purchase in Adapty.\n * You can use it to ensure that you've already processed this purchase\n * (for example tracking one time products).\n * @readonly\n */\n readonly purchaseId: string;\n}\n\n/**\n * Interface representing details about a user's subscription.\n * @public\n */\nexport interface AdaptySubscription {\n /**\n * The date and time when the subscription was activated.\n * @readonly\n */\n readonly activatedAt: Date;\n\n /**\n * Type of active introductory offer, if any.\n * @readonly\n */\n readonly activeIntroductoryOfferType?: OfferType;\n\n /**\n * Identifier of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferId?: string;\n\n /**\n * Type of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferType?: OfferType;\n\n /**\n * The date and time when a billing issue was detected.\n * @readonly\n */\n readonly billingIssueDetectedAt?: Date;\n\n /**\n * The reason for the cancellation of the subscription.\n * @readonly\n */\n readonly cancellationReason?: CancellationReason;\n\n /**\n * The expiration date of the subscription, if applicable.\n * @readonly\n */\n readonly expiresAt?: Date;\n\n /**\n * Flag indicating whether the subscription is currently active.\n * @readonly\n */\n readonly isActive: boolean;\n\n /**\n * Flag indicating whether the subscription is in the grace period.\n * @readonly\n */\n readonly isInGracePeriod: boolean;\n\n /**\n * Flag indicating whether the subscription is set for a lifetime.\n * @readonly\n */\n readonly isLifetime: boolean;\n\n /**\n * Flag indicating whether the subscription was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * Flag indicating whether the subscription was purchased in a sandbox environment.\n * @readonly\n */\n readonly isSandbox: boolean;\n\n /**\n * The date and time when the subscription was renewed.\n * @readonly\n */\n readonly renewedAt?: Date;\n\n /**\n * The date and time when the subscription starts.\n * @readonly\n */\n readonly startsAt?: Date;\n\n /**\n * The store where the subscription was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * The date and time when the subscription was cancelled.\n * @readonly\n */\n readonly unsubscribedAt?: Date;\n\n /**\n * The identifier of the product in the store that was subscribed to.\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * The identifier of the product in the store that was subscribed to.\n * @readonly\n */\n readonly vendorTransactionId: string;\n /**\n * An original transaction id of the purchase in a store that unlocked this subscription.\n * For auto-renewable subscription, this will be an id of the first transaction in this subscription.\n * @readonly\n */\n readonly vendorOriginalTransactionId: string;\n /**\n * Flag indicating whether the subscription is set to auto-renew.\n * @readonly\n */\n readonly willRenew: boolean;\n}\n\n/**\n * Describes an object that represents a product.\n * Used in {@link Adapty.getPaywallProducts} method and in {@link Adapty.makePurchase} method.\n * @public\n */\nexport interface AdaptyPaywallProduct {\n /**\n * A description of the product.\n */\n readonly localizedDescription: string;\n /**\n * The region code of the locale used to format the price of the product.\n * ISO 3166 ALPHA-2 (US, DE)\n */\n readonly regionCode?: string;\n /**\n * The name of the product.\n */\n readonly localizedTitle: string;\n /**\n * Same as `abTestName` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly paywallABTestName: string;\n /**\n * Same as `name` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly paywallName: string;\n readonly accessLevelId: string;\n readonly productType: string;\n /**\n * The cost of the product in the local currency\n */\n readonly price?: AdaptyPrice;\n /**\n * Internal Adapty product identifier.\n * @internal\n */\n readonly adaptyId: string;\n /**\n * Same as `variationId` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly variationId: string;\n /**\n * Unique identifier of a product\n * from App Store Connect or Google Play Console\n */\n readonly vendorProductId: string;\n paywallProductIndex: number;\n webPurchaseUrl?: string;\n /**\n * Internal payload data attached to the product.\n * @internal\n */\n payloadData?: string;\n subscription?: AdaptySubscriptionDetails;\n ios?: {\n /**\n * Boolean value that indicates\n * whether the product is available for family sharing\n * in App Store Connect.\n * Will be `false` for iOS version below 14.0 and macOS version below 11.0.\n * @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}\n */\n readonly isFamilyShareable: boolean;\n };\n}\n\n/**\n * Describes a product promoted in the App Store,\n * received through the `'onPromotedPurchaseReceived'` event.\n *\n * @remarks\n * Unlike {@link AdaptyPaywallProduct}, a promoted product does not belong to a\n * paywall, so it carries no placement, variation or A/B test information.\n * @public\n */\nexport interface AdaptyPromotedProduct {\n /**\n * A description of the product.\n */\n readonly localizedDescription: string;\n /**\n * The name of the product.\n */\n readonly localizedTitle: string;\n /**\n * The region code of the locale used to format the price of the product.\n * ISO 3166 ALPHA-2 (US, DE)\n */\n readonly regionCode?: string;\n /**\n * The cost of the product in the local currency\n */\n readonly price?: AdaptyPrice;\n /**\n * Unique identifier of a product\n * from App Store Connect or Google Play Console\n */\n readonly vendorProductId: string;\n /**\n * Internal payload data attached to the product.\n * @internal\n */\n payloadData?: string;\n subscription?: AdaptySubscriptionDetails;\n ios?: {\n /**\n * Boolean value that indicates\n * whether the product is available for family sharing\n * in App Store Connect.\n * Will be `false` for iOS version below 14.0 and macOS version below 11.0.\n * @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}\n */\n readonly isFamilyShareable: boolean;\n };\n}\n\nexport interface AdaptySubscriptionDetails {\n /**\n * The period details for products that are subscriptions.\n * Will be `null` for iOS version below 11.2 and macOS version below 10.14.4.\n */\n subscriptionPeriod: AdaptySubscriptionPeriod;\n /**\n * The period’s language is determined\n * by the preferred language set on the device.\n */\n localizedSubscriptionPeriod?: string;\n /**\n * A subscription offer if available for the auto-renewable subscription.\n */\n offer?: AdaptySubscriptionOffer;\n\n ios?: {\n /**\n * An identifier of the subscription group\n * to which the subscription belongs.\n * Will be `null` for iOS version below 12.0 and macOS version below 10.14.\n */\n subscriptionGroupIdentifier?: string;\n };\n\n android?: {\n basePlanId: string;\n renewalType?: 'prepaid' | 'autorenewable';\n };\n}\n\n/**\n * Subscription offer model to products\n * @see {@link https://doc.adapty.io/docs/rn-api-reference#adaptysubscriptionoffer}\n */\nexport interface AdaptySubscriptionOffer {\n readonly identifier: AdaptySubscriptionOfferId;\n\n phases: AdaptyDiscountPhase[];\n\n android?: {\n offerTags?: string[];\n };\n}\n\nexport type AdaptySubscriptionOfferId =\n | { id?: string; type: 'introductory' }\n | { id: string; type: 'promotional' | 'win_back' }\n | { id?: string; type: 'code' };\n\n/**\n * Discount model to products\n * @see {@link https://doc.adapty.io/docs/rn-api-reference#adaptyproductdiscount}\n */\nexport interface AdaptyDiscountPhase {\n /**\n * A formatted number of periods of a discount for a user’s locale.\n * @readonly\n */\n readonly localizedNumberOfPeriods?: string;\n /**\n * A formatted subscription period of a discount for a user’s locale.\n * @readonly\n */\n readonly localizedSubscriptionPeriod?: string;\n /**\n * A number of periods this product discount is available.\n * @readonly\n */\n readonly numberOfPeriods: number;\n /**\n * Discount price of a product in a local currency.\n * @readonly\n */\n readonly price: AdaptyPrice;\n /**\n * An information about period for a product discount.\n * @readonly\n */\n readonly subscriptionPeriod: AdaptySubscriptionPeriod;\n\n /**\n * A payment mode for this product discount.\n * @readonly\n */\n readonly paymentMode: OfferType;\n}\n\n/**\n * An object containing information about a subscription period.\n * @public\n */\nexport interface AdaptySubscriptionPeriod {\n /**\n * A number of period units.\n * @readonly\n */\n readonly numberOfUnits: number;\n /**\n * A unit of time that a subscription period is specified in.\n * @readonly\n */\n readonly unit: ProductPeriod;\n}\n\nexport interface AdaptyProfileParameters {\n analyticsDisabled?: boolean;\n codableCustomAttributes?: { [key: string]: any };\n appTrackingTransparencyStatus?: AppTrackingTransparencyStatus;\n firstName?: string;\n lastName?: string;\n gender?: Gender;\n birthday?: string;\n email?: string;\n phoneNumber?: string;\n}\n\nexport interface ProductReference {\n flowProductId?: string;\n vendorId: string;\n adaptyId: string;\n accessLevelId: string;\n productType: string;\n\n ios?: {\n promotionalOfferId?: string;\n winBackOfferId?: string;\n };\n\n android?: {\n basePlanId?: string;\n offerId?: string;\n };\n}\n\n/**\n * Interface representing a product identifier with vendor and platform-specific information.\n * @public\n */\nexport interface AdaptyProductIdentifier {\n /**\n * The vendor-specific product identifier (e.g., App Store or Google Play product ID).\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * The base plan identifier for Google Play subscriptions (Android only).\n * @readonly\n */\n readonly basePlanId?: string;\n\n /**\n * Internal Adapty product identifier.\n * @internal\n * @readonly\n */\n readonly adaptyProductId: string;\n}\n\nexport const WebPresentation = Object.freeze({\n BrowserOutApp: 'browser_out_app',\n BrowserInApp: 'browser_in_app',\n});\nexport type WebPresentation =\n (typeof WebPresentation)[keyof typeof WebPresentation];\n\nexport const RefundPreference = Object.freeze({\n NoPreference: 'no_preference',\n Grant: 'grant',\n Decline: 'decline',\n});\nexport type RefundPreference =\n (typeof RefundPreference)[keyof typeof RefundPreference];\n\nexport type AdaptyInstallationStatus =\n | {\n status: 'not_available' | 'not_determined';\n }\n | {\n status: 'determined';\n details: AdaptyInstallationDetails;\n };\n\nexport interface AdaptyInstallationDetails {\n /**\n * A unique identifier for this installation.\n * @readonly\n */\n readonly installId?: string;\n /**\n * The date and time when the app was installed.\n * @readonly\n */\n readonly installTime: Date;\n /**\n * The total number of times the app has been launched.\n * @readonly\n */\n readonly appLaunchCount: number;\n /**\n * Custom payload data associated with the installation.\n * @readonly\n */\n readonly payload?: string;\n}\n","import type { Event } from './schema';\n\n/**\n * Valid list of callable bridge handlers.\n *\n * The source of truth is `cross_platform.yaml`: one entry per `$requests`\n * method const. `bridge.test.ts` asserts the two stay in sync — a method the\n * native side does not register would fail at runtime, not at compile time.\n * @internal\n */\nexport const MethodNames = [\n 'activate',\n 'adapty_ui_create_flow_view',\n 'adapty_ui_dismiss_flow_view',\n 'adapty_ui_present_flow_view',\n 'adapty_ui_show_dialog',\n 'adapty_ui_create_onboarding_view',\n 'adapty_ui_dismiss_onboarding_view',\n 'adapty_ui_present_onboarding_view',\n 'create_web_paywall_url',\n 'get_current_installation_status',\n 'is_activated',\n 'get_flow',\n 'get_flow_for_default_audience',\n 'get_paywall_products',\n 'get_onboarding',\n 'get_onboarding_for_default_audience',\n 'get_profile',\n 'get_log_level',\n 'get_sdk_version',\n 'identify',\n 'log_show_flow',\n 'logout',\n 'make_promoted_purchase',\n 'make_purchase',\n 'open_web_paywall',\n 'present_code_redemption_sheet',\n 'report_transaction',\n 'restore_purchases',\n 'set_fallback',\n 'set_integration_identifiers',\n 'set_log_level',\n 'update_collecting_refund_data_consent',\n 'update_external_attribution_data',\n 'update_profile',\n 'update_refund_preference',\n 'flow_view_did_answer_permission',\n 'adapty_ui_open_url',\n 'adapty_ui_request_app_review',\n 'observer_purchase_did_start',\n 'observer_purchase_did_finish',\n 'observer_restore_did_start',\n 'observer_restore_did_finish',\n] as const;\nexport type MethodName = (typeof MethodNames)[number];\n\n/**\n * Types of values that can be passed\n * to the bridge without corruption\n */\nexport type Serializable =\n | string\n | number\n | boolean\n | string[]\n | null\n | undefined;\n\n/**\n * Interface of error that emit from native SDK\n */\nexport interface AdaptyNativeError {\n adaptyCode: number;\n message: string;\n detail?: string | undefined;\n}\n\n/**\n * Interface of error that was raised by native bridge\n */\nexport interface AdaptyBridgeError {\n errorType: string;\n name?: string;\n type?: string;\n underlyingError?: string;\n description?: string;\n}\n\n/**\n * The SDK's global events - the ones not scoped to a flow view or an\n * onboarding - as public handler name -> native wire id.\n *\n * Both halves are load-bearing. `keyof` gives {@link GlobalEventName}, the names\n * a consumer passes to `addEventListener`; the values are the ids the native\n * side actually emits. The ids come off `cross_platform.yaml` through the\n * generated schema rather than being written out as free strings, so a typo in\n * {@link GLOBAL_EVENT_TO_NATIVE_EVENT} cannot reach a bridge subscription.\n * `bridge.test.ts` covers the other direction - that no global event in the\n * schema is missing from the map.\n */\ninterface GlobalEventMap {\n onLatestProfileLoad: Event['Event.DidLoadLatestProfile']['id'];\n onPromotedPurchaseReceived: Event['Event.DidReceivePromotedPurchase']['id'];\n onInstallationDetailsSuccess: Event['Event.OnInstallationDetailsSuccess']['id'];\n onInstallationDetailsFail: Event['Event.OnInstallationDetailsFail']['id'];\n}\n\nexport type GlobalEventName = keyof GlobalEventMap;\n\n/**\n * Native wire id of a global SDK event - the counterpart of\n * `FlowEventIdType` and `OnboardingEventIdType` for the events that are not\n * scoped to a view.\n *\n * @remarks\n * Type anything that subscribes to a global event by wire id with this. A bare\n * `string` there is what lets a typo compile, because nothing downstream\n * compares it against the schema.\n */\nexport type GlobalEventIdType = GlobalEventMap[GlobalEventName];\n\n/**\n * Handler name -> native wire id, for the global events.\n *\n * @remarks\n * Wrappers subscribe by handler name, so this is what turns the name the app\n * wrote into the string the bridge expects. It is the global-event counterpart\n * of `HANDLER_TO_NATIVE_EVENT` (flow views) and `HANDLER_TO_EVENT_CONFIG`\n * (onboardings), which own the unqualified names for historical reasons.\n */\nexport const GLOBAL_EVENT_TO_NATIVE_EVENT: GlobalEventMap = {\n onLatestProfileLoad: 'did_load_latest_profile',\n onPromotedPurchaseReceived: 'did_receive_promoted_purchase',\n onInstallationDetailsSuccess: 'on_installation_details_success',\n onInstallationDetailsFail: 'on_installation_details_fail',\n};\n","import { AdaptyError } from '@/adapty-error';\n// Imported for JSDoc {@link} references only.\nimport type { CreateFlowViewParamsInput } from '@/ui-builder/types';\nimport type {\n AdaptyPaywallProduct,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\n\n// Flow Event IDs\nexport const FlowEventId = {\n DidAppear: 'flow_view_did_appear',\n DidDisappear: 'flow_view_did_disappear',\n DidPerformAction: 'flow_view_did_perform_action',\n DidSelectProduct: 'flow_view_did_select_product',\n DidStartPurchase: 'flow_view_did_start_purchase',\n DidFinishPurchase: 'flow_view_did_finish_purchase',\n DidFailPurchase: 'flow_view_did_fail_purchase',\n DidStartRestore: 'flow_view_did_start_restore',\n DidFinishRestore: 'flow_view_did_finish_restore',\n DidFailRestore: 'flow_view_did_fail_restore',\n DidReceiveError: 'flow_view_did_receive_error',\n DidFailLoadingProducts: 'flow_view_did_fail_loading_products',\n DidFinishWebPaymentNavigation: 'flow_view_did_finish_web_payment_navigation',\n DidRequestAppReview: 'flow_view_did_request_app_review',\n DidReceiveAnalyticEvent: 'flow_view_did_receive_analytic_event',\n DidAskPermission: 'flow_view_did_ask_permission',\n ObserverDidInitiatePurchase: 'flow_view_observer_did_initiate_purchase',\n ObserverDidInitiateRestore: 'flow_view_observer_did_initiate_restore',\n} as const;\n\nexport type FlowEventIdType = (typeof FlowEventId)[keyof typeof FlowEventId];\n\n/**\n * Permission identifier a flow view asks the host app to request.\n *\n * The literals below are the known cross-platform set; any string is valid —\n * unknown or platform-specific ids (e.g. Android `'phone'`, `'sms'`) and future\n * values pass through unchanged. The `(string & {})` keeps the known values as\n * autocomplete hints while still accepting arbitrary strings.\n */\nexport type AdaptyPermission =\n | 'push'\n | 'camera'\n | 'microphone'\n | 'location_when_use'\n | 'location_always'\n | 'location_full_accuracy'\n | 'photos'\n | 'contacts'\n | 'tracking'\n | 'calendar'\n | 'bluetooth'\n | 'motion'\n | 'reminders'\n | 'speech'\n | 'media_library'\n | 'local_network'\n | 'focus_status'\n | 'homekit'\n | 'health'\n | 'siri'\n | 'music'\n | (string & {});\n\n// Event View\nexport interface FlowEventView {\n /**\n * The internal identifier of the presented view instance.\n *\n * @remarks\n * It does not correspond to anything in your dashboard.\n */\n id: string;\n /**\n * The placement this flow was fetched for.\n */\n placementId: string;\n /**\n * The variation the flow resolved to, for A/B test attribution.\n */\n variationId: string;\n /**\n * The localization the view was actually built with.\n *\n * @remarks\n * May differ from the requested localization if it is not available in the flow.\n *\n * @see {@link CreateFlowViewParamsInput.locale} — the localization requested\n * when the view was created.\n */\n locale?: string;\n}\n\n// Base Event\ninterface BaseFlowEvent {\n id: FlowEventIdType;\n view: FlowEventView;\n}\n\n// Event Types\nexport interface FlowDidAppearEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidAppear;\n}\n\nexport interface FlowDidDisappearEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidDisappear;\n}\n\nexport type FlowUserAction =\n | { type: 'close' }\n | { type: 'system_back' }\n | { type: 'open_url'; value: string; openIn: WebPresentation }\n | { type: 'custom'; value: string };\n\nexport interface FlowDidPerformActionEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidPerformAction;\n action: FlowUserAction;\n}\n\nexport interface FlowDidSelectProductEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidSelectProduct;\n productId: string;\n}\n\nexport interface FlowDidStartPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidStartPurchase;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidFinishPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishPurchase;\n purchaseResult: AdaptyPurchaseResult;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidFailPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailPurchase;\n error: AdaptyError;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidStartRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidStartRestore;\n}\n\nexport interface FlowDidFinishRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishRestore;\n profile: AdaptyProfile;\n}\n\nexport interface FlowDidFailRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailRestore;\n error: AdaptyError;\n}\n\nexport interface FlowDidReceiveErrorEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidReceiveError;\n error: AdaptyError;\n}\n\nexport interface FlowDidFailLoadingProductsEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailLoadingProducts;\n error: AdaptyError;\n}\n\nexport interface FlowDidFinishWebPaymentNavigationEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishWebPaymentNavigation;\n product?: AdaptyPaywallProduct;\n error?: AdaptyError;\n}\n\nexport interface FlowDidRequestAppReviewEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidRequestAppReview;\n}\n\nexport interface FlowDidReceiveAnalyticEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidReceiveAnalyticEvent;\n name: string;\n params: Record<string, unknown>;\n}\n\nexport interface FlowDidAskPermissionEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidAskPermission;\n /** Correlation id — sent back to native in the response. SDK-internal. */\n eventId: string;\n /** Permission identifier the flow view asks the host to request. */\n permission: AdaptyPermission;\n /** Arbitrary string key/value args attached by the dashboard. */\n customArgs: Record<string, string>;\n}\n\nexport interface FlowObserverDidInitiatePurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.ObserverDidInitiatePurchase;\n /** Correlation id — sent back to native in the reply. SDK-internal. */\n eventId: string;\n /** Product the user initiated the purchase for. */\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowObserverDidInitiateRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.ObserverDidInitiateRestore;\n /** Correlation id — sent back to native in the reply. SDK-internal. */\n eventId: string;\n}\n\nexport type ParsedFlowEvent =\n | FlowDidAppearEvent\n | FlowDidDisappearEvent\n | FlowDidPerformActionEvent\n | FlowDidSelectProductEvent\n | FlowDidStartPurchaseEvent\n | FlowDidFinishPurchaseEvent\n | FlowDidFailPurchaseEvent\n | FlowDidStartRestoreEvent\n | FlowDidFinishRestoreEvent\n | FlowDidFailRestoreEvent\n | FlowDidReceiveErrorEvent\n | FlowDidFailLoadingProductsEvent\n | FlowDidFinishWebPaymentNavigationEvent\n | FlowDidRequestAppReviewEvent\n | FlowDidReceiveAnalyticEvent\n | FlowDidAskPermissionEvent\n | FlowObserverDidInitiatePurchaseEvent\n | FlowObserverDidInitiateRestoreEvent;\n","import { AdaptyError } from '@/adapty-error';\nimport type {\n AdaptyUiOnboardingMeta,\n OnboardingStateUpdatedAction,\n} from '@/ui-builder/types';\n\n// Onboarding Event IDs\nexport const OnboardingEventId = {\n Close: 'onboarding_on_close_action',\n Custom: 'onboarding_on_custom_action',\n Paywall: 'onboarding_on_paywall_action',\n StateUpdated: 'onboarding_on_state_updated_action',\n FinishedLoading: 'onboarding_did_finish_loading',\n Analytics: 'onboarding_on_analytics_action',\n Error: 'onboarding_did_fail_with_error',\n} as const;\n\nexport type OnboardingEventIdType =\n (typeof OnboardingEventId)[keyof typeof OnboardingEventId];\n\n// Event View\nexport interface OnboardingEventView {\n id: string;\n placementId?: string;\n variationId?: string;\n}\n\n// Base Event\ninterface BaseOnboardingEvent {\n id: OnboardingEventIdType;\n view: OnboardingEventView;\n}\n\n// Event Types\nexport interface OnboardingCloseEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Close;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingCustomEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Custom;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingPaywallEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Paywall;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingStateUpdatedEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.StateUpdated;\n action: OnboardingStateUpdatedAction;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingFinishedLoadingEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.FinishedLoading;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingAnalyticsEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Analytics;\n event: { name: string; elementId?: string; reply?: string };\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingErrorEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Error;\n error: AdaptyError;\n}\n\nexport type ParsedOnboardingEvent =\n | OnboardingCloseEvent\n | OnboardingCustomEvent\n | OnboardingPaywallEvent\n | OnboardingStateUpdatedEvent\n | OnboardingFinishedLoadingEvent\n | OnboardingAnalyticsEvent\n | OnboardingErrorEvent;\n","import type { FlowEventHandlers } from './types';\nimport { FlowEventId } from '@/types/flow-events';\nimport type { ParsedFlowEvent, FlowEventIdType } from '@/types/flow-events';\n\ntype EventName = keyof FlowEventHandlers;\n\n/**\n * Resolves native event to handler name based on event data\n */\nexport const NATIVE_EVENT_RESOLVER: Record<\n FlowEventIdType,\n (event: ParsedFlowEvent) => EventName | null\n> = {\n [FlowEventId.DidPerformAction]: event => {\n if (event.id !== FlowEventId.DidPerformAction) return null;\n\n const actionMap: Record<string, EventName> = {\n close: 'onCloseButtonPress',\n system_back: 'onAndroidSystemBack',\n open_url: 'onUrlPress',\n custom: 'onCustomAction',\n };\n\n return actionMap[event.action.type] || null;\n },\n [FlowEventId.DidAppear]: () => 'onAppeared',\n [FlowEventId.DidDisappear]: () => 'onDisappeared',\n [FlowEventId.DidSelectProduct]: () => 'onProductSelected',\n [FlowEventId.DidStartPurchase]: () => 'onPurchaseStarted',\n [FlowEventId.DidFinishPurchase]: () => 'onPurchaseCompleted',\n [FlowEventId.DidFailPurchase]: () => 'onPurchaseFailed',\n [FlowEventId.DidStartRestore]: () => 'onRestoreStarted',\n [FlowEventId.DidFinishRestore]: () => 'onRestoreCompleted',\n [FlowEventId.DidFailRestore]: () => 'onRestoreFailed',\n [FlowEventId.DidReceiveError]: () => 'onError',\n [FlowEventId.DidFailLoadingProducts]: () => 'onLoadingProductsFailed',\n [FlowEventId.DidFinishWebPaymentNavigation]: () =>\n 'onWebPaymentNavigationFinished',\n [FlowEventId.DidRequestAppReview]: () => 'onRequestAppReview',\n [FlowEventId.DidReceiveAnalyticEvent]: () => 'onAnalytics',\n [FlowEventId.DidAskPermission]: () => 'onRequestPermission',\n [FlowEventId.ObserverDidInitiatePurchase]: () =>\n 'onObserverPurchaseInitiated',\n [FlowEventId.ObserverDidInitiateRestore]: () => 'onObserverRestoreInitiated',\n};\n\n/**\n * Maps handler name to native event name\n * Used in addListener/addInternalListener to subscribe to correct native event\n */\nexport const HANDLER_TO_NATIVE_EVENT: Record<EventName, FlowEventIdType> = {\n onCloseButtonPress: FlowEventId.DidPerformAction,\n onAndroidSystemBack: FlowEventId.DidPerformAction,\n onUrlPress: FlowEventId.DidPerformAction,\n onCustomAction: FlowEventId.DidPerformAction,\n onAppeared: FlowEventId.DidAppear,\n onDisappeared: FlowEventId.DidDisappear,\n onProductSelected: FlowEventId.DidSelectProduct,\n onPurchaseStarted: FlowEventId.DidStartPurchase,\n onPurchaseCompleted: FlowEventId.DidFinishPurchase,\n onPurchaseFailed: FlowEventId.DidFailPurchase,\n onRestoreStarted: FlowEventId.DidStartRestore,\n onRestoreCompleted: FlowEventId.DidFinishRestore,\n onRestoreFailed: FlowEventId.DidFailRestore,\n onError: FlowEventId.DidReceiveError,\n onLoadingProductsFailed: FlowEventId.DidFailLoadingProducts,\n onWebPaymentNavigationFinished: FlowEventId.DidFinishWebPaymentNavigation,\n onRequestAppReview: FlowEventId.DidRequestAppReview,\n onAnalytics: FlowEventId.DidReceiveAnalyticEvent,\n onRequestPermission: FlowEventId.DidAskPermission,\n onObserverPurchaseInitiated: FlowEventId.ObserverDidInitiatePurchase,\n onObserverRestoreInitiated: FlowEventId.ObserverDidInitiateRestore,\n};\n\ntype ExtractedArgs<T extends keyof FlowEventHandlers> = Parameters<\n FlowEventHandlers[T]\n>;\n\nexport function extractFlowCallbackArgs<T extends keyof FlowEventHandlers>(\n handlerName: T,\n event: ParsedFlowEvent,\n): ExtractedArgs<T> {\n switch (event.id) {\n case FlowEventId.DidSelectProduct:\n return [event.productId] as ExtractedArgs<T>;\n\n case FlowEventId.DidStartPurchase:\n return [event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishPurchase:\n return [event.purchaseResult, event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFailPurchase:\n return [event.error, event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishRestore:\n return [event.profile] as ExtractedArgs<T>;\n\n case FlowEventId.DidFailRestore:\n case FlowEventId.DidReceiveError:\n case FlowEventId.DidFailLoadingProducts:\n return [event.error] as ExtractedArgs<T>;\n\n case FlowEventId.DidPerformAction:\n // For DidPerformAction, different handlers need different arguments\n if (handlerName === 'onUrlPress' && event.action.type === 'open_url') {\n return [event.action.value, event.action.openIn] as ExtractedArgs<T>;\n }\n if (handlerName === 'onCustomAction' && event.action.type === 'custom') {\n return [event.action.value] as ExtractedArgs<T>;\n }\n // onCloseButtonPress, onAndroidSystemBack don't take arguments\n return [] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishWebPaymentNavigation:\n return [event.product, event.error] as unknown as ExtractedArgs<T>;\n\n case FlowEventId.DidReceiveAnalyticEvent:\n return [event.name, event.params] as ExtractedArgs<T>;\n\n case FlowEventId.DidAskPermission:\n return [event.permission, event.customArgs] as ExtractedArgs<T>;\n\n case FlowEventId.ObserverDidInitiatePurchase:\n case FlowEventId.ObserverDidInitiateRestore:\n // Args (product + SDK-provided start/finish callbacks) are injected by\n // the view emitter's dedicated observer branch, not here.\n return [] as ExtractedArgs<T>;\n\n case FlowEventId.DidAppear:\n return [event.view] as ExtractedArgs<T>;\n\n case FlowEventId.DidRequestAppReview:\n case FlowEventId.DidDisappear:\n case FlowEventId.DidStartRestore:\n return [] as ExtractedArgs<T>;\n }\n}\n","import type { OnboardingEventHandlers } from './types';\nimport { OnboardingEventId } from '@/types/onboarding-events';\nimport type {\n OnboardingEventIdType,\n ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\ntype EventName = keyof OnboardingEventHandlers;\n\n/**\n * Keyed by {@link OnboardingEventIdType} rather than `string`, so an id that is\n * not a real onboarding event cannot be mapped and a newly added one cannot be\n * forgotten. This is what lets {@link HANDLER_TO_EVENT_CONFIG} expose\n * `nativeEvent` as a checked id instead of a bare string.\n */\ntype UiEventMapping = Record<\n OnboardingEventIdType,\n {\n handlerName: keyof OnboardingEventHandlers;\n propertyMap?: {\n [key: string]: string;\n };\n }[]\n>;\n\nexport const ONBOARDING_EVENT_MAPPINGS: UiEventMapping = {\n onboarding_on_close_action: [\n {\n handlerName: 'onClose',\n },\n ],\n onboarding_on_custom_action: [\n {\n handlerName: 'onCustom',\n },\n ],\n onboarding_on_paywall_action: [\n {\n handlerName: 'onPaywall',\n },\n ],\n onboarding_on_state_updated_action: [\n {\n handlerName: 'onStateUpdated',\n },\n ],\n onboarding_did_finish_loading: [\n {\n handlerName: 'onFinishedLoading',\n },\n ],\n onboarding_on_analytics_action: [\n {\n handlerName: 'onAnalytics',\n },\n ],\n onboarding_did_fail_with_error: [\n {\n handlerName: 'onError',\n },\n ],\n};\n\nexport const HANDLER_TO_EVENT_CONFIG: Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n> = Object.entries(ONBOARDING_EVENT_MAPPINGS).reduce(\n (acc, [nativeEvent, mappings]) => {\n mappings.forEach(({ handlerName }) => {\n acc[handlerName] = {\n // Object.entries widens the key to `string`; UiEventMapping already\n // constrains it, so the narrowing is a restatement, not an assumption.\n nativeEvent: nativeEvent as OnboardingEventIdType,\n handlerName,\n };\n });\n return acc;\n },\n {} as Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n >,\n);\n\n// Reverse mapping: nativeEvent -> EventName[]\nexport const NATIVE_EVENT_TO_HANDLERS: Record<string, EventName[]> =\n Object.entries(HANDLER_TO_EVENT_CONFIG).reduce(\n (acc, [handlerName, config]) => {\n if (!acc[config.nativeEvent]) {\n acc[config.nativeEvent] = [];\n }\n const handlers = acc[config.nativeEvent];\n if (handlers) {\n handlers.push(handlerName as EventName);\n }\n return acc;\n },\n {} as Record<string, EventName[]>,\n );\n\ntype ExtractedArgs<T extends keyof OnboardingEventHandlers> = Parameters<\n OnboardingEventHandlers[T]\n>;\n\nexport function extractOnboardingCallbackArgs<\n T extends keyof OnboardingEventHandlers,\n>(_handlerName: T, event: ParsedOnboardingEvent): ExtractedArgs<T> {\n switch (event.id) {\n case OnboardingEventId.Close:\n case OnboardingEventId.Custom:\n case OnboardingEventId.Paywall:\n return [event.actionId, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.StateUpdated:\n return [event.action, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.FinishedLoading:\n return [event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.Analytics:\n return [\n {\n ...event.event,\n // Add backward compatibility: populate element_id from elementId\n element_id: event.event.elementId,\n },\n event.meta,\n ] as ExtractedArgs<T>;\n\n case OnboardingEventId.Error:\n return [event.error] as ExtractedArgs<T>;\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport {\n AdaptyPaywallProduct,\n AdaptyProductIdentifier,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\nimport { FileLocation, MakePurchaseParamsInput } from '@/types/inputs';\nimport type { AdaptyPermission, FlowEventView } from '@/types/flow-events';\n\n/**\n * @internal\n */\nexport type ArgType<T> = T extends () => unknown\n ? void\n : T extends (arg: infer U) => unknown\n ? U\n : void;\n\n/**\n * EventHandler callback should not return a promise,\n * because using `await` may postpone closing a flow view.\n *\n * We don't want to block the UI thread.\n */\nexport type EventHandlerResult = boolean | void;\n\n/**\n * Purchase parameters keyed by AdaptyProductIdentifier objects\n */\nexport type ProductPurchaseParams = Array<{\n productId: AdaptyProductIdentifier;\n params: MakePurchaseParamsInput;\n}>;\n\n/**\n * Result of an OS permission request, returned to native by the SDK.\n */\nexport type FlowPermissionStatus = 'granted' | 'denied';\n\nexport interface FlowPermissionResponse {\n status: FlowPermissionStatus;\n /** Optional human-readable detail (e.g. the OS status string). */\n detail?: string;\n}\n\n/**\n * Hashmap of possible events to their callbacks\n *\n * @see {@link https://adapty.io/docs/react-native-handling-events-1 | [DOC] Handling View Events}\n */\nexport interface FlowEventHandlers {\n /**\n * Called when a user taps the close button on the flow view\n *\n * If you return `true`, the flow view will be closed.\n * We strongly recommend to return `true` in this case.\n * @default true\n */\n onCloseButtonPress: () => EventHandlerResult;\n /**\n * Called when a user navigates back on Android\n *\n * Return `true` to close the flow view.\n * By default, this handler returns `false`, so the flow view stays open.\n * @default false\n */\n onAndroidSystemBack: () => EventHandlerResult;\n /**\n * Called when a user taps the product in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onProductSelected: (productId: string) => EventHandlerResult;\n /**\n * Called when a user taps the purchase button in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult;\n /**\n * Called when the purchase succeeds, the user cancels their purchase, or the purchase appears to be pending\n *\n * If you return `true` from this callback, the flow view will be closed.\n * We strongly recommend returning `purchaseResult.type !== 'user_cancelled'` in this case.\n * @default false\n *\n * @param {AdaptyPurchaseResult} purchaseResult - object, which provides details about the purchase.\n * If the result is `'success'`, it also includes the updated user's profile.\n */\n onPurchaseCompleted: (\n purchaseResult: AdaptyPurchaseResult,\n product: AdaptyPaywallProduct,\n ) => EventHandlerResult;\n /**\n * Called if a purchase fails after a user taps the purchase button\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onPurchaseFailed: (\n error: AdaptyError,\n product: AdaptyPaywallProduct,\n ) => EventHandlerResult;\n /**\n * Called when a user taps the restore button in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onRestoreStarted: () => EventHandlerResult;\n\n /**\n * Called when the flow view disappears\n *\n * If you return `true`, the flow view will be closed.\n * @default false\n */\n onDisappeared: () => EventHandlerResult;\n\n /**\n * Called when the flow view appears\n *\n * If you return `true`, the flow view will be closed.\n * @default false\n *\n * @param view - the flow view that appeared; see {@link FlowEventView} for\n * the fields it carries, of which only `locale` is optional\n */\n onAppeared: (view: FlowEventView) => EventHandlerResult;\n\n onWebPaymentNavigationFinished: (\n product?: AdaptyPaywallProduct,\n error?: AdaptyError,\n ) => EventHandlerResult;\n /**\n * Called when a restore is completed\n *\n * If you return `true` from this callback, the flow view will be closed.\n * @default false\n *\n * @param {AdaptyProfile} profile - updated user profile\n */\n onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult;\n /**\n * Called if a restore fails after a user taps the restore button\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onRestoreFailed: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called when the flow view receives an error (e.g. it fails to render).\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onError: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called if a product list fails to load on a presented view,\n * for example, if there is no internet connection\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult;\n onCustomAction: (actionId: string) => EventHandlerResult;\n /**\n * Called when the user taps a URL/link inside the paywall.\n *\n * @param url - URL to open\n * @param openIn - How the URL was configured to open in the dashboard:\n * `'browser_in_app'` — in-app browser (e.g. `WKWebView` / `Custom Tabs`)\n * `'browser_out_app'` (default) — external browser (e.g. `Linking.openURL`)\n */\n onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult;\n /**\n * Called when the flow view asks the host app to show the native\n * app review prompt (e.g. `SKStoreReviewController` on iOS,\n * In-App Review on Android).\n *\n * This is a notification: returning `true` would close the view,\n * but for an app-review prompt you almost always want to keep it open.\n */\n onRequestAppReview: () => EventHandlerResult;\n /**\n * Called when the flow view reports an analytics event.\n *\n * This is a notification: the return value follows the standard\n * close-on-`true` contract, but you normally keep the view open.\n *\n * @param name - analytics event name\n * @param params - arbitrary event parameters\n */\n onAnalytics: (\n name: string,\n params: Record<string, unknown>,\n ) => EventHandlerResult;\n /**\n * Called when the flow view asks the host app to request an OS-level\n * permission (e.g. notifications, ATT). This is the only **asynchronous**\n * handler: return a `Promise` that resolves with the resulting status.\n *\n * If you do not provide a handler, the SDK replies `'denied'`.\n *\n * @param permission - permission identifier the flow view requested\n * @param customArgs - arbitrary string args configured in the dashboard\n */\n onRequestPermission: (\n permission: AdaptyPermission,\n customArgs: Record<string, string>,\n ) => Promise<FlowPermissionResponse>;\n /**\n * Called in **observer mode** when the user taps the purchase button inside\n * an Adapty-rendered flow view. Adapty does NOT make the purchase —\n * your app performs it through its own purchase API. Drive the flow view's\n * loading state with the two provided callbacks:\n *\n * - call `onStartPurchase()` right before you begin the purchase (shows the\n * flow view's loading indicator);\n * - call `onFinishPurchase()` once it settles, success or failure (hides it).\n *\n * The return value follows the standard close-on-`true` contract; you\n * normally keep the view open (`false`) and dismiss it yourself after the\n * purchase succeeds.\n *\n * @remarks\n * Fires only when the SDK was activated in observer mode\n * (`activate(apiKey, { observerMode: true })`). Without it, Adapty handles\n * purchases itself and this event is never emitted.\n *\n * Adapty does not see the purchase you make, so after it succeeds you must\n * report the transaction to Adapty yourself (e.g. via `reportTransaction`). The\n * `onStartPurchase`/`onFinishPurchase` callbacks only drive the flow view's\n * loading UI;\n *\n * @param product - product the user initiated the purchase for\n * @param onStartPurchase - notify the flow view the purchase started\n * @param onFinishPurchase - notify the flow view the purchase finished\n */\n onObserverPurchaseInitiated: (\n product: AdaptyPaywallProduct,\n onStartPurchase: () => void,\n onFinishPurchase: () => void,\n ) => EventHandlerResult;\n /**\n * Called in **observer mode** when the user taps the restore button inside an\n * Adapty-rendered flow view. Adapty does NOT restore — your app\n * performs it through its own API. Drive the flow view's loading state with the\n * two provided callbacks (`onStartRestore()` / `onFinishRestore()`).\n *\n * @remarks\n * Fires only when the SDK was activated in observer mode\n * (`activate(apiKey, { observerMode: true })`). Without it, Adapty handles\n * restores itself and this event is never emitted.\n *\n * Report any transactions surfaced by the restore to Adapty yourself (e.g.\n * via `reportTransaction`) so they flow into events and analytics. The\n * `onStartRestore`/`onFinishRestore` callbacks only drive the flow view's\n * loading UI; they do not report anything.\n *\n * @param onStartRestore - notify the flow view the restore started\n * @param onFinishRestore - notify the flow view the restore finished\n */\n onObserverRestoreInitiated: (\n onStartRestore: () => void,\n onFinishRestore: () => void,\n ) => EventHandlerResult;\n}\n\nexport interface OnboardingEventHandlers {\n onClose: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onCustom: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onPaywall: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onStateUpdated: (\n action: OnboardingStateUpdatedAction,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onFinishedLoading: (meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onAnalytics: (\n event: {\n name: OnboardingAnalyticsEventName;\n /**\n * @deprecated Use `elementId` instead\n */\n element_id?: string;\n elementId?: string;\n reply?: string;\n },\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onError: (error: AdaptyError) => EventHandlerResult;\n}\n\nexport type OnboardingAnalyticsEventName =\n | 'onboarding_started'\n | 'screen_presented'\n | 'screen_completed'\n | 'second_screen_presented'\n | 'registration_screen_presented'\n | 'products_screen_presented'\n | 'user_email_collected'\n | 'onboarding_completed'\n | (string & {});\n\nexport type AdaptyUiOnboardingMeta = {\n onboardingId: string;\n screenClientId: string;\n screenIndex: number;\n totalScreens: number;\n};\n\nexport type AdaptyUiOnboardingStateParams = {\n id: string;\n value: string;\n label: string;\n};\n\nexport type OnboardingStateUpdatedAction =\n | {\n elementId: string;\n elementType: 'select';\n value: AdaptyUiOnboardingStateParams;\n }\n | {\n elementId: string;\n elementType: 'multi_select';\n value: AdaptyUiOnboardingStateParams[];\n }\n | {\n elementId: string;\n elementType: 'input';\n value:\n | { type: 'text' | 'email'; value: string }\n | { type: 'number'; value: number };\n }\n | {\n elementId: string;\n elementType: 'date_picker';\n value: {\n day?: number;\n month?: number;\n year?: number;\n };\n };\n\n/**\n * Additional options for creating a flow view\n *\n * @see {@link https://docs.adapty.io/docs/paywall-builder-fetching | [DOC] Creating Flow View}\n */\nexport interface CreateFlowViewParamsInput {\n /**\n * The identifier of the localization to render the flow with, e.g. `en`, `es`, `fr`.\n *\n * @remarks\n * When undefined, `en` is requested rather than the flow's default localization.\n * If the requested localization does not exist, the flow's default localization is used.\n *\n * @see {@link FlowEventView.locale} — the localization the view was actually\n * built with.\n */\n locale?: string;\n /**\n * The id of a custom layout to render instead of the one resolved\n * automatically for the current device.\n */\n customLayoutId?: string;\n /**\n * `true` if you want to prefetch products before presenting a flow view.\n */\n prefetchProducts?: boolean;\n /**\n * This value limits the timeout (in milliseconds) for this method.\n */\n loadTimeoutMs?: number;\n /**\n * If you are going to use custom tags functionality, pass an object with tags and corresponding replacement values\n *\n * ```\n * {\n * 'USERNAME': 'Bruce',\n * 'CITY': 'Philadelphia'\n * }\n * ```\n */\n customTags?: Record<string, string>;\n /**\n * If you are going to use custom timer functionality, pass an object with timer ids and corresponding dates the timers should end at\n */\n customTimers?: Record<string, Date>;\n\n customAssets?: Record<string, AdaptyCustomAsset>;\n\n productPurchaseParams?: ProductPurchaseParams;\n\n android?: {\n /**\n * When `true`, the flow view applies safe-area paddings.\n *\n * @platform android\n * @remarks\n * When omitted, the default is decided by the presenting API you use.\n */\n enableSafeArea?: boolean;\n };\n}\n\n/**\n * Additional options for creating an onboarding view\n *\n * @see {@link https://adapty.io/docs/react-native-get-onboardings | [DOC] Creating Onboarding View}\n */\nexport interface CreateOnboardingViewParamsInput {\n /**\n * If you want to change the presentation behavior of external URLs, pass a preferred value.\n *\n * @default {@link WebPresentation.BrowserInApp}\n */\n externalUrlsPresentation?: WebPresentation;\n}\n\nexport interface AdaptyUiView {\n id: string;\n locale?: string;\n}\n\nexport interface AdaptyUiMediaCache {\n memoryStorageTotalCostLimit?: number;\n memoryStorageCountLimit?: number;\n diskStorageSizeLimit?: number;\n}\n\nexport interface AdaptyUiDialogConfig {\n /**\n * The action title to display as part of the dialog. If you provide two actions,\n * be sure `primaryAction` cancels the operation and leaves things unchanged.\n */\n primaryActionTitle: string;\n /**\n * The secondary action title to display as part of the dialog.\n */\n secondaryActionTitle?: string;\n /**\n * The title of the dialog.\n */\n title?: string;\n /**\n * Descriptive text that provides additional details about the reason for the dialog.\n */\n content?: string;\n}\n\nexport const AdaptyUiDialogActionType = Object.freeze({\n primary: 'primary',\n secondary: 'secondary',\n});\nexport type AdaptyUiDialogActionType =\n (typeof AdaptyUiDialogActionType)[keyof typeof AdaptyUiDialogActionType];\n\nexport type AdaptyCustomAsset =\n | AdaptyCustomImageAsset\n | AdaptyCustomVideoAsset\n | AdaptyCustomColorAsset\n | AdaptyCustomGradientAsset;\n\nexport type AdaptyCustomImageAsset =\n | { type: 'image'; base64: string }\n | { type: 'image'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'image'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomVideoAsset =\n | { type: 'video'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'video'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomColorAsset =\n | { type: 'color'; argb: number /* e.g. 0xFFFF0000 (opaque red) */ }\n | { type: 'color'; rgb: number /* e.g. 0xFF0000 (red) */ }\n | { type: 'color'; rgba: number /* e.g. 0xFF0000FF (opaque red) */ };\n\nexport type AdaptyCustomGradientAsset = {\n type: 'linear-gradient';\n values: (\n | { p: number; argb: number }\n | { p: number; rgb: number }\n | { p: number; rgba: number }\n )[];\n points?: { x0?: number; y0?: number; x1?: number; y1?: number };\n};\n\n/**\n * iOS presentation style for flow and onboarding views\n */\nexport type AdaptyIOSPresentationStyle = 'full_screen' | 'page_sheet';\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\n\nconst AdaptyTypes = [\n 'AdaptyError',\n 'AdaptyProfile',\n 'AdaptyPurchaseResult',\n 'AdaptyFlow',\n 'AdaptyPaywallProduct',\n 'AdaptyPromotedProduct',\n 'AdaptyOnboarding',\n 'AdaptyRemoteConfig',\n 'AdaptyInstallationStatus',\n 'AdaptyInstallationDetails',\n 'AdaptyUiView',\n 'AdaptyUiDialogActionType',\n 'AdaptyUiOnboardingMeta',\n 'AdaptyUiOnboardingStateParams',\n 'AdaptyUiOnboardingStateUpdatedAction',\n 'Array<AdaptyPaywallProduct>',\n 'BridgeError',\n 'String',\n 'Boolean',\n 'Void',\n] as const;\n\nexport type AdaptyType = (typeof AdaptyTypes)[number];\n\ninterface AdaptyResult<T> {\n success?: T;\n error?: AdaptyResultError;\n}\n\ninterface AdaptyResultError {\n adaptyCode: number;\n message: string;\n detail?: string;\n}\n\nexport function parseMethodResult<T>(\n factory: CoderFactory,\n input: string,\n resultType: AdaptyType,\n ctx?: LogContext,\n): T {\n const log = ctx?.decode({ methodName: 'parseMethodResult' });\n log?.start(() => ({ input }));\n\n let obj: AdaptyResult<unknown>;\n\n // Attempt to parse the input into a JSON object\n try {\n obj = JSON.parse(input);\n } catch (error) {\n const adaptyError = AdaptyError.failedToDecode(\n `Failed to decode native response. JSON.parse raised an error: ${\n (error as Error)?.message || ''\n }`,\n );\n\n log?.failed(() => ({ error: adaptyError.message }));\n throw adaptyError;\n }\n\n if (obj.hasOwnProperty('success')) {\n if (\n [\n 'String',\n 'Boolean',\n 'Void',\n 'AdaptyUiView',\n 'AdaptyUiDialogActionType',\n ].includes(resultType)\n ) {\n return obj.success as T;\n }\n\n const coder = getCoder(factory, resultType, ctx);\n return coder?.decode(obj.success);\n } else if (obj.hasOwnProperty('error')) {\n const coder = getCoder(factory, 'AdaptyError', ctx);\n const errorData = coder?.decode(obj.error);\n throw (coder as ErrorConverter<any>).getError(errorData);\n } else {\n const adaptyError = AdaptyError.failedToDecode(\n `Failed to decode native response. Response does not have expected \"success\" or \"error\" property`,\n );\n log?.failed(() => ({ error: adaptyError.message }));\n throw adaptyError;\n }\n}\n\nexport function parseCommonEvent(\n factory: CoderFactory,\n event: string,\n input: string,\n ctx?: LogContext,\n) {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n switch (event) {\n case 'did_load_latest_profile':\n return getCoder(factory, 'AdaptyProfile', ctx)?.decode(obj['profile']);\n case 'did_receive_promoted_purchase':\n return getCoder(factory, 'AdaptyPromotedProduct', ctx)?.decode(\n obj['product'],\n );\n case 'on_installation_details_success':\n return getCoder(factory, 'AdaptyInstallationDetails', ctx)?.decode(\n obj['details'],\n );\n case 'on_installation_details_fail':\n return getCoder(factory, 'AdaptyError', ctx)?.decode(obj['error']);\n default:\n return null;\n }\n}\n\nfunction getCoder(\n factory: CoderFactory,\n type: AdaptyType,\n ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> | null {\n ctx?.stack;\n\n switch (type as AdaptyType) {\n case 'AdaptyError':\n return factory.createNativeErrorCoder();\n case 'AdaptyProfile':\n return factory.createProfileCoder();\n case 'AdaptyFlow':\n return factory.createFlowCoder();\n case 'AdaptyPaywallProduct':\n return factory.createPaywallProductCoder();\n case 'AdaptyPromotedProduct':\n return factory.createPromotedProductCoder();\n case 'AdaptyRemoteConfig':\n return factory.createRemoteConfigCoder();\n case 'AdaptyOnboarding':\n return factory.createOnboardingCoder();\n case 'AdaptyPurchaseResult':\n return factory.createPurchaseResultCoder();\n case 'AdaptyInstallationStatus':\n return factory.createInstallationStatusCoder();\n case 'AdaptyInstallationDetails':\n return factory.createInstallationDetailsCoder();\n case 'AdaptyUiOnboardingMeta':\n return factory.createUiOnboardingMetaCoder();\n case 'AdaptyUiOnboardingStateParams':\n return factory.createUiOnboardingStateParamsCoder();\n case 'AdaptyUiOnboardingStateUpdatedAction':\n return factory.createUiOnboardingStateUpdatedActionCoder();\n case 'BridgeError':\n return factory.createBridgeErrorCoder();\n case 'Array<AdaptyPaywallProduct>':\n return factory.createPaywallProductArrayCoder();\n case 'String':\n return null;\n }\n // @ts-ignore\n throw AdaptyError.failedToDecode(\n `Failed to decode native response. Response has unexpected \"type\" property: ${type}`,\n );\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\nimport type {\n AdaptyPaywallProduct,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\nimport {\n FlowEventId,\n type FlowEventView,\n type ParsedFlowEvent,\n type FlowUserAction,\n} from '@/types/flow-events';\n\n// Re-export types for convenience\nexport {\n FlowEventId,\n type FlowEventIdType,\n type FlowEventView,\n type FlowDidAppearEvent,\n type FlowDidDisappearEvent,\n type FlowDidPerformActionEvent,\n type FlowUserAction,\n type FlowDidSelectProductEvent,\n type FlowDidStartPurchaseEvent,\n type FlowDidFinishPurchaseEvent,\n type FlowDidFailPurchaseEvent,\n type FlowDidStartRestoreEvent,\n type FlowDidFinishRestoreEvent,\n type FlowDidFailRestoreEvent,\n type FlowDidReceiveErrorEvent,\n type FlowDidFailLoadingProductsEvent,\n type FlowDidFinishWebPaymentNavigationEvent,\n type FlowDidRequestAppReviewEvent,\n type FlowDidReceiveAnalyticEvent,\n type FlowDidAskPermissionEvent,\n type FlowObserverDidInitiatePurchaseEvent,\n type FlowObserverDidInitiateRestoreEvent,\n type ParsedFlowEvent,\n} from '@/types/flow-events';\n\n// Parser\nexport function parseFlowEvent(\n factory: CoderFactory,\n input: string,\n ctx?: LogContext,\n): ParsedFlowEvent | null {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n\n const eventId = obj['id'] as string | undefined;\n if (!eventId?.startsWith('flow_view_')) {\n return null;\n }\n\n const viewObj = obj['view'] as Record<string, unknown>;\n const view: FlowEventView = {\n id: viewObj['id'] as string,\n placementId: viewObj['placement_id'] as string,\n variationId: viewObj['variation_id'] as string,\n locale: viewObj['locale'] as string | undefined,\n };\n\n switch (eventId) {\n case FlowEventId.DidAppear:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidDisappear:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidPerformAction: {\n const actionObj = obj['action'] as Record<string, unknown>;\n return {\n id: eventId,\n view,\n action: parseFlowUserAction(actionObj),\n };\n }\n\n case FlowEventId.DidSelectProduct:\n return {\n id: eventId,\n view,\n productId: (obj['product_id'] as string) ?? '',\n };\n\n case FlowEventId.DidStartPurchase:\n return {\n id: eventId,\n view,\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.DidFinishPurchase:\n return {\n id: eventId,\n view,\n purchaseResult: getFlowCoder(factory, 'purchaseResult', ctx)!.decode(\n obj['purchased_result'],\n ) as AdaptyPurchaseResult,\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.DidFailPurchase: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n }\n\n case FlowEventId.DidStartRestore:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidFinishRestore:\n return {\n id: eventId,\n view,\n profile: getFlowCoder(factory, 'profile', ctx)!.decode(\n obj['profile'],\n ) as AdaptyProfile,\n };\n\n case FlowEventId.DidFailRestore: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidReceiveError: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidFailLoadingProducts: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidFinishWebPaymentNavigation:\n return {\n id: eventId,\n view,\n product: obj['product']\n ? (getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct)\n : undefined,\n error: obj['error']\n ? (() => {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return errorCoder.getError(decodedError);\n })()\n : undefined,\n };\n\n case FlowEventId.DidRequestAppReview:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidReceiveAnalyticEvent: {\n const params = obj['params'];\n return {\n id: eventId,\n view,\n name: typeof obj['name'] === 'string' ? obj['name'] : '',\n params:\n typeof params === 'object' && params !== null\n ? (params as Record<string, unknown>)\n : {},\n };\n }\n\n case FlowEventId.DidAskPermission:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n permission:\n typeof obj['permission'] === 'string' ? obj['permission'] : '',\n customArgs:\n typeof obj['custom_args'] === 'object' && obj['custom_args'] !== null\n ? (obj['custom_args'] as Record<string, string>)\n : {},\n };\n\n case FlowEventId.ObserverDidInitiatePurchase:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.ObserverDidInitiateRestore:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n };\n\n default:\n return null;\n }\n}\n\nfunction parseFlowUserAction(\n actionObj: Record<string, unknown>,\n): FlowUserAction {\n const type = actionObj['type'] as FlowUserAction['type'];\n switch (type) {\n case 'open_url':\n return {\n type,\n value: actionObj['value'] as string,\n openIn: actionObj['open_in'] as WebPresentation,\n };\n case 'custom':\n return { type, value: actionObj['value'] as string };\n case 'close':\n case 'system_back':\n return { type };\n }\n}\n\ntype FlowCoderType = 'product' | 'profile' | 'purchaseResult' | 'error';\n\nfunction getFlowCoder(\n factory: CoderFactory,\n type: FlowCoderType,\n _ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> {\n switch (type) {\n case 'product':\n return factory.createPaywallProductCoder();\n case 'profile':\n return factory.createProfileCoder();\n case 'purchaseResult':\n return factory.createPurchaseResultCoder();\n case 'error':\n return factory.createNativeErrorCoder();\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\nimport type { AdaptyUiOnboardingMeta } from '@/ui-builder/types';\nimport type { OnboardingStateUpdatedAction } from '@/ui-builder/types';\nimport {\n OnboardingEventId,\n type OnboardingEventView,\n type ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\n// Re-export types for convenience\nexport {\n OnboardingEventId,\n type OnboardingEventIdType,\n type OnboardingEventView,\n type OnboardingCloseEvent,\n type OnboardingCustomEvent,\n type OnboardingPaywallEvent,\n type OnboardingStateUpdatedEvent,\n type OnboardingFinishedLoadingEvent,\n type OnboardingAnalyticsEvent,\n type OnboardingErrorEvent,\n type ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\n// Parser\nexport function parseOnboardingEvent(\n factory: CoderFactory,\n input: string,\n ctx?: LogContext,\n): ParsedOnboardingEvent | null {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n\n const eventId = obj['id'] as string | undefined;\n if (!eventId?.startsWith('onboarding_')) {\n return null;\n }\n\n const viewObj = obj['view'] as Record<string, unknown>;\n const view: OnboardingEventView = {\n id: viewObj['id'] as string,\n placementId: viewObj['placement_id'] as string | undefined,\n variationId: viewObj['variation_id'] as string | undefined,\n };\n const decodeMeta = () =>\n getOnboardingCoder(factory, 'meta', ctx)!.decode(\n obj['meta'],\n ) as AdaptyUiOnboardingMeta;\n\n switch (eventId) {\n case OnboardingEventId.Close:\n case OnboardingEventId.Custom:\n case OnboardingEventId.Paywall:\n return {\n id: eventId,\n view,\n actionId: (obj['action_id'] as string) ?? '',\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.StateUpdated:\n return {\n id: eventId,\n view,\n action: getOnboardingCoder(factory, 'action', ctx)!.decode(\n obj['action'],\n ) as OnboardingStateUpdatedAction,\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.FinishedLoading:\n return {\n id: eventId,\n view,\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.Analytics: {\n const eventObj = obj['event'] as Record<string, any>;\n return {\n id: eventId,\n view,\n event: {\n name: eventObj['name'] as string,\n elementId: eventObj['element_id'] as string | undefined,\n reply: eventObj['reply'] as string | undefined,\n },\n meta: decodeMeta(),\n };\n }\n\n case OnboardingEventId.Error: {\n const errorCoder = getOnboardingCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n default:\n return null;\n }\n}\n\ntype OnboardingCoderType = 'meta' | 'action' | 'error';\n\nfunction getOnboardingCoder(\n factory: CoderFactory,\n type: OnboardingCoderType,\n _ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> {\n switch (type) {\n case 'meta':\n return factory.createUiOnboardingMetaCoder();\n case 'action':\n return factory.createUiOnboardingStateUpdatedActionCoder();\n case 'error':\n return factory.createNativeErrorCoder();\n }\n}\n","/**\n * Generates a short unique identifier.\n * Format: 12 lowercase alphanumeric characters\n */\nexport function generateId(): string {\n let id = '';\n while (id.length < 12) {\n id += Math.random().toString(36).slice(2);\n }\n return id.slice(0, 12);\n}\n","/**\n * Removes undefined properties from an object, preserving the original type structure\n * @param obj - Source object with potentially undefined values\n * @returns Object with undefined values filtered out\n */\nexport function filterUndefined<T extends object>(obj: T): T {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined),\n ) as T;\n}\n","/**\n * Maps over values of an object, transforming each value using the provided function.\n *\n * @param obj - The object to map over\n * @param fn - Function to transform each value\n * @returns New object with transformed values\n */\nexport function mapValues<T extends Record<string, any>>(\n obj: T,\n fn: (value: T[keyof T], key: keyof T) => any,\n): T {\n return Object.fromEntries(\n Object.entries(obj).map(([key, value]) => [key, fn(value, key)]),\n ) as T;\n}\n","/**\n * Checks if a value is a plain object (not an array, null, Date, etc.)\n */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !(value instanceof RegExp) &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Deep merge implementation that replaces arrays and merges objects\n */\nfunction deepMerge(\n target: unknown,\n source: unknown,\n seen = new Set(),\n): unknown {\n // Handle null/undefined cases\n if (source === null || source === undefined) {\n return source;\n }\n\n if (target === null || target === undefined) {\n return source;\n }\n\n // Handle arrays - replace them (source overwrites target)\n if (Array.isArray(source)) {\n return source;\n }\n\n // If target is array but source is not, return source\n if (Array.isArray(target)) {\n return source;\n }\n\n // Handle plain objects - merge recursively\n if (isPlainObject(target) && isPlainObject(source)) {\n // Check for circular references\n if (seen.has(source) || seen.has(target)) {\n throw new Error('Converting circular structure to JSON');\n }\n\n seen.add(source);\n seen.add(target);\n\n const result: Record<string, unknown> = {};\n\n // Get all keys from both objects\n const allKeys = new Set([...Object.keys(target), ...Object.keys(source)]);\n\n for (const key of allKeys) {\n // Skip prototype pollution attempts\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n if (key in source) {\n if (key in target) {\n // Check for circular reference in values\n if (seen.has(source[key]) || seen.has(target[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Recursively merge if key exists in both\n result[key] = deepMerge(target[key], source[key], seen);\n } else {\n // Check for circular reference in source value\n if (seen.has(source[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Use source value if key only exists in source\n result[key] = source[key];\n }\n } else {\n // Check for circular reference in target value\n if (seen.has(target[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Use target value if key only exists in target\n result[key] = target[key];\n }\n }\n\n seen.delete(source);\n seen.delete(target);\n\n return result;\n }\n\n // For all other cases (primitives, functions, dates, etc.), return source\n return source;\n}\n\n/**\n * Universal method for merging options with defaults\n * @param options - input options\n * @param defaults - default values\n * @returns merged object with TResult type\n */\nexport function mergeOptions<TResult = unknown>(\n options: unknown,\n defaults: unknown,\n): TResult {\n return deepMerge(defaults, options) as TResult;\n}\n","function toJSON(this: Error & { originalError: unknown }) {\n return {\n message: this.message,\n name: this.name,\n stack: this.stack,\n originalError:\n this.originalError instanceof Error\n ? {\n message: this.originalError.message,\n name: this.originalError.name,\n }\n : this.originalError,\n };\n}\n/**\n * Wraps a user-provided callback with error context enrichment.\n * Catches exceptions and wraps them with source and handler information.\n */\nexport function withErrorContext<T extends (...args: never[]) => unknown>(\n callback: T,\n handlerName: string,\n source: string,\n): T {\n const wrapped = function (\n this: unknown,\n ...args: Parameters<T>\n ): ReturnType<T> {\n try {\n return callback.apply(this, args) as ReturnType<T>;\n } catch (error) {\n const message = `Unhandled exception in user's handler in ${source}.${handlerName}`;\n\n const wrappedError = new Error(message) as Error & {\n originalError: unknown;\n toJSON: typeof toJSON;\n };\n wrappedError.originalError = error;\n wrappedError.toJSON = toJSON;\n\n throw wrappedError;\n }\n };\n\n return wrapped as T;\n}\n"],"mappings":";;;;;;;;AASA,MAAa,WAAW,OAAO,OAAO;CAKpC,SAAS;CAIT,OAAO;CAMP,MAAM;CAKN,MAAM;AACP,EAAC;AAIF,MAAa,cAAc,OAAO,OAAO;CACvC,6BAA6B;CAC7B,yBAAyB;CACzB,qCACE;AACH,EAAC;AA2KF,MAAa,iDAAiD,OAAO,OAAO;CAC1E,iBAAiB;CACjB,UAAU;CACV,kBAAkB;CAClB,qBAAqB;CACrB,mBAAmB;AACpB,EAAC;;;;ACrNF,SAAS,mBACPA,OACmD;AAEnD,SAAQ,OAAR;EACE,KAAK,QACH,QAAO,QAAQ;EACjB,KAAK,OACH,QAAO,QAAQ;EACjB,KAAK,UACH,QAAO,QAAQ;EACjB,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,aAA8C;GACtD,aAAa;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,0BAA0B;IACxB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,4BAA4B;IAC1B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,wBAAwB;IACtB,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,oBAAoB;IAClB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,IAAI;IACF,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,YAAY;IACV,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,OAAO;IACL,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,gBAAgB;IACd,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,SAAS,EACP,SAAS;IACP,KAAK;IACL,UAAU;IACV,MAAM;GACP,EACF;EACF;;AACF;;;;AC3GD,IAAa,0BAAb,cAA6C,YAAiC;;;OAClE,aAA8C;GACtD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,yBAAyB;IACvB,KAAK;IACL,UAAU;I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AM;GACP;GACD,yBAAyB;IACvB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,mBAAmB;IACjB,KAAK;IACL,UAAU;IACV,MAAM;GACP;EACF;;AACF;;;;AC1BD,IAAa,0BAAb,cAA6C,YAAiC;;;OAClE,aAA8C;GACtD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,YAAY;IACV,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,OAAO;IACL,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,qBAAqB;IACnB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,aAAa;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,gBAAgB;IACd,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,wBAAwB;IACtB,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,4BAA4B;IAC1B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,0BAA0B;IACxB,KAAK;IACL,UAAU;IACV,MAAM;GACP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AO,KAAK,OAAO,AAAC;AAExE,OAAK,MAAM,OAAO,SAAS;AAEzB,OAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,YAC1D;AAGF,OAAI,OAAO,OACT,KAAI,OAAO,QAAQ;AAEjB,QAAI,KAAK,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,CAChD,OAAM,IAAI,MAAM;AAGlB,WAAO,OAAO,UAAU,OAAO,MAAM,OAAO,MAAM,KAAK;GACxD,OAAM;AAEL,QAAI,KAAK,IAAI,OAAO,KAAK,CACvB,OAAM,IAAI,MAAM;AAGlB,WAAO,OAAO,OAAO;GACtB;QACI;AAEL,QAAI,KAAK,IAAI,OAAO,KAAK,CACvB,OAAM,IAAI,MAAM;AAGlB,WAAO,OAAO,OAAO;GACtB;EACF;AAED,OAAK,OAAO,OAAO;AACnB,OAAK,OAAO,OAAO;AAEnB,SAAO;CACR;AAGD,QAAO;AACR;;;;;;;AAQD,SAAgB,aACdC,SACAC,UACS;AACT,QAAO,UAAU,UAAU,QAAQ;AACpC;;;;AC7GD,SAAS,SAAiD;AACxD,QAAO;EACL,SAAS,KAAK;EACd,MAAM,KAAK;EACX,OAAO,KAAK;EACZ,eACE,KAAK,yBAAyB,QAC1B;GACE,SAAS,KAAK,cAAc;GAC5B,MAAM,KAAK,cAAc;EAC1B,IACD,KAAK;CACZ;AACF;;;;;AAKD,SAAgB,iBACdC,UACAC,aACAC,QACG;CACH,MAAM,UAAU,SAEd,GAAG,MACY;AACf,MAAI;AACF,UAAO,SAAS,MAAM,MAAM,KAAK;EAClC,SAAQ,OAAO;GACd,MAAM,WAAW,2CAA2C,OAAO,GAAG,YAAY;GAElF,MAAM,eAAe,IAAI,MAAM;AAI/B,gBAAa,gBAAgB;AAC7B,gBAAa,SAAS;AAEtB,SAAM;EACP;CACF;AAED,QAAO;AACR"}
1
+ {"version":3,"file":"index.mjs","names":["level: LogLevel","consoleLogSink: LogSink","version: string","message: string","funcName: string","config: LoggerConfig","sink: LogSink","id: string","logLevel: LogLevel","message: LazyMessage","params?: LazyParams","event: LogEvent","args: LogScopeConstructor","args: LogArgs","step: Scope","args: ScopeArgs","message: string","method: ScopeArgs","sdkName: string","sdkVersion: string","error: (typeof ErrorCode)[ErrorCode]","code: ErrorCode","input: AdaptyErrorInput","callback: (error: AdaptyError) => void","message: string","error: unknown","platform: IPlatformAdapter","data: CodableModel","data: Serializable","value: unknown","type: StrType<any>","obj: Record<string, any>","key: string","obj: T","value: any","currentObj: Partial<T>","data: Model","properties: Properties<Model, Serializable>","result: Partial<Serializable>","platform?: 'ios' | 'android'","result: Partial<Model>","input: string","value: Date","platform: IPlatformAdapter","sdkMetadata: ISdkMetadataAdapter","apiKey: string","params: Model","config: Serializable","coderFactory: () => Converter<Model, Serializable>","input: Serializable[]","value: Model[]","data: Serializable","data: Model","json: SerializableLayout","model: AdaptyFlowUiSchemaLayout","json: SerializableGrid","model: AdaptyFlowUiSchemaGrid","json: Serializable","model: Model","input: Serialized","value: Model","data: Serializable","data: Model","data: Serializable","data: Model","platform: IPlatformAdapter","params?: Model","result: Serializable","model: AdaptyInstallationDetails","result: Def['AdaptyInstallationDetails']","json: Def['AdaptyInstallationDetails']","model: AdaptyInstallationStatus","details: Def['AdaptyInstallationDetails']","json: Def['AdaptyInstallationStatus']","details: AdaptyInstallationDetails","data: Model","data: Serializable","data: Model","data: Serializable","data: Serializable","data: Serializable","data: Serializable","coder: T | null","input: Record<string, unknown>","result: Record<string, any>","value: Record<string, any>","result: Record<string, unknown>","platform: IPlatformAdapter","data: Model","purchaseParams: Serializable","data: Serializable","data: Model","data: CreateOnboardingViewParamsInput","result: Serializable","date: Date","num: number","digits: number","value: number","input: string","asset: { relativeAssetPath: string } | { fileLocation: FileLocation }","platformOS: PlatformOS","platform: IPlatformAdapter","data: Model","result: Serializable","timers: Record<string, Date>","result: Record<string, string>","assets: Record<string, AdaptyCustomAsset>","asset: { relativeAssetPath: string } | { fileLocation: FileLocation }","value: string","color: string","params: CreateFlowViewParamsInput['productPurchaseParams']","data: Serializable","data: OnboardingStateUpdatedAction","data: Model","deps: CoderDependencies","coderFactory: () => Converter<Model, Serializable>","coder: T | null","GLOBAL_EVENT_TO_NATIVE_EVENT: GlobalEventMap","NATIVE_EVENT_RESOLVER: Record<\n FlowEventIdType,\n (event: ParsedFlowEvent) => EventName | null\n>","actionMap: Record<string, EventName>","HANDLER_TO_NATIVE_EVENT: Record<EventName, FlowEventIdType>","handlerName: T","event: ParsedFlowEvent","ONBOARDING_EVENT_MAPPINGS: UiEventMapping","HANDLER_TO_EVENT_CONFIG: Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n>","NATIVE_EVENT_TO_HANDLERS: Record<string, EventName[]>","_handlerName: T","event: ParsedOnboardingEvent","factory: CoderFactory","input: string","resultType: AdaptyType","ctx?: LogContext","obj: AdaptyResult<unknown>","event: string","obj: Record<string, unknown>","type: AdaptyType","factory: CoderFactory","input: string","ctx?: LogContext","obj: Record<string, unknown>","view: FlowEventView","actionObj: Record<string, unknown>","type: FlowCoderType","_ctx?: LogContext","factory: CoderFactory","input: string","ctx?: LogContext","obj: Record<string, unknown>","view: OnboardingEventView","type: OnboardingCoderType","_ctx?: LogContext","obj: T","obj: T","fn: (value: T[keyof T], key: keyof T) => any","value: unknown","target: unknown","source: unknown","result: Record<string, unknown>","options: unknown","defaults: unknown","callback: T","handlerName: string","source: string"],"sources":["../src/types/inputs.ts","../src/logger/console-sink.ts","../src/logger/log.ts","../src/logger/log-scope.ts","../src/logger/log-context.ts","../src/adapters/defaults.ts","../src/types/error.ts","../src/adapty-error.ts","../src/coders/coder.ts","../src/coders/date.ts","../src/coders/adapty-access-level.ts","../src/coders/adapty-ui-media-cache.ts","../src/coders/adapty-configuration.ts","../src/coders/adapty-subscription-period.ts","../src/coders/adapty-price.ts","../src/coders/adapty-discount-phase.ts","../src/coders/product-reference.ts","../src/coders/array.ts","../src/coders/adapty-placement.ts","../src/coders/adapty-flow-paywall.ts","../src/coders/adapty-flow-ui-schema.ts","../src/coders/json.ts","../src/coders/adapty-remote-config.ts","../src/coders/adapty-flow.ts","../src/coders/adapty-identify-params.ts","../src/coders/adapty-installation-details.ts","../src/coders/adapty-installation-status.ts","../src/coders/adapty-native-error.ts","../src/coders/adapty-non-subscription.ts","../src/coders/adapty-onboarding-builder.ts","../src/coders/adapty-onboarding.ts","../src/coders/adapty-subscription-offer-identifier.ts","../src/coders/adapty-subscription-offer.ts","../src/coders/adapty-subscription-details.ts","../src/coders/adapty-paywall-product.ts","../src/coders/adapty-promoted-product.ts","../src/coders/adapty-profile-parameters.ts","../src/coders/adapty-subscription.ts","../src/coders/hashmap.ts","../src/coders/adapty-profile.ts","../src/coders/adapty-purchase-params.ts","../src/coders/adapty-purchase-result.ts","../src/coders/adapty-ui-dialog-config.ts","../src/coders/adapty-ui-create-onboarding-view-params.ts","../src/coders/utils.ts","../src/coders/adapty-ui-create-flow-view-params.ts","../src/coders/adapty-ui-onboarding-meta.ts","../src/coders/adapty-ui-onboarding-state-params.ts","../src/coders/adapty-ui-onboarding-state-updated-action.ts","../src/coders/bridge-error.ts","../src/coders/factory.ts","../src/types/index.ts","../src/types/bridge.ts","../src/types/flow-events.ts","../src/types/onboarding-events.ts","../src/ui-builder/flow-event-mapping.ts","../src/ui-builder/onboarding-event-mapping.ts","../src/ui-builder/types.ts","../src/coders/parse.ts","../src/coders/parse-flow.ts","../src/coders/parse-onboarding.ts","../src/utils/generate-id.ts","../src/utils/compact-object.ts","../src/utils/map-values.ts","../src/utils/merge-options.ts","../src/utils/with-error-context.ts"],"sourcesContent":["import { AdaptyUiMediaCache } from '@/ui-builder/types';\nimport type { AdaptyMockConfig } from '@/mock/types';\n/**\n * Log levels for the SDK\n *\n * @remarks\n * Logging is performed on a native side.\n * So you are expected to watch logs in Xcode or Android Studio.\n */\nexport const LogLevel = Object.freeze({\n /**\n * Logs any additional information that may be useful during debugging,\n * such as function calls, API queries, etc.\n */\n VERBOSE: 'verbose',\n /**\n * Logs only errors\n */\n ERROR: 'error',\n /**\n * Logs messages from the SDK\n * that do not cause critical errors,\n * but are worth paying attention to\n */\n WARN: 'warn',\n /**\n * Logs various information messages,\n * such as those that log the lifecycle of various modules\n */\n INFO: 'info',\n});\n\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];\n\nexport const FetchPolicy = Object.freeze({\n ReloadRevalidatingCacheData: 'reload_revalidating_cache_data',\n ReturnCacheDataElseLoad: 'return_cache_data_else_load',\n ReturnCacheDataIfNotExpiredElseLoad:\n 'return_cache_data_if_not_expired_else_load',\n});\nexport type FetchPolicy = (typeof FetchPolicy)[keyof typeof FetchPolicy];\n\nexport type GetPlacementParamsInput =\n GetPlacementForDefaultAudienceParamsInput & {\n /**\n * This value limits the timeout (in milliseconds) for this method.\n *\n * @remarks\n * If the timeout is reached, cached data or local fallback will be returned.\n */\n loadTimeoutMs?: number;\n };\n\nexport type GetPlacementForDefaultAudienceParamsInput =\n | {\n /**\n * Fetch policy\n *\n * @remarks\n * By default SDK will try to load data from server and will return cached data in case of failure.\n * Otherwise use `'return_cache_data_else_load'` to return cached data if it exists.\n */\n fetchPolicy?: Exclude<\n FetchPolicy,\n 'return_cache_data_if_not_expired_else_load'\n >;\n }\n | {\n /**\n * Fetch policy\n *\n * @remarks\n * By default SDK will try to load data from server and will return cached data in case of failure.\n * Otherwise use `'return_cache_data_else_load'` to return cached data if it exists.\n */\n fetchPolicy: Extract<\n FetchPolicy,\n 'return_cache_data_if_not_expired_else_load'\n >;\n /**\n * Max age for cached data.\n *\n * @remarks\n * Max time (in seconds) the cache is valid in case of `'return_cache_data_if_not_expired_else_load'` fetch policy.\n */\n maxAgeSeconds: number;\n };\n\n/**\n * Describes optional parameters for the placement preload methods.\n *\n * @remarks\n * Preloading has no fetch policy: it always goes to the network and only warms\n * the placement cache, so unlike {@link GetPlacementParamsInput} the only knob\n * is the timeout.\n */\nexport interface PreloadPlacementsParamsInput {\n /**\n * This value limits the timeout (in milliseconds) for this method.\n *\n * @remarks\n * The native SDKs clamp anything below 1000 ms up to 1000 ms. Reaching the\n * timeout is not an error by itself — the affected placements are retried\n * against the default audience source.\n */\n loadTimeoutMs?: number;\n}\n\n/**\n * Describes optional parameters for the {@link activate} method.\n */\nexport interface ActivateParamsInput {\n /**\n * Observer mode. Turn it on when your app handles purchases and subscription\n * status itself (through your own purchase code or a third-party SDK) and\n * uses Adapty only for sending subscription events and analytics.\n *\n * @remarks\n * This also enables using Adapty Flow (paywall) views in observer mode: the\n * paywall is still rendered by Adapty, but when the user taps buy/restore the\n * SDK does NOT make the purchase — it notifies your app through the\n * `onObserverPurchaseInitiated` / `onObserverRestoreInitiated` flow event\n * handlers. Report completed purchases back to Adapty (e.g. via\n * `reportTransaction`) so they still flow into events and analytics.\n *\n * @defaultValue `false`\n */\n observerMode?: boolean;\n /**\n * User identifier in your system\n *\n * @remarks\n * If none of the parameters are passed, the SDK will generate an ID\n * and use it for a current device.\n * Use your own ID:\n * 1. If you want to support a cross-device experience\n * 2. If you have your own authentication system,\n * and you want to associate adapty profile with your user\n */\n customerUserId?: string;\n /**\n * Log level for the SDK\n *\n * @remarks\n * Logging is performed on a native side.\n * So you are expected to watch logs in Xcode or Android Studio.\n */\n logLevel?: LogLevel;\n\n serverCluster?: 'default' | 'eu' | 'cn';\n backendProxyHost?: string;\n backendProxyPort?: number;\n activateUi?: boolean;\n mediaCache?: AdaptyUiMediaCache;\n\n /**\n * Does not activate SDK until any other method is called\n * Fixes annoying iOS simulator auhtentication\n */\n __debugDeferActivation?: boolean;\n /**\n * Ignores multiple activation attempts on fast refresh.\n * If true, skips activation if SDK is already activated.\n */\n __ignoreActivationOnFastRefresh?: boolean;\n /**\n * Enables mock mode for web platform\n * @remarks\n * When enabled, SDK will use mock implementations instead of native modules.\n * Useful for Expo Web and testing.\n * @defaultValue `false`\n */\n enableMock?: boolean;\n /**\n * Configuration for mock mode\n * @remarks\n * Allows customization of mock data returned by the SDK.\n */\n mockConfig?: AdaptyMockConfig;\n /**\n * Disables IP address collection\n * @defaultValue `false`\n */\n ipAddressCollectionDisabled?: boolean;\n /**\n * Enables the Adapty Attribution service.\n *\n * @remarks\n * When enabled, the SDK registers the install with Adapty Attribution so\n * acquisition data can be attributed without a third-party attribution SDK.\n *\n * @defaultValue `false`\n */\n adaptyAttributionEnabled?: boolean;\n ios?: {\n /**\n * Disables IDFA collection\n * @default false\n */\n idfaCollectionDisabled?: boolean;\n appAccountToken?: string;\n /**\n * Controls whether the SDK will create a new profile when the app is restored from an iCloud backup\n * @defaultValue `false`\n */\n clearDataOnBackup?: boolean;\n };\n android?: {\n /**\n * Disables Google AdvertisingID collection\n * @default false\n */\n adIdCollectionDisabled?: boolean;\n pendingPrepaidPlansEnabled?: boolean;\n localAccessLevelAllowed?: boolean;\n obfuscatedAccountId?: string;\n };\n}\n\nexport interface IdentifyParamsInput {\n ios?: {\n appAccountToken?: string;\n };\n android?: {\n obfuscatedAccountId?: string;\n };\n}\n\nexport interface GetPaywallProductsParamsInput {}\n\nexport const AdaptyAndroidSubscriptionUpdateReplacementMode = Object.freeze({\n ChargeFullPrice: 'charge_full_price',\n Deferred: 'deferred',\n WithoutProration: 'without_proration',\n ChargeProratedPrice: 'charge_prorated_price',\n WithTimeProration: 'with_time_proration',\n});\n// satisfies Record<\n// string,\n// Schema['Input.AdaptyAndroidSubscriptionUpdateParameters']['replacement_mode']\n// >;\n\nexport type AdaptyAndroidSubscriptionUpdateReplacementMode =\n (typeof AdaptyAndroidSubscriptionUpdateReplacementMode)[keyof typeof AdaptyAndroidSubscriptionUpdateReplacementMode];\n\n/**\n * Android purchase parameters structure\n * @public\n */\nexport interface AdaptyAndroidPurchaseParams {\n /**\n * Android subscription update parameters\n * @platform android\n */\n subscriptionUpdateParams?: {\n oldSubVendorProductId: string;\n prorationMode: AdaptyAndroidSubscriptionUpdateReplacementMode;\n };\n /**\n * Whether the offer is personalized\n * @platform android\n * @see {@link https://developer.android.com/google/play/billing/integrate#personalized-price}\n */\n isOfferPersonalized?: boolean;\n}\n\nexport type MakePurchaseParamsInput = {\n /**\n * Android purchase parameters\n * @platform android\n */\n android?: AdaptyAndroidPurchaseParams;\n};\n\nexport type FileLocation = {\n ios: {\n fileName: string;\n };\n android:\n | {\n relativeAssetPath: string;\n }\n | {\n rawResName: string;\n };\n};\n","import type { LogSink } from './types';\nimport type { LogLevel } from '../types/inputs';\n\nfunction getConsoleForLevel(\n level: LogLevel,\n): (message?: any, ...optionalParams: any[]) => void {\n /* eslint-disable no-console */\n switch (level) {\n case 'error':\n return console.error;\n case 'warn':\n return console.warn;\n case 'verbose':\n return console.debug;\n case 'info':\n default:\n return console.info;\n }\n /* eslint-enable no-console */\n}\n\nexport const consoleLogSink: LogSink = {\n id: 'console',\n handle: event => {\n const logger = getConsoleForLevel(event.level);\n logger(event.formatted, event.params);\n },\n};\n","import { LogLevel } from '../types/inputs';\nimport type { LogEvent, LogSink, LoggerConfig } from './types';\nimport { consoleLogSink } from './console-sink';\n\n// Type for lazy evaluation functions\ntype LazyMessage = () => string;\ntype LazyParams = () => Record<string, unknown>;\n\nexport class Log {\n public static logLevel: LogLevel | null = null;\n private static sinks: LogSink[] = [consoleLogSink];\n private static defaultMeta?: LoggerConfig['defaultMeta'];\n private static _version: string = 'unknown';\n\n /**\n * Override the version shown in log messages\n * @internal\n */\n public static setVersion(version: string): void {\n this._version = version;\n }\n\n // Formats a message for logging\n private static formatMessage(message: string, funcName: string): string {\n const now = new Date().toISOString();\n\n return `[${now}] [adapty@${this._version}] \"${funcName}\": ${message}`;\n }\n\n /** Configure JS logger: replace sinks and/or set default metadata */\n public static configure(config: LoggerConfig): void {\n if (config.sinks) {\n for (const sink of this.sinks) sink.destroy?.();\n this.sinks = config.sinks.slice();\n }\n this.defaultMeta = config.defaultMeta;\n }\n\n /** Register additional sink */\n public static addSink(sink: LogSink): void {\n this.sinks.push(sink);\n }\n\n /** Remove sink by id and call its destroy if present */\n public static removeSink(id: string): void {\n const sink = this.sinks.find(sink => sink.id === id);\n this.sinks = this.sinks.filter(sink => sink.id !== id);\n sink?.destroy?.();\n }\n\n /** Clear all sinks and destroy them */\n public static clearSinks(): void {\n const prev = this.sinks;\n this.sinks = [];\n for (const sink of prev) sink.destroy?.();\n }\n\n /**\n * Gets the appropriate log level integer for a log level.\n * @internal\n */\n private static getLogLevelInt(logLevel: LogLevel): number {\n switch (logLevel) {\n case LogLevel.ERROR:\n return 0;\n case LogLevel.WARN:\n return 1;\n case LogLevel.INFO:\n return 2;\n case LogLevel.VERBOSE:\n return 3;\n }\n }\n\n /**\n * Logs a message to the console if the log level is appropriate.\n * Uses lazy evaluation to avoid unnecessary computations.\n * @internal\n */\n public static log(\n logLevel: LogLevel,\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n if (!Log.logLevel) {\n return;\n }\n\n const currentLevel = Log.getLogLevelInt(Log.logLevel);\n const messageLevel = Log.getLogLevelInt(logLevel);\n\n if (messageLevel <= currentLevel) {\n // Lazy evaluation: only compute once per entry\n const resolvedMessage = message();\n const resolvedParams = params ? params() : undefined;\n const mergedParams = this.defaultMeta\n ? {\n ...(this.defaultMeta as Record<string, unknown>),\n ...(resolvedParams ?? {}),\n }\n : resolvedParams;\n\n const formatted = Log.formatMessage(resolvedMessage, funcName);\n const event: LogEvent = {\n timestamp: new Date().toISOString(),\n version: this._version,\n level: logLevel,\n funcName,\n message: resolvedMessage,\n params: mergedParams,\n formatted,\n };\n\n for (const sink of this.sinks) {\n if (sink.levels && !sink.levels.includes(logLevel)) continue;\n try {\n sink.handle(event);\n } catch {\n // ignore sink errors\n }\n }\n }\n }\n\n public static info(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.INFO, funcName, message, params);\n }\n\n public static warn(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.WARN, funcName, message, params);\n }\n\n public static error(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.ERROR, funcName, message, params);\n }\n\n public static verbose(\n funcName: string,\n message: LazyMessage,\n params?: LazyParams,\n ): void {\n this.log(LogLevel.VERBOSE, funcName, message, params);\n }\n}\n","import type { LogArgs } from '@/adapters/interfaces';\nimport { ScopeArgs } from './log-context';\n\nexport type { LogArgs };\ntype LogCallback = (LazyParams: LogArgs) => void;\n\ninterface LogScopeConstructor extends ScopeArgs {\n onStart: LogCallback;\n onSuccess: LogCallback;\n onFailed: LogCallback;\n onWait: LogCallback;\n onWaitComplete: LogCallback;\n}\n\nexport class LogScope {\n public methodName: string;\n private onStart: LogCallback;\n private onSuccess: LogCallback;\n private onFailed: LogCallback;\n private onWait: LogCallback;\n private onWaitComplete: LogCallback;\n\n constructor(args: LogScopeConstructor) {\n this.methodName = args.methodName;\n this.onStart = args.onStart;\n this.onSuccess = args.onSuccess;\n this.onFailed = args.onFailed;\n this.onWait = args.onWait;\n this.onWaitComplete = args.onWaitComplete;\n }\n\n public start(args: LogArgs) {\n this.onStart(args);\n }\n public wait(args: LogArgs) {\n this.onWait(args);\n }\n public waitComplete(args: LogArgs) {\n this.onWaitComplete(args);\n }\n public success(args: LogArgs) {\n this.onSuccess(args);\n }\n public failed(args: LogArgs) {\n this.onFailed(args);\n }\n}\n","import { Log } from './log';\nimport { LogScope } from './log-scope';\nimport type { LogArgs } from './log-scope';\nexport interface ScopeArgs {\n methodName: string;\n}\n\n// Scope of a single stack trace record\ntype Scope = 'EVENT' | 'CALL' | 'ENCODE' | 'BRIDGE' | 'DECODE';\n\n// Displays an interface for a single stack trace record\ninterface Trace {\n action: Scope;\n fn: string;\n payload: LogArgs;\n error?: boolean;\n done?: boolean;\n}\n\n// LogContext instance is a logger context for a single call to a native SDK method\n// It accumulates logs for each step of the call\nexport class LogContext {\n public stack: Trace[] = [];\n\n private createScope(step: Scope, args: ScopeArgs, message: string): LogScope {\n return new LogScope({\n ...args,\n onStart: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n\n Log.verbose(\n args.methodName,\n () => `${message}...`,\n () => payload(),\n );\n },\n onSuccess: payload => {\n this.stack.push({\n action: step,\n fn: args.methodName,\n payload,\n done: true,\n });\n\n Log.verbose(\n args.methodName,\n () => `${message}: OK`,\n () => payload(),\n );\n },\n onFailed: payload => {\n this.stack.push({\n action: step,\n fn: args.methodName,\n payload,\n error: true,\n });\n\n const resolvedStack = this.stack.map(s => ({\n ...s,\n payload: s.payload(),\n }));\n const p = payload() as Record<string, any>;\n p['__stack__'] = resolvedStack;\n Log.error(\n args.methodName,\n () => `${message}: FAILED`,\n () => p,\n );\n },\n onWait: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n Log.verbose(\n args.methodName,\n () => `<HOLD> ${message}`,\n () => payload(),\n );\n },\n onWaitComplete: payload => {\n this.stack.push({ action: step, fn: args.methodName, payload });\n Log.verbose(\n args.methodName,\n () => `<UNLOCKED> ${message}`,\n () => payload(),\n );\n },\n });\n }\n\n // Creates a scope for a event listener\n public event(method: ScopeArgs): LogScope {\n return this.createScope(\n 'EVENT',\n method,\n `Receiving event \"${method.methodName}\"`,\n );\n }\n // Create a scope for a public call\n public call(args: ScopeArgs): LogScope {\n return this.createScope('CALL', args, 'Calling method');\n }\n // Creates a scope for encoding an object\n public encode(args: ScopeArgs): LogScope {\n return this.createScope('ENCODE', args, 'Encoding object');\n }\n // Creates a scope for calling a bridge function\n public bridge(args: ScopeArgs): LogScope {\n return this.createScope('BRIDGE', args, 'Calling bridge function');\n }\n // Creates a scope for decoding a string\n public decode(args: ScopeArgs): LogScope {\n return this.createScope('DECODE', args, 'Decoding string');\n }\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n ILoggerAdapter,\n ILogContext,\n PlatformOS,\n} from './interfaces';\nimport { LogContext } from '@/logger';\n\n/**\n * Default platform adapter with unknown OS\n */\nexport class DefaultPlatformAdapter implements IPlatformAdapter {\n readonly OS: PlatformOS = 'unknown';\n}\n\n/**\n * Default SDK metadata adapter\n */\nexport class DefaultSdkMetadataAdapter implements ISdkMetadataAdapter {\n constructor(\n public readonly sdkName: string = 'unknown',\n public readonly sdkVersion: string = '0.0.0',\n ) {}\n}\n\n/**\n * Default logger adapter using the real LogContext implementation\n */\nexport class DefaultLoggerAdapter implements ILoggerAdapter {\n createContext(): ILogContext {\n return new LogContext();\n }\n}\n","// import SDK type to link to methods in docs.\n// import { AdaptyError } from '../sdk2/error';\n\nconst ErrorCodeMapping = Object.freeze({\n /**\n * System StoreKit codes\n */\n 0: 'unknown',\n /**\n * Client is not allowed to make a request, etc.\n */\n 1: 'clientInvalid',\n /**\n * Invalid purchase identifier, etc.\n */\n 3: 'paymentInvalid',\n /**\n * This device is not allowed to make the payment.\n */\n 4: 'paymentNotAllowed',\n /**\n * Product is not available in the current storefront.\n */\n 5: 'storeProductNotAvailable',\n\n /**\n * User has not allowed access to cloud service information.\n */\n 6: 'cloudServicePermissionDenied',\n\n /**\n * The device could not connect to the network.\n */\n 7: 'cloudServiceNetworkConnectionFailed',\n\n /**\n * User has revoked permission to use this cloud service.\n */\n 8: 'cloudServiceRevoked',\n\n /**\n * The user needs to acknowledge Apple's privacy policy.\n */\n 9: 'privacyAcknowledgementRequired',\n\n /**\n * The app is attempting to use SKPayment's requestData property,\n * but does not have the appropriate entitlement.\n */\n 10: 'unauthorizedRequestData',\n\n /**\n * The specified subscription offer identifier is not valid.\n */\n 11: 'invalidOfferIdentifier',\n\n /**\n * The cryptographic signature provided is not valid.\n */\n 12: 'invalidSignature',\n\n /**\n * One or more parameters from SKPaymentDiscount is missing.\n */\n 13: 'missingOfferParams',\n\n 14: 'invalidOfferPrice',\n\n /**\n * Custom Android codes.\n */\n 20: 'adaptyNotInitialized',\n 22: 'productNotFound',\n 24: 'currentSubscriptionToUpdateNotFoundInHistory',\n 97: 'billingServiceTimeout',\n 98: 'featureNotSupported',\n 99: 'billingServiceDisconnected',\n 102: 'billingServiceUnavailable',\n 103: 'billingUnavailable',\n 105: 'developerError',\n 106: 'billingError',\n 107: 'itemAlreadyOwned',\n 108: 'itemNotOwned',\n 112: 'billingNetworkError',\n\n 1000: 'noProductIDsFound',\n 1002: 'productRequestFailed',\n\n /**\n * In-App Purchases are not allowed on this device.\n */\n 1003: 'cantMakePayments',\n 1004: 'noPurchasesToRestore',\n 1005: 'cantReadReceipt',\n 1006: 'productPurchaseFailed',\n 1010: 'refreshReceiptFailed',\n 1011: 'receiveRestoredTransactionsFailed',\n\n /**\n * You need to be authenticated to perform requests.\n */\n 2002: 'notActivated',\n 2003: 'badRequest',\n 2004: 'serverError',\n 2005: 'networkFailed',\n 2006: 'decodingFailed',\n 2009: 'encodingFailed',\n\n 3000: 'analyticsDisabled',\n /**\n * Wrong parameter was passed.\n */\n 3001: 'wrongParam',\n /**\n * It is not possible to call `.activate` method more than once.\n */\n 3005: 'activateOnceError',\n /**\n * The user profile was changed during the operation.\n */\n 3006: 'profileWasChanged',\n 3007: 'unsupportedData',\n 3100: 'persistingDataError',\n 3101: 'fetchTimeoutError',\n 9000: 'operationInterrupted',\n});\n\nexport const ErrorCode = ErrorCodeMapping;\nexport type ErrorCode = keyof typeof ErrorCodeMapping;\n\nexport const ErrorCodeName = Object.freeze({\n unknown: 0,\n clientInvalid: 1,\n paymentInvalid: 3,\n paymentNotAllowed: 4,\n storeProductNotAvailable: 5,\n cloudServicePermissionDenied: 6,\n cloudServiceNetworkConnectionFailed: 7,\n cloudServiceRevoked: 8,\n privacyAcknowledgementRequired: 9,\n unauthorizedRequestData: 10,\n invalidOfferIdentifier: 11,\n invalidSignature: 12,\n missingOfferParams: 13,\n invalidOfferPrice: 14,\n adaptyNotInitialized: 20,\n productNotFound: 22,\n currentSubscriptionToUpdateNotFoundInHistory: 24,\n billingServiceTimeout: 97,\n featureNotSupported: 98,\n billingServiceDisconnected: 99,\n billingServiceUnavailable: 102,\n billingUnavailable: 103,\n developerError: 105,\n billingError: 106,\n itemAlreadyOwned: 107,\n itemNotOwned: 108,\n billingNetworkError: 112,\n noProductIDsFound: 1000,\n productRequestFailed: 1002,\n cantMakePayments: 1003,\n noPurchasesToRestore: 1004,\n cantReadReceipt: 1005,\n productPurchaseFailed: 1006,\n refreshReceiptFailed: 1010,\n receiveRestoredTransactionsFailed: 1011,\n notActivated: 2002,\n badRequest: 2003,\n serverError: 2004,\n networkFailed: 2005,\n decodingFailed: 2006,\n encodingFailed: 2009,\n analyticsDisabled: 3000,\n wrongParam: 3001,\n activateOnceError: 3005,\n profileWasChanged: 3006,\n unsupportedData: 3007,\n persistingDataError: 3100,\n fetchTimeoutError: 3101,\n operationInterrupted: 9000,\n} as const);\nexport type ErrorCodeName = keyof typeof ErrorCodeName;\n\nexport function getErrorCode(\n error: (typeof ErrorCode)[ErrorCode],\n): ErrorCode | undefined {\n const errorCode = Object.keys(ErrorCode).find(keyStr => {\n const key = Number(keyStr) as ErrorCode;\n return ErrorCode[key] === error;\n });\n\n if (!errorCode) {\n return undefined;\n }\n\n return Number(errorCode) as ErrorCode;\n}\n\nexport function getErrorPrompt(code: ErrorCode): (typeof ErrorCode)[ErrorCode] {\n const prompt = ErrorCode[code];\n\n if (!prompt) {\n return `Unknown code: ${code}` as (typeof ErrorCode)[ErrorCode];\n }\n\n return prompt;\n}\n","import { ErrorCode } from '@/types/error';\n\nexport interface AdaptyErrorInput {\n adaptyCode: ErrorCode;\n message: string;\n detail?: string | undefined;\n}\n\nexport class AdaptyError extends Error {\n // Custom prefix to be shown before log message\n public static prefix = '';\n static middleware?: (error: AdaptyError) => void;\n\n // For example `2` for cancelled payment\n public adaptyCode: ErrorCode;\n // Message that is safe to show to a user\n public localizedDescription: string;\n public detail: string | undefined;\n\n constructor(input: AdaptyErrorInput) {\n super(AdaptyError.getMessage(input));\n\n this.adaptyCode = input.adaptyCode;\n this.localizedDescription = input.message;\n this.detail = input.detail;\n\n if (AdaptyError.middleware) {\n AdaptyError.middleware(this);\n }\n }\n\n public static set onError(callback: (error: AdaptyError) => void) {\n AdaptyError.middleware = callback;\n }\n\n public static failedToDecodeNativeError(\n message: string,\n error: unknown,\n ): AdaptyError {\n return new AdaptyError({\n adaptyCode: 0,\n message: message,\n detail: JSON.stringify(error),\n });\n }\n\n public static failedToEncode(message: string): AdaptyError {\n return new AdaptyError({\n adaptyCode: 2009,\n message: message,\n });\n }\n\n public static failedToDecode(message: string): AdaptyError {\n return new AdaptyError({\n adaptyCode: 2006,\n message: message,\n });\n }\n\n private static getMessage(input: AdaptyErrorInput): string {\n const code = input.adaptyCode;\n const codeText = ErrorCode[code];\n\n let message = `#${code} (${codeText}): ${input.message}`;\n\n if (AdaptyError.prefix) {\n message = `${AdaptyError.prefix} ${message}`;\n }\n\n return message;\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { DefaultPlatformAdapter } from '@/adapters/defaults';\nimport type { IPlatformAdapter } from '@/adapters/interfaces';\nimport { Converter, Properties, StrType } from './types';\n\nexport abstract class Coder<\n Model extends Record<string, any>,\n CodableModel extends Partial<Model>,\n Serializable extends Record<string, any> = Record<string, any>,\n> implements Converter<CodableModel, Serializable> {\n protected readonly platform: IPlatformAdapter;\n protected abstract properties: Properties<CodableModel, Serializable>;\n\n constructor(platform: IPlatformAdapter = new DefaultPlatformAdapter()) {\n this.platform = platform;\n }\n\n encode(data: CodableModel): Serializable {\n return this.encodeWithProperties(data, this.properties);\n }\n // From vendor_product_id to productId\n decode(data: Serializable): CodableModel {\n return this.decodeWithProperties(data, this.properties);\n }\n\n protected isType(value: unknown, type: StrType<any>): boolean {\n switch (type) {\n case 'string':\n case 'boolean':\n case 'number':\n return typeof value === type;\n case 'object':\n return value !== null && typeof value === 'object';\n case 'array':\n return Array.isArray(value);\n }\n }\n\n private getNestedValue(obj: Record<string, any>, key: string): any {\n const keys = key.split('.');\n let current;\n if (typeof obj === 'string') {\n try {\n current = JSON.parse(obj);\n } catch (error) {\n return undefined;\n }\n } else {\n current = obj;\n }\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!;\n\n if (current[key] !== undefined) {\n current = current[key];\n } else {\n return undefined;\n }\n }\n\n return current;\n }\n\n private assignNestedValue<T extends Record<string, any>>(\n obj: T,\n key: string,\n value: any,\n ): T {\n const keys = String(key).split('.');\n let currentObj: Partial<T> = obj;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i] as keyof Partial<T>;\n\n if (currentObj[key] === undefined) {\n currentObj[key] = {} as any;\n }\n\n currentObj = currentObj[key] as any;\n }\n\n currentObj[keys[keys.length - 1] as keyof Partial<T>] = value;\n return obj;\n }\n\n private encodeWithProperties<Model extends Record<string, any>, Serializable>(\n data: Model,\n properties: Properties<Model, Serializable>,\n ): Serializable {\n const result: Partial<Serializable> = {};\n\n for (const key in data) {\n if (key === 'ios' || key === 'android') {\n // Read properties from ios/android platform keys and flatten them\n const platformResult = this.encodeWithProperties(\n data[key],\n (properties as Record<string, any>)[key],\n ) as any;\n\n Object.assign(result, platformResult);\n continue;\n }\n\n const property = properties[key as string];\n if (!property) {\n throw AdaptyError.failedToEncode(\n `Failed to find encoder for property \"${key}\"`,\n );\n }\n\n const converter = property.converter;\n\n this.assignNestedValue(\n result,\n property.key as string,\n converter ? converter.encode(data[key]) : data[key as keyof Model],\n );\n }\n\n return result as Serializable;\n }\n\n private decodeWithProperties<Serializable, Model extends Record<string, any>>(\n data: Serializable,\n properties: Properties<Model, Serializable>,\n platform?: 'ios' | 'android',\n ): Model {\n const result: Partial<Model> = {};\n\n for (const key in properties) {\n if (key === 'android' || key === 'ios') {\n // Add ios/android property and fill platform data there\n result[key as unknown as keyof typeof result] =\n this.decodeWithProperties(\n data,\n (properties as Record<string, any>)[key],\n key,\n ) as any;\n continue;\n }\n\n const property = properties[key];\n if (!property) {\n throw AdaptyError.failedToDecode(\n `Failed to find decoder for property \"${key}\"`,\n );\n }\n\n const value = this.getNestedValue(\n data as Record<string, any>,\n property.key as string,\n );\n\n if (\n property.required &&\n value === undefined &&\n (!platform || platform == this.platform.OS)\n ) {\n throw AdaptyError.failedToDecode(\n `Failed to decode native response, because it is missing required property \"${key}\"`,\n );\n }\n\n // If value is null or undefined and property is not required, continue\n if (value == null) continue;\n\n if (!this.isType(value, property.type)) {\n throw AdaptyError.failedToDecode(\n `Failed to decode native response, because its property \"${key}\" has invalid type. Expected type: ${\n property.type\n }. Received type: ${typeof value}`,\n );\n }\n\n // If a converter is provided, use it to convert the value\n result[key as keyof Model] = property.converter\n ? property.converter.decode(value)\n : (value as any);\n }\n\n return result as Model;\n }\n}\n\nexport abstract class SimpleCoder<\n Model extends Record<string, any>,\n Serializable extends Record<string, any> = Record<string, any>,\n> extends Coder<Model, Model, Serializable> {}\n","import { AdaptyError } from '@/adapty-error';\nimport type { Converter } from './types';\n\n/**\n * Format: yyyy-MM-dd'T'HH:mm:ss.SSSZ\n * OpenAPI: Output.Date\n */\nexport class DateCoder implements Converter<Date, string> {\n decode(input: string): Date {\n let pureValue = input;\n\n if (!input.endsWith('Z')) {\n // React Native seems to have an inconsistent behaviour\n // with dates with timezone offset\n // It is not handled with custom libs like dayjs\n // So we just remove the timezone offset if possible\n\n // Android SDK returns the following format,\n // that resulted in an invalid date for some customers\n // `2023-02-24T07:16:28.000000+0000`\n // solution is:\n // 1. Replace \"+0000\" with \"Z\"\n // 2. Replace microsecs with 0 millisecs\n\n // with the timezone offset removed\n const dateParts = input.split(/[-T:.Z]/);\n const date = new Date(\n Date.UTC(\n parseInt(dateParts[0] ?? '0', 10),\n parseInt(dateParts[1] ?? '0', 10) - 1,\n parseInt(dateParts[2] ?? '0', 10),\n parseInt(dateParts[3] ?? '0', 10),\n parseInt(dateParts[4] ?? '0', 10),\n parseInt(dateParts[5] ?? '0', 10),\n ),\n );\n pureValue = date.toISOString();\n }\n\n const parsedValue = Date.parse(pureValue);\n if (isNaN(parsedValue)) {\n throw AdaptyError.failedToDecode(\n `Failed to decode a date string into JS Date. String value: ${pureValue}`,\n );\n }\n\n return new Date(parsedValue);\n }\n\n encode(value: Date): string {\n return value.toISOString();\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { AdaptyAccessLevel } from '../types';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptyAccessLevel;\ntype Serializable = Def['AdaptyProfile.AccessLevel'];\n\nexport class AdaptyAccessLevelCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n activatedAt: {\n key: 'activated_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n activeIntroductoryOfferType: {\n key: 'active_introductory_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferId: {\n key: 'active_promotional_offer_id',\n required: false,\n type: 'string',\n },\n activePromotionalOfferType: {\n key: 'active_promotional_offer_type',\n required: false,\n type: 'string',\n },\n billingIssueDetectedAt: {\n key: 'billing_issue_detected_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n cancellationReason: {\n key: 'cancellation_reason',\n required: false,\n type: 'string',\n },\n expiresAt: {\n key: 'expires_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n id: {\n key: 'id',\n required: true,\n type: 'string',\n },\n isActive: {\n key: 'is_active',\n required: true,\n type: 'boolean',\n },\n isInGracePeriod: {\n key: 'is_in_grace_period',\n required: true,\n type: 'boolean',\n },\n isLifetime: {\n key: 'is_lifetime',\n required: true,\n type: 'boolean',\n },\n isRefund: {\n key: 'is_refund',\n required: true,\n type: 'boolean',\n },\n renewedAt: {\n key: 'renewed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n startsAt: {\n key: 'starts_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n store: {\n key: 'store',\n required: true,\n type: 'string',\n },\n unsubscribedAt: {\n key: 'unsubscribed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n willRenew: {\n key: 'will_renew',\n required: true,\n type: 'boolean',\n },\n android: {\n offerId: {\n key: 'offer_id',\n required: false,\n type: 'string',\n },\n },\n };\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiMediaCache } from '@/ui-builder/types';\n\ntype Model = AdaptyUiMediaCache;\ntype Serializable = Required<Def['AdaptyConfiguration']>['media_cache'];\n\nexport class AdaptyUiMediaCacheCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n memoryStorageTotalCostLimit: {\n key: 'memory_storage_total_cost_limit',\n required: false,\n type: 'number',\n },\n memoryStorageCountLimit: {\n key: 'memory_storage_count_limit',\n required: false,\n type: 'number',\n },\n diskStorageSizeLimit: {\n key: 'disk_storage_size_limit',\n required: false,\n type: 'number',\n },\n };\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n} from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\nimport type { Def } from '@/types/schema';\nimport { AdaptyUiMediaCacheCoder } from '@/coders/adapty-ui-media-cache';\n\ntype Model = Input.ActivateParamsInput;\ntype Serializable = Def['AdaptyConfiguration'];\n\nexport class AdaptyConfigurationCoder {\n constructor(\n private readonly platform: IPlatformAdapter,\n private readonly sdkMetadata: ISdkMetadataAdapter,\n ) {}\n\n encode(apiKey: string, params: Model): Serializable {\n const config: Serializable = {\n api_key: apiKey,\n cross_platform_sdk_name: this.sdkMetadata.sdkName,\n cross_platform_sdk_version: this.sdkMetadata.sdkVersion,\n };\n\n if (params.customerUserId) {\n config['customer_user_id'] = params.customerUserId;\n }\n\n config['observer_mode'] = params.observerMode ?? false;\n config['ip_address_collection_disabled'] =\n params.ipAddressCollectionDisabled ?? false;\n config['adapty_attribution_enabled'] =\n params.adaptyAttributionEnabled ?? false;\n\n if (params.logLevel) {\n config['log_level'] = params.logLevel;\n }\n\n config['server_cluster'] = params.serverCluster ?? 'default';\n\n if (params.backendProxyHost) {\n config['backend_proxy_host'] = params.backendProxyHost;\n }\n\n if (params.backendProxyPort) {\n config['backend_proxy_port'] = params.backendProxyPort;\n }\n\n config['activate_ui'] = params.activateUi ?? true;\n\n const mediaCacheCoder = new AdaptyUiMediaCacheCoder();\n config['media_cache'] = mediaCacheCoder.encode(\n params.mediaCache ?? {\n memoryStorageTotalCostLimit: 100 * 1024 * 1024,\n memoryStorageCountLimit: 2147483647,\n diskStorageSizeLimit: 100 * 1024 * 1024,\n },\n );\n\n if (this.platform.OS === 'ios') {\n config['apple_idfa_collection_disabled'] =\n params.ios?.idfaCollectionDisabled ?? false;\n if (params.ios?.appAccountToken) {\n config['customer_identity_parameters'] = {\n app_account_token: params.ios.appAccountToken,\n };\n }\n if (params.ios?.clearDataOnBackup !== undefined) {\n config['clear_data_on_backup'] = params.ios.clearDataOnBackup;\n }\n }\n\n if (this.platform.OS === 'android') {\n config['google_adid_collection_disabled'] =\n params.android?.adIdCollectionDisabled ?? false;\n config['google_enable_pending_prepaid_plans'] =\n params.android?.pendingPrepaidPlansEnabled ?? false;\n config['google_local_access_level_allowed'] =\n params.android?.localAccessLevelAllowed ?? false;\n if (params.android?.obfuscatedAccountId) {\n config['customer_identity_parameters'] = {\n obfuscated_account_id: params.android.obfuscatedAccountId,\n };\n }\n }\n\n return config;\n }\n}\n","import type { AdaptySubscriptionPeriod } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptySubscriptionPeriod;\ntype Serializable = Def['AdaptySubscriptionPeriod'];\n\nexport class AdaptySubscriptionPeriodCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n unit: { key: 'unit', required: true, type: 'string' },\n numberOfUnits: { key: 'number_of_units', required: true, type: 'number' },\n };\n}\n","import type { AdaptyPrice } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyPrice;\ntype Serializable = Def['AdaptyPrice'];\n\nexport class AdaptyPriceCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n amount: {\n key: 'amount',\n required: true,\n type: 'number',\n },\n currencyCode: {\n key: 'currency_code',\n required: false,\n type: 'string',\n },\n currencySymbol: {\n key: 'currency_symbol',\n required: false,\n type: 'string',\n },\n localizedString: {\n key: 'localized_string',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptyDiscountPhase } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptyPriceCoder } from './adapty-price';\n\ntype Model = AdaptyDiscountPhase;\ntype Serializable = Def['AdaptySubscriptionOffer.Phase'];\n\nexport class AdaptyDiscountPhaseCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n localizedNumberOfPeriods: {\n key: 'localized_number_of_periods',\n required: false,\n type: 'string',\n },\n localizedSubscriptionPeriod: {\n key: 'localized_subscription_period',\n required: false,\n type: 'string',\n },\n numberOfPeriods: {\n key: 'number_of_periods',\n required: true,\n type: 'number',\n },\n paymentMode: { key: 'payment_mode', required: true, type: 'string' },\n price: {\n key: 'price',\n required: true,\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n subscriptionPeriod: {\n key: 'subscription_period',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionPeriodCoder(),\n },\n };\n}\n","import type { Properties } from './types';\nimport type { ProductReference } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { SimpleCoder } from './coder';\n\ntype Model = ProductReference;\ntype Serializable = Def['AdaptyFlowPaywall.ProductReference'];\n\nexport class ProductReferenceCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n flowProductId: {\n key: 'flow_product_id',\n required: false,\n type: 'string',\n },\n vendorId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n adaptyId: {\n key: 'adapty_product_id',\n required: true,\n type: 'string',\n },\n accessLevelId: {\n key: 'access_level_id',\n required: true,\n type: 'string',\n },\n productType: {\n key: 'product_type',\n required: true,\n type: 'string',\n },\n ios: {\n promotionalOfferId: {\n key: 'promotional_offer_id',\n required: false,\n type: 'string',\n },\n winBackOfferId: {\n key: 'win_back_offer_id',\n required: false,\n type: 'string',\n },\n },\n android: {\n basePlanId: {\n key: 'base_plan_id',\n required: false,\n type: 'string',\n },\n offerId: {\n key: 'offer_id',\n required: false,\n type: 'string',\n },\n },\n };\n}\n","import { Converter } from './types';\n\n// Coder for Array<T>\n// Uses factory function to create coder instances (supports dependency injection)\nexport class ArrayCoder<Model, Serializable> implements Converter<\n Model[],\n Serializable[]\n> {\n constructor(\n private readonly coderFactory: () => Converter<Model, Serializable>,\n ) {}\n\n decode(input: Serializable[]): Model[] {\n const coder = this.coderFactory();\n return input.map(item => coder.decode(item));\n }\n\n encode(value: Model[]): Serializable[] {\n const coder = this.coderFactory();\n return value.map(item => coder.encode(item));\n }\n}\n","import type { AdaptyPlacement } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyPlacement;\ntype Serializable = Def['AdaptyPlacement'];\n\nexport class AdaptyPlacementCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n abTestName: { key: 'ab_test_name', required: true, type: 'string' },\n audienceName: { key: 'audience_name', required: true, type: 'string' },\n id: { key: 'developer_id', required: true, type: 'string' },\n revision: { key: 'revision', required: true, type: 'number' },\n audienceVersionId: {\n key: 'placement_audience_version_id',\n required: true,\n type: 'string',\n },\n isTrackingPurchases: {\n key: 'is_tracking_purchases',\n required: false,\n type: 'boolean',\n },\n };\n}\n","import type { AdaptyFlowPaywall, ProductReference } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { ProductReferenceCoder } from './product-reference';\nimport { ArrayCoder } from './array';\nimport { Coder } from './coder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\n\ntype Model = AdaptyFlowPaywall;\n// `products` is an internal wire-only field: it is the source for deriving\n// `productIdentifiers` on decode and is required by the native wire schema on\n// encode. It is intentionally NOT part of the public `AdaptyFlowPaywall` type,\n// but it is carried on the runtime object so encode round-trips preserve it.\ntype CodableModel = Omit<Model, 'productIdentifiers'> & {\n products?: ProductReference[];\n};\ntype Serializable = Def['AdaptyFlowPaywall'];\n\n// Wire-level properties including the internal `products` field.\n// The `as unknown as` cast is intentional: `products` is required on the wire\n// but optional in CodableModel (so that Model extends CodableModel for\n// override compatibility). The cast bridges the required/optional mismatch.\nconst PROPERTIES = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'paywall_id', required: true, type: 'string' },\n name: { key: 'paywall_name', required: true, type: 'string' },\n products: {\n key: 'products',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new ProductReferenceCoder()),\n },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n webPurchaseUrl: {\n key: 'web_purchase_url',\n required: false,\n type: 'string',\n },\n} as unknown as Properties<CodableModel, Serializable>;\n\nexport class AdaptyFlowPaywallCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = PROPERTIES;\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n // Keep `products` on the runtime object (for encode round-trip) while\n // exposing only `productIdentifiers` on the public type.\n // products is always present on the wire (required: true in PROPERTIES).\n return {\n ...codablePart,\n productIdentifiers: codablePart.products!.map(product => ({\n vendorProductId: product.vendorId,\n adaptyProductId: product.adaptyId,\n basePlanId: product.android?.basePlanId,\n })),\n } as Model;\n }\n\n override encode(data: Model): Serializable {\n // `products` is carried at runtime even though it is not on the public type.\n const { productIdentifiers, ...codablePart } = data as CodableModel &\n Pick<Model, 'productIdentifiers'>;\n return super.encode(codablePart);\n }\n}\n","import type {\n AdaptyFlowUiSchema,\n AdaptyFlowUiSchemaGrid,\n AdaptyFlowUiSchemaLayout,\n} from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Converter } from './types';\n\ntype Model = AdaptyFlowUiSchema;\ntype Serializable = NonNullable<Def['AdaptyFlow']['ui_schema']>;\ntype SerializableGrid = NonNullable<Serializable['grids'][number]>;\ntype SerializableLayout = NonNullable<Serializable['layouts'][number]>;\n\nfunction decodeLayout(json: SerializableLayout): AdaptyFlowUiSchemaLayout {\n return { flowLayoutId: json.flow_layout_id };\n}\n\nfunction encodeLayout(model: AdaptyFlowUiSchemaLayout): SerializableLayout {\n return { flow_layout_id: model.flowLayoutId };\n}\n\nfunction decodeGrid(json: SerializableGrid): AdaptyFlowUiSchemaGrid {\n return {\n ...(json.platforms !== undefined && { platforms: json.platforms }),\n ...(json.devices !== undefined && { devices: json.devices }),\n ...(json.custom_id !== undefined && { customId: json.custom_id }),\n ...(json.h_breakpoints !== undefined && {\n hBreakpoints: json.h_breakpoints,\n }),\n ...(json.v_breakpoints !== undefined && {\n vBreakpoints: json.v_breakpoints,\n }),\n cells: json.cells,\n };\n}\n\nfunction encodeGrid(model: AdaptyFlowUiSchemaGrid): SerializableGrid {\n return {\n ...(model.platforms !== undefined && { platforms: model.platforms }),\n ...(model.devices !== undefined && { devices: model.devices }),\n ...(model.customId !== undefined && { custom_id: model.customId }),\n ...(model.hBreakpoints !== undefined && {\n h_breakpoints: model.hBreakpoints,\n }),\n ...(model.vBreakpoints !== undefined && {\n v_breakpoints: model.vBreakpoints,\n }),\n cells: model.cells,\n };\n}\n\n/**\n * `ui_schema` is written by hand rather than declared through `Properties`,\n * because `platforms` and `devices` are unions of an `'all'` literal and an\n * array, and `PropertyMeta` can only carry a single runtime type per property.\n *\n * The flow is passed back to the native side (e.g. `adapty_ui_create_flow_view`),\n * so this schema has to survive a decode/encode round trip unchanged.\n */\nexport class AdaptyFlowUiSchemaCoder implements Converter<Model, Serializable> {\n decode(json: Serializable): Model {\n return {\n layouts: json.layouts.map(decodeLayout),\n grids: json.grids.map(decodeGrid),\n };\n }\n\n encode(model: Model): Serializable {\n return {\n layouts: model.layouts.map(encodeLayout),\n grids: model.grids.map(encodeGrid),\n };\n }\n}\n","import { Converter } from './types';\n\ntype Model = Record<string, unknown>;\ntype Serialized = string;\n\nexport class JSONCoder implements Converter<Model, Serialized> {\n decode(input: Serialized): Model {\n if (!input) {\n return {};\n }\n\n return JSON.parse(input) as Model;\n }\n encode(value: Model): Serialized {\n if (Object.keys(value).length === 0) {\n return '';\n }\n return JSON.stringify(value);\n }\n}\n","import type { AdaptyRemoteConfig } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { Coder } from './coder';\nimport { JSONCoder } from './json';\n\ntype Model = AdaptyRemoteConfig;\ntype CodableModel = Omit<Model, 'dataString'>;\ntype Serializable = Def['AdaptyRemoteConfig'];\n\nexport class AdaptyRemoteConfigCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = {\n data: {\n key: 'data',\n required: true,\n type: 'string' as any,\n converter: new JSONCoder(),\n },\n lang: {\n key: 'lang',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n const dataString = JSON.stringify(codablePart.data);\n return {\n ...codablePart,\n dataString: dataString.length < 4 ? '' : dataString,\n };\n }\n\n override encode(data: Model): Serializable {\n const { dataString, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import type { AdaptyFlow } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { ArrayCoder } from './array';\nimport { Coder } from './coder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptyFlowPaywallCoder } from './adapty-flow-paywall';\nimport { AdaptyFlowUiSchemaCoder } from './adapty-flow-ui-schema';\n\ntype Model = AdaptyFlow;\n// `hasViewConfiguration` is derived on decode and is not part of the wire\n// schema, so it must be stripped before encoding the flow back to native.\ntype CodableModel = Omit<Model, 'hasViewConfiguration'>;\ntype Serializable = Def['AdaptyFlow'];\n\nexport class AdaptyFlowCoder extends Coder<Model, CodableModel, Serializable> {\n protected properties: Properties<CodableModel, Serializable> = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'flow_id', required: true, type: 'string' },\n name: { key: 'flow_name', required: true, type: 'string' },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n remoteConfigs: {\n key: 'remote_configs',\n required: false,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyRemoteConfigCoder()),\n },\n flowVersionId: {\n key: 'flow_version_id',\n required: false,\n type: 'string',\n },\n paywalls: {\n key: 'variations',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyFlowPaywallCoder()),\n },\n uiSchema: {\n key: 'ui_schema',\n required: false,\n type: 'object',\n converter: new AdaptyFlowUiSchemaCoder(),\n },\n responseCreatedAt: {\n key: 'response_created_at',\n required: true,\n type: 'number',\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n\n return {\n ...codablePart,\n hasViewConfiguration:\n codablePart.flowVersionId !== undefined &&\n codablePart.uiSchema !== undefined,\n };\n }\n\n override encode(data: Model): Serializable {\n const { hasViewConfiguration, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\n\ntype Model = Input.IdentifyParamsInput;\ntype Serializable = {\n app_account_token?: string;\n obfuscated_account_id?: string;\n obfuscated_profile_id?: string;\n};\n\nexport class AdaptyIdentifyParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(params?: Model): Serializable | undefined {\n if (!params) {\n return undefined;\n }\n\n const result: Serializable = {};\n\n if (this.platform.OS === 'ios' && params.ios?.appAccountToken) {\n result.app_account_token = params.ios.appAccountToken;\n }\n\n if (this.platform.OS === 'android' && params.android?.obfuscatedAccountId) {\n result.obfuscated_account_id = params.android.obfuscatedAccountId;\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n }\n}\n","import { AdaptyInstallationDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { Converter } from './types';\nimport { DateCoder } from './date';\n\nexport class AdaptyInstallationDetailsCoder implements Converter<\n AdaptyInstallationDetails,\n Def['AdaptyInstallationDetails']\n> {\n encode(model: AdaptyInstallationDetails): Def['AdaptyInstallationDetails'] {\n const result: Def['AdaptyInstallationDetails'] = {\n install_time: new DateCoder().encode(model.installTime),\n app_launch_count: model.appLaunchCount,\n };\n\n if (model.installId) {\n result.install_id = model.installId;\n }\n\n if (model.payload) {\n result.payload = model.payload;\n }\n\n return result;\n }\n\n decode(json: Def['AdaptyInstallationDetails']): AdaptyInstallationDetails {\n return {\n installTime: new DateCoder().decode(json.install_time),\n appLaunchCount: json.app_launch_count,\n installId: json.install_id,\n payload: json.payload,\n };\n }\n}\n","import { AdaptyInstallationStatus, AdaptyInstallationDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { Converter } from './types';\nimport { DateCoder } from './date';\n\nexport class AdaptyInstallationStatusCoder implements Converter<\n AdaptyInstallationStatus,\n Def['AdaptyInstallationStatus']\n> {\n encode(model: AdaptyInstallationStatus): Def['AdaptyInstallationStatus'] {\n if (model.status === 'determined') {\n const details: Def['AdaptyInstallationDetails'] = {\n install_time: new DateCoder().encode(model.details.installTime),\n app_launch_count: model.details.appLaunchCount,\n };\n\n if (model.details.installId) {\n details.install_id = model.details.installId;\n }\n\n if (model.details.payload) {\n details.payload = model.details.payload;\n }\n\n return {\n status: 'determined',\n details,\n };\n }\n\n return {\n status: model.status,\n };\n }\n\n decode(json: Def['AdaptyInstallationStatus']): AdaptyInstallationStatus {\n if (json.status === 'determined') {\n const details: AdaptyInstallationDetails = {\n installTime: new DateCoder().decode(json.details.install_time),\n appLaunchCount: json.details.app_launch_count,\n installId: json.details.install_id,\n payload: json.details.payload,\n };\n\n return {\n status: 'determined',\n details,\n };\n }\n\n return {\n status: json.status,\n };\n }\n}\n","import type { AdaptyNativeError } from '@/types/bridge';\nimport type { ErrorConverter } from './error-coder';\nimport type { Properties } from './types';\nimport type { Def } from '@/types/schema';\nimport { SimpleCoder } from './coder';\nimport { AdaptyError } from '@/adapty-error';\n\ntype Model = AdaptyNativeError;\ntype Serializable = Def['AdaptyError'];\n\nexport class AdaptyNativeErrorCoder\n extends SimpleCoder<Model, Serializable>\n implements ErrorConverter<Model>\n{\n public type: 'error' = 'error';\n\n protected properties: Properties<Model, Serializable> = {\n adaptyCode: { key: 'adapty_code', required: true, type: 'number' },\n message: { key: 'message', required: true, type: 'string' },\n detail: { key: 'detail', required: false, type: 'string' },\n };\n\n public getError(data: Model): AdaptyError {\n return new AdaptyError({\n adaptyCode: data.adaptyCode as AdaptyError['adaptyCode'],\n message: data.message,\n detail: data.detail,\n });\n }\n}\n","import type { AdaptyNonSubscription } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptyNonSubscription;\ntype Serializable = Def['AdaptyProfile.NonSubscription'];\n\nexport class AdaptyNonSubscriptionCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n isConsumable: { key: 'is_consumable', required: true, type: 'boolean' },\n isRefund: { key: 'is_refund', required: true, type: 'boolean' },\n isSandbox: { key: 'is_sandbox', required: true, type: 'boolean' },\n purchasedAt: {\n key: 'purchased_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n purchaseId: { key: 'purchase_id', required: true, type: 'string' },\n store: { key: 'store', required: true, type: 'string' },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n vendorTransactionId: {\n key: 'vendor_transaction_id',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptyOnboardingBuilder } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyOnboardingBuilder;\ntype Serializable = Required<Def['AdaptyOnboarding']>['onboarding_builder'];\n\nexport class AdaptyOnboardingBuilderCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n url: {\n key: 'config_url',\n required: true,\n type: 'string',\n },\n };\n}\n","import type { AdaptyOnboarding } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { Coder } from './coder';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptyOnboardingBuilderCoder } from './adapty-onboarding-builder';\nimport { AdaptyPlacementCoder } from '@/coders/adapty-placement';\n\ntype Model = AdaptyOnboarding;\ntype CodableModel = Omit<Model, 'hasViewConfiguration'>;\ntype Serializable = Def['AdaptyOnboarding'];\n\nexport class AdaptyOnboardingCoder extends Coder<\n Model,\n CodableModel,\n Serializable\n> {\n protected properties: Properties<CodableModel, Serializable> = {\n placement: {\n key: 'placement',\n required: true,\n type: 'object',\n converter: new AdaptyPlacementCoder(),\n },\n id: { key: 'onboarding_id', required: true, type: 'string' },\n name: { key: 'onboarding_name', required: true, type: 'string' },\n remoteConfig: {\n key: 'remote_config',\n required: false,\n type: 'object',\n converter: new AdaptyRemoteConfigCoder(),\n },\n variationId: { key: 'variation_id', required: true, type: 'string' },\n version: { key: 'response_created_at', required: false, type: 'number' },\n onboardingBuilder: {\n key: 'onboarding_builder',\n required: true,\n type: 'object',\n converter: new AdaptyOnboardingBuilderCoder(),\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n requestLocale: { key: 'request_locale', required: true, type: 'string' },\n };\n\n override decode(data: Serializable): Model {\n const codablePart = super.decode(data);\n return {\n ...codablePart,\n hasViewConfiguration: codablePart.onboardingBuilder !== undefined,\n };\n }\n\n override encode(data: Model): Serializable {\n const { hasViewConfiguration, ...codablePart } = data;\n return super.encode(codablePart);\n }\n}\n","import { AdaptySubscriptionOfferId } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptySubscriptionOfferId;\ntype Serializable = Def['AdaptySubscriptionOffer.Identifier'];\n\nexport class AdaptySubscriptionOfferIdCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n type: {\n key: 'type',\n required: true,\n type: 'string',\n },\n id: {\n key: 'id',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { AdaptySubscriptionOffer } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionOfferIdCoder } from '@/coders/adapty-subscription-offer-identifier';\nimport { ArrayCoder } from '@/coders/array';\nimport { AdaptyDiscountPhaseCoder } from '@/coders/adapty-discount-phase';\n\ntype Model = AdaptySubscriptionOffer;\ntype Serializable = Def['AdaptySubscriptionOffer'];\n\nexport class AdaptySubscriptionOfferCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n identifier: {\n key: 'offer_identifier',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionOfferIdCoder(),\n },\n phases: {\n key: 'phases',\n required: true,\n type: 'array',\n converter: new ArrayCoder(() => new AdaptyDiscountPhaseCoder()),\n },\n android: {\n offerTags: {\n key: 'offer_tags',\n required: false,\n type: 'array',\n },\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n if (!data.offer_tags) {\n const { android, ...partialData } = baseResult;\n return partialData;\n }\n return baseResult;\n }\n}\n","import type { AdaptySubscriptionDetails } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptySubscriptionOfferCoder } from '@/coders/adapty-subscription-offer';\n\ntype Model = AdaptySubscriptionDetails;\ntype Serializable = Def['AdaptyProduct.Subscription'];\n\nexport class AdaptySubscriptionDetailsCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n subscriptionPeriod: {\n key: 'period',\n required: true,\n type: 'object',\n converter: new AdaptySubscriptionPeriodCoder(),\n },\n localizedSubscriptionPeriod: {\n key: 'localized_period',\n required: false,\n type: 'string',\n },\n offer: {\n key: 'offer',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionOfferCoder(),\n },\n ios: {\n subscriptionGroupIdentifier: {\n key: 'group_identifier',\n required: false,\n type: 'string',\n },\n },\n android: {\n basePlanId: {\n key: 'base_plan_id',\n required: true,\n type: 'string',\n },\n renewalType: {\n key: 'renewal_type',\n required: false,\n type: 'string',\n },\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n const propToRemove = data.base_plan_id ? 'ios' : 'android';\n const { [propToRemove]: _, ...partialData } = baseResult;\n return partialData;\n }\n}\n","import type { AdaptyPaywallProduct } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\n\ntype Model = AdaptyPaywallProduct;\ntype Serializable = Def['AdaptyPaywallProduct.Response'];\n\nexport class AdaptyPaywallProductCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n adaptyId: {\n key: 'adapty_product_id',\n required: true,\n type: 'string',\n },\n paywallProductIndex: {\n key: 'paywall_product_index',\n required: true,\n type: 'number',\n },\n localizedDescription: {\n key: 'localized_description',\n required: true,\n type: 'string',\n },\n localizedTitle: { key: 'localized_title', required: true, type: 'string' },\n regionCode: { key: 'region_code', required: false, type: 'string' },\n variationId: {\n key: 'paywall_variation_id',\n required: true,\n type: 'string',\n },\n paywallABTestName: {\n key: 'paywall_ab_test_name',\n required: true,\n type: 'string',\n },\n paywallName: { key: 'paywall_name', required: true, type: 'string' },\n accessLevelId: { key: 'access_level_id', required: true, type: 'string' },\n productType: { key: 'product_type', required: true, type: 'string' },\n price: {\n key: 'price',\n required: false, // Native SDKs require this\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n webPurchaseUrl: {\n key: 'web_purchase_url',\n required: false,\n type: 'string',\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n subscription: {\n key: 'subscription',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionDetailsCoder(),\n },\n ios: {\n isFamilyShareable: {\n key: 'is_family_shareable',\n required: true,\n type: 'boolean',\n },\n },\n };\n\n public getInput(data: Serializable): Def['AdaptyPaywallProduct.Request'] {\n return {\n adapty_product_id: data.adapty_product_id,\n access_level_id: data.access_level_id,\n product_type: data.product_type,\n paywall_product_index: data.paywall_product_index,\n paywall_ab_test_name: data.paywall_ab_test_name,\n payload_data: data.payload_data,\n paywall_name: data.paywall_name,\n paywall_variation_id: data.paywall_variation_id,\n subscription: data.subscription?.offer\n ? {\n offer: {\n offer_identifier: data.subscription.offer.offer_identifier,\n },\n }\n : undefined,\n vendor_product_id: data.vendor_product_id,\n };\n }\n}\n","import type { AdaptyPromotedProduct } from '@/types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\n\ntype Model = AdaptyPromotedProduct;\ntype Serializable = Def['AdaptyPromotedProduct.Response'];\n\nexport class AdaptyPromotedProductCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n localizedDescription: {\n key: 'localized_description',\n required: true,\n type: 'string',\n },\n localizedTitle: { key: 'localized_title', required: true, type: 'string' },\n regionCode: { key: 'region_code', required: false, type: 'string' },\n price: {\n key: 'price',\n required: false, // Native SDKs require this\n type: 'object',\n converter: new AdaptyPriceCoder(),\n },\n payloadData: { key: 'payload_data', required: false, type: 'string' },\n subscription: {\n key: 'subscription',\n required: false,\n type: 'object',\n converter: new AdaptySubscriptionDetailsCoder(),\n },\n ios: {\n isFamilyShareable: {\n key: 'is_family_shareable',\n required: true,\n type: 'boolean',\n },\n },\n };\n\n public getInput(data: Serializable): Def['AdaptyPromotedProduct.Request'] {\n return {\n vendor_product_id: data.vendor_product_id,\n payload_data: data.payload_data,\n subscription: data.subscription?.offer\n ? {\n offer: {\n offer_identifier: data.subscription.offer.offer_identifier,\n },\n }\n : undefined,\n };\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport type { AdaptyProfileParameters } from '@/types';\nimport { SimpleCoder } from './coder';\n\ntype Model = AdaptyProfileParameters;\ntype Serializable = Def['AdaptyProfileParameters'];\n\nexport class AdaptyProfileParametersCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n firstName: { key: 'first_name', required: false, type: 'string' },\n lastName: { key: 'last_name', required: false, type: 'string' },\n gender: { key: 'gender', required: false, type: 'string' },\n birthday: { key: 'birthday', required: false, type: 'string' },\n email: { key: 'email', required: false, type: 'string' },\n phoneNumber: { key: 'phone_number', required: false, type: 'string' },\n appTrackingTransparencyStatus: {\n key: 'att_status',\n required: false,\n type: 'number',\n },\n codableCustomAttributes: {\n key: 'custom_attributes',\n required: false,\n type: 'object',\n },\n analyticsDisabled: {\n key: 'analytics_disabled',\n required: false,\n type: 'boolean',\n },\n };\n}\n","import type { AdaptySubscription } from '../types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { DateCoder } from './date';\n\ntype Model = AdaptySubscription;\ntype Serializable = Def['AdaptyProfile.Subscription'];\n\nexport class AdaptySubscriptionCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n isActive: {\n key: 'is_active',\n required: true,\n type: 'boolean',\n },\n isLifetime: {\n key: 'is_lifetime',\n required: true,\n type: 'boolean',\n },\n vendorProductId: {\n key: 'vendor_product_id',\n required: true,\n type: 'string',\n },\n store: {\n key: 'store',\n required: true,\n type: 'string',\n },\n vendorTransactionId: {\n key: 'vendor_transaction_id',\n required: true,\n type: 'string',\n },\n vendorOriginalTransactionId: {\n key: 'vendor_original_transaction_id',\n required: true,\n type: 'string',\n },\n activatedAt: {\n key: 'activated_at',\n required: true,\n type: 'string',\n converter: new DateCoder(),\n },\n willRenew: {\n key: 'will_renew',\n required: true,\n type: 'boolean',\n },\n isInGracePeriod: {\n key: 'is_in_grace_period',\n required: true,\n type: 'boolean',\n },\n isRefund: {\n key: 'is_refund',\n required: true,\n type: 'boolean',\n },\n isSandbox: {\n key: 'is_sandbox',\n required: true,\n type: 'boolean',\n },\n renewedAt: {\n key: 'renewed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n expiresAt: {\n key: 'expires_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n startsAt: {\n key: 'starts_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n unsubscribedAt: {\n key: 'unsubscribed_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n billingIssueDetectedAt: {\n key: 'billing_issue_detected_at',\n required: false,\n type: 'string',\n converter: new DateCoder(),\n },\n activeIntroductoryOfferType: {\n key: 'active_introductory_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferType: {\n key: 'active_promotional_offer_type',\n required: false,\n type: 'string',\n },\n activePromotionalOfferId: {\n key: 'active_promotional_offer_id',\n required: false,\n type: 'string',\n },\n cancellationReason: {\n key: 'cancellation_reason',\n required: false,\n type: 'string',\n },\n };\n}\n","import type { Converter } from './types';\n\n// Coder for Record<string, T>\nexport class HashmapCoder<T extends Converter<any, any>> implements Converter<\n Record<string, ReturnType<T['decode']>>,\n Record<string, any>\n> {\n private coder: T | null;\n\n constructor(coder: T | null) {\n this.coder = coder;\n }\n\n decode(\n input: Record<string, unknown>,\n ): Record<string, ReturnType<T['decode']>> {\n const result: Record<string, any> = {};\n\n Object.keys(input).forEach(key => {\n const property = input[key as string];\n\n result[key] = this.coder?.decode(property) ?? property;\n });\n\n return result;\n }\n\n encode(value: Record<string, any>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n const property = value[key as string];\n result[key] = this.coder?.encode(property) ?? property;\n });\n\n return result;\n }\n}\n","import type { AdaptyProfile } from '../types';\nimport type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyAccessLevelCoder } from './adapty-access-level';\nimport { AdaptyNonSubscriptionCoder } from './adapty-non-subscription';\nimport { AdaptySubscriptionCoder } from './adapty-subscription';\nimport { HashmapCoder } from './hashmap';\nimport { ArrayCoder } from './array';\n\ntype Model = AdaptyProfile;\ntype Serializable = Def['AdaptyProfile'];\n\nexport class AdaptyProfileCoder extends SimpleCoder<Model, Serializable> {\n protected properties: Properties<Model, Serializable> = {\n accessLevels: {\n key: 'paid_access_levels',\n required: false,\n type: 'object',\n converter: new HashmapCoder(new AdaptyAccessLevelCoder()),\n },\n appliedExternalAttributionProviders: {\n key: 'applied_attribution_sources',\n required: false,\n type: 'array',\n },\n customAttributes: {\n key: 'custom_attributes',\n required: false,\n type: 'object',\n },\n customerUserId: {\n key: 'customer_user_id',\n required: false,\n type: 'string',\n },\n nonSubscriptions: {\n key: 'non_subscriptions',\n required: false,\n type: 'object',\n converter: new HashmapCoder(\n new ArrayCoder(() => new AdaptyNonSubscriptionCoder()),\n ),\n },\n profileId: {\n key: 'profile_id',\n required: true,\n type: 'string',\n },\n subscriptions: {\n key: 'subscriptions',\n required: false,\n type: 'object',\n converter: new HashmapCoder(new AdaptySubscriptionCoder()),\n },\n };\n}\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport * as Input from '@/types/inputs';\n\ntype Model = Input.MakePurchaseParamsInput;\ntype Serializable = Record<string, unknown>;\n\nexport class AdaptyPurchaseParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(data: Model): Serializable {\n if (this.platform.OS !== 'android') {\n return {};\n }\n\n const purchaseParams: Serializable = {};\n\n if (data.android) {\n if (data.android.subscriptionUpdateParams) {\n purchaseParams['subscription_update_params'] = {\n replacement_mode: data.android.subscriptionUpdateParams.prorationMode,\n old_sub_vendor_product_id:\n data.android.subscriptionUpdateParams.oldSubVendorProductId,\n };\n }\n\n if (data.android.isOfferPersonalized !== undefined) {\n purchaseParams['is_offer_personalized'] =\n data.android.isOfferPersonalized;\n }\n }\n\n return purchaseParams;\n }\n}\n","import type { AdaptyPurchaseResult } from '@/types';\nimport type { Def } from '@/types/schema';\nimport { AdaptyProfileCoder } from '@/coders/adapty-profile';\nimport { SimpleCoder } from './coder';\nimport type { Properties } from './types';\n\ntype Model = AdaptyPurchaseResult;\ntype Serializable = Def['AdaptyPurchaseResult'];\n\nexport class AdaptyPurchaseResultCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n type: {\n key: 'type',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): Model {\n const baseResult = super.decode(data);\n if (baseResult.type === 'success') {\n if (!data.profile) {\n throw new Error(\n 'Profile is required for success type of purchase result',\n );\n }\n return {\n ...baseResult,\n profile: new AdaptyProfileCoder(this.platform).decode(data.profile),\n ...(this.platform.OS === 'ios' && data.apple_jws_transaction\n ? { ios: { jwsTransaction: data.apple_jws_transaction } }\n : {}),\n ...(this.platform.OS === 'android' && data.google_purchase_token\n ? { android: { purchaseToken: data.google_purchase_token } }\n : {}),\n };\n }\n return baseResult;\n }\n\n override encode(data: Model): Serializable {\n const { type } = data;\n\n if (type === 'success') {\n if (!('profile' in data)) {\n throw new Error(\n 'Profile is required for success type of purchase result',\n );\n }\n\n return {\n type: 'success',\n profile: new AdaptyProfileCoder(this.platform).encode(data.profile),\n ...(this.platform.OS === 'ios' && data.ios?.jwsTransaction\n ? { apple_jws_transaction: data.ios.jwsTransaction }\n : {}),\n ...(this.platform.OS === 'android' && data.android?.purchaseToken\n ? { google_purchase_token: data.android.purchaseToken }\n : {}),\n };\n }\n\n return super.encode({ type });\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiDialogConfig } from '@/ui-builder/types';\n\ntype Model = AdaptyUiDialogConfig;\ntype Serializable = Def['AdaptyUI.DialogConfiguration'];\n\nexport class AdaptyUiDialogConfigCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n primaryActionTitle: {\n key: 'default_action_title',\n required: true,\n type: 'string',\n },\n secondaryActionTitle: {\n key: 'secondary_action_title',\n required: false,\n type: 'string',\n },\n title: {\n key: 'title',\n required: false,\n type: 'string',\n },\n content: {\n key: 'content',\n required: false,\n type: 'string',\n },\n };\n}\n","import { CreateOnboardingViewParamsInput } from '@/ui-builder/types';\nimport { Req } from '@/types/schema';\n\ntype Serializable = Pick<\n Req['AdaptyUICreateOnboardingView.Request'],\n 'external_urls_presentation'\n>;\n\nexport class AdaptyUICreateOnboardingViewParamsCoder {\n encode(data: CreateOnboardingViewParamsInput): Serializable {\n const result: Serializable = {};\n\n if (data.externalUrlsPresentation) {\n result.external_urls_presentation = data.externalUrlsPresentation;\n }\n\n return result;\n }\n}\n","export const formatDateUTC = (date: Date): string => {\n const pad = (num: number, digits: number = 2): string => {\n const str = num.toString();\n const paddingLength = digits - str.length;\n return paddingLength > 0 ? '0'.repeat(paddingLength) + str : str;\n };\n\n const year = date.getUTCFullYear();\n const month = pad(date.getUTCMonth() + 1);\n const day = pad(date.getUTCDate());\n const hours = pad(date.getUTCHours());\n const minutes = pad(date.getUTCMinutes());\n const seconds = pad(date.getUTCSeconds());\n const millis = pad(date.getUTCMilliseconds(), 3);\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${millis}Z`;\n};\n\nexport const colorToHex = {\n fromARGB(value: number): string {\n const hex = value.toString(16).padStart(8, '0');\n return `#${hex.slice(2)}${hex.slice(0, 2)}`;\n },\n fromRGBA(value: number): string {\n return `#${value.toString(16).padStart(8, '0')}`;\n },\n fromRGB(value: number): string {\n return `#${value.toString(16).padStart(6, '0')}ff`;\n },\n};\n\nexport const extractBase64Data = (input: string): string => {\n const commaIndex = input.indexOf(',');\n if (input.startsWith('data:') && commaIndex !== -1) {\n return input.slice(commaIndex + 1);\n }\n return input;\n};\n\nimport type { FileLocation } from '@/types/inputs';\nimport type { PlatformOS } from '@/adapters/interfaces';\n\nexport const resolveAssetId = (\n asset: { relativeAssetPath: string } | { fileLocation: FileLocation },\n platformOS: PlatformOS,\n): string => {\n if ('relativeAssetPath' in asset) {\n return platformOS === 'android'\n ? `${asset.relativeAssetPath}a`\n : asset.relativeAssetPath;\n }\n\n const fileLocation = asset.fileLocation;\n if (platformOS === 'android') {\n return 'relativeAssetPath' in fileLocation.android\n ? `${fileLocation.android.relativeAssetPath}a`\n : `${(fileLocation.android as { rawResName: string }).rawResName}r`;\n }\n\n return fileLocation.ios.fileName;\n};\n","import type { IPlatformAdapter } from '@/adapters/interfaces';\nimport type {\n CreateFlowViewParamsInput,\n AdaptyCustomAsset,\n} from '@/ui-builder/types';\nimport type { FileLocation } from '@/types/inputs';\nimport type { Def } from '@/types/schema';\nimport { AdaptyPurchaseParamsCoder } from './adapty-purchase-params';\nimport {\n colorToHex,\n extractBase64Data,\n formatDateUTC,\n resolveAssetId,\n} from './utils';\n\ntype Model = CreateFlowViewParamsInput;\ntype Serializable = {\n locale?: Def['AdaptyLocale'];\n custom_layout_id?: string;\n preload_products?: boolean;\n load_timeout?: number;\n custom_tags?: Def['AdaptyUI.CustomTagsValues'];\n custom_timers?: Def['AdaptyUI.CustomTimersValues'];\n custom_assets?: Def['AdaptyUI.CustomAssets'];\n product_purchase_parameters?: Def['AdaptyUI.ProductPurchaseParameters'];\n enable_safe_area_paddings?: boolean;\n};\n\nexport class AdaptyUICreateFlowViewParamsCoder {\n constructor(private readonly platform: IPlatformAdapter) {}\n\n encode(data: Model): Serializable {\n const result: Serializable = {};\n\n if (data.locale !== undefined) {\n result.locale = data.locale;\n }\n\n if (data.customLayoutId !== undefined) {\n result.custom_layout_id = data.customLayoutId;\n }\n\n if (data.prefetchProducts !== undefined) {\n result.preload_products = data.prefetchProducts;\n }\n\n if (data.android?.enableSafeArea !== undefined) {\n result.enable_safe_area_paddings = data.android.enableSafeArea;\n }\n\n if (data.loadTimeoutMs !== undefined) {\n result.load_timeout = data.loadTimeoutMs / 1000;\n }\n\n if (data.customTags) {\n result.custom_tags = data.customTags;\n }\n\n if (data.customTimers) {\n result.custom_timers = this.encodeCustomTimers(data.customTimers);\n }\n\n if (data.customAssets) {\n result.custom_assets = this.encodeCustomAssets(data.customAssets);\n }\n\n if (data.productPurchaseParams) {\n result.product_purchase_parameters = this.encodeProductPurchaseParams(\n data.productPurchaseParams,\n );\n }\n\n return result;\n }\n\n private encodeCustomTimers(\n timers: Record<string, Date>,\n ): Def['AdaptyUI.CustomTimersValues'] {\n const result: Record<string, string> = {};\n for (const key in timers) {\n if (timers.hasOwnProperty(key)) {\n const date = timers[key];\n if (date instanceof Date) {\n result[key] = formatDateUTC(date);\n }\n }\n }\n return result;\n }\n\n private encodeCustomAssets(\n assets: Record<string, AdaptyCustomAsset>,\n ): Def['AdaptyUI.CustomAssets'] {\n const getAssetId = (\n asset: { relativeAssetPath: string } | { fileLocation: FileLocation },\n ): string => {\n return resolveAssetId(asset, this.platform.OS) || '';\n };\n\n return Object.entries(assets)\n .map(([id, asset]): Def['AdaptyUI.CustomAssets'][number] | undefined => {\n switch (asset.type) {\n case 'image':\n return 'base64' in asset\n ? {\n id,\n type: 'image',\n value: extractBase64Data(asset.base64),\n }\n : {\n id,\n type: 'image',\n asset_id: getAssetId(asset),\n };\n\n case 'video':\n return {\n id,\n type: 'video',\n asset_id: getAssetId(asset),\n };\n\n case 'color':\n let value: string;\n\n if ('argb' in asset) {\n value = colorToHex.fromARGB(asset.argb);\n } else if ('rgba' in asset) {\n value = colorToHex.fromRGBA(asset.rgba);\n } else if ('rgb' in asset) {\n value = colorToHex.fromRGB(asset.rgb);\n } else {\n return undefined;\n }\n\n return {\n id,\n type: 'color',\n value,\n };\n\n case 'linear-gradient':\n const { values, points = {} } = asset;\n const { x0 = 0, y0 = 0, x1 = 1, y1 = 0 } = points;\n\n const colorStops = values\n .map(({ p, ...colorInput }) => {\n let color: string;\n\n if ('argb' in colorInput) {\n color = colorToHex.fromARGB(colorInput.argb);\n } else if ('rgba' in colorInput) {\n color = colorToHex.fromRGBA(colorInput.rgba);\n } else if ('rgb' in colorInput) {\n color = colorToHex.fromRGB(colorInput.rgb);\n } else {\n return undefined;\n }\n\n return { color, p };\n })\n .filter(\n (v): v is { color: string; p: number } => v !== undefined,\n );\n\n if (colorStops.length !== values.length) return undefined;\n\n return {\n id,\n type: 'linear-gradient',\n values: colorStops,\n points: { x0, y0, x1, y1 },\n };\n\n default:\n return undefined;\n }\n })\n .filter(\n (item): item is Def['AdaptyUI.CustomAssets'][number] =>\n item !== undefined,\n );\n }\n\n private encodeProductPurchaseParams(\n params: CreateFlowViewParamsInput['productPurchaseParams'],\n ): Def['AdaptyUI.ProductPurchaseParameters'] {\n if (!params) return {};\n\n const purchaseParamsCoder = new AdaptyPurchaseParamsCoder(this.platform);\n return Object.fromEntries(\n params.map(({ productId, params }) => [\n productId.adaptyProductId,\n purchaseParamsCoder.encode(params),\n ]),\n );\n }\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiOnboardingMeta } from '@/ui-builder/types';\n\ntype Model = AdaptyUiOnboardingMeta;\ntype Serializable = Def['AdaptyUI.OnboardingMeta'];\n\nexport class AdaptyUiOnboardingMetaCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n onboardingId: {\n key: 'onboarding_id',\n required: true,\n type: 'string',\n },\n screenClientId: {\n key: 'screen_cid',\n required: true,\n type: 'string',\n },\n screenIndex: {\n key: 'screen_index',\n required: true,\n type: 'number',\n },\n totalScreens: {\n key: 'total_screens',\n required: true,\n type: 'number',\n },\n };\n}\n","import type { Def } from '@/types/schema';\nimport type { Properties } from './types';\nimport { SimpleCoder } from './coder';\nimport { AdaptyUiOnboardingStateParams } from '@/ui-builder/types';\n\ntype Model = AdaptyUiOnboardingStateParams;\ntype Serializable = Def['AdaptyUI.OnboardingsStateParams'];\n\nexport class AdaptyUiOnboardingStateParamsCoder extends SimpleCoder<\n Model,\n Serializable\n> {\n protected properties: Properties<Model, Serializable> = {\n id: {\n key: 'id',\n required: true,\n type: 'string',\n },\n value: {\n key: 'value',\n required: true,\n type: 'string',\n },\n label: {\n key: 'label',\n required: true,\n type: 'string',\n },\n };\n}\n","import type { Def, Event } from '@/types/schema';\nimport type { OnboardingStateUpdatedAction } from '@/ui-builder/types';\nimport { SimpleCoder } from './coder';\nimport type { Properties } from './types';\nimport { AdaptyUiOnboardingStateParamsCoder } from './adapty-ui-onboarding-state-params';\n\ntype Model = OnboardingStateUpdatedAction;\ntype BaseModel = Omit<Model, 'value'>;\ntype Serializable = Event['OnboardingViewEvent.OnStateUpdatedAction']['action'];\ntype SerializableStateParam = Def['AdaptyUI.OnboardingsStateParams'];\n\nexport class AdaptyUiOnboardingStateUpdatedActionCoder extends SimpleCoder<\n BaseModel,\n Serializable\n> {\n private readonly paramCoder = new AdaptyUiOnboardingStateParamsCoder();\n\n protected properties: Properties<BaseModel, Serializable> = {\n elementId: {\n key: 'element_id',\n required: true,\n type: 'string',\n },\n elementType: {\n key: 'element_type',\n required: true,\n type: 'string',\n },\n };\n\n override decode(data: Serializable): OnboardingStateUpdatedAction {\n const base = super.decode(data);\n const { elementType } = base;\n\n switch (elementType) {\n case 'select':\n return {\n ...base,\n elementType: 'select',\n value: this.paramCoder.decode(data.value as SerializableStateParam),\n };\n case 'multi_select':\n return {\n ...base,\n elementType: 'multi_select',\n value: Array.isArray(data.value)\n ? data.value.map(v => this.paramCoder.decode(v))\n : [],\n };\n case 'input':\n return {\n ...base,\n elementType: 'input',\n value: data.value as\n | { type: 'text' | 'email'; value: string }\n | { type: 'number'; value: number },\n };\n case 'date_picker':\n return {\n ...base,\n elementType: 'date_picker',\n value: data.value as { day?: number; month?: number; year?: number },\n };\n default:\n throw new Error(`Unknown element_type: ${elementType}`);\n }\n }\n\n override encode(data: OnboardingStateUpdatedAction): Serializable {\n const base = super.encode(data);\n const { elementType } = data;\n switch (elementType) {\n case 'select':\n return {\n ...base,\n element_type: 'select',\n value: this.paramCoder.encode(data.value),\n };\n case 'multi_select':\n return {\n ...base,\n element_type: 'multi_select',\n value: data.value.map(v => this.paramCoder.encode(v)),\n };\n case 'input':\n return {\n ...base,\n element_type: 'input',\n value: data.value,\n };\n case 'date_picker':\n return {\n ...base,\n element_type: 'date_picker',\n value: data.value,\n };\n default:\n throw new Error(`Unknown elementType: ${elementType}`);\n }\n }\n}\n","import { AdaptyBridgeError } from '@/types/bridge';\nimport { SimpleCoder } from './coder';\nimport { Properties } from './types';\nimport { ErrorConverter } from './error-coder';\nimport { AdaptyError } from '@/adapty-error';\n\ntype Model = AdaptyBridgeError;\ntype Serializable = Record<string, any>;\n\nexport class BridgeErrorCoder\n extends SimpleCoder<Model, Serializable>\n implements ErrorConverter<Model>\n{\n public type: 'error' = 'error';\n\n protected properties: Properties<Model, Serializable> = {\n errorType: {\n key: 'error_type',\n required: true,\n type: 'string',\n },\n name: {\n key: 'name',\n required: false,\n type: 'string',\n },\n type: {\n key: 'type',\n required: false,\n type: 'string',\n },\n underlyingError: {\n key: 'parent_error',\n required: false,\n type: 'string',\n },\n description: {\n key: 'description',\n required: false,\n type: 'string',\n },\n };\n\n public getError(data: Model): AdaptyError {\n switch (data.errorType) {\n case 'missingRequiredArgument':\n return new AdaptyError({\n adaptyCode: 3001,\n message: `Required parameter \"${data.name} was not passed to a native module\"`,\n });\n case 'typeMismatch':\n return new AdaptyError({\n adaptyCode: 3001,\n message: `Passed parameter \"${data.name}\" has invalid type. Expected type: ${data.type}\"`,\n });\n case 'encodingFailed':\n return new AdaptyError({\n adaptyCode: 2009,\n message: `Bridge layer failed to encode response. Bridge error: ${JSON.stringify(\n data.underlyingError ?? {},\n )}\"`,\n });\n case 'wrongParam':\n case 'WRONG_PARAMETER':\n return new AdaptyError({\n adaptyCode: 3001,\n message:\n data.name ??\n `Wrong parameter. Bridge error: ${JSON.stringify(\n data.underlyingError ?? {},\n )}\"`,\n });\n case 'methodNotImplemented':\n return new AdaptyError({\n adaptyCode: 2003,\n message: 'Requested bridge handle not found',\n });\n case 'unsupportedIosVersion':\n return new AdaptyError({\n adaptyCode: 2003,\n message: 'Unsupported iOS version',\n });\n case 'unexpectedError':\n default:\n return new AdaptyError({\n adaptyCode: 0,\n message: `Unexpected error occurred: ${JSON.stringify(\n data.underlyingError ?? {},\n )}`,\n });\n }\n }\n}\n","import type {\n IPlatformAdapter,\n ISdkMetadataAdapter,\n ILoggerAdapter,\n} from '@/adapters/interfaces';\nimport { AdaptyAccessLevelCoder } from './adapty-access-level';\nimport { AdaptyConfigurationCoder } from './adapty-configuration';\nimport { AdaptyDiscountPhaseCoder } from './adapty-discount-phase';\nimport { AdaptyFlowPaywallCoder } from './adapty-flow-paywall';\nimport { AdaptyFlowUiSchemaCoder } from './adapty-flow-ui-schema';\nimport { AdaptyFlowCoder } from './adapty-flow';\nimport { AdaptyIdentifyParamsCoder } from './adapty-identify-params';\nimport { AdaptyInstallationDetailsCoder } from './adapty-installation-details';\nimport { AdaptyInstallationStatusCoder } from './adapty-installation-status';\nimport { AdaptyNativeErrorCoder } from './adapty-native-error';\nimport { AdaptyNonSubscriptionCoder } from './adapty-non-subscription';\nimport { AdaptyOnboardingBuilderCoder } from './adapty-onboarding-builder';\nimport { AdaptyOnboardingCoder } from './adapty-onboarding';\nimport { AdaptyPaywallProductCoder } from './adapty-paywall-product';\nimport { AdaptyPlacementCoder } from './adapty-placement';\nimport { AdaptyPriceCoder } from './adapty-price';\nimport { AdaptyPromotedProductCoder } from './adapty-promoted-product';\nimport { AdaptyProfileParametersCoder } from './adapty-profile-parameters';\nimport { AdaptyProfileCoder } from './adapty-profile';\nimport { AdaptyPurchaseParamsCoder } from './adapty-purchase-params';\nimport { AdaptyPurchaseResultCoder } from './adapty-purchase-result';\nimport { AdaptyRemoteConfigCoder } from './adapty-remote-config';\nimport { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';\nimport { AdaptySubscriptionOfferIdCoder } from './adapty-subscription-offer-identifier';\nimport { AdaptySubscriptionOfferCoder } from './adapty-subscription-offer';\nimport { AdaptySubscriptionPeriodCoder } from './adapty-subscription-period';\nimport { AdaptySubscriptionCoder } from './adapty-subscription';\nimport { AdaptyUiDialogConfigCoder } from './adapty-ui-dialog-config';\nimport { AdaptyUICreateOnboardingViewParamsCoder } from './adapty-ui-create-onboarding-view-params';\nimport { AdaptyUICreateFlowViewParamsCoder } from './adapty-ui-create-flow-view-params';\nimport { AdaptyUiMediaCacheCoder } from './adapty-ui-media-cache';\nimport { AdaptyUiOnboardingMetaCoder } from './adapty-ui-onboarding-meta';\nimport { AdaptyUiOnboardingStateParamsCoder } from './adapty-ui-onboarding-state-params';\nimport { AdaptyUiOnboardingStateUpdatedActionCoder } from './adapty-ui-onboarding-state-updated-action';\nimport { ArrayCoder } from './array';\nimport { BridgeErrorCoder } from './bridge-error';\nimport { DateCoder } from './date';\nimport { HashmapCoder } from './hashmap';\nimport { JSONCoder } from './json';\nimport { ProductReferenceCoder } from './product-reference';\nimport type { Converter } from './types';\n\n/**\n * Dependencies container for coders\n */\nexport interface CoderDependencies {\n platform: IPlatformAdapter;\n sdkMetadata: ISdkMetadataAdapter;\n logger?: ILoggerAdapter;\n}\n\n/**\n * Factory for creating coders with injected dependencies\n */\nexport class CoderFactory {\n constructor(private readonly deps: CoderDependencies) {}\n\n createAccessLevelCoder(): AdaptyAccessLevelCoder {\n return new AdaptyAccessLevelCoder(this.deps.platform);\n }\n\n createConfigurationCoder(): AdaptyConfigurationCoder {\n return new AdaptyConfigurationCoder(\n this.deps.platform,\n this.deps.sdkMetadata,\n );\n }\n\n createDateCoder(): DateCoder {\n return new DateCoder();\n }\n\n createDiscountPhaseCoder(): AdaptyDiscountPhaseCoder {\n return new AdaptyDiscountPhaseCoder(this.deps.platform);\n }\n\n createPurchaseParamsCoder(): AdaptyPurchaseParamsCoder {\n return new AdaptyPurchaseParamsCoder(this.deps.platform);\n }\n\n createPurchaseResultCoder(): AdaptyPurchaseResultCoder {\n return new AdaptyPurchaseResultCoder(this.deps.platform);\n }\n\n createIdentifyParamsCoder(): AdaptyIdentifyParamsCoder {\n return new AdaptyIdentifyParamsCoder(this.deps.platform);\n }\n\n createInstallationDetailsCoder(): AdaptyInstallationDetailsCoder {\n return new AdaptyInstallationDetailsCoder();\n }\n\n createInstallationStatusCoder(): AdaptyInstallationStatusCoder {\n return new AdaptyInstallationStatusCoder();\n }\n\n createJsonCoder(): JSONCoder {\n return new JSONCoder();\n }\n\n createNativeErrorCoder(): AdaptyNativeErrorCoder {\n return new AdaptyNativeErrorCoder(this.deps.platform);\n }\n\n createNonSubscriptionCoder(): AdaptyNonSubscriptionCoder {\n return new AdaptyNonSubscriptionCoder(this.deps.platform);\n }\n\n createOnboardingBuilderCoder(): AdaptyOnboardingBuilderCoder {\n return new AdaptyOnboardingBuilderCoder(this.deps.platform);\n }\n\n createOnboardingCoder(): AdaptyOnboardingCoder {\n return new AdaptyOnboardingCoder(this.deps.platform);\n }\n\n createFlowCoder(): AdaptyFlowCoder {\n return new AdaptyFlowCoder(this.deps.platform);\n }\n\n createFlowPaywallCoder(): AdaptyFlowPaywallCoder {\n return new AdaptyFlowPaywallCoder(this.deps.platform);\n }\n\n createFlowUiSchemaCoder(): AdaptyFlowUiSchemaCoder {\n return new AdaptyFlowUiSchemaCoder();\n }\n\n createPaywallProductCoder(): AdaptyPaywallProductCoder {\n return new AdaptyPaywallProductCoder(this.deps.platform);\n }\n\n createPlacementCoder(): AdaptyPlacementCoder {\n return new AdaptyPlacementCoder(this.deps.platform);\n }\n\n createPriceCoder(): AdaptyPriceCoder {\n return new AdaptyPriceCoder(this.deps.platform);\n }\n\n createProductReferenceCoder(): ProductReferenceCoder {\n return new ProductReferenceCoder(this.deps.platform);\n }\n\n createProfileCoder(): AdaptyProfileCoder {\n return new AdaptyProfileCoder(this.deps.platform);\n }\n\n createProfileParametersCoder(): AdaptyProfileParametersCoder {\n return new AdaptyProfileParametersCoder(this.deps.platform);\n }\n\n createPromotedProductCoder(): AdaptyPromotedProductCoder {\n return new AdaptyPromotedProductCoder(this.deps.platform);\n }\n\n createRemoteConfigCoder(): AdaptyRemoteConfigCoder {\n return new AdaptyRemoteConfigCoder(this.deps.platform);\n }\n\n createSubscriptionCoder(): AdaptySubscriptionCoder {\n return new AdaptySubscriptionCoder(this.deps.platform);\n }\n\n createSubscriptionDetailsCoder(): AdaptySubscriptionDetailsCoder {\n return new AdaptySubscriptionDetailsCoder(this.deps.platform);\n }\n\n createSubscriptionOfferCoder(): AdaptySubscriptionOfferCoder {\n return new AdaptySubscriptionOfferCoder(this.deps.platform);\n }\n\n createSubscriptionOfferIdCoder(): AdaptySubscriptionOfferIdCoder {\n return new AdaptySubscriptionOfferIdCoder(this.deps.platform);\n }\n\n createSubscriptionPeriodCoder(): AdaptySubscriptionPeriodCoder {\n return new AdaptySubscriptionPeriodCoder(this.deps.platform);\n }\n\n createUiCreateOnboardingViewParamsCoder(): AdaptyUICreateOnboardingViewParamsCoder {\n return new AdaptyUICreateOnboardingViewParamsCoder();\n }\n\n createUiCreateFlowViewParamsCoder(): AdaptyUICreateFlowViewParamsCoder {\n return new AdaptyUICreateFlowViewParamsCoder(this.deps.platform);\n }\n\n createUiDialogConfigCoder(): AdaptyUiDialogConfigCoder {\n return new AdaptyUiDialogConfigCoder(this.deps.platform);\n }\n\n createUiMediaCacheCoder(): AdaptyUiMediaCacheCoder {\n return new AdaptyUiMediaCacheCoder(this.deps.platform);\n }\n\n createUiOnboardingMetaCoder(): AdaptyUiOnboardingMetaCoder {\n return new AdaptyUiOnboardingMetaCoder(this.deps.platform);\n }\n\n createUiOnboardingStateParamsCoder(): AdaptyUiOnboardingStateParamsCoder {\n return new AdaptyUiOnboardingStateParamsCoder(this.deps.platform);\n }\n\n createUiOnboardingStateUpdatedActionCoder(): AdaptyUiOnboardingStateUpdatedActionCoder {\n return new AdaptyUiOnboardingStateUpdatedActionCoder(this.deps.platform);\n }\n\n createBridgeErrorCoder(): BridgeErrorCoder {\n return new BridgeErrorCoder(this.deps.platform);\n }\n\n createArrayCoder<Model, Serializable>(\n coderFactory: () => Converter<Model, Serializable>,\n ): ArrayCoder<Model, Serializable> {\n return new ArrayCoder(coderFactory);\n }\n\n createPaywallProductArrayCoder(): ArrayCoder<any, any> {\n return new ArrayCoder(() => this.createPaywallProductCoder());\n }\n\n createHashmapCoder<T extends Converter<any, any>>(\n coder: T | null,\n ): HashmapCoder<T> {\n return new HashmapCoder(coder);\n }\n}\n","// import SDK type to link to methods in docs.\nimport type { Adapty } from '@/adapty-handler';\n\nexport const VendorStore = Object.freeze({\n AppStore: 'app_store',\n PlayStore: 'play_store',\n Adapty: 'adapty',\n});\nexport type VendorStore = (typeof VendorStore)[keyof typeof VendorStore];\n\nexport const OfferType = Object.freeze({\n FreeTrial: 'free_trial',\n PayAsYouGo: 'pay_as_you_go',\n PayUpFront: 'pay_up_front',\n});\nexport type OfferType = (typeof OfferType)[keyof typeof OfferType];\n\nexport const CancellationReason = Object.freeze({\n VolountarilyCancelled: 'voluntarily_cancelled',\n BillingError: 'billing_error',\n Refund: 'refund',\n PriceIncrease: 'price_increase',\n ProductWasNotAvailable: 'product_was_not_available',\n Unknown: 'unknown',\n});\nexport type CancellationReason =\n (typeof CancellationReason)[keyof typeof CancellationReason];\n\nexport const Gender = Object.freeze({\n Female: 'f',\n Male: 'm',\n Other: 'o',\n});\nexport type Gender = (typeof Gender)[keyof typeof Gender];\n\nexport const AppTrackingTransparencyStatus = Object.freeze({\n NotDetermined: 0,\n Restricted: 1,\n Denied: 2,\n Authorized: 3,\n Unknown: 4,\n});\nexport type AppTrackingTransparencyStatus =\n (typeof AppTrackingTransparencyStatus)[keyof typeof AppTrackingTransparencyStatus];\n\nexport const ProductPeriod = Object.freeze({\n Day: 'day',\n Week: 'week',\n Month: 'month',\n Year: 'year',\n});\nexport type ProductPeriod = (typeof ProductPeriod)[keyof typeof ProductPeriod];\n\nexport interface AdaptyPrice {\n /**\n * Price as number\n */\n amount: number;\n /**\n * The currency code of the locale\n * used to format the price of the product.\n * The ISO 4217 (USD, EUR).\n */\n currencyCode?: string;\n /**\n * The currency symbol of the locale\n * used to format the price of the product.\n * ($, €).\n */\n currencySymbol?: string;\n /**\n * A price’s language is determined\n * by the preferred language set on the device.\n * On Android, the formatted price from Google Play as is.\n */\n localizedString?: string;\n}\n\n/**\n * Describes a single paywall variation inside a flow.\n * @public\n */\nexport interface AdaptyFlowPaywall {\n readonly placement: AdaptyPlacement;\n\n /**\n * A paywall name.\n * @readonly\n */\n readonly name: string;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this paywall.\n * @readonly\n */\n readonly variationId: string;\n /**\n * Array of product identifiers for this paywall\n * @readonly\n */\n readonly productIdentifiers: AdaptyProductIdentifier[];\n\n id: string;\n webPurchaseUrl?: string;\n}\n\n/**\n * Describes a single layout of a flow UI schema.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchemaLayout {\n readonly flowLayoutId: string;\n}\n\n/**\n * Describes a single grid of a flow UI schema.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchemaGrid {\n /**\n * Platforms this grid applies to, or `'all'` for every platform.\n * @readonly\n */\n readonly platforms?: 'all' | ('ios' | 'android')[];\n /**\n * Device classes this grid applies to, or `'all'` for every device class.\n * @readonly\n */\n readonly devices?: 'all' | ('phone' | 'tab')[];\n readonly customId?: string;\n readonly hBreakpoints?: number[];\n readonly vBreakpoints?: number[];\n readonly cells: number[];\n}\n\n/**\n * Layout schema used by the Adapty UI builder to render a flow.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n */\nexport interface AdaptyFlowUiSchema {\n readonly layouts: AdaptyFlowUiSchemaLayout[];\n readonly grids: AdaptyFlowUiSchemaGrid[];\n}\n\n/**\n * Describes an object that represents a flow,\n * fetched for a placement.\n * @public\n */\nexport interface AdaptyFlow {\n readonly placement: AdaptyPlacement;\n\n /**\n * If `true`, it is possible to fetch the view object\n * and use it with AdaptyUI library.\n *\n * @remarks\n * Derived on decode: `true` only when the flow has both a\n * `flowVersionId` and a `uiSchema`.\n * @readonly\n */\n readonly hasViewConfiguration: boolean;\n\n /**\n * A flow name.\n * @readonly\n */\n readonly name: string;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this flow.\n * @readonly\n */\n readonly variationId: string;\n /**\n * Remote configs configured in Adapty Dashboard for this flow.\n * @readonly\n */\n readonly remoteConfigs?: AdaptyRemoteConfig[];\n /**\n * Paywall variations contained in this flow.\n * @readonly\n */\n readonly paywalls: AdaptyFlowPaywall[];\n /**\n * Layout schema used by the Adapty UI builder to render this flow.\n *\n * @remarks\n * Renderer data, not a public API.\n * @internal\n * @readonly\n */\n readonly uiSchema?: AdaptyFlowUiSchema;\n\n id: string;\n /**\n * Renderer-internal version of the flow's view configuration.\n *\n * @remarks\n * Opaque to the app: carried only so a flow handed back to the native side\n * keeps it. Use {@link AdaptyFlow.hasViewConfiguration} to tell whether the\n * flow can be rendered.\n * @internal\n */\n flowVersionId?: string;\n /** Server response creation timestamp in milliseconds. */\n responseCreatedAt: number;\n payloadData?: string;\n}\n\nexport interface AdaptyOnboarding {\n readonly placement: AdaptyPlacement;\n /**\n * If `true`, it is possible to fetch the view object\n * and use it with AdaptyUI library.\n * @readonly\n */\n readonly hasViewConfiguration: boolean;\n\n /**\n * A paywall name.\n * @readonly\n */\n readonly name: string;\n /**\n * A remote config configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly remoteConfig?: AdaptyRemoteConfig;\n /**\n * An identifier of a variation,\n * used to attribute purchases to this paywall.\n * @readonly\n */\n readonly variationId: string;\n\n id: string;\n version?: number;\n payloadData?: string;\n requestLocale: string;\n onboardingBuilder: AdaptyOnboardingBuilder;\n}\n\nexport interface AdaptyPlacement {\n /**\n * Parent A/B test name.\n * @readonly\n */\n readonly abTestName: string;\n\n /**\n * A name of an audience to which the paywall belongs.\n * @readonly\n */\n readonly audienceName: string;\n /**\n * ID of a placement configured in Adapty Dashboard.\n * @readonly\n */\n readonly id: string;\n /**\n * Current revision (version) of a paywall.\n * Every change within a paywall creates a new revision.\n * @readonly\n */\n readonly revision: number;\n\n isTrackingPurchases?: boolean;\n audienceVersionId: string;\n}\n\n/**\n * Describes an object that represents a remote config of a paywall.\n * @public\n */\nexport interface AdaptyRemoteConfig {\n /**\n * Identifier of a paywall locale.\n * @readonly\n */\n readonly lang: string;\n /**\n * A custom dictionary configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly data: Record<string, any>;\n /**\n * A custom JSON string configured in Adapty Dashboard for this paywall.\n * @readonly\n */\n readonly dataString: string;\n}\n\nexport interface AdaptyOnboardingBuilder {\n readonly url: string;\n}\n\nexport type AdaptyPurchaseResult =\n | {\n type: 'pending' | 'user_cancelled';\n }\n | {\n type: 'success';\n profile: AdaptyProfile;\n ios?: {\n jwsTransaction?: string;\n };\n android?: {\n purchaseToken?: string;\n };\n };\n\n/**\n * Identifiers of attribution providers applied to the profile.\n *\n * Other identifiers may be emitted in future versions, so any string is accepted\n * @public\n */\nexport type AdaptyExternalAttributionProvider =\n | 'apple_search_ads'\n | 'adjust'\n | 'appsflyer'\n | 'branch'\n | 'tenjin'\n | 'custom'\n | (string & {});\n\n/**\n * Interface representing a user profile in Adapty,\n * including details about the user's subscriptions and consumable products.\n * @public\n */\nexport interface AdaptyProfile {\n /**\n * Object that maps access level identifiers (configured by you in Adapty Dashboard)\n * to the corresponding access level details. The value can be `null`\n * if the user does not have any access levels.\n * @readonly\n */\n readonly accessLevels?: Record<string, AdaptyAccessLevel>;\n\n /**\n * Identifiers of attribution providers applied to the profile.\n * @readonly\n */\n readonly appliedExternalAttributionProviders?: AdaptyExternalAttributionProvider[];\n\n /**\n * Object representing custom attributes set for the user using\n * the {@link Adapty.updateProfile} method.\n * @readonly\n */\n readonly customAttributes?: Record<string, any>;\n\n /**\n * The identifier for a user in your system.\n * @readonly\n */\n readonly customerUserId?: string;\n\n /**\n * Object that maps product ids from the store to an array of\n * information about the user's non-subscription purchases.\n * The value can be `null` if the user does not have any purchases.\n * @readonly\n */\n readonly nonSubscriptions?: Record<string, AdaptyNonSubscription[]>;\n\n /**\n * The identifier for a user in Adapty.\n */\n readonly profileId: string;\n\n /**\n * Object that maps product ids from a store to\n * information about the user's subscriptions.\n * The value can be `null` if the user does not have any subscriptions.\n * @readonly\n */\n readonly subscriptions?: Record<string, AdaptySubscription>;\n}\n\n/**\n * Interface representing access level details of a user.\n * @public\n */\nexport interface AdaptyAccessLevel {\n /**\n * The date and time when the access level was activated.\n * @readonly\n */\n readonly activatedAt: Date;\n\n /**\n * Type of active introductory offer, if any.\n * @readonly\n */\n readonly activeIntroductoryOfferType?: OfferType;\n\n /**\n * Identifier of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferId?: string;\n\n /**\n * Type of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferType?: OfferType;\n\n /**\n * The date and time when a billing issue was detected.\n * @readonly\n */\n readonly billingIssueDetectedAt?: Date;\n\n /**\n * The reason for the cancellation of the subscription.\n * @readonly\n */\n readonly cancellationReason?: CancellationReason;\n\n /**\n * The expiration date of the access level, if applicable.\n * @readonly\n */\n readonly expiresAt?: Date;\n\n /**\n * Unique identifier of the access level\n * configured by you in Adapty Dashboard.\n * @readonly\n */\n readonly id: string;\n\n /**\n * Flag indicating whether the access level is currently active.\n * @readonly\n */\n readonly isActive: boolean;\n\n /**\n * Flag indicating whether this auto-renewable subscription is in the grace period.\n * @readonly\n */\n readonly isInGracePeriod: boolean;\n\n /**\n * Flag indicating whether this access level is active for a lifetime.\n * @readonly\n */\n readonly isLifetime: boolean;\n\n /**\n * Flag indicating whether this purchase was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * The date and time when the access level was renewed.\n * @readonly\n */\n readonly renewedAt?: Date;\n\n /**\n * The start date of this access level.\n * @readonly\n */\n readonly startsAt?: Date;\n\n /**\n * The store where the purchase that unlocked this access level was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * The date and time when the auto-renewable subscription was cancelled.\n * @readonly\n */\n readonly unsubscribedAt?: Date;\n\n /**\n * The identifier of the product in the store that unlocked this access level.\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * Flag indicating whether this auto-renewable subscription is set to renew.\n * @readonly\n */\n readonly willRenew: boolean;\n\n android?: {\n offerId?: string;\n };\n}\n\n/**\n * Interface representing a consumable or non-subscription purchase made by the user.\n * @public\n */\nexport interface AdaptyNonSubscription {\n /**\n * Flag indicating whether the product is consumable.\n * @readonly\n */\n readonly isConsumable: boolean;\n\n /**\n * Flag indicating whether the purchase was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * Flag indicating whether the product was purchased in a sandbox environment.\n * @readonly\n */\n readonly isSandbox: boolean;\n\n /**\n * The date and time when the purchase was made.\n * @readonly\n */\n readonly purchasedAt: Date;\n\n /**\n * The identifier of the product in the store that was purchased.\n * @readonly\n */\n readonly vendorProductId: string;\n /**\n * The identifier of the product in the store that was purchased.\n * @readonly\n */\n readonly vendorTransactionId?: string;\n\n /**\n * The store where the purchase was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * An identifier of the purchase in Adapty.\n * You can use it to ensure that you've already processed this purchase\n * (for example tracking one time products).\n * @readonly\n */\n readonly purchaseId: string;\n}\n\n/**\n * Interface representing details about a user's subscription.\n * @public\n */\nexport interface AdaptySubscription {\n /**\n * The date and time when the subscription was activated.\n * @readonly\n */\n readonly activatedAt: Date;\n\n /**\n * Type of active introductory offer, if any.\n * @readonly\n */\n readonly activeIntroductoryOfferType?: OfferType;\n\n /**\n * Identifier of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferId?: string;\n\n /**\n * Type of the active promotional offer, if any.\n * @readonly\n */\n readonly activePromotionalOfferType?: OfferType;\n\n /**\n * The date and time when a billing issue was detected.\n * @readonly\n */\n readonly billingIssueDetectedAt?: Date;\n\n /**\n * The reason for the cancellation of the subscription.\n * @readonly\n */\n readonly cancellationReason?: CancellationReason;\n\n /**\n * The expiration date of the subscription, if applicable.\n * @readonly\n */\n readonly expiresAt?: Date;\n\n /**\n * Flag indicating whether the subscription is currently active.\n * @readonly\n */\n readonly isActive: boolean;\n\n /**\n * Flag indicating whether the subscription is in the grace period.\n * @readonly\n */\n readonly isInGracePeriod: boolean;\n\n /**\n * Flag indicating whether the subscription is set for a lifetime.\n * @readonly\n */\n readonly isLifetime: boolean;\n\n /**\n * Flag indicating whether the subscription was refunded.\n * @readonly\n */\n readonly isRefund: boolean;\n\n /**\n * Flag indicating whether the subscription was purchased in a sandbox environment.\n * @readonly\n */\n readonly isSandbox: boolean;\n\n /**\n * The date and time when the subscription was renewed.\n * @readonly\n */\n readonly renewedAt?: Date;\n\n /**\n * The date and time when the subscription starts.\n * @readonly\n */\n readonly startsAt?: Date;\n\n /**\n * The store where the subscription was made.\n * @readonly\n */\n readonly store: VendorStore;\n\n /**\n * The date and time when the subscription was cancelled.\n * @readonly\n */\n readonly unsubscribedAt?: Date;\n\n /**\n * The identifier of the product in the store that was subscribed to.\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * The identifier of the product in the store that was subscribed to.\n * @readonly\n */\n readonly vendorTransactionId: string;\n /**\n * An original transaction id of the purchase in a store that unlocked this subscription.\n * For auto-renewable subscription, this will be an id of the first transaction in this subscription.\n * @readonly\n */\n readonly vendorOriginalTransactionId: string;\n /**\n * Flag indicating whether the subscription is set to auto-renew.\n * @readonly\n */\n readonly willRenew: boolean;\n}\n\n/**\n * Describes an object that represents a product.\n * Used in {@link Adapty.getPaywallProducts} method and in {@link Adapty.makePurchase} method.\n * @public\n */\nexport interface AdaptyPaywallProduct {\n /**\n * A description of the product.\n */\n readonly localizedDescription: string;\n /**\n * The region code of the locale used to format the price of the product.\n * ISO 3166 ALPHA-2 (US, DE)\n */\n readonly regionCode?: string;\n /**\n * The name of the product.\n */\n readonly localizedTitle: string;\n /**\n * Same as `abTestName` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly paywallABTestName: string;\n /**\n * Same as `name` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly paywallName: string;\n readonly accessLevelId: string;\n readonly productType: string;\n /**\n * The cost of the product in the local currency\n */\n readonly price?: AdaptyPrice;\n /**\n * Internal Adapty product identifier.\n * @internal\n */\n readonly adaptyId: string;\n /**\n * Same as `variationId` property of the parent {@link AdaptyFlowPaywall}.\n */\n readonly variationId: string;\n /**\n * Unique identifier of a product\n * from App Store Connect or Google Play Console\n */\n readonly vendorProductId: string;\n paywallProductIndex: number;\n webPurchaseUrl?: string;\n /**\n * Internal payload data attached to the product.\n * @internal\n */\n payloadData?: string;\n subscription?: AdaptySubscriptionDetails;\n ios?: {\n /**\n * Boolean value that indicates\n * whether the product is available for family sharing\n * in App Store Connect.\n * Will be `false` for iOS version below 14.0 and macOS version below 11.0.\n * @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}\n */\n readonly isFamilyShareable: boolean;\n };\n}\n\n/**\n * Describes a product promoted in the App Store,\n * received through the `'onPromotedPurchaseReceived'` event.\n *\n * @remarks\n * Unlike {@link AdaptyPaywallProduct}, a promoted product does not belong to a\n * paywall, so it carries no placement, variation or A/B test information.\n * @public\n */\nexport interface AdaptyPromotedProduct {\n /**\n * A description of the product.\n */\n readonly localizedDescription: string;\n /**\n * The name of the product.\n */\n readonly localizedTitle: string;\n /**\n * The region code of the locale used to format the price of the product.\n * ISO 3166 ALPHA-2 (US, DE)\n */\n readonly regionCode?: string;\n /**\n * The cost of the product in the local currency\n */\n readonly price?: AdaptyPrice;\n /**\n * Unique identifier of a product\n * from App Store Connect or Google Play Console\n */\n readonly vendorProductId: string;\n /**\n * Internal payload data attached to the product.\n * @internal\n */\n payloadData?: string;\n subscription?: AdaptySubscriptionDetails;\n ios?: {\n /**\n * Boolean value that indicates\n * whether the product is available for family sharing\n * in App Store Connect.\n * Will be `false` for iOS version below 14.0 and macOS version below 11.0.\n * @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}\n */\n readonly isFamilyShareable: boolean;\n };\n}\n\nexport interface AdaptySubscriptionDetails {\n /**\n * The period details for products that are subscriptions.\n * Will be `null` for iOS version below 11.2 and macOS version below 10.14.4.\n */\n subscriptionPeriod: AdaptySubscriptionPeriod;\n /**\n * The period’s language is determined\n * by the preferred language set on the device.\n */\n localizedSubscriptionPeriod?: string;\n /**\n * A subscription offer if available for the auto-renewable subscription.\n */\n offer?: AdaptySubscriptionOffer;\n\n ios?: {\n /**\n * An identifier of the subscription group\n * to which the subscription belongs.\n * Will be `null` for iOS version below 12.0 and macOS version below 10.14.\n */\n subscriptionGroupIdentifier?: string;\n };\n\n android?: {\n basePlanId: string;\n renewalType?: 'prepaid' | 'autorenewable';\n };\n}\n\n/**\n * Subscription offer model to products\n * @see {@link https://doc.adapty.io/docs/rn-api-reference#adaptysubscriptionoffer}\n */\nexport interface AdaptySubscriptionOffer {\n readonly identifier: AdaptySubscriptionOfferId;\n\n phases: AdaptyDiscountPhase[];\n\n android?: {\n offerTags?: string[];\n };\n}\n\nexport type AdaptySubscriptionOfferId =\n | { id?: string; type: 'introductory' }\n | { id: string; type: 'promotional' | 'win_back' }\n | { id?: string; type: 'code' };\n\n/**\n * Discount model to products\n * @see {@link https://doc.adapty.io/docs/rn-api-reference#adaptyproductdiscount}\n */\nexport interface AdaptyDiscountPhase {\n /**\n * A formatted number of periods of a discount for a user’s locale.\n * @readonly\n */\n readonly localizedNumberOfPeriods?: string;\n /**\n * A formatted subscription period of a discount for a user’s locale.\n * @readonly\n */\n readonly localizedSubscriptionPeriod?: string;\n /**\n * A number of periods this product discount is available.\n * @readonly\n */\n readonly numberOfPeriods: number;\n /**\n * Discount price of a product in a local currency.\n * @readonly\n */\n readonly price: AdaptyPrice;\n /**\n * An information about period for a product discount.\n * @readonly\n */\n readonly subscriptionPeriod: AdaptySubscriptionPeriod;\n\n /**\n * A payment mode for this product discount.\n * @readonly\n */\n readonly paymentMode: OfferType;\n}\n\n/**\n * An object containing information about a subscription period.\n * @public\n */\nexport interface AdaptySubscriptionPeriod {\n /**\n * A number of period units.\n * @readonly\n */\n readonly numberOfUnits: number;\n /**\n * A unit of time that a subscription period is specified in.\n * @readonly\n */\n readonly unit: ProductPeriod;\n}\n\nexport interface AdaptyProfileParameters {\n analyticsDisabled?: boolean;\n codableCustomAttributes?: { [key: string]: any };\n appTrackingTransparencyStatus?: AppTrackingTransparencyStatus;\n firstName?: string;\n lastName?: string;\n gender?: Gender;\n birthday?: string;\n email?: string;\n phoneNumber?: string;\n}\n\nexport interface ProductReference {\n flowProductId?: string;\n vendorId: string;\n adaptyId: string;\n accessLevelId: string;\n productType: string;\n\n ios?: {\n promotionalOfferId?: string;\n winBackOfferId?: string;\n };\n\n android?: {\n basePlanId?: string;\n offerId?: string;\n };\n}\n\n/**\n * Interface representing a product identifier with vendor and platform-specific information.\n * @public\n */\nexport interface AdaptyProductIdentifier {\n /**\n * The vendor-specific product identifier (e.g., App Store or Google Play product ID).\n * @readonly\n */\n readonly vendorProductId: string;\n\n /**\n * The base plan identifier for Google Play subscriptions (Android only).\n * @readonly\n */\n readonly basePlanId?: string;\n\n /**\n * Internal Adapty product identifier.\n * @internal\n * @readonly\n */\n readonly adaptyProductId: string;\n}\n\nexport const WebPresentation = Object.freeze({\n BrowserOutApp: 'browser_out_app',\n BrowserInApp: 'browser_in_app',\n});\nexport type WebPresentation =\n (typeof WebPresentation)[keyof typeof WebPresentation];\n\nexport const RefundPreference = Object.freeze({\n NoPreference: 'no_preference',\n Grant: 'grant',\n Decline: 'decline',\n});\nexport type RefundPreference =\n (typeof RefundPreference)[keyof typeof RefundPreference];\n\nexport type AdaptyInstallationStatus =\n | {\n status: 'not_available' | 'not_determined';\n }\n | {\n status: 'determined';\n details: AdaptyInstallationDetails;\n };\n\nexport interface AdaptyInstallationDetails {\n /**\n * A unique identifier for this installation.\n * @readonly\n */\n readonly installId?: string;\n /**\n * The date and time when the app was installed.\n * @readonly\n */\n readonly installTime: Date;\n /**\n * The total number of times the app has been launched.\n * @readonly\n */\n readonly appLaunchCount: number;\n /**\n * Custom payload data associated with the installation.\n * @readonly\n */\n readonly payload?: string;\n}\n","import type { Event } from './schema';\n\n/**\n * Valid list of callable bridge handlers.\n *\n * The source of truth is `cross_platform.yaml`: one entry per `$requests`\n * method const. `bridge.test.ts` asserts the two stay in sync — a method the\n * native side does not register would fail at runtime, not at compile time.\n * @internal\n */\nexport const MethodNames = [\n 'activate',\n 'adapty_ui_create_flow_view',\n 'adapty_ui_destroy_flow_view',\n 'adapty_ui_dismiss_flow_view',\n 'adapty_ui_present_flow_view',\n 'adapty_ui_show_dialog',\n 'adapty_ui_create_onboarding_view',\n 'adapty_ui_dismiss_onboarding_view',\n 'adapty_ui_present_onboarding_view',\n 'create_web_paywall_url',\n 'get_current_installation_status',\n 'is_activated',\n 'get_flow',\n 'get_flow_for_default_audience',\n 'get_paywall_products',\n 'get_pending_store_message_types',\n 'get_onboarding',\n 'get_onboarding_for_default_audience',\n 'get_profile',\n 'get_log_level',\n 'get_sdk_version',\n 'identify',\n 'log_show_flow',\n 'logout',\n 'make_promoted_purchase',\n 'make_purchase',\n 'open_web_paywall',\n 'preload_flows',\n 'preload_flows_for_default_audience',\n 'present_code_redemption_sheet',\n 'report_transaction',\n 'restore_purchases',\n 'set_fallback',\n 'set_integration_identifiers',\n 'set_log_level',\n 'show_store_messages',\n 'update_collecting_refund_data_consent',\n 'update_external_attribution_data',\n 'update_profile',\n 'update_refund_preference',\n 'flow_view_did_answer_permission',\n 'adapty_ui_open_url',\n 'adapty_ui_request_app_review',\n 'observer_purchase_did_start',\n 'observer_purchase_did_finish',\n 'observer_restore_did_start',\n 'observer_restore_did_finish',\n] as const;\nexport type MethodName = (typeof MethodNames)[number];\n\n/**\n * Types of values that can be passed\n * to the bridge without corruption\n */\nexport type Serializable =\n | string\n | number\n | boolean\n | string[]\n | null\n | undefined;\n\n/**\n * Interface of error that emit from native SDK\n */\nexport interface AdaptyNativeError {\n adaptyCode: number;\n message: string;\n detail?: string | undefined;\n}\n\n/**\n * Interface of error that was raised by native bridge\n */\nexport interface AdaptyBridgeError {\n errorType: string;\n name?: string;\n type?: string;\n underlyingError?: string;\n description?: string;\n}\n\n/**\n * The SDK's global events - the ones not scoped to a flow view or an\n * onboarding - as public handler name -> native wire id.\n *\n * Both halves are load-bearing. `keyof` gives {@link GlobalEventName}, the names\n * a consumer passes to `addEventListener`; the values are the ids the native\n * side actually emits. The ids come off `cross_platform.yaml` through the\n * generated schema rather than being written out as free strings, so a typo in\n * {@link GLOBAL_EVENT_TO_NATIVE_EVENT} cannot reach a bridge subscription.\n * `bridge.test.ts` covers the other direction - that no global event in the\n * schema is missing from the map.\n */\ninterface GlobalEventMap {\n onLatestProfileLoad: Event['Event.DidLoadLatestProfile']['id'];\n onPromotedPurchaseReceived: Event['Event.DidReceivePromotedPurchase']['id'];\n onInstallationDetailsSuccess: Event['Event.OnInstallationDetailsSuccess']['id'];\n onInstallationDetailsFail: Event['Event.OnInstallationDetailsFail']['id'];\n}\n\nexport type GlobalEventName = keyof GlobalEventMap;\n\n/**\n * Native wire id of a global SDK event - the counterpart of\n * `FlowEventIdType` and `OnboardingEventIdType` for the events that are not\n * scoped to a view.\n *\n * @remarks\n * Type anything that subscribes to a global event by wire id with this. A bare\n * `string` there is what lets a typo compile, because nothing downstream\n * compares it against the schema.\n */\nexport type GlobalEventIdType = GlobalEventMap[GlobalEventName];\n\n/**\n * Handler name -> native wire id, for the global events.\n *\n * @remarks\n * Wrappers subscribe by handler name, so this is what turns the name the app\n * wrote into the string the bridge expects. It is the global-event counterpart\n * of `HANDLER_TO_NATIVE_EVENT` (flow views) and `HANDLER_TO_EVENT_CONFIG`\n * (onboardings), which own the unqualified names for historical reasons.\n */\nexport const GLOBAL_EVENT_TO_NATIVE_EVENT: GlobalEventMap = {\n onLatestProfileLoad: 'did_load_latest_profile',\n onPromotedPurchaseReceived: 'did_receive_promoted_purchase',\n onInstallationDetailsSuccess: 'on_installation_details_success',\n onInstallationDetailsFail: 'on_installation_details_fail',\n};\n","import { AdaptyError } from '@/adapty-error';\n// Imported for JSDoc {@link} references only.\nimport type { CreateFlowViewParamsInput } from '@/ui-builder/types';\nimport type {\n AdaptyPaywallProduct,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\n\n// Flow Event IDs\nexport const FlowEventId = {\n DidAppear: 'flow_view_did_appear',\n DidDisappear: 'flow_view_did_disappear',\n DidPerformAction: 'flow_view_did_perform_action',\n DidSelectProduct: 'flow_view_did_select_product',\n DidStartPurchase: 'flow_view_did_start_purchase',\n DidFinishPurchase: 'flow_view_did_finish_purchase',\n DidFailPurchase: 'flow_view_did_fail_purchase',\n DidStartRestore: 'flow_view_did_start_restore',\n DidFinishRestore: 'flow_view_did_finish_restore',\n DidFailRestore: 'flow_view_did_fail_restore',\n DidReceiveError: 'flow_view_did_receive_error',\n DidFailLoadingProducts: 'flow_view_did_fail_loading_products',\n DidFinishWebPaymentNavigation: 'flow_view_did_finish_web_payment_navigation',\n DidRequestAppReview: 'flow_view_did_request_app_review',\n DidReceiveAnalyticEvent: 'flow_view_did_receive_analytic_event',\n DidAskPermission: 'flow_view_did_ask_permission',\n ObserverDidInitiatePurchase: 'flow_view_observer_did_initiate_purchase',\n ObserverDidInitiateRestore: 'flow_view_observer_did_initiate_restore',\n} as const;\n\nexport type FlowEventIdType = (typeof FlowEventId)[keyof typeof FlowEventId];\n\n/**\n * Permission identifier a flow view asks the host app to request.\n *\n * The literals below are the known cross-platform set; any string is valid —\n * unknown or platform-specific ids (e.g. Android `'phone'`, `'sms'`) and future\n * values pass through unchanged. The `(string & {})` keeps the known values as\n * autocomplete hints while still accepting arbitrary strings.\n */\nexport type AdaptyPermission =\n | 'push'\n | 'camera'\n | 'microphone'\n | 'location_when_use'\n | 'location_always'\n | 'location_full_accuracy'\n | 'photos'\n | 'contacts'\n | 'tracking'\n | 'calendar'\n | 'bluetooth'\n | 'motion'\n | 'reminders'\n | 'speech'\n | 'media_library'\n | 'local_network'\n | 'focus_status'\n | 'homekit'\n | 'health'\n | 'siri'\n | 'music'\n | (string & {});\n\n// Event View\nexport interface FlowEventView {\n /**\n * The internal identifier of the presented view instance.\n *\n * @remarks\n * It does not correspond to anything in your dashboard.\n */\n id: string;\n /**\n * The placement this flow was fetched for.\n */\n placementId: string;\n /**\n * The variation the flow resolved to, for A/B test attribution.\n */\n variationId: string;\n /**\n * The localization the view was actually built with.\n *\n * @remarks\n * May differ from the requested localization if it is not available in the flow.\n *\n * @see {@link CreateFlowViewParamsInput.locale} — the localization requested\n * when the view was created.\n */\n locale?: string;\n}\n\n// Base Event\ninterface BaseFlowEvent {\n id: FlowEventIdType;\n view: FlowEventView;\n}\n\n// Event Types\nexport interface FlowDidAppearEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidAppear;\n}\n\nexport interface FlowDidDisappearEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidDisappear;\n}\n\nexport type FlowUserAction =\n | { type: 'close' }\n | { type: 'system_back' }\n | { type: 'open_url'; value: string; openIn: WebPresentation }\n | { type: 'custom'; value: string };\n\nexport interface FlowDidPerformActionEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidPerformAction;\n action: FlowUserAction;\n}\n\nexport interface FlowDidSelectProductEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidSelectProduct;\n productId: string;\n}\n\nexport interface FlowDidStartPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidStartPurchase;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidFinishPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishPurchase;\n purchaseResult: AdaptyPurchaseResult;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidFailPurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailPurchase;\n error: AdaptyError;\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowDidStartRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidStartRestore;\n}\n\nexport interface FlowDidFinishRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishRestore;\n profile: AdaptyProfile;\n}\n\nexport interface FlowDidFailRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailRestore;\n error: AdaptyError;\n}\n\nexport interface FlowDidReceiveErrorEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidReceiveError;\n error: AdaptyError;\n}\n\nexport interface FlowDidFailLoadingProductsEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFailLoadingProducts;\n error: AdaptyError;\n}\n\nexport interface FlowDidFinishWebPaymentNavigationEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidFinishWebPaymentNavigation;\n product?: AdaptyPaywallProduct;\n error?: AdaptyError;\n}\n\nexport interface FlowDidRequestAppReviewEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidRequestAppReview;\n}\n\nexport interface FlowDidReceiveAnalyticEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidReceiveAnalyticEvent;\n name: string;\n params: Record<string, unknown>;\n}\n\nexport interface FlowDidAskPermissionEvent extends BaseFlowEvent {\n id: typeof FlowEventId.DidAskPermission;\n /** Correlation id — sent back to native in the response. SDK-internal. */\n eventId: string;\n /** Permission identifier the flow view asks the host to request. */\n permission: AdaptyPermission;\n /** Arbitrary string key/value args attached by the dashboard. */\n customArgs: Record<string, string>;\n}\n\nexport interface FlowObserverDidInitiatePurchaseEvent extends BaseFlowEvent {\n id: typeof FlowEventId.ObserverDidInitiatePurchase;\n /** Correlation id — sent back to native in the reply. SDK-internal. */\n eventId: string;\n /** Product the user initiated the purchase for. */\n product: AdaptyPaywallProduct;\n}\n\nexport interface FlowObserverDidInitiateRestoreEvent extends BaseFlowEvent {\n id: typeof FlowEventId.ObserverDidInitiateRestore;\n /** Correlation id — sent back to native in the reply. SDK-internal. */\n eventId: string;\n}\n\nexport type ParsedFlowEvent =\n | FlowDidAppearEvent\n | FlowDidDisappearEvent\n | FlowDidPerformActionEvent\n | FlowDidSelectProductEvent\n | FlowDidStartPurchaseEvent\n | FlowDidFinishPurchaseEvent\n | FlowDidFailPurchaseEvent\n | FlowDidStartRestoreEvent\n | FlowDidFinishRestoreEvent\n | FlowDidFailRestoreEvent\n | FlowDidReceiveErrorEvent\n | FlowDidFailLoadingProductsEvent\n | FlowDidFinishWebPaymentNavigationEvent\n | FlowDidRequestAppReviewEvent\n | FlowDidReceiveAnalyticEvent\n | FlowDidAskPermissionEvent\n | FlowObserverDidInitiatePurchaseEvent\n | FlowObserverDidInitiateRestoreEvent;\n","import { AdaptyError } from '@/adapty-error';\nimport type {\n AdaptyUiOnboardingMeta,\n OnboardingStateUpdatedAction,\n} from '@/ui-builder/types';\n\n// Onboarding Event IDs\nexport const OnboardingEventId = {\n Close: 'onboarding_on_close_action',\n Custom: 'onboarding_on_custom_action',\n Paywall: 'onboarding_on_paywall_action',\n StateUpdated: 'onboarding_on_state_updated_action',\n FinishedLoading: 'onboarding_did_finish_loading',\n Analytics: 'onboarding_on_analytics_action',\n Error: 'onboarding_did_fail_with_error',\n} as const;\n\nexport type OnboardingEventIdType =\n (typeof OnboardingEventId)[keyof typeof OnboardingEventId];\n\n// Event View\nexport interface OnboardingEventView {\n id: string;\n placementId?: string;\n variationId?: string;\n}\n\n// Base Event\ninterface BaseOnboardingEvent {\n id: OnboardingEventIdType;\n view: OnboardingEventView;\n}\n\n// Event Types\nexport interface OnboardingCloseEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Close;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingCustomEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Custom;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingPaywallEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Paywall;\n actionId: string;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingStateUpdatedEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.StateUpdated;\n action: OnboardingStateUpdatedAction;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingFinishedLoadingEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.FinishedLoading;\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingAnalyticsEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Analytics;\n event: { name: string; elementId?: string; reply?: string };\n meta: AdaptyUiOnboardingMeta;\n}\n\nexport interface OnboardingErrorEvent extends BaseOnboardingEvent {\n id: typeof OnboardingEventId.Error;\n error: AdaptyError;\n}\n\nexport type ParsedOnboardingEvent =\n | OnboardingCloseEvent\n | OnboardingCustomEvent\n | OnboardingPaywallEvent\n | OnboardingStateUpdatedEvent\n | OnboardingFinishedLoadingEvent\n | OnboardingAnalyticsEvent\n | OnboardingErrorEvent;\n","import type { FlowEventHandlers } from './types';\nimport { FlowEventId } from '@/types/flow-events';\nimport type { ParsedFlowEvent, FlowEventIdType } from '@/types/flow-events';\n\ntype EventName = keyof FlowEventHandlers;\n\n/**\n * Resolves native event to handler name based on event data\n */\nexport const NATIVE_EVENT_RESOLVER: Record<\n FlowEventIdType,\n (event: ParsedFlowEvent) => EventName | null\n> = {\n [FlowEventId.DidPerformAction]: event => {\n if (event.id !== FlowEventId.DidPerformAction) return null;\n\n const actionMap: Record<string, EventName> = {\n close: 'onCloseButtonPress',\n system_back: 'onAndroidSystemBack',\n open_url: 'onUrlPress',\n custom: 'onCustomAction',\n };\n\n return actionMap[event.action.type] || null;\n },\n [FlowEventId.DidAppear]: () => 'onAppeared',\n [FlowEventId.DidDisappear]: () => 'onDisappeared',\n [FlowEventId.DidSelectProduct]: () => 'onProductSelected',\n [FlowEventId.DidStartPurchase]: () => 'onPurchaseStarted',\n [FlowEventId.DidFinishPurchase]: () => 'onPurchaseCompleted',\n [FlowEventId.DidFailPurchase]: () => 'onPurchaseFailed',\n [FlowEventId.DidStartRestore]: () => 'onRestoreStarted',\n [FlowEventId.DidFinishRestore]: () => 'onRestoreCompleted',\n [FlowEventId.DidFailRestore]: () => 'onRestoreFailed',\n [FlowEventId.DidReceiveError]: () => 'onError',\n [FlowEventId.DidFailLoadingProducts]: () => 'onLoadingProductsFailed',\n [FlowEventId.DidFinishWebPaymentNavigation]: () =>\n 'onWebPaymentNavigationFinished',\n [FlowEventId.DidRequestAppReview]: () => 'onRequestAppReview',\n [FlowEventId.DidReceiveAnalyticEvent]: () => 'onAnalytics',\n [FlowEventId.DidAskPermission]: () => 'onRequestPermission',\n [FlowEventId.ObserverDidInitiatePurchase]: () =>\n 'onObserverPurchaseInitiated',\n [FlowEventId.ObserverDidInitiateRestore]: () => 'onObserverRestoreInitiated',\n};\n\n/**\n * Maps handler name to native event name\n * Used in addListener/addInternalListener to subscribe to correct native event\n */\nexport const HANDLER_TO_NATIVE_EVENT: Record<EventName, FlowEventIdType> = {\n onCloseButtonPress: FlowEventId.DidPerformAction,\n onAndroidSystemBack: FlowEventId.DidPerformAction,\n onUrlPress: FlowEventId.DidPerformAction,\n onCustomAction: FlowEventId.DidPerformAction,\n onAppeared: FlowEventId.DidAppear,\n onDisappeared: FlowEventId.DidDisappear,\n onProductSelected: FlowEventId.DidSelectProduct,\n onPurchaseStarted: FlowEventId.DidStartPurchase,\n onPurchaseCompleted: FlowEventId.DidFinishPurchase,\n onPurchaseFailed: FlowEventId.DidFailPurchase,\n onRestoreStarted: FlowEventId.DidStartRestore,\n onRestoreCompleted: FlowEventId.DidFinishRestore,\n onRestoreFailed: FlowEventId.DidFailRestore,\n onError: FlowEventId.DidReceiveError,\n onLoadingProductsFailed: FlowEventId.DidFailLoadingProducts,\n onWebPaymentNavigationFinished: FlowEventId.DidFinishWebPaymentNavigation,\n onRequestAppReview: FlowEventId.DidRequestAppReview,\n onAnalytics: FlowEventId.DidReceiveAnalyticEvent,\n onRequestPermission: FlowEventId.DidAskPermission,\n onObserverPurchaseInitiated: FlowEventId.ObserverDidInitiatePurchase,\n onObserverRestoreInitiated: FlowEventId.ObserverDidInitiateRestore,\n};\n\ntype ExtractedArgs<T extends keyof FlowEventHandlers> = Parameters<\n FlowEventHandlers[T]\n>;\n\nexport function extractFlowCallbackArgs<T extends keyof FlowEventHandlers>(\n handlerName: T,\n event: ParsedFlowEvent,\n): ExtractedArgs<T> {\n switch (event.id) {\n case FlowEventId.DidSelectProduct:\n return [event.productId] as ExtractedArgs<T>;\n\n case FlowEventId.DidStartPurchase:\n return [event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishPurchase:\n return [event.purchaseResult, event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFailPurchase:\n return [event.error, event.product] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishRestore:\n return [event.profile] as ExtractedArgs<T>;\n\n case FlowEventId.DidFailRestore:\n case FlowEventId.DidReceiveError:\n case FlowEventId.DidFailLoadingProducts:\n return [event.error] as ExtractedArgs<T>;\n\n case FlowEventId.DidPerformAction:\n // For DidPerformAction, different handlers need different arguments\n if (handlerName === 'onUrlPress' && event.action.type === 'open_url') {\n return [event.action.value, event.action.openIn] as ExtractedArgs<T>;\n }\n if (handlerName === 'onCustomAction' && event.action.type === 'custom') {\n return [event.action.value] as ExtractedArgs<T>;\n }\n // onCloseButtonPress, onAndroidSystemBack don't take arguments\n return [] as ExtractedArgs<T>;\n\n case FlowEventId.DidFinishWebPaymentNavigation:\n return [event.product, event.error] as unknown as ExtractedArgs<T>;\n\n case FlowEventId.DidReceiveAnalyticEvent:\n return [event.name, event.params] as ExtractedArgs<T>;\n\n case FlowEventId.DidAskPermission:\n return [event.permission, event.customArgs] as ExtractedArgs<T>;\n\n case FlowEventId.ObserverDidInitiatePurchase:\n case FlowEventId.ObserverDidInitiateRestore:\n // Args (product + SDK-provided start/finish callbacks) are injected by\n // the view emitter's dedicated observer branch, not here.\n return [] as ExtractedArgs<T>;\n\n case FlowEventId.DidAppear:\n return [event.view] as ExtractedArgs<T>;\n\n case FlowEventId.DidRequestAppReview:\n case FlowEventId.DidDisappear:\n case FlowEventId.DidStartRestore:\n return [] as ExtractedArgs<T>;\n }\n}\n","import type { OnboardingEventHandlers } from './types';\nimport { OnboardingEventId } from '@/types/onboarding-events';\nimport type {\n OnboardingEventIdType,\n ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\ntype EventName = keyof OnboardingEventHandlers;\n\n/**\n * Keyed by {@link OnboardingEventIdType} rather than `string`, so an id that is\n * not a real onboarding event cannot be mapped and a newly added one cannot be\n * forgotten. This is what lets {@link HANDLER_TO_EVENT_CONFIG} expose\n * `nativeEvent` as a checked id instead of a bare string.\n */\ntype UiEventMapping = Record<\n OnboardingEventIdType,\n {\n handlerName: keyof OnboardingEventHandlers;\n propertyMap?: {\n [key: string]: string;\n };\n }[]\n>;\n\nexport const ONBOARDING_EVENT_MAPPINGS: UiEventMapping = {\n onboarding_on_close_action: [\n {\n handlerName: 'onClose',\n },\n ],\n onboarding_on_custom_action: [\n {\n handlerName: 'onCustom',\n },\n ],\n onboarding_on_paywall_action: [\n {\n handlerName: 'onPaywall',\n },\n ],\n onboarding_on_state_updated_action: [\n {\n handlerName: 'onStateUpdated',\n },\n ],\n onboarding_did_finish_loading: [\n {\n handlerName: 'onFinishedLoading',\n },\n ],\n onboarding_on_analytics_action: [\n {\n handlerName: 'onAnalytics',\n },\n ],\n onboarding_did_fail_with_error: [\n {\n handlerName: 'onError',\n },\n ],\n};\n\nexport const HANDLER_TO_EVENT_CONFIG: Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n> = Object.entries(ONBOARDING_EVENT_MAPPINGS).reduce(\n (acc, [nativeEvent, mappings]) => {\n mappings.forEach(({ handlerName }) => {\n acc[handlerName] = {\n // Object.entries widens the key to `string`; UiEventMapping already\n // constrains it, so the narrowing is a restatement, not an assumption.\n nativeEvent: nativeEvent as OnboardingEventIdType,\n handlerName,\n };\n });\n return acc;\n },\n {} as Record<\n keyof OnboardingEventHandlers,\n {\n nativeEvent: OnboardingEventIdType;\n handlerName: keyof OnboardingEventHandlers;\n }\n >,\n);\n\n// Reverse mapping: nativeEvent -> EventName[]\nexport const NATIVE_EVENT_TO_HANDLERS: Record<string, EventName[]> =\n Object.entries(HANDLER_TO_EVENT_CONFIG).reduce(\n (acc, [handlerName, config]) => {\n if (!acc[config.nativeEvent]) {\n acc[config.nativeEvent] = [];\n }\n const handlers = acc[config.nativeEvent];\n if (handlers) {\n handlers.push(handlerName as EventName);\n }\n return acc;\n },\n {} as Record<string, EventName[]>,\n );\n\ntype ExtractedArgs<T extends keyof OnboardingEventHandlers> = Parameters<\n OnboardingEventHandlers[T]\n>;\n\nexport function extractOnboardingCallbackArgs<\n T extends keyof OnboardingEventHandlers,\n>(_handlerName: T, event: ParsedOnboardingEvent): ExtractedArgs<T> {\n switch (event.id) {\n case OnboardingEventId.Close:\n case OnboardingEventId.Custom:\n case OnboardingEventId.Paywall:\n return [event.actionId, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.StateUpdated:\n return [event.action, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.FinishedLoading:\n return [event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.Analytics:\n return [\n {\n ...event.event,\n // Add backward compatibility: populate element_id from elementId\n element_id: event.event.elementId,\n },\n event.meta,\n ] as ExtractedArgs<T>;\n\n case OnboardingEventId.Error:\n return [event.error] as ExtractedArgs<T>;\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport {\n AdaptyPaywallProduct,\n AdaptyProductIdentifier,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\nimport { FileLocation, MakePurchaseParamsInput } from '@/types/inputs';\nimport type { AdaptyPermission, FlowEventView } from '@/types/flow-events';\n\n/**\n * @internal\n */\nexport type ArgType<T> = T extends () => unknown\n ? void\n : T extends (arg: infer U) => unknown\n ? U\n : void;\n\n/**\n * EventHandler callback should not return a promise,\n * because using `await` may postpone closing a flow view.\n *\n * We don't want to block the UI thread.\n */\nexport type EventHandlerResult = boolean | void;\n\n/**\n * Purchase parameters keyed by AdaptyProductIdentifier objects\n */\nexport type ProductPurchaseParams = Array<{\n productId: AdaptyProductIdentifier;\n params: MakePurchaseParamsInput;\n}>;\n\n/**\n * Result of an OS permission request, returned to native by the SDK.\n */\nexport type FlowPermissionStatus = 'granted' | 'denied';\n\nexport interface FlowPermissionResponse {\n status: FlowPermissionStatus;\n /** Optional human-readable detail (e.g. the OS status string). */\n detail?: string;\n}\n\n/**\n * Hashmap of possible events to their callbacks\n *\n * @see {@link https://adapty.io/docs/react-native-handling-events-1 | [DOC] Handling View Events}\n */\nexport interface FlowEventHandlers {\n /**\n * Called when a user taps the close button on the flow view\n *\n * If you return `true`, the flow view will be closed.\n * We strongly recommend to return `true` in this case.\n * @default true\n */\n onCloseButtonPress: () => EventHandlerResult;\n /**\n * Called when a user navigates back on Android\n *\n * Return `true` to close the flow view.\n * By default, this handler returns `false`, so the flow view stays open.\n * @default false\n */\n onAndroidSystemBack: () => EventHandlerResult;\n /**\n * Called when a user taps the product in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onProductSelected: (productId: string) => EventHandlerResult;\n /**\n * Called when a user taps the purchase button in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult;\n /**\n * Called when the purchase succeeds, the user cancels their purchase, or the purchase appears to be pending\n *\n * If you return `true` from this callback, the flow view will be closed.\n * We strongly recommend returning `purchaseResult.type !== 'user_cancelled'` in this case.\n * @default false\n *\n * @param {AdaptyPurchaseResult} purchaseResult - object, which provides details about the purchase.\n * If the result is `'success'`, it also includes the updated user's profile.\n */\n onPurchaseCompleted: (\n purchaseResult: AdaptyPurchaseResult,\n product: AdaptyPaywallProduct,\n ) => EventHandlerResult;\n /**\n * Called if a purchase fails after a user taps the purchase button\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onPurchaseFailed: (\n error: AdaptyError,\n product: AdaptyPaywallProduct,\n ) => EventHandlerResult;\n /**\n * Called when a user taps the restore button in the flow view\n *\n * If you return `true` from this callback, the flow view will be closed.\n */\n onRestoreStarted: () => EventHandlerResult;\n\n /**\n * Called when the flow view disappears\n *\n * If you return `true`, the flow view will be closed.\n * @default false\n */\n onDisappeared: () => EventHandlerResult;\n\n /**\n * Called when the flow view appears\n *\n * If you return `true`, the flow view will be closed.\n * @default false\n *\n * @param view - the flow view that appeared; see {@link FlowEventView} for\n * the fields it carries, of which only `locale` is optional\n */\n onAppeared: (view: FlowEventView) => EventHandlerResult;\n\n onWebPaymentNavigationFinished: (\n product?: AdaptyPaywallProduct,\n error?: AdaptyError,\n ) => EventHandlerResult;\n /**\n * Called when a restore is completed\n *\n * If you return `true` from this callback, the flow view will be closed.\n * @default false\n *\n * @param {AdaptyProfile} profile - updated user profile\n */\n onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult;\n /**\n * Called if a restore fails after a user taps the restore button\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onRestoreFailed: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called when the flow view receives an error (e.g. it fails to render).\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onError: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called if a product list fails to load on a presented view,\n * for example, if there is no internet connection\n *\n * If you return `true` from this callback, the flow view will be closed.\n *\n * @param {AdaptyError} error - AdaptyError object with error code and message\n */\n onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult;\n onCustomAction: (actionId: string) => EventHandlerResult;\n /**\n * Called when the user taps a URL/link inside the paywall.\n *\n * @param url - URL to open\n * @param openIn - How the URL was configured to open in the dashboard:\n * `'browser_in_app'` — in-app browser (e.g. `WKWebView` / `Custom Tabs`)\n * `'browser_out_app'` (default) — external browser (e.g. `Linking.openURL`)\n */\n onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult;\n /**\n * Called when the flow view asks the host app to show the native\n * app review prompt (e.g. `SKStoreReviewController` on iOS,\n * In-App Review on Android).\n *\n * This is a notification: returning `true` would close the view,\n * but for an app-review prompt you almost always want to keep it open.\n */\n onRequestAppReview: () => EventHandlerResult;\n /**\n * Called when the flow view reports an analytics event.\n *\n * This is a notification: the return value follows the standard\n * close-on-`true` contract, but you normally keep the view open.\n *\n * @param name - analytics event name\n * @param params - arbitrary event parameters\n */\n onAnalytics: (\n name: string,\n params: Record<string, unknown>,\n ) => EventHandlerResult;\n /**\n * Called when the flow view asks the host app to request an OS-level\n * permission (e.g. notifications, ATT). This is the only **asynchronous**\n * handler: return a `Promise` that resolves with the resulting status.\n *\n * If you do not provide a handler, the SDK replies `'denied'`.\n *\n * @param permission - permission identifier the flow view requested\n * @param customArgs - arbitrary string args configured in the dashboard\n */\n onRequestPermission: (\n permission: AdaptyPermission,\n customArgs: Record<string, string>,\n ) => Promise<FlowPermissionResponse>;\n /**\n * Called in **observer mode** when the user taps the purchase button inside\n * an Adapty-rendered flow view. Adapty does NOT make the purchase —\n * your app performs it through its own purchase API. Drive the flow view's\n * loading state with the two provided callbacks:\n *\n * - call `onStartPurchase()` right before you begin the purchase (shows the\n * flow view's loading indicator);\n * - call `onFinishPurchase()` once it settles, success or failure (hides it).\n *\n * The return value follows the standard close-on-`true` contract; you\n * normally keep the view open (`false`) and dismiss it yourself after the\n * purchase succeeds.\n *\n * @remarks\n * Fires only when the SDK was activated in observer mode\n * (`activate(apiKey, { observerMode: true })`). Without it, Adapty handles\n * purchases itself and this event is never emitted.\n *\n * Adapty does not see the purchase you make, so after it succeeds you must\n * report the transaction to Adapty yourself (e.g. via `reportTransaction`). The\n * `onStartPurchase`/`onFinishPurchase` callbacks only drive the flow view's\n * loading UI;\n *\n * @param product - product the user initiated the purchase for\n * @param onStartPurchase - notify the flow view the purchase started\n * @param onFinishPurchase - notify the flow view the purchase finished\n */\n onObserverPurchaseInitiated: (\n product: AdaptyPaywallProduct,\n onStartPurchase: () => void,\n onFinishPurchase: () => void,\n ) => EventHandlerResult;\n /**\n * Called in **observer mode** when the user taps the restore button inside an\n * Adapty-rendered flow view. Adapty does NOT restore — your app\n * performs it through its own API. Drive the flow view's loading state with the\n * two provided callbacks (`onStartRestore()` / `onFinishRestore()`).\n *\n * @remarks\n * Fires only when the SDK was activated in observer mode\n * (`activate(apiKey, { observerMode: true })`). Without it, Adapty handles\n * restores itself and this event is never emitted.\n *\n * Report any transactions surfaced by the restore to Adapty yourself (e.g.\n * via `reportTransaction`) so they flow into events and analytics. The\n * `onStartRestore`/`onFinishRestore` callbacks only drive the flow view's\n * loading UI; they do not report anything.\n *\n * @param onStartRestore - notify the flow view the restore started\n * @param onFinishRestore - notify the flow view the restore finished\n */\n onObserverRestoreInitiated: (\n onStartRestore: () => void,\n onFinishRestore: () => void,\n ) => EventHandlerResult;\n}\n\nexport interface OnboardingEventHandlers {\n onClose: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onCustom: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onPaywall: (\n actionId: string,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onStateUpdated: (\n action: OnboardingStateUpdatedAction,\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onFinishedLoading: (meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onAnalytics: (\n event: {\n name: OnboardingAnalyticsEventName;\n /**\n * @deprecated Use `elementId` instead\n */\n element_id?: string;\n elementId?: string;\n reply?: string;\n },\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onError: (error: AdaptyError) => EventHandlerResult;\n}\n\nexport type OnboardingAnalyticsEventName =\n | 'onboarding_started'\n | 'screen_presented'\n | 'screen_completed'\n | 'second_screen_presented'\n | 'registration_screen_presented'\n | 'products_screen_presented'\n | 'user_email_collected'\n | 'onboarding_completed'\n | (string & {});\n\nexport type AdaptyUiOnboardingMeta = {\n onboardingId: string;\n screenClientId: string;\n screenIndex: number;\n totalScreens: number;\n};\n\nexport type AdaptyUiOnboardingStateParams = {\n id: string;\n value: string;\n label: string;\n};\n\nexport type OnboardingStateUpdatedAction =\n | {\n elementId: string;\n elementType: 'select';\n value: AdaptyUiOnboardingStateParams;\n }\n | {\n elementId: string;\n elementType: 'multi_select';\n value: AdaptyUiOnboardingStateParams[];\n }\n | {\n elementId: string;\n elementType: 'input';\n value:\n | { type: 'text' | 'email'; value: string }\n | { type: 'number'; value: number };\n }\n | {\n elementId: string;\n elementType: 'date_picker';\n value: {\n day?: number;\n month?: number;\n year?: number;\n };\n };\n\n/**\n * Additional options for creating a flow view\n *\n * @see {@link https://docs.adapty.io/docs/paywall-builder-fetching | [DOC] Creating Flow View}\n */\nexport interface CreateFlowViewParamsInput {\n /**\n * The identifier of the localization to render the flow with, e.g. `en`, `es`, `fr`.\n *\n * @remarks\n * When undefined, `en` is requested rather than the flow's default localization.\n * If the requested localization does not exist, the flow's default localization is used.\n *\n * @see {@link FlowEventView.locale} — the localization the view was actually\n * built with.\n */\n locale?: string;\n /**\n * The id of a custom layout to render instead of the one resolved\n * automatically for the current device.\n */\n customLayoutId?: string;\n /**\n * `true` if you want to prefetch products before presenting a flow view.\n */\n prefetchProducts?: boolean;\n /**\n * This value limits the timeout (in milliseconds) for this method.\n */\n loadTimeoutMs?: number;\n /**\n * If you are going to use custom tags functionality, pass an object with tags and corresponding replacement values\n *\n * ```\n * {\n * 'USERNAME': 'Bruce',\n * 'CITY': 'Philadelphia'\n * }\n * ```\n */\n customTags?: Record<string, string>;\n /**\n * If you are going to use custom timer functionality, pass an object with timer ids and corresponding dates the timers should end at\n */\n customTimers?: Record<string, Date>;\n\n customAssets?: Record<string, AdaptyCustomAsset>;\n\n productPurchaseParams?: ProductPurchaseParams;\n\n android?: {\n /**\n * When `true`, the flow view applies safe-area paddings.\n *\n * @platform android\n * @remarks\n * When omitted, the default is decided by the presenting API you use.\n */\n enableSafeArea?: boolean;\n };\n}\n\n/**\n * Additional options for creating an onboarding view\n *\n * @see {@link https://adapty.io/docs/react-native-get-onboardings | [DOC] Creating Onboarding View}\n */\nexport interface CreateOnboardingViewParamsInput {\n /**\n * If you want to change the presentation behavior of external URLs, pass a preferred value.\n *\n * @default {@link WebPresentation.BrowserInApp}\n */\n externalUrlsPresentation?: WebPresentation;\n}\n\nexport interface AdaptyUiView {\n id: string;\n locale?: string;\n}\n\nexport interface AdaptyUiMediaCache {\n memoryStorageTotalCostLimit?: number;\n memoryStorageCountLimit?: number;\n diskStorageSizeLimit?: number;\n}\n\nexport interface AdaptyUiDialogConfig {\n /**\n * The action title to display as part of the dialog. If you provide two actions,\n * be sure `primaryAction` cancels the operation and leaves things unchanged.\n */\n primaryActionTitle: string;\n /**\n * The secondary action title to display as part of the dialog.\n */\n secondaryActionTitle?: string;\n /**\n * The title of the dialog.\n */\n title?: string;\n /**\n * Descriptive text that provides additional details about the reason for the dialog.\n */\n content?: string;\n}\n\nexport const AdaptyUiDialogActionType = Object.freeze({\n primary: 'primary',\n secondary: 'secondary',\n});\nexport type AdaptyUiDialogActionType =\n (typeof AdaptyUiDialogActionType)[keyof typeof AdaptyUiDialogActionType];\n\nexport type AdaptyCustomAsset =\n | AdaptyCustomImageAsset\n | AdaptyCustomVideoAsset\n | AdaptyCustomColorAsset\n | AdaptyCustomGradientAsset;\n\nexport type AdaptyCustomImageAsset =\n | { type: 'image'; base64: string }\n | { type: 'image'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'image'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomVideoAsset =\n | { type: 'video'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'video'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomColorAsset =\n | { type: 'color'; argb: number /* e.g. 0xFFFF0000 (opaque red) */ }\n | { type: 'color'; rgb: number /* e.g. 0xFF0000 (red) */ }\n | { type: 'color'; rgba: number /* e.g. 0xFF0000FF (opaque red) */ };\n\nexport type AdaptyCustomGradientAsset = {\n type: 'linear-gradient';\n values: (\n | { p: number; argb: number }\n | { p: number; rgb: number }\n | { p: number; rgba: number }\n )[];\n points?: { x0?: number; y0?: number; x1?: number; y1?: number };\n};\n\n/**\n * iOS presentation style for flow and onboarding views\n */\nexport type AdaptyIOSPresentationStyle = 'full_screen' | 'page_sheet';\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\n\nconst AdaptyTypes = [\n 'AdaptyError',\n 'AdaptyProfile',\n 'AdaptyPurchaseResult',\n 'AdaptyFlow',\n 'AdaptyPaywallProduct',\n 'AdaptyPromotedProduct',\n 'AdaptyOnboarding',\n 'AdaptyRemoteConfig',\n 'AdaptyInstallationStatus',\n 'AdaptyInstallationDetails',\n 'AdaptyUiView',\n 'AdaptyUiDialogActionType',\n 'AdaptyUiOnboardingMeta',\n 'AdaptyUiOnboardingStateParams',\n 'AdaptyUiOnboardingStateUpdatedAction',\n 'Array<AdaptyPaywallProduct>',\n 'BridgeError',\n 'String',\n 'Boolean',\n 'Void',\n] as const;\n\nexport type AdaptyType = (typeof AdaptyTypes)[number];\n\ninterface AdaptyResult<T> {\n success?: T;\n error?: AdaptyResultError;\n}\n\ninterface AdaptyResultError {\n adaptyCode: number;\n message: string;\n detail?: string;\n}\n\nexport function parseMethodResult<T>(\n factory: CoderFactory,\n input: string,\n resultType: AdaptyType,\n ctx?: LogContext,\n): T {\n const log = ctx?.decode({ methodName: 'parseMethodResult' });\n log?.start(() => ({ input }));\n\n let obj: AdaptyResult<unknown>;\n\n // Attempt to parse the input into a JSON object\n try {\n obj = JSON.parse(input);\n } catch (error) {\n const adaptyError = AdaptyError.failedToDecode(\n `Failed to decode native response. JSON.parse raised an error: ${\n (error as Error)?.message || ''\n }`,\n );\n\n log?.failed(() => ({ error: adaptyError.message }));\n throw adaptyError;\n }\n\n if (obj.hasOwnProperty('success')) {\n if (\n [\n 'String',\n 'Boolean',\n 'Void',\n 'AdaptyUiView',\n 'AdaptyUiDialogActionType',\n ].includes(resultType)\n ) {\n return obj.success as T;\n }\n\n const coder = getCoder(factory, resultType, ctx);\n return coder?.decode(obj.success);\n } else if (obj.hasOwnProperty('error')) {\n const coder = getCoder(factory, 'AdaptyError', ctx);\n const errorData = coder?.decode(obj.error);\n throw (coder as ErrorConverter<any>).getError(errorData);\n } else {\n const adaptyError = AdaptyError.failedToDecode(\n `Failed to decode native response. Response does not have expected \"success\" or \"error\" property`,\n );\n log?.failed(() => ({ error: adaptyError.message }));\n throw adaptyError;\n }\n}\n\nexport function parseCommonEvent(\n factory: CoderFactory,\n event: string,\n input: string,\n ctx?: LogContext,\n) {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n switch (event) {\n case 'did_load_latest_profile':\n return getCoder(factory, 'AdaptyProfile', ctx)?.decode(obj['profile']);\n case 'did_receive_promoted_purchase':\n return getCoder(factory, 'AdaptyPromotedProduct', ctx)?.decode(\n obj['product'],\n );\n case 'on_installation_details_success':\n return getCoder(factory, 'AdaptyInstallationDetails', ctx)?.decode(\n obj['details'],\n );\n case 'on_installation_details_fail':\n return getCoder(factory, 'AdaptyError', ctx)?.decode(obj['error']);\n default:\n return null;\n }\n}\n\nfunction getCoder(\n factory: CoderFactory,\n type: AdaptyType,\n ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> | null {\n ctx?.stack;\n\n switch (type as AdaptyType) {\n case 'AdaptyError':\n return factory.createNativeErrorCoder();\n case 'AdaptyProfile':\n return factory.createProfileCoder();\n case 'AdaptyFlow':\n return factory.createFlowCoder();\n case 'AdaptyPaywallProduct':\n return factory.createPaywallProductCoder();\n case 'AdaptyPromotedProduct':\n return factory.createPromotedProductCoder();\n case 'AdaptyRemoteConfig':\n return factory.createRemoteConfigCoder();\n case 'AdaptyOnboarding':\n return factory.createOnboardingCoder();\n case 'AdaptyPurchaseResult':\n return factory.createPurchaseResultCoder();\n case 'AdaptyInstallationStatus':\n return factory.createInstallationStatusCoder();\n case 'AdaptyInstallationDetails':\n return factory.createInstallationDetailsCoder();\n case 'AdaptyUiOnboardingMeta':\n return factory.createUiOnboardingMetaCoder();\n case 'AdaptyUiOnboardingStateParams':\n return factory.createUiOnboardingStateParamsCoder();\n case 'AdaptyUiOnboardingStateUpdatedAction':\n return factory.createUiOnboardingStateUpdatedActionCoder();\n case 'BridgeError':\n return factory.createBridgeErrorCoder();\n case 'Array<AdaptyPaywallProduct>':\n return factory.createPaywallProductArrayCoder();\n case 'String':\n return null;\n }\n // @ts-ignore\n throw AdaptyError.failedToDecode(\n `Failed to decode native response. Response has unexpected \"type\" property: ${type}`,\n );\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\nimport type {\n AdaptyPaywallProduct,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '@/types';\nimport {\n FlowEventId,\n type FlowEventView,\n type ParsedFlowEvent,\n type FlowUserAction,\n} from '@/types/flow-events';\n\n// Re-export types for convenience\nexport {\n FlowEventId,\n type FlowEventIdType,\n type FlowEventView,\n type FlowDidAppearEvent,\n type FlowDidDisappearEvent,\n type FlowDidPerformActionEvent,\n type FlowUserAction,\n type FlowDidSelectProductEvent,\n type FlowDidStartPurchaseEvent,\n type FlowDidFinishPurchaseEvent,\n type FlowDidFailPurchaseEvent,\n type FlowDidStartRestoreEvent,\n type FlowDidFinishRestoreEvent,\n type FlowDidFailRestoreEvent,\n type FlowDidReceiveErrorEvent,\n type FlowDidFailLoadingProductsEvent,\n type FlowDidFinishWebPaymentNavigationEvent,\n type FlowDidRequestAppReviewEvent,\n type FlowDidReceiveAnalyticEvent,\n type FlowDidAskPermissionEvent,\n type FlowObserverDidInitiatePurchaseEvent,\n type FlowObserverDidInitiateRestoreEvent,\n type ParsedFlowEvent,\n} from '@/types/flow-events';\n\n// Parser\nexport function parseFlowEvent(\n factory: CoderFactory,\n input: string,\n ctx?: LogContext,\n): ParsedFlowEvent | null {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n\n const eventId = obj['id'] as string | undefined;\n if (!eventId?.startsWith('flow_view_')) {\n return null;\n }\n\n const viewObj = obj['view'] as Record<string, unknown>;\n const view: FlowEventView = {\n id: viewObj['id'] as string,\n placementId: viewObj['placement_id'] as string,\n variationId: viewObj['variation_id'] as string,\n locale: viewObj['locale'] as string | undefined,\n };\n\n switch (eventId) {\n case FlowEventId.DidAppear:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidDisappear:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidPerformAction: {\n const actionObj = obj['action'] as Record<string, unknown>;\n return {\n id: eventId,\n view,\n action: parseFlowUserAction(actionObj),\n };\n }\n\n case FlowEventId.DidSelectProduct:\n return {\n id: eventId,\n view,\n productId: (obj['product_id'] as string) ?? '',\n };\n\n case FlowEventId.DidStartPurchase:\n return {\n id: eventId,\n view,\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.DidFinishPurchase:\n return {\n id: eventId,\n view,\n purchaseResult: getFlowCoder(factory, 'purchaseResult', ctx)!.decode(\n obj['purchased_result'],\n ) as AdaptyPurchaseResult,\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.DidFailPurchase: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n }\n\n case FlowEventId.DidStartRestore:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidFinishRestore:\n return {\n id: eventId,\n view,\n profile: getFlowCoder(factory, 'profile', ctx)!.decode(\n obj['profile'],\n ) as AdaptyProfile,\n };\n\n case FlowEventId.DidFailRestore: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidReceiveError: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidFailLoadingProducts: {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n case FlowEventId.DidFinishWebPaymentNavigation:\n return {\n id: eventId,\n view,\n product: obj['product']\n ? (getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct)\n : undefined,\n error: obj['error']\n ? (() => {\n const errorCoder = getFlowCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return errorCoder.getError(decodedError);\n })()\n : undefined,\n };\n\n case FlowEventId.DidRequestAppReview:\n return {\n id: eventId,\n view,\n };\n\n case FlowEventId.DidReceiveAnalyticEvent: {\n const params = obj['params'];\n return {\n id: eventId,\n view,\n name: typeof obj['name'] === 'string' ? obj['name'] : '',\n params:\n typeof params === 'object' && params !== null\n ? (params as Record<string, unknown>)\n : {},\n };\n }\n\n case FlowEventId.DidAskPermission:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n permission:\n typeof obj['permission'] === 'string' ? obj['permission'] : '',\n customArgs:\n typeof obj['custom_args'] === 'object' && obj['custom_args'] !== null\n ? (obj['custom_args'] as Record<string, string>)\n : {},\n };\n\n case FlowEventId.ObserverDidInitiatePurchase:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n product: getFlowCoder(factory, 'product', ctx)!.decode(\n obj['product'],\n ) as AdaptyPaywallProduct,\n };\n\n case FlowEventId.ObserverDidInitiateRestore:\n return {\n id: eventId,\n view,\n eventId: typeof obj['event_id'] === 'string' ? obj['event_id'] : '',\n };\n\n default:\n return null;\n }\n}\n\nfunction parseFlowUserAction(\n actionObj: Record<string, unknown>,\n): FlowUserAction {\n const type = actionObj['type'] as FlowUserAction['type'];\n switch (type) {\n case 'open_url':\n return {\n type,\n value: actionObj['value'] as string,\n openIn: actionObj['open_in'] as WebPresentation,\n };\n case 'custom':\n return { type, value: actionObj['value'] as string };\n case 'close':\n case 'system_back':\n return { type };\n }\n}\n\ntype FlowCoderType = 'product' | 'profile' | 'purchaseResult' | 'error';\n\nfunction getFlowCoder(\n factory: CoderFactory,\n type: FlowCoderType,\n _ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> {\n switch (type) {\n case 'product':\n return factory.createPaywallProductCoder();\n case 'profile':\n return factory.createProfileCoder();\n case 'purchaseResult':\n return factory.createPurchaseResultCoder();\n case 'error':\n return factory.createNativeErrorCoder();\n }\n}\n","import { AdaptyError } from '@/adapty-error';\nimport { LogContext } from '../logger';\nimport { ErrorConverter } from './error-coder';\nimport type { CoderFactory } from './factory';\nimport type { Converter } from './types';\nimport type { AdaptyUiOnboardingMeta } from '@/ui-builder/types';\nimport type { OnboardingStateUpdatedAction } from '@/ui-builder/types';\nimport {\n OnboardingEventId,\n type OnboardingEventView,\n type ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\n// Re-export types for convenience\nexport {\n OnboardingEventId,\n type OnboardingEventIdType,\n type OnboardingEventView,\n type OnboardingCloseEvent,\n type OnboardingCustomEvent,\n type OnboardingPaywallEvent,\n type OnboardingStateUpdatedEvent,\n type OnboardingFinishedLoadingEvent,\n type OnboardingAnalyticsEvent,\n type OnboardingErrorEvent,\n type ParsedOnboardingEvent,\n} from '@/types/onboarding-events';\n\n// Parser\nexport function parseOnboardingEvent(\n factory: CoderFactory,\n input: string,\n ctx?: LogContext,\n): ParsedOnboardingEvent | null {\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(input);\n } catch (error) {\n throw AdaptyError.failedToDecode(\n `Failed to decode event: ${(error as Error)?.message}`,\n );\n }\n\n const eventId = obj['id'] as string | undefined;\n if (!eventId?.startsWith('onboarding_')) {\n return null;\n }\n\n const viewObj = obj['view'] as Record<string, unknown>;\n const view: OnboardingEventView = {\n id: viewObj['id'] as string,\n placementId: viewObj['placement_id'] as string | undefined,\n variationId: viewObj['variation_id'] as string | undefined,\n };\n const decodeMeta = () =>\n getOnboardingCoder(factory, 'meta', ctx)!.decode(\n obj['meta'],\n ) as AdaptyUiOnboardingMeta;\n\n switch (eventId) {\n case OnboardingEventId.Close:\n case OnboardingEventId.Custom:\n case OnboardingEventId.Paywall:\n return {\n id: eventId,\n view,\n actionId: (obj['action_id'] as string) ?? '',\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.StateUpdated:\n return {\n id: eventId,\n view,\n action: getOnboardingCoder(factory, 'action', ctx)!.decode(\n obj['action'],\n ) as OnboardingStateUpdatedAction,\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.FinishedLoading:\n return {\n id: eventId,\n view,\n meta: decodeMeta(),\n };\n\n case OnboardingEventId.Analytics: {\n const eventObj = obj['event'] as Record<string, any>;\n return {\n id: eventId,\n view,\n event: {\n name: eventObj['name'] as string,\n elementId: eventObj['element_id'] as string | undefined,\n reply: eventObj['reply'] as string | undefined,\n },\n meta: decodeMeta(),\n };\n }\n\n case OnboardingEventId.Error: {\n const errorCoder = getOnboardingCoder(\n factory,\n 'error',\n ctx,\n ) as ErrorConverter<any>;\n const decodedError = errorCoder.decode(obj['error']);\n return {\n id: eventId,\n view,\n error: errorCoder.getError(decodedError),\n };\n }\n\n default:\n return null;\n }\n}\n\ntype OnboardingCoderType = 'meta' | 'action' | 'error';\n\nfunction getOnboardingCoder(\n factory: CoderFactory,\n type: OnboardingCoderType,\n _ctx?: LogContext,\n): Converter<any, any> | ErrorConverter<any> {\n switch (type) {\n case 'meta':\n return factory.createUiOnboardingMetaCoder();\n case 'action':\n return factory.createUiOnboardingStateUpdatedActionCoder();\n case 'error':\n return factory.createNativeErrorCoder();\n }\n}\n","/**\n * Generates a short unique identifier.\n * Format: 12 lowercase alphanumeric characters\n */\nexport function generateId(): string {\n let id = '';\n while (id.length < 12) {\n id += Math.random().toString(36).slice(2);\n }\n return id.slice(0, 12);\n}\n","/**\n * Removes undefined properties from an object, preserving the original type structure\n * @param obj - Source object with potentially undefined values\n * @returns Object with undefined values filtered out\n */\nexport function filterUndefined<T extends object>(obj: T): T {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined),\n ) as T;\n}\n","/**\n * Maps over values of an object, transforming each value using the provided function.\n *\n * @param obj - The object to map over\n * @param fn - Function to transform each value\n * @returns New object with transformed values\n */\nexport function mapValues<T extends Record<string, any>>(\n obj: T,\n fn: (value: T[keyof T], key: keyof T) => any,\n): T {\n return Object.fromEntries(\n Object.entries(obj).map(([key, value]) => [key, fn(value, key)]),\n ) as T;\n}\n","/**\n * Checks if a value is a plain object (not an array, null, Date, etc.)\n */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !(value instanceof RegExp) &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Deep merge implementation that replaces arrays and merges objects\n */\nfunction deepMerge(\n target: unknown,\n source: unknown,\n seen = new Set(),\n): unknown {\n // Handle null/undefined cases\n if (source === null || source === undefined) {\n return source;\n }\n\n if (target === null || target === undefined) {\n return source;\n }\n\n // Handle arrays - replace them (source overwrites target)\n if (Array.isArray(source)) {\n return source;\n }\n\n // If target is array but source is not, return source\n if (Array.isArray(target)) {\n return source;\n }\n\n // Handle plain objects - merge recursively\n if (isPlainObject(target) && isPlainObject(source)) {\n // Check for circular references\n if (seen.has(source) || seen.has(target)) {\n throw new Error('Converting circular structure to JSON');\n }\n\n seen.add(source);\n seen.add(target);\n\n const result: Record<string, unknown> = {};\n\n // Get all keys from both objects\n const allKeys = new Set([...Object.keys(target), ...Object.keys(source)]);\n\n for (const key of allKeys) {\n // Skip prototype pollution attempts\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n if (key in source) {\n if (key in target) {\n // Check for circular reference in values\n if (seen.has(source[key]) || seen.has(target[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Recursively merge if key exists in both\n result[key] = deepMerge(target[key], source[key], seen);\n } else {\n // Check for circular reference in source value\n if (seen.has(source[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Use source value if key only exists in source\n result[key] = source[key];\n }\n } else {\n // Check for circular reference in target value\n if (seen.has(target[key])) {\n throw new Error('Converting circular structure to JSON');\n }\n // Use target value if key only exists in target\n result[key] = target[key];\n }\n }\n\n seen.delete(source);\n seen.delete(target);\n\n return result;\n }\n\n // For all other cases (primitives, functions, dates, etc.), return source\n return source;\n}\n\n/**\n * Universal method for merging options with defaults\n * @param options - input options\n * @param defaults - default values\n * @returns merged object with TResult type\n */\nexport function mergeOptions<TResult = unknown>(\n options: unknown,\n defaults: unknown,\n): TResult {\n return deepMerge(defaults, options) as TResult;\n}\n","function toJSON(this: Error & { originalError: unknown }) {\n return {\n message: this.message,\n name: this.name,\n stack: this.stack,\n originalError:\n this.originalError instanceof Error\n ? {\n message: this.originalError.message,\n name: this.originalError.name,\n }\n : this.originalError,\n };\n}\n/**\n * Wraps a user-provided callback with error context enrichment.\n * Catches exceptions and wraps them with source and handler information.\n */\nexport function withErrorContext<T extends (...args: never[]) => unknown>(\n callback: T,\n handlerName: string,\n source: string,\n): T {\n const wrapped = function (\n this: unknown,\n ...args: Parameters<T>\n ): ReturnType<T> {\n try {\n return callback.apply(this, args) as ReturnType<T>;\n } catch (error) {\n const message = `Unhandled exception in user's handler in ${source}.${handlerName}`;\n\n const wrappedError = new Error(message) as Error & {\n originalError: unknown;\n toJSON: typeof toJSON;\n };\n wrappedError.originalError = error;\n wrappedError.toJSON = toJSON;\n\n throw wrappedError;\n }\n };\n\n return wrapped as T;\n}\n"],"mappings":";;;;;;;;AASA,MAAa,WAAW,OAAO,OAAO;CAKpC,SAAS;CAIT,OAAO;CAMP,MAAM;CAKN,MAAM;AACP,EAAC;AAIF,MAAa,cAAc,OAAO,OAAO;CACvC,6BAA6B;CAC7B,yBAAyB;CACzB,qCACE;AACH,EAAC;AA+LF,MAAa,iDAAiD,OAAO,OAAO;CAC1E,iBAAiB;CACjB,UAAU;CACV,kBAAkB;CAClB,qBAAqB;CACrB,mBAAmB;AACpB,E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AA6D,UAAU,EACzE;AAGH,SAAO,IAAI,KAAK;CACjB;CAED,OAAOC,OAAqB;AAC1B,SAAO,MAAM,aAAa;CAC3B;AACF;;;;AC3CD,IAAa,yBAAb,cAA4C,YAAiC;;;OACjE,aAA8C;GACtD,aAAa;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,0BAA0B;IACxB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,4BAA4B;IAC1B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,wBAAwB;IACtB,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,oBAAoB;IAClB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,IAAI;IACF,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,YAAY;IACV,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,OAAO;IACL,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,gBAAgB;IACd,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,SAAS,EACP,SAAS;IACP,KAAK;IACL,UAAU;IACV,MAAM;GACP,EACF;EACF;;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,OAAO;IAAE,KAAK;IAAS,UAAU;IAAO,MAAM;GAAU;GACxD,aAAa;IAAE,KAAK;IAAgB,UAAU;IAAO,MAAM;GAAU;GACrE,+BAA+B;IAC7B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,yBAAyB;IACvB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,mBAAmB;IACjB,KAAK;IACL,UAAU;IACV,MAAM;GACP;EACF;;AACF;;;;AC1BD,IAAa,0BAAb,cAA6C,YAAiC;;;OAClE,aAA8C;GACtD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,YAAY;IACV,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,OAAO;IACL,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,qBAAqB;IACnB,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,6BAA6B;IAC3B,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,aAAa;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,iBAAiB;IACf,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;GACP;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,WAAW;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,UAAU;IACR,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,gBAAgB;IACd,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,wBAAwB;IACtB,KAAK;IACL,UAAU;IACV,MAAM;IACN,WAAW,IAAI;GAChB;GACD,6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