@wireai/activation 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +33 -4
- package/dist/analytics/index.d.mts +21 -3
- package/dist/analytics/index.d.ts +21 -3
- package/dist/analytics/index.js +94 -61
- package/dist/analytics/index.js.map +1 -1
- package/dist/analytics/index.mjs +91 -62
- package/dist/analytics/index.mjs.map +1 -1
- package/dist/{currentSession-DdDkprpM.d.mts → currentSession-C0_odnIW.d.mts} +101 -1
- package/dist/{currentSession-D0Vq7_VE.d.ts → currentSession-DdnUq2HQ.d.ts} +101 -1
- package/dist/index.d.mts +3 -49
- package/dist/index.d.ts +3 -49
- package/dist/index.js +50 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -42
- package/dist/index.mjs.map +1 -1
- package/dist/questionnaire/index.js +10 -2
- package/dist/questionnaire/index.js.map +1 -1
- package/dist/questionnaire/index.mjs +10 -2
- package/dist/questionnaire/index.mjs.map +1 -1
- package/dist/reviews/index.d.mts +1 -1
- package/dist/reviews/index.d.ts +1 -1
- package/dist/reviews/index.js +24 -9
- package/dist/reviews/index.js.map +1 -1
- package/dist/reviews/index.mjs +24 -9
- package/dist/reviews/index.mjs.map +1 -1
- package/dist/{transport-Bzb-bcB2.d.mts → transport-BGW9uXZJ.d.mts} +0 -15
- package/dist/{transport-B31G0Cib.d.ts → transport-jUJd5kxu.d.ts} +0 -15
- package/llms.txt +8 -0
- package/package.json +1 -1
- package/src/analytics/analyticsFacade.ts +72 -9
- package/src/analytics/eventQueue.ts +12 -11
- package/src/analytics/index.ts +9 -0
- package/src/analytics/reportClientEvent.ts +12 -2
- package/src/context/userContext.ts +55 -0
- package/src/identity/userIdentity.ts +10 -0
- package/src/index.ts +5 -1
- package/src/questionnaire/transport.ts +5 -1
- package/src/reviews/decision.ts +8 -1
- package/src/reviews/transport.ts +6 -8
- package/src/session-analytics/lifecycle.ts +6 -11
- package/src/session-analytics/useLifecycleEvents.ts +41 -27
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/expo-modules-core/src/errors/CodedError.ts","../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts","../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../node_modules/expo-modules-core/src/requireNativeModule.ts","../node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts","../node_modules/expo-modules-core/src/registerWebModule.ts","../node_modules/expo-modules-core/src/TypedArrays.types.ts","../node_modules/expo-modules-core/src/PermissionsInterface.ts","../node_modules/expo-modules-core/src/PermissionsHook.ts","../node_modules/expo-modules-core/src/Refs.ts","../node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts","../node_modules/expo-modules-core/src/reload.ts","../node_modules/expo-modules-core/src/index.ts","../node_modules/expo-constants/src/Constants.types.ts","../node_modules/expo-constants/src/ExponentConstants.ts","../node_modules/expo-constants/src/Constants.ts","../src/theme/defaultTheme.ts","../src/theme/ThemeContext.tsx","../src/components/Illustration.tsx","../src/illustrations/defaultIllustrations.tsx","../src/icons/IconRegistry.tsx","../src/theme/typography.ts","../src/motion/motionSpec.ts","../src/motion/useReducedMotion.ts","../src/components/AnimatedSparkle.tsx","../src/components/LoadingBlock.tsx","../src/components/LoadingScreen.tsx","../src/components/StepProgress.tsx","../src/components/OnboardingScaffold.tsx","../src/components/Button.tsx","../src/components/ErrorBlock.tsx","../src/components/CardLayout.tsx","../src/components/CompletionView.tsx","../src/components/CardHandoff.tsx","../src/utils/deriveAnswers.ts","../src/utils/readProgress.ts","../src/analytics/reportClientEvent.ts","../src/analytics/sendPreview.ts","../src/OnboardingFlow.tsx","../src/cards/ChipSelectCard.tsx","../src/cards/TextInputCard.tsx","../src/icons/expoIcons.ts","../src/icons/vocabulary.ts","../src/icons/WireIcon.tsx","../src/cards/optionSchema.ts","../src/cards/SelectionCard.tsx","../src/cards/CardGridSelectCard.tsx","../src/cards/StatusCard.tsx","../src/cards/NumberStepperCard.tsx","../src/cards/InterstitialCard.tsx","../src/cards/index.ts","../src/device/appVersion.ts","../src/device/deviceModel.ts","../src/device/deviceContext.ts","../src/analytics/currentSession.ts","../src/session/persistedSession.ts","../src/identity/userIdentity.ts","../src/WireOnboarding.tsx","../src/DemoOnboarding.tsx","../src/theme/themeFromBrand.ts","../src/components/DoneBlock.tsx","../src/motion/centeredModalMotion.ts","../src/components/CenteredModal.tsx","../src/features/defaults.ts","../src/features/cache.ts","../src/features/fetchWireFeatures.ts","../src/features/useWireFeatures.ts","../src/features/WireFeaturesProvider.tsx","../src/config/wireConfigFromEnv.ts","../src/config/onboardingFlag.ts","../src/analytics/analyticsEvent.ts","../src/attribution/attribution.ts","../src/context/userContext.ts","../src/context/deviceId.ts","../src/activation/revalidation.ts","../src/activation/wireActivation.ts","../src/activation/useWireActivation.ts","../src/session-analytics/reportSessionStart.ts","../src/session-analytics/useSessionStart.ts","../src/session-analytics/lifecycle.ts","../src/analytics/eventQueue.ts","../src/session-analytics/useLifecycleEvents.ts"],"names":["name","_a","TurboModuleRegistry","AppOwnership","ExecutionEnvironment","UserInterfaceIdiom","Platform","NativeModules","createContext","useMemo","useContext","jsx","View","Text","jsxs","StyleSheet","EMPTY_REGISTRY","useState","useEffect","AccessibilityInfo","useRef","Animated","Easing","styles","React","SafeAreaView","TouchableOpacity","useCallback","Pressable","makeStyles","KeyboardAvoidingView","ScrollView","easeWire","Fragment","useWireAIThread","useWireAIAction","_b","_c","_d","step","_e","_f","ComponentRenderer","z","schema","useWindowDimensions","TextInput","Image","runtimeRequire","interop","constants","safeInterop","Dimensions","I18nManager","WireAIProvider","Modal","forwardRef","useImperativeHandle","BackHandler","READ_TIMEOUT_MS","withTimeout","cached","globalSlot","useSyncExternalStore","AppState","parsePersisted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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UAAA,EAAY;AAClD,QAAA,IAAI,cAAA,IAAkB,IAAA,EAAM,cAAA,GAAiB,IAAA,CAAK,GAAA,EAAI;AACtD,QAAA;AAAA,MACF;AACA,MAAA,IAAI,UAAU,QAAA,EAAU;AACtB,QAAA,MAAM,KAAA,GAAQ,cAAA;AACd,QAAA,cAAA,GAAiB,IAAA;AACjB,QAAA,IAAI,SAAS,IAAA,IAAQ,IAAA,CAAK,KAAI,GAAI,KAAA,IAAS,uBAAuB,WAAA,EAAY;AAAA,MAChF;AAAA,IACF,CAAA;AACA,IAAA,MAAM,GAAA,GAAM0D,oBAAAA,CAAS,gBAAA,CAAiB,QAAA,EAAU,QAAQ,CAAA;AACxD,IAAA,OAAO,MAAM;AAEX,MAAA,IAAI,OAAO,OAAQ,GAAA,CAAgC,MAAA,KAAW,UAAA,MAAgB,MAAA,EAAO;AAAA,IACvF,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AACP","file":"index.js","sourcesContent":["/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as Record<string, ProxyNativeModule>;\n","// Copyright © 2024 650 Industries.\nimport type { TurboModule } from 'react-native';\n\nexport function createTurboModuleToExpoProxy(turboModule: TurboModule | null, name: string) {\n return null;\n}\n","// Installs the expo global on web\nimport './polyfill';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n // No-op on web\n}\n","import { TurboModuleRegistry } from 'react-native';\n\nimport NativeModulesProxy from './NativeModulesProxy';\nimport { createTurboModuleToExpoProxy } from './TurboModuleToExpoModuleProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n try {\n return (\n globalThis.expo?.modules?.[moduleName] ??\n NativeModulesProxy[moduleName] ??\n createTurboModuleToExpoProxy(TurboModuleRegistry.get(moduleName), moduleName) ??\n null\n );\n } catch (e) {\n const error = e as Error;\n console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);\n return null;\n }\n}\n","import { CodedError } from '../errors/CodedError';\nimport { requireOptionalNativeModule } from '../requireNativeModule';\n\ntype LogListener = {\n action: (...data: any[]) => void;\n eventName: string;\n};\n\nif (\n __DEV__ &&\n typeof window !== 'undefined' &&\n (process.env.EXPO_OS === 'android' || process.env.EXPO_OS === 'ios')\n) {\n const NativeJSLogger = requireOptionalNativeModule('ExpoModulesCoreJSLogger');\n if (NativeJSLogger) {\n const onNewException: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewError',\n action: console.error,\n };\n\n const onNewWarning: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewWarning',\n action: console.warn,\n };\n\n const onNewDebug: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewDebug',\n action: console.debug,\n };\n\n const onNewInfo: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewInfo',\n action: console.info,\n };\n\n const onNewTrace: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewTrace',\n action: console.trace,\n };\n\n const listeners: LogListener[] = [\n onNewException,\n onNewWarning,\n onNewDebug,\n onNewInfo,\n onNewTrace,\n ];\n\n for (const listener of listeners) {\n NativeJSLogger.addListener(listener.eventName, ({ message }: { message: string }) => {\n listener.action(message);\n });\n }\n }\n}\n\ndeclare namespace globalThis {\n let ExpoModulesCore_CodedError: undefined | typeof CodedError;\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\nimport type { NativeModule } from './ts-declarations/NativeModule';\n\n/**\n * Registers a web module.\n * @param moduleImplementation A class that extends `NativeModule`. The class is registered under `globalThis.expo.modules[className]`.\n * @param moduleName A name to register the module under `globalThis.expo.modules[className]`.\n * @returns A singleton instance of the class passed into arguments.\n */\n\nexport function registerWebModule<\n EventsMap extends Record<never, never>,\n ModuleType extends typeof NativeModule<EventsMap>,\n>(moduleImplementation: ModuleType, moduleName: string): ModuleType {\n ensureNativeModulesAreInstalled();\n\n moduleName = moduleName ?? moduleImplementation.name;\n if (!moduleName) {\n throw new Error(\n 'Web module implementation is missing a name - it is either not a class or has been minified. Pass the name as a second argument to the `registerWebModule` function.'\n );\n }\n if (!globalThis?.expo?.modules) {\n globalThis.expo.modules = {};\n }\n if (globalThis.expo.modules[moduleName]) {\n return globalThis.expo.modules[moduleName];\n }\n globalThis.expo.modules[moduleName] = new moduleImplementation();\n return globalThis.expo.modules[moduleName];\n}\n","/** A union type for all integer based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type IntBasedTypedArray = Int8Array | Int16Array | Int32Array;\n\n/** A union type for all unsigned integer based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type UintBasedTypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;\n\n/** A union type for all floating point based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type FloatBasedTypedArray = Float32Array | Float64Array;\n\n/** A [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) describes an array-like view of an underlying binary data buffer. */\nexport type TypedArray = IntBasedTypedArray | UintBasedTypedArray | FloatBasedTypedArray;\n","export enum PermissionStatus {\n /**\n * User has granted the permission.\n */\n GRANTED = 'granted',\n /**\n * User hasn't granted or denied the permission yet.\n */\n UNDETERMINED = 'undetermined',\n /**\n * User has denied the permission.\n */\n DENIED = 'denied',\n}\n\n/**\n * Permission expiration time. Currently, all permissions are granted permanently.\n */\nexport type PermissionExpiration = 'never' | number;\n\n/**\n * An object obtained by permissions get and request functions.\n */\nexport type PermissionResponse = {\n /**\n * Determines the status of the permission.\n */\n status: PermissionStatus;\n /**\n * Determines time when the permission expires.\n */\n expires: PermissionExpiration;\n /**\n * A convenience boolean that indicates if the permission is granted.\n */\n granted: boolean;\n /**\n * Indicates if user can be asked again for specific permission.\n * If not, one should be directed to the Settings app\n * in order to enable/disable the permission.\n */\n canAskAgain: boolean;\n};\n","// Copyright © 2024 650 Industries.\n\n'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { PermissionResponse } from './PermissionsInterface';\n\n// These types are identical, but improves the readability for suggestions in editors\ntype RequestPermissionMethod<Permission extends PermissionResponse> = () => Promise<Permission>;\ntype GetPermissionMethod<Permission extends PermissionResponse> = () => Promise<Permission>;\n\ntype PermissionHookMethods<Permission extends PermissionResponse, Options = never> = {\n /** The permission method that requests the user to grant permission. */\n requestMethod: (options?: Options) => Promise<Permission>;\n /** The permission method that only fetches the current permission status. */\n getMethod: (options?: Options) => Promise<Permission>;\n};\n\ntype PermissionHookBehavior = {\n /** If the hook should automatically fetch the current permission status, without asking the user. */\n get?: boolean;\n /** If the hook should automatically request the user to grant permission. */\n request?: boolean;\n};\n\nexport type PermissionHookOptions<Options extends object> = PermissionHookBehavior & Options;\n\n/**\n * Get or request permission for protected functionality within the app.\n * It uses separate permission requesters to interact with a single permission.\n * By default, the hook will only retrieve the permission status.\n */\nfunction usePermission<Permission extends PermissionResponse, Options extends object>(\n methods: PermissionHookMethods<Permission, Options>,\n options?: PermissionHookOptions<Options>\n): [Permission | null, RequestPermissionMethod<Permission>, GetPermissionMethod<Permission>] {\n const isMounted = useRef(true);\n const [status, setStatus] = useState<Permission | null>(null);\n const { get = true, request = false, ...permissionOptions } = options || {};\n\n const getPermission = useCallback(async () => {\n let response: Permission;\n if (Object.keys(permissionOptions).length > 0) {\n response = await methods.getMethod(permissionOptions as Options);\n } else {\n response = await methods.getMethod();\n }\n if (isMounted.current) setStatus(response);\n return response;\n }, [methods.getMethod]);\n\n const requestPermission = useCallback(async () => {\n let response: Permission;\n if (Object.keys(permissionOptions).length > 0) {\n response = await methods.requestMethod(permissionOptions as Options);\n } else {\n response = await methods.requestMethod();\n }\n if (isMounted.current) setStatus(response);\n return response;\n }, [methods.requestMethod]);\n\n useEffect(\n function runMethods() {\n if (request) requestPermission();\n if (!request && get) getPermission();\n },\n [get, request, requestPermission, getPermission]\n );\n\n // Workaround for unmounting components receiving state updates\n useEffect(function didMount() {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return [status, requestPermission, getPermission];\n}\n\n/**\n * Create a new permission hook with the permission methods built-in.\n * This can be used to quickly create specific permission hooks in every module.\n */\nexport function createPermissionHook<Permission extends PermissionResponse, Options extends object>(\n methods: PermissionHookMethods<Permission, Options>\n) {\n return (options?: PermissionHookOptions<Options>) =>\n usePermission<Permission, Options>(methods, options);\n}\n","import { createRef, type RefObject } from 'react';\n\n/**\n * Create a React ref object that is friendly for snapshots.\n * It will be represented as `[React.ref]` in snapshots.\n * @returns A React ref object.\n */\nexport function createSnapshotFriendlyRef<T>(): RefObject<T | null> {\n return createRef<T>();\n}\n","'use client';\n\nimport type { DependencyList } from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport type { SharedObject } from '../ts-declarations/SharedObject';\n\n/**\n * Returns a shared object, which is automatically cleaned up when the component is unmounted.\n */\nexport function useReleasingSharedObject<TSharedObject extends SharedObject>(\n factory: () => TSharedObject,\n dependencies: DependencyList\n): TSharedObject {\n const objectRef = useRef<TSharedObject | null>(null);\n const objectRefToRelease = useRef<TSharedObject | null>(null);\n const isFastRefresh = useRef(false);\n const previousDependencies = useRef<DependencyList>(dependencies);\n\n if (objectRef.current == null) {\n objectRef.current = factory();\n }\n\n const object = useMemo(() => {\n let newObject = objectRef.current;\n const dependenciesAreEqual =\n previousDependencies.current?.length === dependencies.length &&\n dependencies.every((value, index) => value === previousDependencies.current[index]);\n\n // If the dependencies have changed, schedule the previous object for release and create a new one,\n // otherwise this has been called because of an unrelated fast refresh, and we don't want to release the object.\n if (!newObject || !dependenciesAreEqual) {\n objectRefToRelease.current = objectRef.current;\n newObject = factory();\n objectRef.current = newObject;\n previousDependencies.current = dependencies;\n }\n return newObject;\n }, dependencies);\n\n useEffect(() => {\n // When the object changes, release the previous one - it is important to do this in a useEffect, so that we don't release\n // the object during render.\n if (objectRefToRelease.current) {\n objectRefToRelease.current.release();\n objectRefToRelease.current = null;\n }\n }, [object]);\n\n useMemo(() => {\n isFastRefresh.current = true;\n }, []);\n\n useEffect(() => {\n isFastRefresh.current = false;\n\n return () => {\n // This will be called on every fast refresh and on unmount, but we only want to release the object on unmount.\n if (!isFastRefresh.current && objectRef.current) {\n objectRef.current.release();\n }\n };\n }, []);\n\n return object;\n}\n","/**\n * Reloads the app. This method works for both release and debug builds.\n *\n * Unlike [`Updates.reloadAsync()`](/versions/latest/sdk/updates/#updatesreloadasync),\n * this function does not use a new update even if one is available. It only reloads the app using the same JavaScript bundle that is currently running.\n *\n * @param reason The reason for reloading the app. This is used only for some platforms.\n */\nexport async function reloadAppAsync(reason: string = 'Reloaded from JS call'): Promise<void> {\n await globalThis.expo?.reloadAppAsync(reason);\n}\n","import './ts-declarations/global';\nimport './sweet/setUpJsLogger.fx';\nimport './polyfill';\n\nexport type * from './ts-declarations/global';\n\nexport { EventEmitter, type EventSubscription } from './EventEmitter';\nexport { NativeModule } from './NativeModule';\nexport { SharedObject } from './SharedObject';\nexport { SharedRef } from './SharedRef';\n\nexport { default as Platform } from './Platform';\nexport { default as uuid } from './uuid';\n\nexport type { ProxyNativeModule } from './NativeModulesProxy.types';\nexport { requireNativeViewManager } from './NativeViewManagerAdapter';\n\nexport * from './requireNativeModule';\nexport * from './registerWebModule';\nexport * from './TypedArrays.types';\n\nexport * from './PermissionsInterface';\nexport * from './PermissionsHook';\n\nexport * from './Refs';\n\nexport * from './hooks/useReleasingSharedObject';\nexport * from './reload';\n\n// Errors\nexport { CodedError } from './errors/CodedError';\nexport { UnavailabilityError } from './errors/UnavailabilityError';\n\n// Deprecated\nexport { LegacyEventEmitter } from './LegacyEventEmitter';\nexport { default as NativeModulesProxy } from './NativeModulesProxy';\n\nexport { installOnUIRuntime } from './worklets';\n","import type { ExpoConfig } from 'expo/config';\nimport type {\n EASConfig as ManifestsEASConfig,\n ExpoGoConfig as ManifestsExpoGoConfig,\n ExpoUpdatesManifest,\n EmbeddedManifest,\n ManifestAsset as ManifestAssetForReExport,\n ManifestExtra as ManifestExtraForReExport,\n ClientScopingConfig as ClientScopingConfigForReExport,\n ExpoGoPackagerOpts as ExpoGoPackagerOptsForReExport,\n // @ts-ignore -- optional interface, will gracefully degrade to `any` not installed\n} from 'expo-manifests';\n\nexport enum AppOwnership {\n /**\n * The experience is running inside the Expo Go app.\n * @deprecated Use [`Constants.executionEnvironment`](#executionenvironment) instead.\n */\n Expo = 'expo',\n}\n\n/**\n * Identifies where the app's JavaScript bundle is currently running.\n */\nexport enum ExecutionEnvironment {\n /** A project that includes native project directories that you maintain directly in your\n * [existing React Native project](/bare/overview/).\n */\n Bare = 'bare',\n /** Production/release build created with or without EAS Build. */\n Standalone = 'standalone',\n /** Expo Go or a development build built with `expo-dev-client`. */\n StoreClient = 'storeClient',\n}\n\n// @needsAudit\n/**\n * Current supported values are `handset`, `tablet`, `desktop` and `tv`. CarPlay will show up\n * as `unsupported`.\n */\nexport enum UserInterfaceIdiom {\n Handset = 'handset',\n Tablet = 'tablet',\n Desktop = 'desktop',\n TV = 'tv',\n Unsupported = 'unsupported',\n}\n\n// @needsAudit\n/**\n * @platform ios\n */\nexport type IOSManifest = {\n /**\n * The build number specified in the embedded **Info.plist** value for `CFBundleVersion` in this app.\n * In a standalone app, you can set this with the `ios.buildNumber` value in **app.json**. This\n * may differ from the value in `Constants.expoConfig.ios.buildNumber` because the manifest\n * can be updated, whereas this value will never change for a given native binary.\n * The value is set to `null` in case you run your app in Expo Go.\n */\n buildNumber: string | null;\n /**\n * The Apple internal model identifier for this device.\n * @example\n * `iPhone1,1`\n * @deprecated Use `expo-device`'s [`Device.modelId`](./device/#devicemodelid).\n */\n platform: string;\n /**\n * The human-readable model name of this device. For example, `\"iPhone 7 Plus\"` if it can be determined,\n * otherwise will be `null`.\n * @deprecated Moved to `expo-device` as [`Device.modelName`](./device/#devicemodelname).\n */\n model: string | null;\n /**\n * The user interface idiom of the current device, such as whether the app is running on an iPhone, iPad, Mac or Apple TV.\n * @deprecated Use `expo-device`'s [`Device.getDeviceTypeAsync()`](./device/#devicegetdevicetypeasync).\n */\n userInterfaceIdiom: UserInterfaceIdiom;\n /**\n * The version of iOS running on this device.\n * @example\n * `10.3`\n * @deprecated Use `expo-device`'s [`Device.osVersion`](./device/#deviceosversion).\n */\n systemVersion: string;\n} & Record<string, any>;\n\n// @needsAudit\n/**\n * @platform android\n */\nexport type AndroidManifest = {\n /**\n * The version code set by `android.versionCode` in app.json.\n * The value is set to `null` in case you run your app in Expo Go.\n * @deprecated Use `expo-application`'s [`Application.nativeBuildVersion`](./application/#applicationnativebuildversion).\n */\n versionCode: number;\n} & Record<string, any>;\n\n/**\n * @platform web\n */\nexport type WebManifest = Record<string, any>;\n\n// type re-exports to prevent breaking change\n\nexport type ManifestAsset = ManifestAssetForReExport;\nexport type Manifest = ExpoUpdatesManifest;\nexport type ManifestExtra = ManifestExtraForReExport;\nexport type EASConfig = ManifestsEASConfig;\nexport type ClientScopingConfig = ClientScopingConfigForReExport;\nexport type ExpoGoConfig = ManifestsExpoGoConfig;\nexport type ExpoGoPackagerOpts = ExpoGoPackagerOptsForReExport;\n\n// @needsAudit @docsMissing\nexport type PlatformManifest = {\n ios?: IOSManifest;\n android?: AndroidManifest;\n web?: WebManifest;\n detach?: {\n scheme?: string;\n [key: string]: any;\n };\n scheme?: string;\n hostUri?: string;\n developer?: string;\n} & Record<string, any>;\n\n// @needsAudit @docsMissing\nexport type NativeConstants = {\n /**\n * @hidden\n */\n name: 'ExponentConstants';\n /**\n * Returns `expo` when running in Expo Go, otherwise `null`.\n * @deprecated Use [`Constants.executionEnvironment`](#executionenvironment) instead.\n */\n appOwnership: AppOwnership | null;\n /**\n * Returns `true` when the app is running in debug mode (`__DEV__`). Otherwise, returns `false`.\n */\n debugMode: boolean;\n /**\n * A human-readable name for the device type.\n */\n deviceName?: string;\n /**\n * The [device year class](https://github.com/facebook/device-year-class) of this device.\n * @deprecated Moved to `expo-device` as [`Device.deviceYearClass`](./device/#deviceyearclass).\n */\n deviceYearClass: number | null;\n /**\n * Returns the current execution environment.\n */\n executionEnvironment: ExecutionEnvironment;\n experienceUrl: string;\n /**\n * Nullable only on the web.\n */\n expoRuntimeVersion: string | null;\n /**\n * The version string of the Expo Go app currently running.\n * Returns `null` in existing React Native projects and on web.\n */\n expoVersion: string | null;\n isDetached?: boolean;\n intentUri?: string;\n /**\n * Returns `true` if the app is running in headless mode. Otherwise, returns `false`.\n */\n isHeadless: boolean;\n linkingUri: string;\n\n /**\n * @hidden\n * Manifest embedded in the build. Returns `null` when `manifest2` is non-null.\n * @deprecated Use `Constants.expoConfig` instead, which behaves more consistently across EAS Build\n * and EAS Update.\n */\n manifest: EmbeddedManifest | null;\n /**\n * Manifest for Expo apps using modern Expo Updates from a remote source, such as apps that\n * use EAS Update. `Constants.expoConfig` should be used for accessing the Expo config object.\n */\n manifest2: ExpoUpdatesManifest | null;\n /**\n * The standard Expo config object defined in **app.json** and **app.config.js** files. For both\n * classic and modern manifests, whether they are embedded or remote.\n */\n expoConfig:\n | (ExpoConfig & {\n /**\n * Only present during development using @expo/cli.\n */\n hostUri?: string;\n })\n | null;\n /**\n * The standard Expo Go config object populated when running in Expo Go.\n */\n expoGoConfig: ManifestsExpoGoConfig | null;\n /**\n * The standard EAS config object populated when using EAS.\n */\n easConfig: ManifestsEASConfig | null;\n /**\n * A string that is unique to the current session of your app. It is different across apps and\n * across multiple launches of the same app.\n */\n sessionId: string;\n /**\n * The default status bar height for the device. Does not factor in changes when location tracking\n * is in use or a phone call is active.\n */\n statusBarHeight: number;\n /**\n * A list of the system font names available on the current device.\n */\n systemFonts: string[];\n systemVersion?: number;\n /**\n * @hidden\n */\n supportedExpoSdks?: string[];\n /**\n * Returns the specific platform manifest object.\n *\n * > **Note**: This is distinct from the `manifest` and `manifest2`.\n */\n platform?: PlatformManifest;\n /**\n * Gets the user agent string which would be included in requests sent by a web view running on\n * this device. This is probably not the same user agent you might be providing in your JS `fetch`\n * requests.\n */\n getWebViewUserAgentAsync: () => Promise<string | null>;\n} & Record<string, any>;\n\n/**\n * @hidden\n */\nexport type Constants = NativeConstants & {\n /**\n * > **Warning**: Do not use this property. Use `manifest` by default.\n *\n * In certain cases accessing manifest via this property\n * suppresses important warning about missing manifest.\n */\n __unsafeNoWarnManifest?: EmbeddedManifest;\n /**\n * > **Warning**: Do not use this property. Use `manifest2` by default.\n *\n * In certain cases accessing manifest via this property\n * suppresses important warning about missing manifest.\n */\n __unsafeNoWarnManifest2?: ExpoUpdatesManifest;\n};\n","import { requireOptionalNativeModule } from 'expo-modules-core';\n\nexport default requireOptionalNativeModule('ExponentConstants');\n","// TODO(@kitten): Add missing optional peers\n\nimport type { ExpoConfig } from 'expo/config';\n// @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\nimport type {\n EmbeddedManifest,\n EASConfig,\n ExpoGoConfig,\n ExpoUpdatesManifest,\n // @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\n} from 'expo-manifests';\nimport { CodedError, requireOptionalNativeModule } from 'expo-modules-core';\n// @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\nimport type { Manifest as UpdatesManifest, ExpoUpdatesModule } from 'expo-updates';\nimport { Platform, NativeModules } from 'react-native';\n\nimport { type Constants, ExecutionEnvironment } from './Constants.types';\nimport ExponentConstants from './ExponentConstants';\ntype DevLauncherManifest = ExpoUpdatesManifest;\n\nexport {\n type AndroidManifest,\n AppOwnership,\n type Constants,\n ExecutionEnvironment,\n type IOSManifest,\n type NativeConstants,\n type PlatformManifest,\n UserInterfaceIdiom,\n type WebManifest,\n} from './Constants.types';\n\nif (!ExponentConstants) {\n console.warn(\n \"No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?\"\n );\n}\n\nconst ExpoUpdates = requireOptionalNativeModule<ExpoUpdatesModule>('ExpoUpdates');\n\nlet rawUpdatesManifest: UpdatesManifest | null = null;\n// If expo-updates defines a non-empty manifest, prefer that one\nif (ExpoUpdates) {\n let updatesManifest: object | undefined;\n if (ExpoUpdates.manifest) {\n updatesManifest = ExpoUpdates.manifest;\n } else if (ExpoUpdates.manifestString) {\n updatesManifest = JSON.parse(ExpoUpdates.manifestString);\n }\n if (updatesManifest && Object.keys(updatesManifest).length > 0) {\n rawUpdatesManifest = updatesManifest as any;\n }\n}\n\n// If dev-launcher defines a non-empty manifest, prefer that one\nlet rawDevLauncherManifest: DevLauncherManifest | null = null;\nif (NativeModules.EXDevLauncher) {\n let devLauncherManifest;\n if (NativeModules.EXDevLauncher.manifestString) {\n devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);\n }\n\n if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {\n rawDevLauncherManifest = devLauncherManifest as any;\n }\n}\n\n// Fall back to ExponentConstants.manifest if we don't have one from Updates\nlet rawAppConfig: ExpoConfig | null = null;\nif (ExponentConstants && ExponentConstants.manifest) {\n const appConfig: object | string = ExponentConstants.manifest;\n\n // On Android we pass the manifest in JSON form so this step is necessary\n if (typeof appConfig === 'string') {\n rawAppConfig = JSON.parse(appConfig);\n } else {\n rawAppConfig = appConfig as any;\n }\n}\n\ntype RawManifest = UpdatesManifest | DevLauncherManifest | ExpoConfig;\nlet rawManifest: RawManifest | null = rawUpdatesManifest ?? rawDevLauncherManifest ?? rawAppConfig;\n\nconst { name, appOwnership, ...nativeConstants } = (ExponentConstants || {}) as any;\n\nconst constants: Constants = {\n ...nativeConstants,\n // Ensure this is null in bare workflow\n appOwnership: appOwnership ?? null,\n};\n\nObject.defineProperties(constants, {\n /**\n * Use `manifest` property by default.\n * This property is only used for internal purposes.\n * It behaves similarly to the original one, but suppresses warning upon no manifest available.\n * `expo-asset` uses it to prevent users from seeing mentioned warning.\n */\n __unsafeNoWarnManifest: {\n get(): EmbeddedManifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n __unsafeNoWarnManifest2: {\n get(): ExpoUpdatesManifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n manifest: {\n get(): EmbeddedManifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n manifest2: {\n get(): ExpoUpdatesManifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n expoConfig: {\n get():\n | (ExpoConfig & {\n /**\n * Only present during development using @expo/cli.\n */\n hostUri?: string;\n })\n | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n // if running an embedded update, maybeManifest is a EmbeddedManifest which doesn't have\n // the expo config. Instead, the embedded expo-constants app.config should be used.\n if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {\n return rawAppConfig;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.expoClient ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n expoGoConfig: {\n get(): ExpoGoConfig | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.expoGo ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n easConfig: {\n get(): EASConfig | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.eas ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n __rawManifest_TEST: {\n get(): RawManifest | null {\n return rawManifest;\n },\n set(value: RawManifest | null) {\n rawManifest = value;\n },\n enumerable: false,\n },\n});\n\nfunction isEmbeddedManifest(manifest: RawManifest): manifest is EmbeddedManifest {\n return !isExpoUpdatesManifest(manifest);\n}\n\nfunction isExpoUpdatesManifest(manifest: RawManifest): manifest is ExpoUpdatesManifest {\n return 'metadata' in manifest;\n}\n\nfunction getManifest(suppressWarning = false): RawManifest | null {\n if (!rawManifest) {\n const invalidManifestType = rawManifest === null ? 'null' : 'undefined';\n if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.Bare &&\n Platform.OS !== 'web'\n ) {\n if (!suppressWarning) {\n console.warn(\n `Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`\n );\n }\n } else if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient ||\n nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone\n ) {\n // If we somehow get here, this is a truly exceptional state to be in.\n // Constants.manifest should *always* be defined in those contexts.\n throw new CodedError(\n 'ERR_CONSTANTS_MANIFEST_UNAVAILABLE',\n `Constants.manifest is ${invalidManifestType}, must be an object.`\n );\n }\n }\n return rawManifest;\n}\n\nexport default constants as Constants;\n","/**\n * defaultOnboardingTheme — a neutral, light, brand-agnostic baseline. Consumers\n * pass a `Partial<OnboardingTheme>` that is deep-merged over this (see\n * `mergeTheme`), so they only override what differs from neutral.\n */\nimport type { OnboardingTheme } from \"./types\";\n\nexport const defaultOnboardingTheme: OnboardingTheme = {\n colors: {\n background: \"#FFFFFF\",\n surface: \"#F7F7F8\",\n text: \"#101114\",\n textMuted: \"#6B7280\",\n primary: \"#111111\",\n onPrimary: \"#FFFFFF\",\n primarySoft: \"rgba(17,17,17,0.06)\",\n border: \"#E4E4E7\",\n borderStrong: \"#C7C7CC\",\n disabled: \"#EBEBEB\",\n success: \"#16A34A\",\n warning: \"#D97706\",\n error: \"#DC2626\",\n info: \"#2563EB\",\n },\n fonts: {\n regular: undefined,\n medium: undefined,\n bold: undefined,\n baseSize: 16,\n scale: 1,\n },\n radius: {\n sm: 8,\n md: 12,\n lg: 16,\n full: 9999,\n },\n spacing: {\n xs: 4,\n sm: 8,\n md: 16,\n lg: 24,\n xl: 32,\n },\n // Circled (pill) CTA by default; an app can pass `button: { radius: 12 }` for\n // a rounded rectangle, or override height/paddingX to match its design system.\n button: {\n radius: 9999,\n height: 52,\n paddingX: 24,\n },\n};\n\n/**\n * Deep-merge a partial theme over the default. Two levels deep is enough — the\n * theme is intentionally shallow (colors/fonts/radius/spacing), so we merge each\n * known sub-object and leave scalars to overwrite.\n */\nexport const mergeTheme = (\n override?: Partial<OnboardingTheme>,\n): OnboardingTheme => {\n if (!override) return defaultOnboardingTheme;\n return {\n colors: { ...defaultOnboardingTheme.colors, ...override.colors },\n fonts: { ...defaultOnboardingTheme.fonts, ...override.fonts },\n radius: { ...defaultOnboardingTheme.radius, ...override.radius },\n spacing: { ...defaultOnboardingTheme.spacing, ...override.spacing },\n button: { ...defaultOnboardingTheme.button, ...override.button },\n };\n};\n","/**\n * ThemeContext — provides the resolved OnboardingTheme to every shell element and\n * themed card via `useOnboardingTheme()`. WHY a context rather than prop-drilling:\n * the cards are mounted by the SDK's ComponentRenderer (not by us), so we can't\n * pass them props directly — they must read the theme from context.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport { mergeTheme } from \"./defaultTheme\";\nimport type { OnboardingTheme } from \"./types\";\n\nconst OnboardingThemeContext = createContext<OnboardingTheme | null>(null);\n\nexport type OnboardingThemeProviderProps = {\n /** Partial overrides merged over the neutral default theme. */\n theme?: Partial<OnboardingTheme>;\n children: React.ReactNode;\n};\n\nexport const OnboardingThemeProvider: React.FC<OnboardingThemeProviderProps> = ({\n theme,\n children,\n}) => {\n const resolved = useMemo(() => mergeTheme(theme), [theme]);\n return (\n <OnboardingThemeContext.Provider value={resolved}>\n {children}\n </OnboardingThemeContext.Provider>\n );\n};\n\n/**\n * Read the active theme. Falls back to the default theme when used outside a\n * provider so a stray card never crashes — it just renders neutral.\n */\nexport const useOnboardingTheme = (): OnboardingTheme => {\n const ctx = useContext(OnboardingThemeContext);\n return ctx ?? mergeTheme();\n};\n","/**\n * Illustration registry — lets the host app supply brand artwork (SVG / Lottie /\n * Image nodes) keyed by name, which the backend references from an InterstitialCard\n * by `illustration`. Keeping the registry in React context (rather than as a card\n * prop) is what keeps the kit dependency-free: the kit never imports react-native-svg\n * or Lottie — the app brings its own nodes and the kit just slots the matching one.\n *\n * <WireOnboarding illustrations={{ \"before-after\": <BeforeAfter/> }} ... />\n *\n * When the backend names an illustration the registry doesn't have, the\n * InterstitialCard falls back to its `imageUrl` (a plain RN <Image>).\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nexport type IllustrationRegistry = Record<string, React.ReactNode>;\n\n/** One shared empty registry so an unconfigured provider never allocates a fresh {} per render. */\nconst EMPTY_REGISTRY: IllustrationRegistry = {};\n\nconst IllustrationContext = createContext<IllustrationRegistry>(EMPTY_REGISTRY);\n\nexport type IllustrationProviderProps = {\n registry?: IllustrationRegistry;\n children: React.ReactNode;\n};\n\nexport const IllustrationProvider: React.FC<IllustrationProviderProps> = ({\n registry,\n children,\n}) => {\n const value = useMemo(() => registry ?? EMPTY_REGISTRY, [registry]);\n return <IllustrationContext.Provider value={value}>{children}</IllustrationContext.Provider>;\n};\n\n/** Look up an app-supplied illustration node by name. Returns undefined if absent. */\nexport const useIllustration = (name?: string): React.ReactNode | undefined => {\n const registry = useContext(IllustrationContext);\n if (!name) return undefined;\n return registry[name];\n};\n","/**\n * defaultIllustrations — a tiny, dependency-free fallback registry so an app can\n * render `InterstitialCard` with ZERO illustration code. These are plain\n * <View>/<Text> glyphs (NO react-native-svg, NO Lottie, NO image assets) themed\n * from the active OnboardingTheme, covering the common backend-emitted names.\n *\n * Spread it under your own artwork — your named nodes win:\n *\n * illustrations={{ ...defaultIllustrations, ...myIllustrations }}\n *\n * Names match what the onboarding backend commonly emits via an InterstitialCard's\n * `illustration`: `momentum` (forward-motion arc) and `before-after` (two states).\n * Add more by spreading your own — these are only sensible defaults.\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\n\n/** A soft tinted disc with a centered glyph — the shared frame for every default. */\nconst Glyph: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const t = useOnboardingTheme();\n return (\n <View\n style={[\n styles.disc,\n { backgroundColor: t.colors.primarySoft, borderRadius: t.radius.full },\n ]}\n >\n <Text style={[styles.glyphText, { color: t.colors.primary }]} allowFontScaling={false}>\n {children}\n </Text>\n </View>\n );\n};\n\n/** Forward-motion / momentum: an upward arrow. */\nconst MomentumGlyph: React.FC = () => <Glyph>{\"↗\"}</Glyph>;\n\n/** Before → after: two states with an arrow between. */\nconst BeforeAfterGlyph: React.FC = () => {\n const t = useOnboardingTheme();\n return (\n <View style={styles.row}>\n <View\n style={[\n styles.chip,\n { borderColor: t.colors.border, borderRadius: t.radius.md },\n ]}\n />\n <Text style={[styles.arrow, { color: t.colors.primary }]} allowFontScaling={false}>\n {\"→\"}\n </Text>\n <View\n style={[\n styles.chip,\n { backgroundColor: t.colors.primarySoft, borderColor: t.colors.primary, borderRadius: t.radius.md },\n ]}\n />\n </View>\n );\n};\n\n/**\n * The default registry. `WireOnboarding`'s `illustrations` prop is\n * `Record<string, ReactNode>`, so these are concrete element nodes.\n */\nexport const defaultIllustrations: Record<string, React.ReactNode> = {\n momentum: <MomentumGlyph />,\n \"before-after\": <BeforeAfterGlyph />,\n};\n\nconst styles = StyleSheet.create({\n disc: {\n width: 96,\n height: 96,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n glyphText: {\n fontSize: 44,\n fontWeight: \"700\",\n lineHeight: 52,\n },\n row: {\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 12,\n },\n chip: {\n width: 56,\n height: 56,\n borderWidth: 2,\n },\n arrow: {\n fontSize: 28,\n fontWeight: \"700\",\n },\n});\n","/**\n * Icon registry — the host's escape hatch, and the FIRST step of icon resolution.\n *\n * Deliberately the same shape and philosophy as the `illustrations` registry\n * (components/Illustration.tsx): name → ReactNode, held in context, so an app can ship brand\n * SVG / Lottie / Image nodes the kit never imports. Here it means a host can:\n *\n * • override any vocabulary name with its own brand mark (`{ instagram: <MyIgGlyph/> }`), or\n * • supply icons WITHOUT installing `@expo/vector-icons` at all, or\n * • extend the vocabulary with names of its own — the AI emits `\"my-thing\"`, the host renders\n * it, and the kit needs no release.\n *\n * <WireOnboarding icons={{ instagram: <BrandIg/> }} ... />\n *\n * A name the registry doesn't have falls through to `@expo/vector-icons`, then to no icon at\n * all. See `WireIcon`.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nexport type WireIconRegistry = Record<string, React.ReactNode>;\n\n/** One shared empty registry so an unconfigured provider never allocates a fresh {} per render. */\nconst EMPTY_REGISTRY: WireIconRegistry = {};\n\nconst IconContext = createContext<WireIconRegistry>(EMPTY_REGISTRY);\n\nexport type IconRegistryProviderProps = {\n registry?: WireIconRegistry;\n children: React.ReactNode;\n};\n\nexport const IconRegistryProvider: React.FC<IconRegistryProviderProps> = ({\n registry,\n children,\n}) => {\n const value = useMemo(() => registry ?? EMPTY_REGISTRY, [registry]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n};\n\n/**\n * Look up a host-supplied icon node by name. Returns undefined if absent.\n *\n * The OWN-property check matters here for the same reason it does in `vocabulary.ts`: the name\n * is LLM-authored, and a bare `registry[name]` answers `\"toString\"` with an inherited function\n * — which is truthy, so it would be handed to React as a child and blow up the card. An icon\n * name must never be able to do that.\n */\nexport const useHostIcon = (name?: string): React.ReactNode | undefined => {\n const registry = useContext(IconContext);\n if (!name) return undefined;\n if (!Object.prototype.hasOwnProperty.call(registry, name)) return undefined;\n return registry[name];\n};\n","/**\n * typography — derive concrete RN text styles from the theme's font config, so\n * every label/title/caption in the kit scales from one `baseSize` + `scale` and\n * picks the right family. Cards call these instead of hardcoding fontSize/weight.\n */\nimport type { TextStyle } from \"react-native\";\nimport type { OnboardingFonts } from \"./types\";\n\nconst round = (n: number) => Math.round(n);\n\n/** Body text — the reference size. */\nexport const bodyStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.regular,\n fontSize: round(f.baseSize * f.scale),\n lineHeight: round(f.baseSize * f.scale * 1.5),\n});\n\n/** Slightly smaller secondary/hint text. */\nexport const captionStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.regular,\n fontSize: round(f.baseSize * 0.8125 * f.scale),\n lineHeight: round(f.baseSize * 0.8125 * f.scale * 1.5),\n});\n\n/** Emphasised label (e.g. a card question). */\nexport const labelStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.medium ?? f.bold,\n fontSize: round(f.baseSize * f.scale),\n lineHeight: round(f.baseSize * f.scale * 1.4),\n fontWeight: f.medium ? undefined : (\"600\" as const),\n});\n\n/** Heading (status title, done block). */\nexport const headingStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.bold,\n fontSize: round(f.baseSize * 1.25 * f.scale),\n lineHeight: round(f.baseSize * 1.25 * f.scale * 1.3),\n fontWeight: f.bold ? undefined : (\"700\" as const),\n});\n\n/** Button label. */\nexport const buttonLabelStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.bold ?? f.medium,\n fontSize: round(f.baseSize * f.scale),\n fontWeight: f.bold ? undefined : (\"600\" as const),\n});\n","/**\n * motionSpec — the single source of truth for every animation value in the kit,\n * extracted 1:1 from the Wire Activation card-interactions design canvas\n * (see design-refs/EXTRACTED-SPEC.md for the row-by-row mapping).\n *\n * Pure constants + pure helpers only — NO react-native import — so the spec is\n * unit-testable under node:test and components can't drift from the design\n * without a red test.\n */\n\n/** The design system's \"ease-wire\" curve: cubic-bezier(0.16, 1, 0.3, 1). */\nexport const WIRE_BEZIER = [0.16, 1, 0.3, 1] as const;\n\n/** Design-system duration tokens (colors_and_type.css --duration-*). */\nexport const DURATION_FAST_MS = 150;\nexport const DURATION_BASE_MS = 300;\nexport const DURATION_SLOW_MS = 500;\n\n/** Reduce-motion fallback: a short fade to the final frame, never a frozen mid-state. */\nexport const REDUCED_FADE_MS = 120;\n\n// ── Press feedback (spec rows 1, 4, 20) ─────────────────────────────────────\nexport const ROW_PRESS_SCALE = 0.975;\nexport const CHIP_PRESS_SCALE = 0.94;\nexport const BUTTON_PRESS_SCALE = 0.975;\n/** Reduce-motion press feedback: opacity dip instead of scale. */\nexport const REDUCED_PRESS_OPACITY = 0.85;\nexport const PRESS_SPRING = { friction: 8, tension: 220 } as const;\nexport const BUTTON_PRESS_SPRING = { friction: 8, tension: 240 } as const;\n\n// ── Selection state changes (spec rows 2, 3, 5, 6) ──────────────────────────\nexport const SELECT_FILL_MS = 180;\nexport const CHIP_FILL_MS = 160;\nexport const CHECK_SPRING = { friction: 6, tension: 180 } as const;\nexport const CHECK_SCALE_FROM = 0.6;\n\n// ── Card-to-card handoff (spec rows 7-10) ───────────────────────────────────\nexport const CARD_ENTER_MS = 220;\nexport const CARD_EXIT_MS = 180;\n/** The exit starts this long BEFORE the enter (enter is delayed by this). */\nexport const CARD_EXIT_LEAD_MS = 80;\nexport const CARD_SLIDE_PX = 26;\nexport const CARD_ENTER_SCALE_FROM = 0.96;\n/** The interstitial keeps the shell's springier value-beat (AnimatedCard idiom). */\nexport const CARD_SPRING = { damping: 14, stiffness: 180, mass: 1 } as const;\n/** Loader-to-card handoff: the loader just fades out. */\nexport const LOADER_HANDOFF_FADE_MS = 120;\n\n// ── InterstitialCard reveal (spec rows 11-13) ───────────────────────────────\nexport const INTERSTITIAL_HEAD_MS = 500;\nexport const INTERSTITIAL_HEAD_STAGGER_MS = 100;\nexport const INTERSTITIAL_ITEM_MS = 300;\nexport const INTERSTITIAL_ITEM_STAGGER_MS = 90;\nexport const INTERSTITIAL_ITEM_BASE_DELAY_MS = 200;\nexport const INTERSTITIAL_CHECK_DELAY_MS = 200;\nexport const INTERSTITIAL_CHECK_SCALE_FROM = 0.4;\n\n/** Delay before work item `index` begins its reveal (row lands after the head). */\nexport const interstitialItemDelay = (index: number): number =>\n INTERSTITIAL_ITEM_BASE_DELAY_MS + index * INTERSTITIAL_ITEM_STAGGER_MS;\n\n/** Delay before work item `index`'s check pops (200ms after its row starts). */\nexport const interstitialCheckDelay = (index: number): number =>\n interstitialItemDelay(index) + INTERSTITIAL_CHECK_DELAY_MS;\n\n// ── Status / completion payoff (spec rows 14-16) ────────────────────────────\nexport const STATUS_POP_SPRING = { friction: 6, tension: 200 } as const;\nexport const STATUS_POP_SCALE_FROM = 0.4;\nexport const STATUS_BURST_MS = 500;\nexport const STATUS_BURST_SCALE_FROM = 0.4;\nexport const STATUS_BURST_SCALE_TO = 1.5;\nexport const STATUS_BURST_OPACITY_FROM = 0.5;\nexport const STATUS_COPY_MS = 300;\nexport const STATUS_COPY_STAGGER_MS = 80;\n/** Copy starts settling once the badge pop is visibly underway. */\nexport const STATUS_COPY_BASE_DELAY_MS = 200;\n\n/** Delay before payoff copy line `index` fades up. */\nexport const statusCopyDelay = (index: number): number =>\n STATUS_COPY_BASE_DELAY_MS + index * STATUS_COPY_STAGGER_MS;\n\n// ── Loading treatment (spec rows 17-19) ─────────────────────────────────────\nexport const LOADER_PULSE_MS = 1600;\nexport const LOADER_PULSE_MIN_OPACITY = 0.35;\nexport const LOADER_ORBIT_MS = 2400;\n/** Skeleton lines appear only when the fetch runs past this. */\nexport const SKELETON_DELAY_MS = 300;\nexport const SKELETON_PULSE_MS = 1500;\nexport const SKELETON_MIN_OPACITY = 0.45;\n\n// ── Progress bar (spec row 21) ──────────────────────────────────────────────\nexport const PROGRESS_MS = 400;\n\n// ── Dev/QA duration scale (slow-mo for judging motion) ──────────────────────\n// A module-level multiplier applied to every timing DURATION (and stagger\n// delay) at animation start. 1 = design speed; 2 = half-speed slow-mo. Springs\n// are physics-based (friction/tension) and do NOT scale. This is a dev/QA tool\n// (the playground's tweak panel drives it) — production code never calls the\n// setter, so the default 1 keeps shipped motion exactly on spec.\n\nlet durationScale = 1;\n\n/** Set the global duration multiplier (clamped to 0.1-10; invalid resets to 1). */\nexport const setMotionDurationScale = (scale: number): void => {\n durationScale = Number.isFinite(scale) && scale > 0 ? Math.min(10, Math.max(0.1, scale)) : 1;\n};\n\nexport const getMotionDurationScale = (): number => durationScale;\n\n/** Apply the current duration scale to a spec duration/delay (rounded ms). */\nexport const scaledMs = (ms: number): number => Math.round(ms * durationScale);\n\n// ── Reduce-motion helpers (pure, shared by every animated component) ────────\n\nexport type EntranceSpec = {\n /** Duration to animate with (falls back to the short fade under reduce motion). */\n duration: number;\n /** Whether transforms (translate/scale) may move; false = opacity-only fade. */\n useTransform: boolean;\n};\n\n/** Entrances: full motion normally; a 120ms opacity-only fade under reduce motion. */\nexport const entranceSpec = (reduced: boolean, durationMs: number): EntranceSpec =>\n reduced\n ? { duration: REDUCED_FADE_MS, useTransform: false }\n : { duration: durationMs, useTransform: true };\n\n/** State changes (select fills etc.): snap instantly under reduce motion. */\nexport const stateChangeDuration = (reduced: boolean, durationMs: number): number =>\n reduced ? 0 : durationMs;\n\n/** Looping/ambient animations run only when motion is allowed. */\nexport const loopEnabled = (reduced: boolean): boolean => !reduced;\n","/**\n * useReducedMotion — the kit's ONE reduce-motion gate. Reads the OS setting via\n * AccessibilityInfo and stays subscribed to `reduceMotionChanged`, so every\n * animated component lands on its final frame (or a ~120ms fade) the moment the\n * user flips the setting — no restart needed.\n *\n * This closes the gap documented in ai_rules/rules/performance.md §3: every\n * animation in the kit must consume this hook (usually through the pure helpers\n * in motionSpec.ts: `entranceSpec` / `stateChangeDuration` / `loopEnabled`).\n */\nimport { useEffect, useState } from \"react\";\nimport { AccessibilityInfo } from \"react-native\";\n\n// Last-known value, module-level: cards remount every turn (keyed on message id),\n// and a `useState(false)` default would flash one animated frame per turn for a\n// reduce-motion user before the async read resolves.\nlet lastKnown = false;\n\nexport const useReducedMotion = (): boolean => {\n const [reduced, setReduced] = useState(lastKnown);\n\n useEffect(() => {\n let mounted = true;\n AccessibilityInfo.isReduceMotionEnabled()\n .then((value) => {\n lastKnown = value;\n if (mounted) setReduced(value);\n })\n .catch(() => {\n // Unavailable (e.g. some test envs): keep the last-known value.\n });\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", (value) => {\n lastKnown = value;\n setReduced(value);\n });\n return () => {\n mounted = false;\n sub?.remove();\n };\n }, []);\n\n return reduced;\n};\n","/**\n * AnimatedSparkle — the themed \"AI is thinking\" glyph (✦), animated with RN's\n * built-in `Animated` (native driver) so the kit needs neither reanimated nor a\n * vector-icon dependency.\n *\n * Variants:\n * - \"spin\" (default, unchanged): continuous rotation — the original loader.\n * - \"pulse\": the Wire Activation loading treatment — the mark breathes\n * (opacity 0.35 ↔ 1, 1600ms loop) instead of rotating.\n *\n * Reduce motion: no loop at all — the glyph renders static at full opacity\n * (final frame), per design-refs/EXTRACTED-SPEC.md row 17.\n */\nimport React, { useEffect, useRef } from \"react\";\nimport { Animated, Easing, StyleSheet, Text } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { LOADER_PULSE_MIN_OPACITY, LOADER_PULSE_MS, loopEnabled, scaledMs } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst ROTATION_MS = 1800;\n\nexport type AnimatedSparkleProps = {\n /** Glyph size in px. */\n size?: number;\n /** Override color; defaults to the theme primary. */\n color?: string;\n /** \"spin\" rotates (default, the original), \"pulse\" breathes (the loader treatment). */\n variant?: \"spin\" | \"pulse\";\n};\n\nconst _AnimatedSparkle: React.FC<AnimatedSparkleProps> = ({ size = 30, color, variant = \"spin\" }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const progress = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n if (!loopEnabled(reduced)) {\n // Static final frame: no rotation, full opacity.\n progress.setValue(0);\n return;\n }\n const loop =\n variant === \"pulse\"\n ? Animated.loop(\n Animated.sequence([\n Animated.timing(progress, {\n toValue: 1,\n duration: scaledMs(LOADER_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(progress, {\n toValue: 0,\n duration: scaledMs(LOADER_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n )\n : Animated.loop(\n Animated.timing(progress, {\n toValue: 1,\n duration: scaledMs(ROTATION_MS),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n );\n loop.start();\n return () => loop.stop();\n }, [progress, variant, reduced]);\n\n const rotate = progress.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] });\n const pulse = progress.interpolate({\n inputRange: [0, 1],\n outputRange: [1, LOADER_PULSE_MIN_OPACITY],\n });\n\n const animatedStyle = reduced\n ? undefined\n : variant === \"pulse\"\n ? { opacity: pulse }\n : { transform: [{ rotate }] };\n\n // The glyph lives in a fixed size×size box (alignItems/justifyContent:center) so the\n // font's side-bearing and Android includeFontPadding can't shove the visible mark off\n // center. The box carries the transform too, so a spinning box still rotates around its\n // own center → the ✦ spins in place, optically centered on both axes.\n return (\n <Animated.View style={[styles.box, { width: size, height: size }, animatedStyle]}>\n <Text\n accessibilityElementsHidden\n importantForAccessibility=\"no\"\n style={[\n styles.glyph,\n {\n width: size,\n fontSize: size,\n lineHeight: size,\n color: color ?? t.colors.primary,\n },\n ]}\n >\n ✦\n </Text>\n </Animated.View>\n );\n};\n\nexport const AnimatedSparkle = React.memo(_AnimatedSparkle);\n\nconst styles = StyleSheet.create({\n box: { alignItems: \"center\", justifyContent: \"center\" },\n glyph: {\n textAlign: \"center\",\n textAlignVertical: \"center\",\n includeFontPadding: false,\n },\n});\n","/**\n * LoadingBlock — the \"AI is thinking\" indicator, shown before the first card and\n * between every turn (each round-trip to the backend). The Wire Activation\n * loading treatment: no generic spinner — the brand mark breathes inside a\n * dashed ring while an accent dot orbits it, and skeleton lines appear (softly\n * pulsing) only when the fetch runs past 300ms so a fast turn never flashes\n * placeholder chrome (design-refs/EXTRACTED-SPEC.md rows 17-19).\n *\n * Reduce motion: static mark + copy, no orbit, no pulse.\n */\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { AnimatedSparkle } from \"./AnimatedSparkle\";\nimport {\n LOADER_ORBIT_MS,\n SKELETON_DELAY_MS,\n SKELETON_MIN_OPACITY,\n SKELETON_PULSE_MS,\n loopEnabled,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst STAGE_SIZE = 96;\nconst ORBIT_DOT = 9;\n\nexport type LoadingBlockProps = {\n /** Primary line, e.g. \"Thinking…\". */\n title?: string;\n /** Supporting line under the title. */\n hint?: string;\n};\n\n/** The orbiting accent dot: a full-stage rotating layer with the dot at 12 o'clock. */\nconst OrbitDot: React.FC<{ color: string; reduced: boolean }> = ({ color, reduced }) => {\n const spin = useRef(new Animated.Value(0)).current;\n useEffect(() => {\n if (!loopEnabled(reduced)) return;\n const loop = Animated.loop(\n Animated.timing(spin, {\n toValue: 1,\n duration: scaledMs(LOADER_ORBIT_MS),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n );\n loop.start();\n return () => loop.stop();\n }, [spin, reduced]);\n\n if (reduced) return null;\n const rotate = spin.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] });\n return (\n <Animated.View pointerEvents=\"none\" style={[StyleSheet.absoluteFill, { transform: [{ rotate }] }]}>\n <View style={[styles.orbitDot, { backgroundColor: color }]} />\n </Animated.View>\n );\n};\n\n/** A skeleton line that softly pulses (static under reduce motion). */\nconst SkeletonLine: React.FC<{ width: `${number}%`; delay: number; color: string; reduced: boolean }> = ({\n width,\n delay,\n color,\n reduced,\n}) => {\n const pulse = useRef(new Animated.Value(1)).current;\n useEffect(() => {\n if (!loopEnabled(reduced)) return;\n const loop = Animated.loop(\n Animated.sequence([\n Animated.delay(delay),\n Animated.timing(pulse, {\n toValue: SKELETON_MIN_OPACITY,\n duration: scaledMs(SKELETON_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(pulse, {\n toValue: 1,\n duration: scaledMs(SKELETON_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n );\n loop.start();\n return () => loop.stop();\n }, [pulse, delay, reduced]);\n\n return (\n <Animated.View\n style={[styles.skeletonLine, { width, backgroundColor: color, opacity: reduced ? 1 : pulse }]}\n />\n );\n};\n\nconst _LoadingBlock: React.FC<LoadingBlockProps> = ({\n title = \"Thinking…\",\n hint = \"Personalizing your experience\",\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n // The loader fills its parent (flex:1) and centers in it. In the flow that parent is the\n // scaffold BODY (the same content region the cards render into), so the loader lands at the\n // content-area center — visually consistent with the cards it hands off to. Standalone\n // (LoadingScreen / a playground CardFrame) it centers in whatever bounds it. No screen-inset\n // math and no transform: it inherits the content area it is dropped into, so it is centered\n // in every context by construction.\n\n // Skeleton lines are gated behind the 300ms window: a fast fetch never shows them.\n const [showSkeleton, setShowSkeleton] = useState(false);\n useEffect(() => {\n const timer = setTimeout(() => setShowSkeleton(true), SKELETON_DELAY_MS);\n return () => clearTimeout(timer);\n }, []);\n\n return (\n <View style={[styles.center, { padding: t.spacing.lg }]}>\n {/*\n * The stage is the ANCHOR: it's the only in-flow child, so `justifyContent:\n * center` lands the icon at the true center of the flow area. Title, hint and\n * the (300ms-gated) skeleton hang BELOW it in an absolutely-positioned column,\n * so they never displace the icon — previously they lived in the same centered\n * column, which re-balanced (and jumped the icon UP ~½ its height) the moment\n * the skeleton lines mounted at 300ms.\n */}\n <View style={styles.stage}>\n <View style={[styles.ring, { borderColor: t.colors.border, borderRadius: t.radius.full }]} />\n <OrbitDot color={t.colors.primary} reduced={reduced} />\n <AnimatedSparkle size={40} variant=\"pulse\" />\n </View>\n <View\n style={[\n styles.labels,\n { marginTop: STAGE_SIZE / 2 + t.spacing.lg, gap: t.spacing.md, paddingHorizontal: t.spacing.lg },\n ]}\n pointerEvents=\"none\"\n >\n {title ? (\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n ) : null}\n {hint ? (\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {hint}\n </Text>\n ) : null}\n {showSkeleton ? (\n <View style={[styles.skeleton, { gap: t.spacing.sm, marginTop: t.spacing.sm }]}>\n <SkeletonLine width=\"80%\" delay={0} color={t.colors.surface} reduced={reduced} />\n <SkeletonLine width=\"60%\" delay={200} color={t.colors.surface} reduced={reduced} />\n </View>\n ) : null}\n </View>\n </View>\n );\n};\n\nexport const LoadingBlock = React.memo(_LoadingBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n // Absolutely-positioned label column, pinned just under the centered stage: its top\n // edge starts at the flow center (top: 50%) and the inline marginTop (STAGE_SIZE/2 +\n // a gap) drops it below the stage. Out of flow → it never moves the stage, so the\n // 300ms skeleton reveal grows DOWNWARD only and the icon stays centered.\n labels: { position: \"absolute\", top: \"50%\", left: 0, right: 0, alignItems: \"center\" },\n stage: {\n width: STAGE_SIZE,\n height: STAGE_SIZE,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n ring: {\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n borderWidth: 1.5,\n borderStyle: \"dashed\",\n },\n orbitDot: {\n position: \"absolute\",\n top: -ORBIT_DOT / 2 + 1,\n left: STAGE_SIZE / 2 - ORBIT_DOT / 2,\n width: ORBIT_DOT,\n height: ORBIT_DOT,\n borderRadius: ORBIT_DOT / 2,\n },\n skeleton: { width: \"100%\", alignItems: \"center\" },\n skeletonLine: { height: 12, borderRadius: 6 },\n});\n","/**\n * LoadingScreen — the STANDALONE loader surface: a full-area safe frame that centers a\n * LoadingBlock dead in the middle of the screen. Used for the loader slots that render on\n * their own (no OnboardingScaffold around them): the cold-start \"getting started\" wait, the\n * resumed-session \"restoring\" wait, and the transient error/timeout retry beat.\n *\n * WHY a dedicated frame: those slots used to return a bare <LoadingBlock/>, whose flex:1 only\n * fills whatever the host happened to give it — with no safe area and, if the host didn't\n * bound it, no height at all (top-anchored). This wraps them in the same SafeAreaView the flow\n * uses, so the standalone loaders center exactly like the between-turns loader (both fill their\n * parent flex:1 region and center in it — here the SafeAreaView, in the flow the scaffold body).\n * One consistent centered look.\n */\nimport React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { LoadingBlock, type LoadingBlockProps } from \"./LoadingBlock\";\n\nconst _LoadingScreen: React.FC<LoadingBlockProps> = ({ title, hint }) => {\n const t = useOnboardingTheme();\n return (\n <SafeAreaView\n edges={[\"top\", \"bottom\"]}\n style={[styles.flex, { backgroundColor: t.colors.background }]}\n >\n <LoadingBlock title={title} hint={hint} />\n </SafeAreaView>\n );\n};\n\nexport const LoadingScreen = React.memo(_LoadingScreen);\n\nconst styles = StyleSheet.create({\n flex: { flex: 1 },\n});\n","/**\n * StepProgress — a single themed progress bar that conveys forward motion. It never\n * shows a \"Step X of N\" number (the count would read as a promise the model may not\n * keep), but it can be *paced* two ways:\n *\n * - Default (no `approxScreens`): an asymptotic curve of the step index — always\n * advances, never reaches the end until the flow actually completes.\n * - With `approxScreens`: when the host knows roughly how many screens the flow\n * runs (e.g. the backend's screen budget), the fill tracks `step / approxScreens`\n * (capped below 100% until `complete`). More truthful pacing, still no number.\n */\nimport React, { useEffect, useRef } from \"react\";\nimport { Animated, Easing, StyleSheet, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { PROGRESS_MS, WIRE_BEZIER, scaledMs, stateChangeDuration } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nexport type StepProgressProps = {\n /** 1-based index of the current step. Drives the fill. */\n step: number;\n /** When true, fill to 100% (flow finished). */\n complete?: boolean;\n /**\n * Approximate total number of screens, if known (e.g. the backend screen budget).\n * Paces the bar as `step / approxScreens` instead of the asymptotic curve. Never\n * shown as a number — it only shapes the fill. Omit for the asymptotic default.\n */\n approxScreens?: number;\n};\n\n// Asymptotic default: each step closes ~38% of the remaining gap, so the bar always\n// moves but never hits the end on its own: step1≈38%, step2≈62%, step3≈76%…\nconst DECAY = 0.62;\nconst MIN_FILL = 0.08;\n// When pacing by an approximate total, never look finished until `complete`.\nconst APPROX_CAP = 0.95;\n\nconst targetFor = (step: number, complete?: boolean, approxScreens?: number): number => {\n if (complete) return 1;\n const s = Number.isFinite(step) && step > 0 ? Math.floor(step) : 1;\n if (approxScreens && approxScreens > 0) {\n return Math.max(MIN_FILL, Math.min(APPROX_CAP, s / approxScreens));\n }\n return Math.max(MIN_FILL, 1 - DECAY ** s);\n};\n\nconst _StepProgress: React.FC<StepProgressProps> = ({ step, complete, approxScreens }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const fill = useRef(new Animated.Value(targetFor(step, complete, approxScreens))).current;\n\n // 400ms ease-wire per the design spec (design-refs/EXTRACTED-SPEC.md row 21).\n // A growing total re-targets the same value, so the fill eases forward and never\n // snaps back. Reduce motion: jump straight to the ratio.\n useEffect(() => {\n Animated.timing(fill, {\n toValue: targetFor(step, complete, approxScreens),\n duration: scaledMs(stateChangeDuration(reduced, PROGRESS_MS)),\n easing: easeWire,\n useNativeDriver: false, // animating width %\n }).start();\n }, [fill, step, complete, approxScreens, reduced]);\n\n const width = fill.interpolate({ inputRange: [0, 1], outputRange: [\"0%\", \"100%\"] });\n\n return (\n <View style={[styles.track, { backgroundColor: t.colors.border, borderRadius: t.radius.full }]}>\n <Animated.View\n style={[\n styles.fill,\n { width, backgroundColor: t.colors.primary, borderRadius: t.radius.full },\n ]}\n />\n </View>\n );\n};\n\nexport const StepProgress = React.memo(_StepProgress);\n\nconst styles = StyleSheet.create({\n track: { height: 6, width: \"100%\", overflow: \"hidden\" },\n fill: { height: 6 },\n});\n","/**\n * OnboardingScaffold — the themed shell that wraps every step:\n * [ safe area ]\n * header -> StepProgress (a numberless fill — never \"Step X of N\") + optional Skip\n * body -> the rendered card (children), full-screen (flex: 1)\n * footer -> optional Back link\n *\n * WHY a single scaffold: the body content changes every turn (it's an\n * SDK-rendered card), but the chrome — progress, skip, back, padding, safe area —\n * stays constant. Keeping it here means cards never re-implement the frame.\n *\n * The body no longer centers/scrolls the card: each card fills the body via the\n * shared CardLayout, which owns its own scroll + bottom-pinned CTA (Cal-AI style).\n * The safe area uses `react-native-safe-area-context` (top + bottom edges) — the\n * RN core SafeAreaView is deprecated and iOS-only, so the kit takes the standard\n * Expo/RN peer instead of shipping cropped layouts on Android + notched devices.\n */\nimport React, { useMemo } from \"react\";\nimport { StyleSheet, Text, TouchableOpacity, View } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle } from \"../theme/typography\";\nimport { StepProgress } from \"./StepProgress\";\n\nexport type OnboardingScaffoldProps = {\n /** 1-based index of the current step; drives the (countless) progress bar. */\n step: number;\n /** When true, the progress bar fills to 100% (flow finished). */\n complete?: boolean;\n /** Approximate total screens, if known — paces the bar (never shown). */\n approxScreens?: number;\n /** Optional Back action — hidden when omitted (e.g. on the first step). */\n onBack?: () => void;\n /** Optional Skip action — hidden when omitted. */\n onSkip?: () => void;\n skipLabel?: string;\n backLabel?: string;\n children: React.ReactNode;\n};\n\nconst _OnboardingScaffold: React.FC<OnboardingScaffoldProps> = ({\n step,\n complete,\n approxScreens,\n onBack,\n onSkip,\n skipLabel = \"Skip\",\n backLabel = \"Back\",\n children,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const hit = { top: 12, bottom: 12, left: 12, right: 12 };\n\n return (\n <SafeAreaView\n edges={[\"top\", \"bottom\"]}\n style={[styles.flex, { backgroundColor: t.colors.background }]}\n >\n <View style={[styles.header, { paddingHorizontal: t.spacing.md, paddingTop: t.spacing.md }]}>\n <View style={styles.progressWrap}>\n <StepProgress step={step} complete={complete} approxScreens={approxScreens} />\n </View>\n {onSkip ? (\n <TouchableOpacity onPress={onSkip} hitSlop={hit} style={styles.skip}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted }]}>{skipLabel}</Text>\n </TouchableOpacity>\n ) : null}\n </View>\n\n {/* Full-screen body (flex:1): the card (via CardLayout) fills this and pins its own CTA,\n and the between-turns LoadingBlock fills+centers in this SAME region — so the loader\n lands at the content-area center, consistent with the cards, not the full-screen center. */}\n <View\n style={[styles.body, { paddingHorizontal: t.spacing.md, paddingTop: t.spacing.md }]}\n >\n {children}\n </View>\n\n {onBack ? (\n <View style={[styles.footer, { paddingHorizontal: t.spacing.md, paddingBottom: t.spacing.sm }]}>\n <TouchableOpacity onPress={onBack} hitSlop={hit}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted }]}>{backLabel}</Text>\n </TouchableOpacity>\n </View>\n ) : null}\n </SafeAreaView>\n );\n};\n\nexport const OnboardingScaffold = React.memo(_OnboardingScaffold);\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n flex: { flex: 1 },\n header: { flexDirection: \"row\", alignItems: \"center\" },\n progressWrap: { flex: 1 },\n body: { flex: 1 },\n footer: { flexDirection: \"row\", justifyContent: \"flex-start\" },\n skip: { marginLeft: t.spacing.md },\n });\n}\n","/**\n * Button — the kit's themed primary/outline button, replacing the SDK's hardcoded\n * `Btn`. Every color/radius/font comes from the active theme.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md row 20): \"a footer button that answers\n * the tap\" — scale 1→0.975 spring on press-in, back on release, native driver.\n * Reduce motion: an opacity dip to 0.85 while pressed, no scale. Disabled keeps\n * the `disabled` token fill with no press handler (unchanged).\n */\nimport React, { useCallback, useRef } from \"react\";\nimport { Animated, Pressable, StyleSheet, Text } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { buttonLabelStyle } from \"../theme/typography\";\nimport {\n BUTTON_PRESS_SCALE,\n BUTTON_PRESS_SPRING,\n REDUCED_FADE_MS,\n REDUCED_PRESS_OPACITY,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\ntype Variant = \"primary\" | \"outline\";\n\ntype ButtonProps = {\n title: string;\n onPress?: () => void;\n variant?: Variant;\n disabled?: boolean;\n /** Stretch to the container width — for form-style CTAs (e.g. the review form's\n * \"Send feedback\"). Default false keeps the content-width pill used by cards. */\n fullWidth?: boolean;\n};\n\nconst _Button: React.FC<ButtonProps> = ({\n title,\n onPress,\n variant = \"primary\",\n disabled = false,\n fullWidth = false,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const isPrimary = variant === \"primary\";\n\n // 0 = at rest, 1 = pressed. Scale normally; opacity dip under reduce motion.\n const pressT = useRef(new Animated.Value(0)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) {\n Animated.timing(pressT, {\n toValue: to,\n duration: scaledMs(REDUCED_FADE_MS),\n useNativeDriver: true,\n }).start();\n return;\n }\n Animated.spring(pressT, {\n toValue: to,\n friction: BUTTON_PRESS_SPRING.friction,\n tension: BUTTON_PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressT, reduced],\n );\n const lastPress = useRef<number>(0);\n const handlePress = useCallback(() => {\n if (!onPress) return;\n const now = Date.now();\n if (now - lastPress.current < 500) return;\n lastPress.current = now;\n onPress();\n }, [onPress]);\n\n const handlePressIn = useCallback(() => pressTo(1), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(0), [pressTo]);\n\n const scale = pressT.interpolate({\n inputRange: [0, 1],\n outputRange: [1, reduced ? 1 : BUTTON_PRESS_SCALE],\n });\n const opacity = pressT.interpolate({\n inputRange: [0, 1],\n outputRange: [1, reduced ? REDUCED_PRESS_OPACITY : 1],\n });\n\n return (\n <Pressable\n onPress={disabled ? undefined : handlePress}\n onPressIn={disabled ? undefined : handlePressIn}\n onPressOut={disabled ? undefined : handlePressOut}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityState={{ disabled }}\n style={fullWidth ? styles.fill : undefined}\n >\n <Animated.View\n style={[\n styles.base,\n fullWidth && styles.fill,\n {\n borderRadius: t.button.radius,\n minHeight: t.button.height,\n paddingHorizontal: t.button.paddingX,\n opacity,\n transform: [{ scale }],\n },\n isPrimary\n ? { backgroundColor: disabled ? t.colors.disabled : t.colors.primary }\n : { borderWidth: 1.5, borderColor: disabled ? t.colors.border : t.colors.primary },\n ]}\n >\n <Text\n style={[\n buttonLabelStyle(t.fonts),\n {\n color: disabled\n ? t.colors.textMuted\n : isPrimary\n ? t.colors.onPrimary\n : t.colors.primary,\n },\n ]}\n >\n {title}\n </Text>\n </Animated.View>\n </Pressable>\n );\n};\n\nexport const Button = React.memo(_Button);\n\nconst styles = StyleSheet.create({\n base: { alignItems: \"center\", justifyContent: \"center\" },\n fill: { width: \"100%\" },\n});\n","/**\n * ErrorBlock — shown on backend error/timeout. Carries a retry action so the flow\n * never dead-ends. The host decides what retry does (re-send start, or fall back).\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"./Button\";\n\nexport type ErrorBlockProps = {\n title?: string;\n message?: string;\n retryLabel?: string;\n onRetry?: () => void;\n};\n\nconst _ErrorBlock: React.FC<ErrorBlockProps> = ({\n title = \"Something went wrong\",\n message = \"We couldn't load this step. You can try again.\",\n retryLabel = \"Try again\",\n onRetry,\n}) => {\n const t = useOnboardingTheme();\n return (\n <View style={[styles.center, { gap: t.spacing.md, padding: t.spacing.lg }]}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n {onRetry ? <Button title={retryLabel} onPress={onRetry} variant=\"outline\" /> : null}\n </View>\n );\n};\n\nexport const ErrorBlock = React.memo(_ErrorBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * CardLayout — the shared full-screen card body every card renders into. It owns\n * the Cal-AI style vertical rhythm so no card re-implements layout:\n *\n * [ title ] ← fixed at top (small gap → subtitle)\n * [ subtitle / hint ]\n * [ ─ scrollable content ─ ]← options / chips / input; a flex:1 ScrollView that\n * fills the gap, so it scrolls only when tall and\n * otherwise just pushes the footer down\n * [ footer / CTA ] ← the submit button, ANCHORED to the bottom\n *\n * The middle ScrollView (flex:1) IS the flexible spacer: when the content is short\n * it grows to fill, pinning the footer to the bottom of the screen; when the\n * content is many/tall options it scrolls while the CTA stays put. Everything\n * reads from the theme tokens — no hardcoded spacing or color.\n *\n * `align=\"center\"` vertically centers the content (used by the value/status beats:\n * InterstitialCard / StatusCard), keeping the same pinned-CTA footer.\n *\n * The whole column sits in a KeyboardAvoidingView (behavior=\"padding\") so the pinned\n * footer rides above the soft keyboard on text questions (TextInputCard). On hosts\n * whose window already resizes for the keyboard the computed overlap is ~0, so the\n * padding is a no-op — safe on both iOS and Android, edge-to-edge or not.\n */\nimport React, { useMemo } from \"react\";\nimport { KeyboardAvoidingView, ScrollView, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle, labelStyle } from \"../theme/typography\";\n\nexport type CardLayoutProps = {\n /** Fixed question/label shown at the top. Omit for a header-less centered beat. */\n title?: string;\n /** Optional supporting line under the title (small gap between them). */\n subtitle?: string;\n /** The options / chips / input area — the scrollable middle. */\n children: React.ReactNode;\n /** The pinned bottom CTA (usually a <Button/>). Omitted → no footer. */\n footer?: React.ReactNode;\n /** Vertical alignment of the middle content. \"top\" (questions) | \"center\" (beats). */\n align?: \"top\" | \"center\";\n /** Custom title node (e.g. StatusCard's icon+title row) rendered in place of `title`. */\n titleNode?: React.ReactNode;\n};\n\nconst _CardLayout: React.FC<CardLayoutProps> = ({\n title,\n subtitle,\n children,\n footer,\n align = \"top\",\n titleNode,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const hasHeader = !!title || !!subtitle || !!titleNode;\n\n return (\n <KeyboardAvoidingView style={styles.fill} behavior=\"padding\">\n {hasHeader ? (\n <View style={styles.header}>\n {titleNode ??\n (title ? (\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{title}</Text>\n ) : null)}\n {subtitle ? (\n <Text\n style={[\n bodyStyle(t.fonts),\n { color: t.colors.textMuted, marginTop: t.spacing.xs },\n ]}\n >\n {subtitle}\n </Text>\n ) : null}\n </View>\n ) : null}\n\n <ScrollView\n style={styles.fill}\n contentContainerStyle={[\n styles.scrollContent,\n align === \"center\" && styles.center,\n ]}\n keyboardShouldPersistTaps=\"handled\"\n keyboardDismissMode=\"on-drag\"\n showsVerticalScrollIndicator={false}\n >\n {children}\n </ScrollView>\n\n {footer ? <View style={styles.footer}>{footer}</View> : null}\n </KeyboardAvoidingView>\n );\n};\n\nexport const CardLayout = React.memo(_CardLayout);\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n fill: { flex: 1 },\n header: { marginBottom: t.spacing.lg },\n footer: { paddingTop: t.spacing.lg },\n // flexGrow lets a short content block grow to fill (pinning the footer) while a\n // tall one scrolls past the visible area.\n scrollContent: { flexGrow: 1 },\n center: { justifyContent: \"center\" },\n });\n}\n","/**\n * CompletionView — the terminal \"you're all set\" screen, shown when the flow\n * reaches its final StatusCard. It surfaces the backend's recap (what the app\n * will do for the user, derived from their answers) and a single clear CTA.\n *\n * WHY a dedicated screen (not an instant hand-off): the backend spends the last\n * turn summarizing the user's tastes and what their experience will now look\n * like. The user should actually SEE that payoff and tap to continue — so\n * `onContinue` fires only on the button press, never automatically.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 14-16, the peak-end beat): the\n * badge pops in with a spring (scale 0.4→1, slight overshoot), ONE soft accent\n * burst radiates once behind it (scale 0.4→1.5, opacity 0.5→0, 500ms) —\n * celebratory without confetti — and the copy fades up 80ms apart. Everything\n * settles well under a second. Reduce motion: final frame, no burst.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"./Button\";\nimport { CardLayout } from \"./CardLayout\";\nimport {\n STATUS_BURST_MS,\n STATUS_BURST_OPACITY_FROM,\n STATUS_BURST_SCALE_FROM,\n STATUS_BURST_SCALE_TO,\n STATUS_COPY_MS,\n STATUS_POP_SCALE_FROM,\n STATUS_POP_SPRING,\n WIRE_BEZIER,\n scaledMs,\n statusCopyDelay,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\nconst BADGE_SIZE = 64;\nconst BURST_SIZE = 104;\n\nexport type CompletionViewProps = {\n title: string;\n message?: string;\n ctaLabel?: string;\n onContinue: () => void;\n};\n\nconst _CompletionView: React.FC<CompletionViewProps> = ({\n title,\n message,\n ctaLabel = \"Let's go\",\n onContinue,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const [submitted, setSubmitted] = useState(false);\n\n const pop = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const burst = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const titleT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const messageT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n\n useEffect(() => {\n if (reduced) {\n // Final frame: badge + copy settled, burst already faded out.\n pop.setValue(1);\n burst.setValue(1);\n titleT.setValue(1);\n messageT.setValue(1);\n return;\n }\n const rise = (value: Animated.Value, delay: number) =>\n Animated.timing(value, {\n toValue: 1,\n duration: scaledMs(STATUS_COPY_MS),\n delay,\n easing: easeWire,\n useNativeDriver: true,\n });\n const anims = [\n Animated.spring(pop, {\n toValue: 1,\n friction: STATUS_POP_SPRING.friction,\n tension: STATUS_POP_SPRING.tension,\n useNativeDriver: true,\n }),\n // One-shot celebratory burst: fires once, never loops.\n Animated.timing(burst, {\n toValue: 1,\n duration: scaledMs(STATUS_BURST_MS),\n easing: Easing.out(Easing.ease),\n useNativeDriver: true,\n }),\n rise(titleT, scaledMs(statusCopyDelay(0))),\n rise(messageT, scaledMs(statusCopyDelay(1))),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, pop, burst, titleT, messageT]);\n\n const handlePress = useCallback(() => {\n if (submitted) return;\n setSubmitted(true);\n onContinue();\n }, [submitted, onContinue]);\n\n const scale = pop.interpolate({ inputRange: [0, 1], outputRange: [STATUS_POP_SCALE_FROM, 1] });\n const burstScale = burst.interpolate({\n inputRange: [0, 1],\n outputRange: [STATUS_BURST_SCALE_FROM, STATUS_BURST_SCALE_TO],\n });\n const burstOpacity = burst.interpolate({\n inputRange: [0, 1],\n outputRange: [STATUS_BURST_OPACITY_FROM, 0],\n });\n const riseStyle = (value: Animated.Value) => ({\n opacity: value,\n transform: [{ translateY: value.interpolate({ inputRange: [0, 1], outputRange: [10, 0] }) }],\n });\n\n return (\n <CardLayout\n align=\"center\"\n footer={<Button title={ctaLabel} onPress={handlePress} variant=\"primary\" disabled={submitted} />}\n >\n <View style={[styles.center, { gap: t.spacing.md }]}>\n <View style={styles.badgeStage}>\n {/* Soft accent burst behind the badge: primarySoft keeps the tint calm. */}\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.burst,\n {\n backgroundColor: t.colors.primarySoft,\n borderRadius: t.radius.full,\n opacity: burstOpacity,\n transform: [{ scale: burstScale }],\n },\n ]}\n />\n <Animated.View\n style={[\n styles.badge,\n {\n backgroundColor: t.colors.primarySoft,\n borderRadius: t.radius.full,\n transform: [{ scale }],\n opacity: pop,\n },\n ]}\n >\n <Text style={[styles.check, { color: t.colors.primary }]}>✓</Text>\n </Animated.View>\n </View>\n\n <Animated.View style={riseStyle(titleT)}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n </Animated.View>\n {message ? (\n <Animated.View style={riseStyle(messageT)}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n </Animated.View>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const CompletionView = React.memo(_CompletionView);\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n badgeStage: {\n width: BURST_SIZE,\n height: BURST_SIZE,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n burst: { position: \"absolute\", width: BURST_SIZE, height: BURST_SIZE },\n badge: { width: BADGE_SIZE, height: BADGE_SIZE, alignItems: \"center\", justifyContent: \"center\" },\n check: { fontSize: 34, fontWeight: \"800\" },\n});\n","/**\n * CardHandoff — the card-to-card transition from the Wire Activation design:\n * \"cards hand off, they don't cut\". When `transitionKey` changes, the outgoing\n * child leaves left (translateX 0→-26, fade, 180ms) in an absolute layer while\n * the incoming child arrives from the right (translateX +26→0, fade, 220ms)\n * delayed by the 80ms exit lead — one moving surface, ~300ms total.\n *\n * Variants (per child):\n * - \"slide\": questions — the directional stepper motion above.\n * - \"spring\": the InterstitialCard value beat — scale 0.96→1 spring pop\n * (the shell's springier variant, kept from AnimatedCard).\n * - \"fade\": loaders — enter/exit as a plain 120ms fade so the \"thinking\"\n * state hands off to the first card without a hard cut.\n *\n * `direction` mirrors the whole slide for BACK navigation, so a step the user\n * returns to comes back from the side it left toward. Spatial consistency: if\n * \"next\" pushes left, \"back\" must pull right, or the stack loses its geography.\n *\n * `layout` picks how the moving surface is sized. \"fill\" (default) is the\n * full-screen flow, where the pane owns the viewport. \"auto\" is for a pane\n * inside an auto-height container (the CenteredModal card): `flex: 1` there\n * resolves to a ZERO-height child under Yoga — flex-basis 0 with no free space\n * to grow into — so the in-flow layer must size to its own content instead.\n *\n * Reduce motion: every handoff becomes a 120ms crossfade, no translate/scale.\n * All values run on the native driver (transform/opacity only); in-flight\n * animations are stopped when superseded and on unmount.\n *\n * This SUPERSEDES the enter-only AnimatedCard: same keyed-remount contract from\n * OnboardingFlow (the child renderer stays keyed on the message id), plus the\n * paired exit layer the design calls for.\n */\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet } from \"react-native\";\nimport {\n CARD_ENTER_MS,\n CARD_ENTER_SCALE_FROM,\n CARD_EXIT_LEAD_MS,\n CARD_EXIT_MS,\n CARD_SLIDE_PX,\n CARD_SPRING,\n LOADER_HANDOFF_FADE_MS,\n REDUCED_FADE_MS,\n WIRE_BEZIER,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nexport type CardHandoffVariant = \"slide\" | \"spring\" | \"fade\";\n\n/** Which way the stack is moving. \"backward\" mirrors the slide (see the header note). */\nexport type CardHandoffDirection = \"forward\" | \"backward\";\n\n/** How the moving surface is sized. \"auto\" = a pane in an auto-height container. */\nexport type CardHandoffLayout = \"fill\" | \"auto\";\n\nexport type CardHandoffProps = {\n /** Identity of the current child (e.g. the message id). A change runs the handoff. */\n transitionKey: string;\n /** How the CURRENT child enters (and, snapshotted, how it will later exit). */\n variant?: CardHandoffVariant;\n /** Travel direction of THIS transition. Default \"forward\". */\n direction?: CardHandoffDirection;\n /** Sizing mode. Default \"fill\" (the full-screen flow). */\n layout?: CardHandoffLayout;\n children: React.ReactNode;\n};\n\ntype Snapshot = { key: string; node: React.ReactNode; variant: CardHandoffVariant };\n\nconst _CardHandoff: React.FC<CardHandoffProps> = ({\n transitionKey,\n variant = \"slide\",\n direction = \"forward\",\n layout = \"fill\",\n children,\n}) => {\n const reduced = useReducedMotion();\n const [leaving, setLeaving] = useState<Snapshot | null>(null);\n\n const enterT = useRef(new Animated.Value(0)).current;\n const exitT = useRef(new Animated.Value(0)).current;\n // The previous render's child, snapshotted so it can play the exit layer.\n const prev = useRef<Snapshot>({ key: transitionKey, node: children, variant });\n const running = useRef<{ enter?: Animated.CompositeAnimation; exit?: Animated.CompositeAnimation }>({});\n const mounted = useRef(false);\n\n // One orchestration effect, run every render: refresh the snapshot while the key\n // is stable; on a key change, snapshot the old child into the exit layer and run\n // the paired exit+enter. (No deps array on purpose — `children` is a fresh node\n // every parent render and must keep the snapshot current.)\n useEffect(() => {\n const last = prev.current;\n prev.current = { key: transitionKey, node: children, variant };\n\n // First mount: enter only (the design's initial reveal), nothing exits.\n if (!mounted.current) {\n mounted.current = true;\n running.current.enter = startEnter(enterT, variant, reduced, 0);\n return;\n }\n if (last.key === transitionKey) return;\n\n running.current.enter?.stop();\n running.current.exit?.stop();\n setLeaving(last);\n enterT.setValue(0);\n exitT.setValue(0);\n\n const exitDuration = reduced\n ? REDUCED_FADE_MS\n : last.variant === \"fade\"\n ? LOADER_HANDOFF_FADE_MS\n : CARD_EXIT_MS;\n const exit = Animated.timing(exitT, {\n toValue: 1,\n duration: scaledMs(exitDuration),\n easing: easeWire,\n useNativeDriver: true,\n });\n running.current.exit = exit;\n exit.start();\n\n const enter = startEnter(enterT, variant, reduced, reduced ? 0 : CARD_EXIT_LEAD_MS, () =>\n setLeaving(null),\n );\n running.current.enter = enter;\n });\n\n // Stop anything in flight on unmount (leaked animations drain the JS thread).\n useEffect(\n () => () => {\n running.current.enter?.stop();\n running.current.exit?.stop();\n },\n [],\n );\n\n const enterStyle = {\n opacity: enterT,\n transform: transformFor(variant, enterT, reduced, \"enter\", direction),\n };\n\n return (\n <>\n {leaving ? (\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n {\n opacity: exitT.interpolate({ inputRange: [0, 1], outputRange: [1, 0] }),\n // The CURRENT direction drives BOTH layers: one transition, one geography.\n transform: transformFor(leaving.variant, exitT, reduced, \"exit\", direction),\n },\n ]}\n >\n {leaving.node}\n </Animated.View>\n ) : null}\n <Animated.View key={variant} style={[layout === \"fill\" ? styles.fill : null, enterStyle]}>\n {children}\n </Animated.View>\n </>\n );\n};\n\n/** Kick off the enter animation for a variant (spring for the value beat, timing otherwise). */\nconst startEnter = (\n value: Animated.Value,\n variant: CardHandoffVariant,\n reduced: boolean,\n delay: number,\n onDone?: () => void,\n): Animated.CompositeAnimation => {\n value.setValue(0);\n const anim =\n !reduced && variant === \"spring\"\n ? Animated.spring(value, {\n toValue: 1,\n delay: scaledMs(delay),\n damping: CARD_SPRING.damping,\n stiffness: CARD_SPRING.stiffness,\n mass: CARD_SPRING.mass,\n useNativeDriver: true,\n })\n : Animated.timing(value, {\n toValue: 1,\n delay: scaledMs(delay),\n duration: scaledMs(\n reduced\n ? REDUCED_FADE_MS\n : variant === \"fade\"\n ? LOADER_HANDOFF_FADE_MS\n : CARD_ENTER_MS,\n ),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start(({ finished }) => {\n if (finished) onDone?.();\n });\n return anim;\n};\n\n/**\n * Transform track per variant/layer; reduce motion = opacity-only crossfade.\n *\n * `travel` mirrors the X axis: forward pushes the stack left (new arrives from the\n * right), backward pulls it right (new arrives from the left).\n */\nconst transformFor = (\n variant: CardHandoffVariant,\n t: Animated.Value,\n reduced: boolean,\n layer: \"enter\" | \"exit\",\n travel: CardHandoffDirection,\n) => {\n if (reduced || variant === \"fade\") return [];\n if (variant === \"spring\" && layer === \"enter\") {\n return [{ scale: t.interpolate({ inputRange: [0, 1], outputRange: [CARD_ENTER_SCALE_FROM, 1] }) }];\n }\n const slide = travel === \"forward\" ? CARD_SLIDE_PX : -CARD_SLIDE_PX;\n return [\n {\n translateX: t.interpolate({\n inputRange: [0, 1],\n outputRange: layer === \"enter\" ? [slide, 0] : [0, -slide],\n }),\n },\n ];\n};\n\nexport const CardHandoff = React.memo(_CardHandoff);\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n});\n","/**\n * deriveAnswers — read the user's structured choices off the thread.\n *\n * The cards send answers back as natural-language strings (the SDK's\n * useWireAIAction wraps them, e.g. `I selected: [\"Food\",\"Travel\"]`,\n * `My answer is: \"Casablanca\"`). We pair each rendered question with the reply\n * that followed it and key the answer by the backend's progress `key` when\n * present (so `username`/`interests`/`city` come back under their real keys),\n * else by the question text. No second LLM call — the values ARE the data.\n */\nimport type { Message } from \"wireai-rn\";\n\nconst stripPrefix = (s: string): string =>\n s.replace(/^(I selected:|My answer is:|I tapped:)\\s*/i, \"\").trim();\n\nconst tryParse = (s: string): unknown => {\n try {\n return JSON.parse(s);\n } catch {\n return s;\n }\n};\n\nexport const deriveAnswers = (messages: Message[]): Record<string, unknown> => {\n const out: Record<string, unknown> = {};\n for (let i = 0; i < messages.length; i++) {\n const m = messages[i];\n const r = m?.response;\n if (!m || m.role !== \"assistant\" || !r || r.action !== \"render\") continue;\n\n const props = (r.props ?? {}) as Record<string, unknown>;\n const progress = props.progress as { key?: string } | undefined;\n const questionText =\n (props.title as string) ?? (props.label as string) ?? (props.question as string);\n const key = progress?.key || questionText;\n\n const reply = messages[i + 1];\n if (key && reply?.role === \"user\") {\n out[key] = tryParse(stripPrefix(reply.content));\n }\n }\n return out;\n};\n","/**\n * readProgress — pull the backend's progress metadata off a render response.\n *\n * The managed backend rides `{ step, total, key }` inside the Wire envelope's\n * `props.progress`. That's the only field that survives the SDK's strict client\n * validation (extra top-level keys get folded into props; the card's own schema\n * silently strips `progress` from its render props, but it stays readable on\n * `response.props`). All fields are optional so an older backend just falls back\n * to the local counter.\n */\nimport type { WireAIResponse } from \"wireai-rn\";\nimport type { OnboardingProgress } from \"../types\";\n\ntype PartialProgress = {\n step?: number;\n total?: number;\n key?: string;\n skippable?: boolean;\n};\n\nexport const readProgress = (response?: WireAIResponse): PartialProgress => {\n if (!response || response.action !== \"render\") return {};\n const props = (response.props ?? {}) as Record<string, unknown>;\n const raw = props.progress;\n if (!raw || typeof raw !== \"object\") return {};\n const p = raw as Partial<OnboardingProgress>;\n return {\n step: typeof p.step === \"number\" ? p.step : undefined,\n total: typeof p.total === \"number\" ? p.total : undefined,\n key: typeof p.key === \"string\" ? p.key : undefined,\n skippable: typeof p.skippable === \"boolean\" ? p.skippable : undefined,\n };\n};\n","/**\n * reportClientEvent — forward DEVICE-ONLY onboarding events to the Wire AI analytics\n * backend (`POST {serverUrl}/v1/events`), completing the funnel for events the server\n * can't observe on its own.\n *\n * The backend already records the server-observable funnel during the A2A flow\n * (`session_started`, `screen_shown`, `answer_submitted`, `completed`, `llm_fallback`,\n * and even `screen_skipped` — it derives that from the kit's skip sentinel). The one\n * event no server request can capture is `dropped`: the user closing the app / unmounting\n * the flow without finishing. That's what this reporter is for.\n *\n * Contract (server: routers/onboarding.py → analytics/events.py):\n * POST {serverUrl}/v1/events\n * Authorization: Bearer {apiKey}\n * { \"events\": [ { event_type, session_id, screen_index?, component?, question_key?,\n * latency_ms?, meta?, device?, user_context? } ] }\n * The server fills `app_id` + `environment` from the resolving key (never send app_id),\n * and silently skips malformed events — one bad payload never fails the batch.\n *\n * ⚠️ Correlation: `session_id` MUST equal the A2A `contextId` the server uses to key the\n * server-side events, or the funnel report (which groups by `session_id`) treats this as a\n * phantom session. See `makeSessionId` + WireOnboarding for how the kit seeds it.\n *\n * Fire-and-forget: this never throws into the UI and never awaits — analytics must never\n * be able to break onboarding.\n */\nimport type { DeviceContext } from \"../device/deviceContext\";\n\n/** Event types a CLIENT may report. The rest of the funnel is server-side; sending those\n * here would double-count. `screen_skipped` is included for completeness, but the kit does\n * NOT emit it — the backend already derives it from the skip sentinel (see OnboardingFlow).\n * `client_fallback` is emitted by the kit when the AI flow degrades to the static fallback,\n * so the dashboard's fallback-rate counts the whole-flow case (distinct from the server's\n * per-turn `llm_fallback`). The server back-fills a `session_started` for it if unseen.\n * This is the SINGLE fallback signal — hosts must NOT also report their own.\n * `identify` binds the host's opaque `user_id` to this `session_id` (late binding — the user\n * registered during/after onboarding). It carries no funnel weight; the server maps the\n * session to the user and back-fills a `session_started` if it never saw the session.\n * `app_event` is the host's own in-app event (the `createAnalytics` façade's `track`/`screen`\n * route through the offline queue as first-class `ClientEvent`s). The server already ingests\n * it — `reportAppEvent` (reviews/transport) has fired `event_type='app_event'` all along; this\n * widening just lets the same shape flow through the durable queue instead of a blind POST. */\nexport type ClientEventType =\n | \"screen_skipped\"\n | \"dropped\"\n | \"client_fallback\"\n | \"identify\"\n | \"app_event\";\n\n/** One client-reported event. Mirrors the server's `OnboardingEvent` (client-settable fields). */\nexport type ClientEvent = {\n event_type: ClientEventType;\n /** Must match the server-side A2A contextId for this onboarding (see makeSessionId). */\n session_id: string;\n /** 0-based index of the screen the event refers to (matches server `screen_shown`). */\n screen_index?: number;\n component?: string;\n question_key?: string;\n latency_ms?: number;\n /** JSON-stringified extras; the server stores it verbatim. */\n meta?: string;\n /**\n * Privacy-label-neutral device snapshot (platform / form factor / locale / host appVersion).\n * Sent as an object; the server sanitizes + persists it and derives a coarse country. Old\n * servers ignore this unknown field — fully backward compatible. See device/deviceContext.ts.\n */\n device?: DeviceContext;\n /**\n * Host-injected, non-PII context (signup method, referral, plan, hashed user id). Old servers\n * ignore it. MUST NOT contain PII like raw emails — see the README `userContext` section.\n */\n user_context?: Record<string, string | number | boolean>;\n /**\n * The host's OPAQUE PSEUDONYMOUS user id (their internal id, NOT an email/name). Required on\n * `identify`, optional (rides along) on other events. Trimmed + capped at 128 chars host-side.\n * Lets the backend reconcile onboarding sessions to real users. Old servers ignore it.\n */\n user_id?: string;\n};\n\n/** Where to POST. Derived from `WireOnboardingConfig` (`serverUrl` + `apiKey`). */\nexport type ClientEventTarget = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n};\n\n/**\n * A unique-per-onboarding session id. Used both as the client event `session_id` AND as the\n * seed the kit forwards to the backend so the SERVER adopts it as the A2A `contextId` — making\n * client and server agree (see WireOnboarding + the SDK-correlation note in the kit docs).\n * No crypto dependency: timestamp + random is collision-safe for a single device's onboarding.\n */\nexport const makeSessionId = (): string =>\n `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * The ONE place the `/v1/events` POST is described (url + method + headers + body). Both the\n * fire-and-forget {@link reportClientEvents} and the awaitable {@link reportClientEventsAwait}\n * build their request here so there is a SINGLE definition of the events transport — no second\n * copy of the endpoint path, headers, or envelope shape to drift. Returns `null` when there is\n * nothing to send (no target / no events) or serialization throws, so callers just bail.\n */\nconst buildEventsRequest = (\n target: ClientEventTarget | undefined,\n events: ClientEvent[],\n): { url: string; init: RequestInit } | null => {\n if (!target?.serverUrl || events.length === 0) return null;\n try {\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n return { url, init: { method: \"POST\", headers, body: JSON.stringify({ events }) } };\n } catch {\n // URL construction or JSON serialization failed — nothing to send.\n return null;\n }\n};\n\n/**\n * POST one or more client events, fire-and-forget. A missing/invalid target, a build error,\n * a missing `fetch`, or a network failure is swallowed — the call returns immediately and the\n * request (if any) runs in the background.\n */\nexport const reportClientEvents = (\n target: ClientEventTarget | undefined,\n events: ClientEvent[],\n): void => {\n try {\n const req = buildEventsRequest(target, events);\n if (!req) return;\n void fetch(req.url, req.init).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // A missing `fetch` — swallow.\n }\n};\n\n/** Convenience single-event wrapper around {@link reportClientEvents}. */\nexport const reportClientEvent = (\n target: ClientEventTarget | undefined,\n event: ClientEvent,\n): void => reportClientEvents(target, [event]);\n\n/**\n * AWAITABLE sibling of {@link reportClientEvents}: POST one or more client events through the SAME\n * `/v1/events` path, but resolve only once the server has RESPONDED — so a decision re-fetch fired\n * immediately after is guaranteed to see the event in the session stream (this is the guarantee\n * `wire.track` needs before it triggers decision revalidation). Never throws: a missing/invalid\n * target, a missing `fetch`, a network error, or a non-2xx status all resolve to `false`. Resolves\n * `true` only on a 2xx response.\n */\nexport const reportClientEventsAwait = async (\n target: ClientEventTarget | undefined,\n events: ClientEvent[],\n): Promise<boolean> => {\n try {\n const req = buildEventsRequest(target, events);\n if (!req) return false;\n const res = await fetch(req.url, req.init);\n return Boolean(res && res.ok);\n } catch {\n // Unreachable / missing-fetch / network — best-effort, report failure.\n return false;\n }\n};\n\n/** Convenience single-event wrapper around {@link reportClientEventsAwait}. */\nexport const reportClientEventAwait = (\n target: ClientEventTarget | undefined,\n event: ClientEvent,\n): Promise<boolean> => reportClientEventsAwait(target, [event]);\n","/**\n * sendPreview — fire-and-forget PREFETCH of the next A2A turn, so the backend can warm\n * its generation cache during a moment the user isn't waiting.\n *\n * Two callers, both firing the SAME text the real commit will send (the backend keys the\n * preview cache on the raw message string, so a mismatch just misses harmlessly):\n * 1. InterstitialCard — its answer is always \"continue\" (SDK-wrapped `My answer is: \"continue\"`),\n * warmed while the user reads the momentum screen.\n * 2. Choice cards (Selection/ChipSelect) — warmed on selection-change with the exact\n * `I selected: ${JSON.stringify(value)}` the Continue tap will send, so the perceptibly-slow\n * first LLM question returns from cache. See OnboardingFlow.previewOnSelect.\n *\n * Contract (mirrors the A2A `message/send` shape, but a distinct `method`):\n * POST {serverUrl}/a2a\n * Authorization: Bearer {apiKey}\n * { jsonrpc:\"2.0\", id:<rand>, method:\"message/preview\",\n * params:{ message:{ role:\"user\", parts:[{ text }] }, contextId:<sessionId>,\n * metadata:{ sessionId } } }\n *\n * Fire-and-forget, exactly like reportClientEvent: never awaits, never throws into the UI —\n * a prefetch that fails just means the real turn generates normally.\n */\n\n/** Where to POST the preview. Same tenant creds as the flow (`serverUrl` + `apiKey`). */\nexport type PreviewTarget = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/a2a` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n};\n\n/** What to preview: the session to warm and the message the user is about to send. */\nexport type PreviewArgs = {\n /** A2A contextId for this onboarding (the kit session id). */\n sessionId: string;\n /** The message that will be committed next (for interstitials, always \"continue\"). */\n userMessage: string;\n};\n\n/**\n * Warm the next turn's cache, fire-and-forget. A missing/invalid target, a build error,\n * a missing `fetch`, or a network failure is swallowed — the call returns immediately and\n * the request (if any) runs in the background.\n */\nexport const sendPreview = (\n target: PreviewTarget | undefined,\n { sessionId, userMessage }: PreviewArgs,\n): void => {\n if (!target?.serverUrl) return;\n try {\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/a2a`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n void fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: Math.floor(Math.random() * 1e9),\n method: \"message/preview\",\n params: {\n message: { role: \"user\", parts: [{ text: userMessage }] },\n contextId: sessionId,\n metadata: { sessionId },\n },\n }),\n }).catch(() => {\n // Network/transport error — prefetch is best-effort, swallow.\n });\n } catch {\n // URL construction, JSON serialization, or a missing fetch — swallow.\n }\n};\n","/**\n * OnboardingFlow — the inner engine. Mirrors the proven production-app usage of the SDK\n * (useWireAIThread + useWireAIAction + ComponentRenderer) and layers on the kit's\n * shell, progress, and per-step validators.\n *\n * Lifecycle per turn:\n * 1. Auto-send `startMessage` once → backend returns the first card.\n * 2. Show LoadingBlock until the first card arrives AND between every turn\n * (while `isLoading`); on error/timeout, auto-retry up to `maxRetries`, then\n * degrade to the host's static `fallbackFlow` (preferred), else `onError`, else\n * an inline ErrorBlock — so a generation failure never breaks onboarding.\n * 3. Render the latest card inside OnboardingScaffold. The progress bar follows\n * an asymptotic curve of the step index — it never reveals a total.\n * 4. Before any answer is sent, if the current screen's question key has a\n * validator, run it; on failure show the error inline and DON'T advance.\n * 5. On the terminal StatusCard, show CompletionView (the recap of what the app\n * will do for the user) and fire onComplete only when they tap its CTA.\n *\n * Lifecycle events (started / per-turn / error) are surfaced via `onEvent` so a\n * host can keep its analytics even though the kit owns the thread loop.\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n ComponentRenderer,\n useWireAIAction,\n useWireAIThread,\n type Message,\n} from \"wireai-rn\";\nimport { OnboardingScaffold } from \"./components/OnboardingScaffold\";\nimport { LoadingBlock } from \"./components/LoadingBlock\";\nimport { LoadingScreen } from \"./components/LoadingScreen\";\nimport { ErrorBlock } from \"./components/ErrorBlock\";\nimport { CompletionView } from \"./components/CompletionView\";\nimport { CardHandoff } from \"./components/CardHandoff\";\nimport { deriveAnswers } from \"./utils/deriveAnswers\";\nimport { readProgress } from \"./utils/readProgress\";\nimport { reportClientEvent, type ClientEventTarget } from \"./analytics/reportClientEvent\";\nimport { sendPreview } from \"./analytics/sendPreview\";\nimport type { DeviceContext } from \"./device/deviceContext\";\nimport type { OnboardingCopy, OnboardingEvent, OnboardingResult, StepValidator } from \"./types\";\n\ntype OnboardingFlowProps = {\n validators?: Record<string, StepValidator>;\n onComplete: (result: OnboardingResult) => void;\n onSkip?: () => void;\n onError?: (err: unknown) => void;\n onEvent?: (event: OnboardingEvent) => void;\n copy?: Partial<OnboardingCopy>;\n approxScreens?: number;\n startMessage: string;\n startTimeoutMs: number;\n /** Static onboarding rendered when the AI flow fails and retries are exhausted. */\n fallbackFlow?: React.ReactNode;\n /** Consecutive failures to auto-retry before degrading. */\n maxRetries: number;\n /** Where to POST device-only client events (`dropped`). Omit to disable reporting. */\n reportTarget?: ClientEventTarget;\n /** Session id shared with the backend (A2A contextId), so `dropped` correlates. */\n sessionId: string;\n /**\n * Device snapshot + host-injected user context, attached to every client event so the\n * backend can segment the funnel by device. Old servers ignore the extra fields.\n */\n clientContext?: {\n device?: DeviceContext;\n userContext?: Record<string, string | number | boolean>;\n /** The host's opaque user id (see WireOnboarding `userId`), rides `dropped`/`client_fallback`. */\n userId?: string;\n };\n /**\n * True when `sessionId` was restored from persisted storage (app killed mid-flow).\n * The kickoff then sends the skip sentinel instead of `startMessage` — the server\n * would record the literal start text as the ANSWER to the pending question, while\n * the sentinel advances one card recording nothing — and fires `resumed` instead of\n * `started` so host funnels don't double-count the session.\n */\n resumed?: boolean;\n};\n\n// The kit's per-question Skip sends this sentinel; the backend skips ONE question\n// (advances one card, no answer recorded). Must match the backend's SKIP_ONE_SENTINEL.\nconst SKIP_ONE_SENTINEL = \"__wireai_skip__\";\n\n// Callbacks that carry the user's ANSWER (and so must pass validation first).\nconst ANSWER_CALLBACKS = [\"onSubmit\", \"onSelect\", \"onConfirm\", \"onPress\"] as const;\n\nexport const DEFAULT_COPY: OnboardingCopy = {\n startingTitle: \"Getting started…\",\n startingHint: \"Setting up your onboarding\",\n restoringTitle: \"Picking up where you left off…\",\n restoringHint: \"Restoring your session\",\n thinkingTitle: \"Personalizing…\",\n thinkingHint: \"Tailoring your next question\",\n checkingTitle: \"Checking…\",\n checkingHint: \"One moment\",\n completeTitle: \"You're all set\",\n completeCta: \"Let's go\",\n};\n\nexport const OnboardingFlow: React.FC<OnboardingFlowProps> = ({\n validators,\n onComplete,\n onError,\n onEvent,\n copy,\n approxScreens,\n startMessage,\n startTimeoutMs,\n fallbackFlow,\n maxRetries,\n reportTarget,\n sessionId,\n resumed = false,\n clientContext,\n}) => {\n const { messages, error, isLoading, sendMessage, reset } = useWireAIThread();\n const makeActions = useWireAIAction(sendMessage);\n\n const c = useMemo<OnboardingCopy>(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);\n\n // Hold the latest event/error callbacks in refs so the lifecycle effects below\n // stay stable (and fire exactly once) regardless of the host re-passing closures.\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onCompleteRef = useRef(onComplete);\n onCompleteRef.current = onComplete;\n const validatorsRef = useRef(validators);\n validatorsRef.current = validators;\n\n // Client-event reporting refs, captured so the unmount cleanup (which runs once, with a\n // stale closure) reads current values.\n const reportTargetRef = useRef(reportTarget);\n reportTargetRef.current = reportTarget;\n const sessionIdRef = useRef(sessionId);\n sessionIdRef.current = sessionId;\n // Device + user context, held in a ref so the mount-once unmount cleanup (the `dropped`\n // reporter, which runs with a stale closure) reads the current snapshot.\n const clientContextRef = useRef(clientContext);\n clientContextRef.current = clientContext;\n // Last 0-based screen index we showed the user (matches the server's `screen_shown`\n // index). Used as the `dropped` event's screen_index. -1 = nothing shown yet.\n const lastScreenIndexRef = useRef(-1);\n // Trailing-edge debounce timer for prefetch-on-select (see previewOnSelect below).\n const previewTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const started = useRef(false);\n const finished = useRef(false);\n const errored = useRef(false);\n const attempts = useRef(0);\n // Mirror of the `degraded` state for the unmount cleanup: a degrade to the static\n // fallback is NOT a drop, so `dropped` must not fire after it.\n const degradedRef = useRef(false);\n const [degraded, setDegraded] = useState(false);\n const [timedOut, setTimedOut] = useState(false);\n const [validationError, setValidationError] = useState<string | undefined>();\n const [validating, setValidating] = useState(false);\n\n const lastCard = useMemo<Message | undefined>(\n () => [...messages].reverse().find((m) => m.role === \"assistant\" && m.response?.action === \"render\"),\n [messages],\n );\n\n // Local fallback counter — how many distinct rendered cards we've seen.\n const renderedCount = useMemo(\n () => messages.filter((m) => m.role === \"assistant\" && m.response?.action === \"render\").length,\n [messages],\n );\n\n const progress = useMemo(() => readProgress(lastCard?.response), [lastCard]);\n\n // 1. Auto-start: the backend treats the first inbound message as \"begin\".\n // On a RESUMED session (persisted id restored after an app kill) the kickoff is\n // the skip sentinel instead: the server has this session mid-flow with a pending\n // question, and would record `startMessage`'s literal text as its ANSWER — the\n // sentinel advances one card recording nothing (a `screen_skipped`). On a session\n // the server no longer knows (restart/expiry), the sentinel degrades cleanly to a\n // normal kickoff under the same id. Retries re-send the same kickoff.\n useEffect(() => {\n if (started.current) return;\n started.current = true;\n sendMessage(resumed ? SKIP_ONE_SENTINEL : startMessage);\n // Surface the session id (the A2A contextId) on the start event so a host can capture it\n // and bind a user AFTER the flow via `identifyOnboarding({ contextId })` — completion clears\n // the persisted session, so the in-flight event is the reliable post-flow handle. sessionId\n // is stable for the whole session (minted before this subtree mounts), so this stays mount-once.\n onEventRef.current?.(\n resumed\n ? { type: \"resumed\", contextId: sessionId }\n : { type: \"started\", contextId: sessionId },\n );\n }, [sendMessage, startMessage, resumed, sessionId]);\n\n // 2. Startup watchdog.\n useEffect(() => {\n if (lastCard) return;\n const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);\n return () => clearTimeout(timer);\n }, [lastCard, startTimeoutMs]);\n\n // A new card arrived → clear any prior inline validation error + emit a turn event.\n useEffect(() => {\n setValidationError(undefined);\n if (!lastCard?.id) return;\n const step = progress.step ?? renderedCount;\n // Remember the latest screen we showed (0-based) for a possible `dropped` event.\n lastScreenIndexRef.current = Math.max(0, step - 1);\n onEventRef.current?.({\n type: \"turn\",\n step,\n component: lastCard.response?.component,\n });\n // Prefetch: an InterstitialCard's answer is always \"continue\", so we can warm the next\n // turn's cache during the momentum window — by the time the user taps Continue the following\n // card is already generated. The preview MUST use the exact text the real Continue tap sends,\n // or the backend's message-keyed preview cache misses. The card's onSubmit(\"continue\") is\n // wrapped by the SDK as `My answer is: ${JSON.stringify(value)}`, so mirror that here.\n // Fire-and-forget; a failed/missed preview just means the real turn generates normally.\n if (lastCard.response?.component === \"InterstitialCard\") {\n sendPreview(reportTargetRef.current, {\n sessionId: sessionIdRef.current,\n userMessage: `My answer is: ${JSON.stringify(\"continue\")}`,\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastCard?.id]);\n\n // `dropped`: the user abandoned onboarding. No backend request fires on unmount, so the\n // server can't see this — the client must report it. Fire ONLY on a true unmount that\n // did NOT complete (`onComplete` never ran) and did NOT degrade to the static fallback\n // (a degrade is a reliability fallback, not a user drop). Refs keep this effect mount-once.\n useEffect(() => {\n return () => {\n if (finished.current || degradedRef.current) return;\n reportClientEvent(reportTargetRef.current, {\n event_type: \"dropped\",\n session_id: sessionIdRef.current,\n screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : undefined,\n device: clientContextRef.current?.device,\n user_context: clientContextRef.current?.userContext,\n user_id: clientContextRef.current?.userId,\n });\n };\n }, []);\n\n // Silently restart the thread from turn one (shared by auto-retry + manual retry).\n // Does NOT clear the attempt counter or the degraded flag — the caller decides that.\n const restartThread = useCallback(() => {\n setTimedOut(false);\n started.current = false;\n errored.current = false;\n reset();\n }, [reset]);\n\n // 3. Error/timeout → auto-retry a transient blip, then degrade to the static flow.\n // Each failure: log `error`; if we have retries left, restart the thread silently\n // (`retry`); once exhausted, mark `degraded` so the render falls through to the\n // host's `fallbackFlow`/`onError` (`fallback`). Counter is a ref → survives the\n // reset()-driven re-renders. This is the \"AI fails → static onboarding, never a\n // broken screen\" guarantee.\n useEffect(() => {\n if (errored.current) return;\n if (!error && !timedOut) return;\n errored.current = true;\n const reason: \"backend\" | \"timeout\" = error ? \"backend\" : \"timeout\";\n onEventRef.current?.({ type: \"error\", reason });\n attempts.current += 1;\n if (attempts.current <= maxRetries) {\n onEventRef.current?.({ type: \"retry\", reason, attempt: attempts.current });\n restartThread();\n } else {\n onEventRef.current?.({ type: \"fallback\", reason });\n // Report the degrade to the backend so the dashboard's fallback-rate reflects it.\n // Server-side `llm_fallback` fires per single degraded turn; this `client_fallback`\n // captures the whole-flow case (AI gave up, the user got static onboarding). The server\n // ingests it idempotently and back-fills a `session_started` if it never saw the session,\n // so even a device that dropped straight to its static manifest shows as a counted\n // fallback session. This is the ONE fallback signal — hosts must NOT also report it.\n reportClientEvent(reportTargetRef.current, {\n event_type: \"client_fallback\",\n session_id: sessionIdRef.current,\n screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : undefined,\n meta: JSON.stringify({ reason }),\n device: clientContextRef.current?.device,\n user_context: clientContextRef.current?.userContext,\n user_id: clientContextRef.current?.userId,\n });\n degradedRef.current = true;\n setDegraded(true);\n onErrorRef.current?.(error ?? new Error(\"Onboarding timed out\"));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [error, timedOut, maxRetries]);\n\n // 5. Completion: the terminal StatusCard is rendered as CompletionView; we fire\n // onComplete only when the user taps its CTA (guarded so it fires once).\n const handleFinish = useCallback(() => {\n if (finished.current) return;\n finished.current = true;\n onCompleteRef.current({ answers: deriveAnswers(messages), raw: messages });\n }, [messages]);\n\n // Manual retry (the no-fallback ErrorBlock button): clear the degrade + counter so\n // the user gets a fresh set of attempts.\n const handleRetry = useCallback(() => {\n attempts.current = 0;\n degradedRef.current = false;\n setDegraded(false);\n restartThread();\n }, [restartThread]);\n\n // Per-question Skip: tell the backend to skip THIS question only and advance to the\n // next card (no answer recorded) — distinct from finishing the flow. Rendered only\n // when the current card is `skippable` (see the scaffold below).\n //\n // NOTE: we deliberately do NOT report a client `screen_skipped` here. The backend already\n // emits `screen_skipped` (correctly correlated by its own contextId, with screen_index +\n // question_key) when it processes this SKIP_ONE_SENTINEL — see the server engine. A client\n // emission would double-count. The reporter supports `screen_skipped` for clients whose skip\n // never reaches the server, which is not the case for this kit.\n const skipQuestion = useCallback(() => {\n if (isLoading) return;\n sendMessage(SKIP_ONE_SENTINEL);\n }, [isLoading, sendMessage]);\n\n // Prefetch on SELECT — the fix for \"the first AI question is always the slowest\". Q1 is a\n // deterministic base card (instant); Q2 is the first LLM turn, and neither cache protects it\n // (flow-cache misses a novel answer combo, the provider prompt-cache is cold on the first\n // call). Choice cards hold their selection LOCALLY and only commit on Continue, so there's a\n // real gap we can use: as the user picks, fire a debounced `message/preview` keyed on the\n // EXACT text the Continue tap will send (`I selected: ${JSON.stringify(value)}`), so the\n // backend generates Q2 during the pick→Continue window. By the time they tap Continue it's\n // already cached → the slow question returns instantly. Fire-and-forget: if they change the\n // selection after the last preview, the real turn just generates normally (never worse than\n // today). Trailing-edge debounced so rapid multi-select toggles warm at most once.\n const previewOnSelect = useCallback((value: string | string[]) => {\n const target = reportTargetRef.current;\n if (!target?.serverUrl) return;\n if (Array.isArray(value) ? value.length === 0 : !value) return;\n if (previewTimer.current) clearTimeout(previewTimer.current);\n previewTimer.current = setTimeout(() => {\n sendPreview(target, {\n sessionId: sessionIdRef.current,\n userMessage: `I selected: ${JSON.stringify(value)}`,\n });\n }, 300);\n }, []);\n\n // Cancel any pending preview on unmount so a fired-but-unsent warm can't outlive the flow.\n useEffect(() => () => {\n if (previewTimer.current) clearTimeout(previewTimer.current);\n }, []);\n\n // 4. Wrap the SDK's action callbacks so an answer is validated before it's sent.\n const wrappedActions = useCallback(\n (messageId: string) => {\n const base = makeActions(messageId);\n const key = progress.key;\n const validator = key ? validatorsRef.current?.[key] : undefined;\n if (!validator) return base;\n\n const out: Record<string, (...args: unknown[]) => void> = { ...base };\n for (const name of ANSWER_CALLBACKS) {\n const original = base[name];\n if (!original) continue;\n out[name] = (...args: unknown[]) => {\n const value = args[0];\n // Only string answers are validatable (e.g. username). Pass others through.\n if (typeof value !== \"string\") return original(...args);\n setValidating(true);\n validator(value)\n .then((res) => {\n if (res.ok) {\n setValidationError(undefined);\n original(...args);\n } else {\n setValidationError(res.error ?? \"That value isn't available.\");\n }\n })\n .catch(() => {\n // A validator failure must never block the user — let them proceed.\n original(...args);\n })\n .finally(() => setValidating(false));\n };\n }\n return out;\n },\n [makeActions, progress.key],\n );\n\n // ── Render ────────────────────────────────────────────────────────────────\n // Degraded (retries exhausted): render the host's static onboarding in place —\n // the \"AI failed → your static flow, never a broken screen\" guarantee. If no\n // static flow was supplied, hand off to onError (host navigates away), else the\n // inline retry screen as a last resort.\n if (degraded) {\n if (fallbackFlow !== undefined) return <>{fallbackFlow}</>;\n if (onError) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n return (\n <ErrorBlock\n onRetry={handleRetry}\n message={\n timedOut\n ? \"This is taking longer than expected. Try again?\"\n : \"We couldn't reach the onboarding service. Try again?\"\n }\n />\n );\n }\n\n // Errored but not yet degraded → an auto-retry is in flight. Show a neutral loader\n // so a transient blip never flashes an error screen.\n if (error || timedOut) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n\n const response = lastCard?.response;\n\n // No card yet → the first \"thinking\" screen.\n if (!lastCard || !response) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n\n // Step index drives the progress bar. A total (never shown) only paces the fill:\n // prefer a backend-supplied total, else the host's approximate prop, else asymptotic.\n const step = progress.step ?? renderedCount;\n const total = progress.total ?? approxScreens;\n const isTerminal = response.action === \"render\" && response.component === \"StatusCard\";\n\n // Terminal recap: show what the app will now do for the user (backend-authored),\n // and finish only when they tap the CTA.\n if (isTerminal) {\n const props = (response.props ?? {}) as {\n title?: string;\n message?: string;\n ctaLabel?: string;\n };\n return (\n <OnboardingScaffold step={step} complete approxScreens={total}>\n <CompletionView\n title={props.title ?? c.completeTitle}\n message={props.message}\n ctaLabel={props.ctaLabel ?? c.completeCta}\n onContinue={handleFinish}\n />\n </OnboardingScaffold>\n );\n }\n\n const overrides: Record<string, unknown> = {\n ...wrappedActions(lastCard.id),\n // Inject the inline error onto whichever card supports it (TextInputCard).\n validationError,\n // Choice cards (Selection/ChipSelect) call this as the live selection changes, so the flow\n // can prefetch the next turn before Continue. Non-committing; ignored by cards that don't use it.\n onSelectionChange: previewOnSelect,\n };\n\n return (\n <OnboardingScaffold\n step={step}\n onSkip={progress.skippable ? skipQuestion : undefined}\n approxScreens={total}\n >\n {/* CardHandoff pairs the exit with the enter (the design's \"cards hand off,\n they don't cut\"): the answered card leaves left while the next arrives\n from the right; loader states enter/exit as a short fade. transitionKey\n identifies WHAT is on screen — loader states get a stable key per state,\n cards key on the message id. */}\n <CardHandoff\n transitionKey={validating ? \"loader:checking\" : isLoading ? \"loader:thinking\" : lastCard.id}\n variant={\n validating || isLoading\n ? \"fade\"\n : lastCard.response?.component === \"InterstitialCard\"\n ? \"spring\"\n : \"slide\"\n }\n >\n {validating ? (\n <LoadingBlock title={c.checkingTitle} hint={c.checkingHint} />\n ) : isLoading ? (\n // Between turns: the answer was sent and we're waiting on the next card.\n // Show the \"thinking\" loader instead of leaving the old card on screen.\n <LoadingBlock title={c.thinkingTitle} hint={c.thinkingHint} />\n ) : (\n // key={lastCard.id} is load-bearing: cards (SelectionCard/ChipSelectCard)\n // hold internal `selected`/`submitted` state, and React reuses a component\n // instance across turns when the rendered type is identical (e.g. two\n // SelectionCards in a row). Without a per-turn key the second card inherits\n // the first's `submitted=true` and silently rejects all taps. Keying on the\n // message id forces a fresh mount every turn. (CardHandoff's transitionKey\n // shares the id, but this renderer key stays the state-isolation guarantee.)\n <ComponentRenderer\n key={lastCard.id}\n messageId={lastCard.id}\n response={response}\n callbackOverrides={overrides as never}\n />\n )}\n </CardHandoff>\n </OnboardingScaffold>\n );\n};\n","/**\n * Themed ChipSelectCard — drop-in replacement for the OSS SDK's ChipSelectCard.\n * Identical `name`, `propsSchema`, `defaultProps`, and `onSelect` callback contract\n * so the SDK's ComponentRenderer drives it transparently. Only the look is themed.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 4-6): chips tick on press (scale\n * 0.94 spring), the selected accent fill crossfades in over 160ms (native-driver\n * opacity overlay) with the label flipping to `onPrimary` and a check popping in.\n * Deselect reverses. Reduce motion: color swap only, check shown instantly.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { captionStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n CHECK_SCALE_FROM,\n CHECK_SPRING,\n CHIP_FILL_MS,\n CHIP_PRESS_SCALE,\n PRESS_SPRING,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\n// Mirror of the SDK schema — must stay identical so the registry + validator agree.\nconst schema = z.object({\n title: z.string().describe(\"Question or section header, e.g. 'Which season?'\"),\n chips: z\n .array(z.string())\n .min(1)\n .describe(\"List of option labels shown as chips, e.g. ['Spring','Summer','Autumn','Winter']\"),\n multiSelect: z.boolean().optional().describe(\"Allow multiple chips selected at once, default true\"),\n submitLabel: z.string().optional().describe(\"Confirm button label, default: Continue\"),\n maxSelections: z.number().optional().describe(\"Maximum number of chips the user can select at once\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype ChipItemProps = {\n chip: string;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (chip: string) => void;\n};\n\nconst _ChipItem: React.FC<ChipItemProps> = ({ chip, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(chip), [chip, onToggle]);\n\n // Press tick: scale 1→0.94, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(CHIP_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: full accent pill, crossfaded in over 160ms on a native-driver\n // opacity overlay (EXTRACTED-SPEC.md D7). Reduce motion: instant swap.\n const fillT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(fillT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, CHIP_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, fillT]);\n\n // Check pop on select (the width-slide of the canvas is a layout animation the\n // native driver can't express — see EXTRACTED-SPEC.md D4).\n const checkT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n if (!isSelected) {\n checkT.setValue(0);\n return;\n }\n if (reduced) {\n checkT.setValue(1);\n return;\n }\n checkT.setValue(0);\n const anim = Animated.spring(checkT, {\n toValue: 1,\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, checkT]);\n\n const checkScale = checkT.interpolate({ inputRange: [0, 1], outputRange: [CHECK_SCALE_FROM, 1] });\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={chip}\n >\n <Animated.View\n style={[\n styles.chip,\n {\n borderRadius: t.radius.full,\n paddingHorizontal: t.spacing.md,\n paddingVertical: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.background,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.fillOverlay,\n {\n borderRadius: t.radius.full,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primary,\n opacity: fillT,\n },\n ]}\n />\n {isSelected ? (\n <Animated.Text\n style={[\n styles.check,\n { color: t.colors.onPrimary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n ) : null}\n <Text\n style={[\n captionStyle(t.fonts),\n styles.chipLabel,\n { color: isSelected ? t.colors.onPrimary : t.colors.textMuted },\n ]}\n >\n {chip}\n </Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst ChipItem = React.memo(_ChipItem);\n\nconst _ChipSelectCard: React.FC<Props> = ({\n title,\n chips,\n multiSelect = true,\n submitLabel = \"Continue\",\n maxSelections,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (chip: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) => {\n if (prev.includes(chip)) return prev.filter((c) => c !== chip);\n if (maxSelections && prev.length >= maxSelections) return prev;\n return [...prev, chip];\n });\n } else {\n setSelected([chip]);\n }\n },\n [submitted, multiSelect, maxSelections],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n subtitle={maxSelections ? `Select up to ${maxSelections}` : undefined}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={[styles.chipsRow, { gap: t.spacing.sm + t.spacing.xs }]}>\n {chips.map((chip) => (\n <ChipItem\n key={chip}\n chip={chip}\n isSelected={selected.includes(chip)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const ChipSelectCard: WireAIComponent = {\n name: \"ChipSelectCard\",\n description:\n \"Use for compact short labels: seasons, activities, travel styles, moods, categories. Ideal for 4–12 single-word or two-word options. Use SelectionCard instead when options need descriptions; use CardGridSelectCard for a smaller set (2–6) of visual choices that each deserve an icon.\",\n component: React.memo(_ChipSelectCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { multiSelect: true, submitLabel: \"Continue\" },\n};\n\nconst styles = StyleSheet.create({\n chipsRow: { flexDirection: \"row\", flexWrap: \"wrap\" },\n chip: { borderWidth: 1.5, flexDirection: \"row\", alignItems: \"center\", gap: 6, overflow: \"hidden\" },\n fillOverlay: { borderWidth: 1.5 },\n chipLabel: { fontWeight: \"600\" },\n check: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n});\n","/**\n * Themed TextInputCard — drop-in for the OSS SDK's TextInputCard. Same `name`,\n * `propsSchema`, `defaultProps`, and `onSubmit(value: string)` contract. The input\n * is themed and supports an optional inline error string (used by the kit's\n * per-step validators — e.g. \"username taken\"), set via the `validationError` prop\n * which the OnboardingFlow injects through callbackOverrides.\n *\n * Open-ended answers (goals, notes, \"what would make this better\") render a tall\n * multi-line box by default so the user has room to actually write. Short fields\n * (a name, a username) set `multiline: false` for the compact single-line height.\n */\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, TextInput, View, useWindowDimensions } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle, captionStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\n\nconst schema = z.object({\n label: z.string().describe(\"Input field label / the question being asked\"),\n hint: z\n .string()\n .optional()\n .describe(\n \"One short line under the question giving context: what the answer is used for or why you ask. Add it whenever the question alone might be unclear.\"\n ),\n placeholder: z\n .string()\n .optional()\n .describe(\n 'A concrete example answer shown inside the box, phrased like a real user wrote it and starting with \"e.g. \". ALWAYS provide one for open-ended questions: it shows the expected answer shape and inspires the user.'\n ),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Submit\"),\n multiline: z\n .boolean()\n .optional()\n .describe(\n \"Tall multi-line box for open-ended answers (goals, notes, feedback). Default true. Set false for a single-line field like a name or username.\"\n ),\n lines: z\n .number()\n .optional()\n .describe(\"Approx visible rows when multiline (default 6). Height is capped at 40% of the screen.\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: string) => void;\n /**\n * Inline error injected by OnboardingFlow when a validator rejects the value\n * (e.g. username already taken). Re-enables the input so the user can edit.\n */\n validationError?: string;\n };\n\nconst _TextInputCard: React.FC<Props> = ({\n label,\n hint,\n placeholder,\n submitLabel = \"Submit\",\n onSubmit,\n validationError,\n multiline = true,\n lines = 6,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const { height: screenHeight } = useWindowDimensions();\n const [value, setValue] = useState(\"\");\n const [submitted, setSubmitted] = useState(false);\n\n // A validator rejection arrives as `validationError`; reopen the field so the\n // user can fix their answer instead of being stuck on a submitted state.\n const locked = submitted && !validationError;\n\n // Multi-line free-text gets a generous box (~`lines` rows), capped at 40% of\n // screen height so it stays comfortable on small devices. Single-line fields\n // keep the compact 52pt height.\n const APPROX_ROW_HEIGHT = 26;\n const minHeight = multiline\n ? Math.min(Math.max(lines, 4) * APPROX_ROW_HEIGHT + t.spacing.md * 2, screenHeight * 0.4)\n : 52;\n\n const handleSubmit = useCallback(() => {\n if (value.trim() && onSubmit && !locked) {\n setSubmitted(true);\n onSubmit(value.trim());\n }\n }, [value, onSubmit, locked]);\n\n return (\n <CardLayout\n title={label}\n subtitle={hint}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={!value.trim() || locked}\n />\n }\n >\n <View style={styles.row}>\n <TextInput\n value={value}\n onChangeText={setValue}\n placeholder={placeholder ?? \"\"}\n placeholderTextColor={t.colors.textMuted}\n editable={!locked}\n multiline={multiline}\n numberOfLines={multiline ? lines : 1}\n textAlignVertical={multiline ? \"top\" : \"center\"}\n style={[\n bodyStyle(t.fonts),\n styles.input,\n {\n color: t.colors.text,\n backgroundColor: t.colors.surface,\n borderRadius: t.radius.md,\n borderColor: validationError ? t.colors.error : t.colors.border,\n padding: t.spacing.md,\n minHeight,\n },\n ]}\n />\n {validationError ? (\n <Text style={[captionStyle(t.fonts), { color: t.colors.error }]}>{validationError}</Text>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const TextInputCard: WireAIComponent = {\n name: \"TextInputCard\",\n description:\n \"Use when the user needs to type a free-text answer: an open-ended goal, notes, feedback, a name, a destination, a search query. Multi-line by default (great for open-ended goals); set multiline:false for a short single-line field like a name. Use NumberStepperCard for numeric ranges with known bounds.\",\n component: React.memo(_TextInputCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Submit\", multiline: true, lines: 6 },\n};\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n row: { gap: t.spacing.sm },\n input: { borderWidth: 1 },\n });\n}\n","/**\n * expoIcons — resolve an `@expo/vector-icons` family, lazily and optionally.\n *\n * ── WHY THIS DOES NOT BREAK THE NO-NATIVE-DEPENDENCY POLICY ──────────────────────────────\n *\n * The policy (see `questionnaire/QuestionnaireGate.tsx`'s back-chevron note, `AnimatedSparkle`,\n * `coachmarks/GestureHint`, `cards/StatusCard`'s Unicode STATUS_ICONS) says: no vector library\n * is worth FORCING EVERY HOST INTO A NATIVE REBUILD. Read it precisely — what it forbids is\n * forcing hosts, not the existence of an icon.\n *\n * `@expo/vector-icons` is an OPTIONAL peer:\n *\n * • A host WITHOUT it installs the kit fine (optional peer → npm never fetches it) and renders\n * fine (icon → null, layout unchanged). To BUNDLE fine it must let Metro know the module is\n * allowed to be missing — see \"OPTIONALITY IS A BUILD-TIME CONTRACT\" below.\n * • A host WITH it gets real brand icons. Both live host apps already ship it\n * (`@expo/vector-icons ^15.0.3`), so neither needs a rebuild — which matters because\n * neither can be force-updated: both ship new store builds only and never OTA.\n * • A host that wants neither can override every name with its own artwork through the\n * `icons` registry, so the library is never on the critical path at all.\n *\n * ── THE SPECIFIER MUST BE A STRING LITERAL — THIS IS THE WHOLE BUG ───────────────────────\n *\n * DO NOT \"restore\" the old `const req = require; req(moduleName)` shape. It could never work,\n * and it shipped broken in 0.8.0. What that shape actually did, proven in a real `expo export`\n * bundle and in Expo SDK 55's runtime:\n *\n * 1. Metro collects dependencies STATICALLY, by matching a call whose callee is literally the\n * identifier `require` and whose argument is a STRING LITERAL. Aliasing `require` to a local\n * hid the call from the collector, so this module's dependencyMap was emitted EMPTY (`[]`)\n * and `@expo/vector-icons` was never put in the bundle at all.\n * 2. At runtime the alias did NOT point at Node's `require`. Metro renames the free `require`\n * identifier to the module factory's require param, so `req` WAS `metroRequire`, whose\n * module registry is keyed by NUMERIC module ids. Handing it the string \"@expo/vector-icons\"\n * could never match a key, so it threw `Requiring unknown module \"@expo/vector-icons\"` —\n * even in a bundle that contained the module.\n * 3. That throw never reached the `catch` below. Metro's own `guardedLoadModule` wraps the\n * load, catches the error FIRST, and routes it to `global.ErrorUtils.reportFatalError(e)`\n * instead of rethrowing (Expo SDK 55: `@expo/cli/build/metro-require/require.js:151-165`).\n * So the call returned `undefined` — icon silently null — AND logged a red fatal error. A\n * try/catch cannot guard a require that Metro never lets throw.\n *\n * A LITERAL `require(\"@expo/vector-icons\")` is collected, is bundled, and resolves SYNCHRONOUSLY\n * through the numeric dependencyMap — the same reason `reviews/storeReview.ts`'s literal\n * `await import(\"expo-store-review\")` has always worked. (The old comment here claimed the alias\n * worked \"exactly like expo-store-review\". It was the opposite: storeReview's specifier is a\n * literal, and that is precisely why it resolves and this one did not.)\n *\n * ── OPTIONALITY IS A BUILD-TIME CONTRACT, AND THE TRY/CATCH IS LOAD-BEARING ──────────────\n *\n * Metro has NO runtime resolution: every specifier is resolved when the bundle is built. It does\n * have a real optional-dependency mechanism, and it needs BOTH halves of what is written below:\n * a LITERAL specifier (so the dep is collected at all) AND the call inside a TRY/CATCH — that is\n * literally how Metro marks a dependency `isOptional`. When the peer is absent, Metro then puts\n * `null` in this module's dependencyMap and `metroRequire(null, \"@expo/vector-icons\")` throws\n * \"Cannot find module\" from its own `moduleId === null` branch, BEFORE `guardedLoadModule` — so\n * unlike the string-id path in the autopsy above, that throw really does land in the catch below.\n * So do NOT \"simplify\" the try/catch away: it is what keeps the peer optional, not just tidy.\n *\n * That mechanism rides on the transformer's `allowOptionalDependencies`, which Expo enables by\n * default but bare `metro-config` defaults to FALSE. For hosts in the second camp, the kit ships\n * a safety net: `withWireOnboarding` (metro/index.js) installs a `resolveRequest` that maps an\n * absent optional peer to an EMPTY module, landing on exactly the degradation path below (no\n * families on the namespace → `undefined` → icon renders null).\n */\nimport type { WireIconFamily } from \"./vocabulary\";\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime (the kit's own\n// tests run under `node --test` as ESM). Declared locally so this type-checks without ambient\n// Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded literal require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/**\n * The minimal shape the kit uses from a vector-icons family. A COMPONENT TYPE, not a plain\n * function: these are real React components (createIconSet output) and must be mounted via\n * JSX/createElement, never invoked directly — calling one bypasses the reconciler and breaks\n * the moment the family uses hooks or is a class.\n */\nexport type IconComponent = import(\"react\").ComponentType<{\n name: string;\n size?: number;\n color?: string;\n allowFontScaling?: boolean;\n}>;\n\n/**\n * The production resolver. The specifier is a LITERAL so Metro collects it (see the header); the\n * `moduleName` parameter exists only to keep the `OptionalRequire` seam shape, so anything other\n * than the one module this file owns resolves to undefined.\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (moduleName !== \"@expo/vector-icons\") return undefined;\n if (typeof require !== \"function\") return undefined;\n try {\n return require(\"@expo/vector-icons\");\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n // `@expo/vector-icons` exposes the families as NAMED exports; prefer the namespace when it\n // already carries them, and only fall back to `default` for a CJS-interop wrapper.\n const ns = mod as Record<string, unknown>;\n if (ns.MaterialCommunityIcons || ns.Ionicons) return ns;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return ns;\n};\n\n/**\n * Narrow an unknown export to something mountable. A vector-icons family is either a function\n * component or a class (`createIconSet` has returned both across versions), and React.memo /\n * forwardRef wrappers are objects — so accept an object carrying a `$$typeof` too, and reject\n * anything else rather than handing the reconciler a non-component.\n */\nconst asComponent = (value: unknown): IconComponent | undefined => {\n if (typeof value === \"function\") return value as IconComponent;\n if (value && typeof value === \"object\" && \"$$typeof\" in (value as object)) {\n return value as IconComponent;\n }\n return undefined;\n};\n\n/**\n * Module-level memo. `null` = \"we looked and it is not there\" (distinct from \"not looked yet\"),\n * so an absent peer costs exactly one failed require per process, not one per rendered icon.\n */\nlet cached: Record<string, unknown> | null | undefined;\n\n/** Reset the memo. TEST-ONLY seam — production never calls it. */\nexport const resetIconModuleCache = (): void => {\n cached = undefined;\n};\n\n/**\n * Resolve one icon family component, or undefined when the peer is absent/unresolvable.\n * Never throws: an icon is decorative, so it must never be able to break a card.\n *\n * `requireModule` is injectable so tests can exercise BOTH the found and absent paths without\n * installing the native peer (same convention as `detectAppVersion`).\n */\nexport const resolveIconFamily = (\n family: WireIconFamily,\n requireModule: OptionalRequire = runtimeRequire,\n): IconComponent | undefined => {\n try {\n if (cached === undefined || requireModule !== runtimeRequire) {\n const resolved = interop(requireModule(\"@expo/vector-icons\"));\n // Don't poison the module memo from an injected test require.\n if (requireModule === runtimeRequire) cached = resolved ?? null;\n if (!resolved) return undefined;\n return asComponent(resolved[family]);\n }\n if (cached === null) return undefined;\n return asComponent(cached[family]);\n } catch {\n return undefined;\n }\n};\n","/**\n * The Wire icon VOCABULARY — the stable, semantic contract between the AI and the kit.\n *\n * The model emits a plain semantic string (`\"instagram\"`, `\"friend\"`, `\"wedding\"`), never a\n * raw icon-library glyph name. That indirection is the whole point:\n *\n * • The model is never coupled to a library version. `@expo/vector-icons` renaming a glyph,\n * or a host swapping the library out for brand SVGs, changes THIS map — not the prompt,\n * not the server, and not a single stored answer.\n * • A host can override any name with its own artwork (see `IconRegistry`), so brand icons\n * need no kit change.\n * • An unknown name degrades to no icon (see `WireIcon`), which is why the vocabulary can\n * grow without a coordinated kit+server release.\n *\n * `WIRE_ICON_NAMES` is exported so the server/AI side can be taught the list verbatim — paste\n * it into the prompt as the allowed `icon` values. Keep names SEMANTIC (what the option means)\n * rather than visual (what the glyph looks like): the model reasons about meaning.\n *\n * Every glyph below was verified to exist in the `@expo/vector-icons` 15.0.3 glyphmaps that\n * both live host apps already ship. MaterialCommunityIcons is the default family (the broadest\n * single set); Ionicons covers the few brand logos MCI lacks (TikTok, Discord).\n */\n\n/** The icon families this kit resolves out of `@expo/vector-icons`. Both are root exports. */\nexport type WireIconFamily = \"MaterialCommunityIcons\" | \"Ionicons\";\n\n/** One vocabulary entry: the concrete glyph a semantic name resolves to. */\nexport interface WireIconGlyph {\n family: WireIconFamily;\n /** The library's own glyph name — an INTERNAL detail. The AI never sees or emits this. */\n name: string;\n}\n\n/**\n * The semantic name → concrete glyph map. Grouped by the onboarding questions these actually\n * serve: acquisition channels (\"where did you hear about us\"), intent/occasion (\"what brings\n * you here\"), and a general-purpose set for everything else.\n */\nexport const WIRE_ICON_GLYPHS = {\n // ── Acquisition channels (\"where did you hear about us?\") ──────────────────\n instagram: { family: \"MaterialCommunityIcons\", name: \"instagram\" },\n tiktok: { family: \"Ionicons\", name: \"logo-tiktok\" },\n youtube: { family: \"MaterialCommunityIcons\", name: \"youtube\" },\n facebook: { family: \"MaterialCommunityIcons\", name: \"facebook\" },\n twitter: { family: \"MaterialCommunityIcons\", name: \"twitter\" },\n reddit: { family: \"MaterialCommunityIcons\", name: \"reddit\" },\n linkedin: { family: \"MaterialCommunityIcons\", name: \"linkedin\" },\n discord: { family: \"Ionicons\", name: \"logo-discord\" },\n whatsapp: { family: \"MaterialCommunityIcons\", name: \"whatsapp\" },\n twitch: { family: \"MaterialCommunityIcons\", name: \"twitch\" },\n snapchat: { family: \"MaterialCommunityIcons\", name: \"snapchat\" },\n pinterest: { family: \"MaterialCommunityIcons\", name: \"pinterest\" },\n google: { family: \"MaterialCommunityIcons\", name: \"google\" },\n search: { family: \"MaterialCommunityIcons\", name: \"magnify\" },\n friend: { family: \"MaterialCommunityIcons\", name: \"account-heart\" },\n podcast: { family: \"MaterialCommunityIcons\", name: \"podcast\" },\n blog: { family: \"MaterialCommunityIcons\", name: \"post\" },\n newsletter: { family: \"MaterialCommunityIcons\", name: \"email-outline\" },\n news: { family: \"MaterialCommunityIcons\", name: \"newspaper\" },\n \"app-store\": { family: \"MaterialCommunityIcons\", name: \"apple\" },\n ad: { family: \"MaterialCommunityIcons\", name: \"bullhorn\" },\n\n // ── Intent / occasion (\"what brings you here?\") ────────────────────────────\n wedding: { family: \"MaterialCommunityIcons\", name: \"ring\" },\n birthday: { family: \"MaterialCommunityIcons\", name: \"cake-variant\" },\n baby: { family: \"MaterialCommunityIcons\", name: \"baby-carriage\" },\n travel: { family: \"MaterialCommunityIcons\", name: \"airplane\" },\n work: { family: \"MaterialCommunityIcons\", name: \"briefcase\" },\n celebration: { family: \"MaterialCommunityIcons\", name: \"party-popper\" },\n store: { family: \"MaterialCommunityIcons\", name: \"storefront\" },\n school: { family: \"MaterialCommunityIcons\", name: \"school\" },\n team: { family: \"MaterialCommunityIcons\", name: \"account-multiple\" },\n growth: { family: \"MaterialCommunityIcons\", name: \"trending-up\" },\n\n // ── General purpose ────────────────────────────────────────────────────────\n sparkle: { family: \"MaterialCommunityIcons\", name: \"star-four-points\" },\n heart: { family: \"MaterialCommunityIcons\", name: \"heart\" },\n star: { family: \"MaterialCommunityIcons\", name: \"star\" },\n fire: { family: \"MaterialCommunityIcons\", name: \"fire\" },\n target: { family: \"MaterialCommunityIcons\", name: \"target\" },\n trophy: { family: \"MaterialCommunityIcons\", name: \"trophy\" },\n rocket: { family: \"MaterialCommunityIcons\", name: \"rocket-launch\" },\n clock: { family: \"MaterialCommunityIcons\", name: \"clock-outline\" },\n calendar: { family: \"MaterialCommunityIcons\", name: \"calendar-star\" },\n camera: { family: \"MaterialCommunityIcons\", name: \"camera\" },\n image: { family: \"MaterialCommunityIcons\", name: \"image\" },\n video: { family: \"MaterialCommunityIcons\", name: \"video\" },\n mic: { family: \"MaterialCommunityIcons\", name: \"microphone\" },\n music: { family: \"MaterialCommunityIcons\", name: \"music\" },\n book: { family: \"MaterialCommunityIcons\", name: \"book-open-variant\" },\n food: { family: \"MaterialCommunityIcons\", name: \"silverware-fork-knife\" },\n coffee: { family: \"MaterialCommunityIcons\", name: \"coffee\" },\n fitness: { family: \"MaterialCommunityIcons\", name: \"dumbbell\" },\n health: { family: \"MaterialCommunityIcons\", name: \"heart-pulse\" },\n meditation: { family: \"MaterialCommunityIcons\", name: \"meditation\" },\n sleep: { family: \"MaterialCommunityIcons\", name: \"sleep\" },\n brain: { family: \"MaterialCommunityIcons\", name: \"brain\" },\n idea: { family: \"MaterialCommunityIcons\", name: \"lightbulb-on\" },\n money: { family: \"MaterialCommunityIcons\", name: \"cash\" },\n shopping: { family: \"MaterialCommunityIcons\", name: \"cart\" },\n gift: { family: \"MaterialCommunityIcons\", name: \"gift\" },\n home: { family: \"MaterialCommunityIcons\", name: \"home\" },\n car: { family: \"MaterialCommunityIcons\", name: \"car\" },\n pet: { family: \"MaterialCommunityIcons\", name: \"paw\" },\n plant: { family: \"MaterialCommunityIcons\", name: \"sprout\" },\n sun: { family: \"MaterialCommunityIcons\", name: \"white-balance-sunny\" },\n moon: { family: \"MaterialCommunityIcons\", name: \"weather-night\" },\n globe: { family: \"MaterialCommunityIcons\", name: \"earth\" },\n \"map-pin\": { family: \"MaterialCommunityIcons\", name: \"map-marker\" },\n compass: { family: \"MaterialCommunityIcons\", name: \"compass\" },\n flag: { family: \"MaterialCommunityIcons\", name: \"flag\" },\n bookmark: { family: \"MaterialCommunityIcons\", name: \"bookmark\" },\n bell: { family: \"MaterialCommunityIcons\", name: \"bell\" },\n mail: { family: \"MaterialCommunityIcons\", name: \"email\" },\n phone: { family: \"MaterialCommunityIcons\", name: \"phone\" },\n chat: { family: \"MaterialCommunityIcons\", name: \"chat\" },\n user: { family: \"MaterialCommunityIcons\", name: \"account\" },\n users: { family: \"MaterialCommunityIcons\", name: \"account-group\" },\n settings: { family: \"MaterialCommunityIcons\", name: \"cog\" },\n tools: { family: \"MaterialCommunityIcons\", name: \"tools\" },\n puzzle: { family: \"MaterialCommunityIcons\", name: \"puzzle\" },\n chart: { family: \"MaterialCommunityIcons\", name: \"chart-line\" },\n shield: { family: \"MaterialCommunityIcons\", name: \"shield-check\" },\n lock: { family: \"MaterialCommunityIcons\", name: \"lock\" },\n cloud: { family: \"MaterialCommunityIcons\", name: \"cloud\" },\n pencil: { family: \"MaterialCommunityIcons\", name: \"pencil\" },\n check: { family: \"MaterialCommunityIcons\", name: \"check-circle\" },\n plus: { family: \"MaterialCommunityIcons\", name: \"plus-circle\" },\n question: { family: \"MaterialCommunityIcons\", name: \"help-circle\" },\n other: { family: \"MaterialCommunityIcons\", name: \"dots-horizontal-circle\" },\n} as const satisfies Record<string, WireIconGlyph>;\n\n/** A name in the vocabulary. The card schemas accept any string and degrade — see `WireIcon`. */\nexport type WireIconName = keyof typeof WIRE_ICON_GLYPHS;\n\n/**\n * Every semantic name, as a plain array — the list to paste into the server/AI prompt as the\n * allowed `icon` values. Sorted for a stable, diffable prompt.\n */\nexport const WIRE_ICON_NAMES: readonly string[] = Object.keys(WIRE_ICON_GLYPHS).sort();\n\n/**\n * Look up a semantic name. Returns undefined for anything outside the vocabulary.\n *\n * The OWN-property check is load-bearing, not defensive noise: the name comes from an LLM, and\n * a plain object lookup answers `\"toString\"` / `\"constructor\"` / `\"valueOf\"` with an inherited\n * `Object.prototype` member. That would hand back a function where a `{family, name}` is\n * expected — a non-glyph masquerading as one. Caught by the vocabulary canary.\n */\nexport const lookupIconGlyph = (name: string | undefined): WireIconGlyph | undefined => {\n if (!name) return undefined;\n if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return undefined;\n return (WIRE_ICON_GLYPHS as Record<string, WireIconGlyph>)[name];\n};\n","/**\n * WireIcon — render one semantic icon name, or nothing at all.\n *\n * RESOLUTION ORDER (each step falls through to the next, never throws):\n * 1. the host `icons` registry — brand artwork, zero kit deps (IconRegistry.tsx)\n * 2. `@expo/vector-icons` — if the optional peer resolves (expoIcons.ts)\n * 3. NOTHING — render null\n *\n * Step 3 is a FEATURE, not a failure mode. The AI emits icon names from a vocabulary that will\n * keep growing, against production apps that ship on their own schedule (new store builds only,\n * never OTA, so they cannot be force-updated). So an unknown, misspelled, hallucinated, or\n * simply newer-than-this-client name MUST be a no-op: no crash, no broken-glyph tofu box, and\n * no layout shift. Returning `null` (rather than a spacer or a placeholder) is what gives the\n * last property — a row with an unresolvable icon lays out EXACTLY like a row with no icon,\n * because the parent's flex `gap` adds no space for a null child.\n *\n * An icon is always DECORATIVE: the label carries the meaning, so the icon is hidden from\n * assistive tech and never becomes the accessible name of its option.\n */\nimport React from \"react\";\nimport { StyleSheet, View } from \"react-native\";\n\nimport { resolveIconFamily, type OptionalRequire } from \"./expoIcons\";\nimport { useHostIcon } from \"./IconRegistry\";\nimport { lookupIconGlyph } from \"./vocabulary\";\n\nexport type WireIconProps = {\n /** A semantic name from the vocabulary (see vocabulary.ts). Unknown → renders nothing. */\n name?: string;\n /** Glyph size in px. */\n size?: number;\n /** Glyph color. Callers pass a THEME token — never a raw hex. */\n color?: string;\n /** Injectable resolver. TEST-ONLY seam; production uses the guarded runtime require. */\n requireModule?: OptionalRequire;\n};\n\nconst _WireIcon: React.FC<WireIconProps> = ({ name, size = 20, color, requireModule }) => {\n // 1) Host artwork wins — it can also cover names outside the vocabulary entirely.\n const hostIcon = useHostIcon(name);\n if (hostIcon) {\n return (\n <View\n style={styles.decorative}\n accessible={false}\n importantForAccessibility=\"no-hide-descendants\"\n >\n {hostIcon}\n </View>\n );\n }\n\n // 2) The vocabulary → a concrete glyph, then the optional peer. Both may miss; both degrade.\n const glyph = lookupIconGlyph(name);\n if (!glyph) return null;\n\n const Family = resolveIconFamily(glyph.family, requireModule);\n if (!Family) return null;\n\n return (\n <View\n style={styles.decorative}\n accessible={false}\n importantForAccessibility=\"no-hide-descendants\"\n >\n <Family\n name={glyph.name}\n size={size}\n color={color}\n // Icons are sized by the layout, not the text scale — a large accessibility font must\n // not blow up a card grid. The LABEL still scales, which is what carries the meaning.\n allowFontScaling={false}\n />\n </View>\n );\n};\n\nexport const WireIcon = React.memo(_WireIcon);\nWireIcon.displayName = \"WireIcon\";\n\nconst styles = StyleSheet.create({\n // No size/margin of its own: the glyph decides its footprint, so an absent icon and a\n // present one differ by exactly the glyph — never by a wrapper.\n decorative: {},\n});\n","/**\n * The shared option shape for the choice cards (SelectionCard, CardGridSelectCard).\n *\n * ── BACK-COMPAT, IN BOTH DIRECTIONS (the hard gate) ──────────────────────────────────────\n *\n * NEW option → OLD kit: `z.object` STRIPS unknown keys, and the SDK renderer mounts\n * `parsed.data` (not the raw props — see wireai-rn `renderer/ComponentRenderer.tsx`). So a\n * client on kit 0.7.x that receives `{value, label, icon}` silently drops `icon` and renders\n * the plain row it always did. No throw, no fallback card. This is what makes it safe to teach\n * the server `icon` before every host has re-pinned — and it MUST stay true, so never make\n * this schema `.strict()`.\n *\n * OLD option → NEW kit: the `preprocess` still coerces a bare `\"Spring\"` into\n * `{value:\"Spring\", label:\"Spring\"}`, exactly as before. A bare string and a bare\n * `{value,label}` both keep working untouched.\n *\n * `icon` is a plain `z.string()`, NOT a z.enum of the vocabulary. Deliberate: an unknown name\n * must degrade to no icon (WireIcon does that), never fail validation. If it were an enum, one\n * hallucinated or newer-than-this-client icon name would turn the whole card into a\n * LLM_SCHEMA_ERROR and cost the user their question — a catastrophic trade for a decoration.\n */\nimport { z } from \"zod\";\n\nimport { WIRE_ICON_NAMES } from \"../icons/vocabulary\";\n\n/**\n * The icon `.describe()` — an LLM ROUTING INSTRUCTION, not a type label (frequent_rules #4).\n * The vocabulary is inlined so the model reads the allowed values right where it fills the\n * field, and the list stays generated from the SSOT rather than drifting in a hand-typed copy.\n */\nexport const ICON_FIELD_DESCRIPTION =\n \"Optional icon for this option, making the choice scannable at a glance. Pick the ONE name \" +\n \"whose meaning matches the option (e.g. 'instagram' for an Instagram answer, 'friend' for \" +\n \"'A friend told me', 'wedding' for a wedding). Omit it when no name fits — a wrong icon is \" +\n `worse than none. Allowed values: ${WIRE_ICON_NAMES.join(\", \")}.`;\n\nexport const optionObjectSchema = z.object({\n value: z.string().describe(\"Option value\"),\n label: z.string().describe(\"Option display label\"),\n icon: z.string().optional().describe(ICON_FIELD_DESCRIPTION),\n});\n\nexport type CardOption = z.infer<typeof optionObjectSchema>;\n\n/** A bare string stays a valid option: coerce it to `{value, label}` before validating. */\nconst coerceOptions = (arr: unknown) =>\n Array.isArray(arr)\n ? arr.map((item) => (typeof item === \"string\" ? { value: item, label: item } : item))\n : arr;\n\n/** The `options` field, with its card-specific routing description. */\nexport const optionsField = (description: string) =>\n z.preprocess(coerceOptions, z.array(optionObjectSchema).min(1)).describe(description);\n\n/**\n * Component-level tolerance for the SAME coercion the schema does.\n *\n * WHY BOTH: in production the SDK renderer re-parses props and hands the card `parsed.data`, so\n * options arrive normalized. But a card is a plain exported component — the canary suite and any\n * host composing it directly mount it with raw props, where a bare string would otherwise read\n * `opt.value === undefined` and render an empty, unkeyed row. Cheap, total, and keeps the\n * component honest on its own contract instead of relying on a caller that may not exist.\n */\nexport const normalizeOptions = (options: ReadonlyArray<string | CardOption>): CardOption[] =>\n options.map((opt) => (typeof opt === \"string\" ? { value: opt, label: opt } : opt));\n","/**\n * Themed SelectionCard — drop-in for the OSS SDK's SelectionCard. Same `name`,\n * `propsSchema` (including the string|object option preprocess), `defaultProps`,\n * and `onSelect(string | string[])` contract. Radio/checkbox styling is themed.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 1-3): rows tick on press (scale\n * 0.975 spring), the selected fill/border eases in over 180ms ease-wire (a\n * native-driver opacity crossfade of a selected-style overlay), and the check\n * dot pops with a spring. All gated by useReducedMotion (snap, no spring).\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { labelStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport { WireIcon } from \"../icons/WireIcon\";\nimport { normalizeOptions, optionsField, type CardOption } from \"./optionSchema\";\nimport {\n CHECK_SCALE_FROM,\n CHECK_SPRING,\n PRESS_SPRING,\n ROW_PRESS_SCALE,\n SELECT_FILL_MS,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n title: z.string().describe(\"Question or prompt for the user\"),\n options: optionsField(\"List of choices\"),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Continue\"),\n multiSelect: z.boolean().optional().describe(\"Allow multiple selections\"),\n});\n\ntype Props = Omit<z.infer<typeof schema>, \"options\"> &\n InjectedProps & {\n /** Bare strings stay valid (normalized on the way in) — see optionSchema.ts. */\n options: ReadonlyArray<string | CardOption>;\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype OptionRowProps = {\n opt: CardOption;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (value: string) => void;\n};\n\nconst _OptionRow: React.FC<OptionRowProps> = ({ opt, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(opt.value), [opt.value, onToggle]);\n\n // Press tick: scale 1→0.975, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(ROW_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: the selected border+bg live on an absolute overlay whose opacity\n // crossfades in 180ms ease-wire — same visual as a color interpolation, but it\n // stays on the native driver (see EXTRACTED-SPEC.md D7). Reduce motion: snap.\n const selectT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(selectT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, SELECT_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, selectT]);\n\n // Check pop: scale 0.6→1 + fade, springy. Reduce motion: shown at scale 1 instantly.\n const checkT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n if (!isSelected) {\n checkT.setValue(0);\n return;\n }\n if (reduced) {\n checkT.setValue(1);\n return;\n }\n checkT.setValue(0);\n const anim = Animated.spring(checkT, {\n toValue: 1,\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, checkT]);\n\n const checkScale = checkT.interpolate({ inputRange: [0, 1], outputRange: [CHECK_SCALE_FROM, 1] });\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={opt.label}\n >\n <Animated.View\n style={[\n styles.option,\n {\n padding: t.spacing.md,\n borderRadius: t.radius.md,\n gap: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.background,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.selectedOverlay,\n {\n borderRadius: t.radius.md,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primarySoft,\n opacity: selectT,\n },\n ]}\n />\n <View\n style={[\n styles.indicator,\n { borderRadius: t.radius.full },\n isSelected\n ? { borderColor: t.colors.primary, backgroundColor: t.colors.primary }\n : { borderColor: t.colors.borderStrong, backgroundColor: \"transparent\" },\n ]}\n >\n {isSelected ? (\n <Animated.Text\n style={[\n styles.check,\n { color: t.colors.onPrimary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n ) : null}\n </View>\n {/* Accent discipline: the label keeps the text color in both states; the\n accent lives on the border, fill, and dot only. The icon obeys the same rule —\n it holds `text` in BOTH states rather than flipping to the accent, because an\n icon is not an excuse to invent a second accent. Decorative + unresolvable-safe:\n an unknown name renders null, so the row lays out exactly as an icon-less one. */}\n <WireIcon name={opt.icon} size={20} color={t.colors.text} />\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{opt.label}</Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst OptionRow = React.memo(_OptionRow);\n\nconst _SelectionCard: React.FC<Props> = ({\n title,\n options,\n submitLabel = \"Continue\",\n multiSelect = false,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const opts = React.useMemo(() => normalizeOptions(options), [options]);\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (value: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) => (prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value]));\n } else {\n setSelected([value]);\n }\n },\n [submitted, multiSelect],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={{ gap: t.spacing.sm + t.spacing.xs }}>\n {opts.map((opt) => (\n <OptionRow\n key={opt.value}\n opt={opt}\n isSelected={selected.includes(opt.value)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const SelectionCard: WireAIComponent = {\n name: \"SelectionCard\",\n description:\n \"Use for mutually exclusive (radio) or multi-select (checkbox) choices from 2–8 options, as a vertical list of rows. Best when options are wordy or need reading. Options may carry an optional `icon` from the vocabulary to make the list scannable. Use ChipSelectCard instead when options are short single words; use CardGridSelectCard when the options are visual and each has an obvious icon (occasions, channels, categories).\",\n component: React.memo(_SelectionCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Continue\", multiSelect: false },\n};\n\nconst styles = StyleSheet.create({\n option: { borderWidth: 1.5, flexDirection: \"row\", alignItems: \"center\", overflow: \"hidden\" },\n selectedOverlay: { borderWidth: 1.5 },\n indicator: { width: 24, height: 24, borderWidth: 2, alignItems: \"center\", justifyContent: \"center\" },\n check: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n});\n","/**\n * CardGridSelectCard — icon-led choices as a two-column grid of small cards.\n *\n * The shape Malik asked for (2026-07-16): \"the multi select needs to be a small card like this\n * one, with an icon on top, it is much better.\" Icon top-left, short label beneath, the whole\n * card is the tap target, selection lives on the card itself.\n *\n * ┌──────────────┐ ┌──────────────┐\n * │ ◇ │ │ ▣ │ ← icon on top\n * │ Wedding day │ │ Birthday │ ← label beneath\n * └──────────────┘ └──────────────┘\n *\n * WHY A NEW CARD RATHER THAN A `display` MODE ON SelectionCard: the card's `description` IS the\n * router — it is the only thing the model reads when choosing (frequent_rules #4). SelectionCard\n * already carries two modes behind one description; a third (\"a list, but sometimes a grid, and\n * then the icons matter\") cannot be stated honestly in one string, and a muddy description makes\n * the model pick the wrong card. The kit already has the precedent: ChipSelectCard exists ONLY\n * because \"compact vs. descriptive\" is a presentation difference worth its own name, over the\n * very same pick-from-options job. Back-compat costs nothing here — `supportedComponents`\n * (WireOnboarding.tsx) means an already-shipped client never advertises this name, so the server\n * intersects it away and can never emit it to the apps already in the stores. See the CHANGELOG.\n *\n * Layout is percentage flex, never a measured width: `flexBasis` ~47% + `flexGrow` makes exactly\n * two per row that fill the width, with no Dimensions read, no onLayout, and no re-render on\n * rotation. An odd last card stretches the row — deliberate, and the same thing every native\n * grid does.\n *\n * Motion mirrors SelectionCard's OptionRow exactly (press tick spring + a native-driver opacity\n * crossfade of the selected overlay), so the two cards feel like one system.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { labelStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport { WireIcon } from \"../icons/WireIcon\";\nimport { normalizeOptions, optionsField, type CardOption } from \"./optionSchema\";\nimport {\n PRESS_SPRING,\n ROW_PRESS_SCALE,\n SELECT_FILL_MS,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n title: z.string().describe(\"Question or prompt for the user, e.g. 'What brings you here?'\"),\n options: optionsField(\n \"The choices, 2-6 of them. Give EVERY option an `icon` from the vocabulary — the icon is \" +\n \"the point of this card, and an option without one renders as a bare label next to \" +\n \"icon-bearing neighbours. Keep labels short (1-3 words) so they fit a half-width card.\",\n ),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Continue\"),\n multiSelect: z\n .boolean()\n .optional()\n .describe(\"Allow multiple cards selected at once, default true\"),\n});\n\ntype Props = Omit<z.infer<typeof schema>, \"options\"> &\n InjectedProps & {\n /** Bare strings stay valid (normalized on the way in) — see optionSchema.ts. */\n options: ReadonlyArray<string | CardOption>;\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype OptionCardProps = {\n opt: CardOption;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (value: string) => void;\n};\n\nconst _OptionCard: React.FC<OptionCardProps> = ({ opt, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(opt.value), [opt.value, onToggle]);\n\n // Press tick: scale 1→0.975, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(ROW_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: accent border + tinted wash on an absolute overlay whose opacity crossfades\n // (native driver — see EXTRACTED-SPEC.md D7). Reduce motion: snap.\n const selectT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(selectT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, SELECT_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, selectT]);\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={opt.label}\n style={styles.cell}\n >\n <Animated.View\n style={[\n styles.card,\n {\n padding: t.spacing.md,\n borderRadius: t.radius.lg,\n gap: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.surface,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.selectedOverlay,\n {\n borderRadius: t.radius.lg,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primarySoft,\n opacity: selectT,\n },\n ]}\n />\n {/* Accent discipline (same rule as SelectionCard's rows): label AND icon keep the text\n color in both states; the accent lives on the border and fill only. An unresolvable\n icon renders null, so a card with a bad name lays out like one with no icon. */}\n <WireIcon name={opt.icon} size={24} color={t.colors.text} />\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{opt.label}</Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst OptionCard = React.memo(_OptionCard);\n\nconst _CardGridSelectCard: React.FC<Props> = ({\n title,\n options,\n submitLabel = \"Continue\",\n multiSelect = true,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const opts = React.useMemo(() => normalizeOptions(options), [options]);\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (value: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n } else {\n setSelected([value]);\n }\n },\n [submitted, multiSelect],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={[styles.grid, { gap: t.spacing.sm }]}>\n {opts.map((opt) => (\n <OptionCard\n key={opt.value}\n opt={opt}\n isSelected={selected.includes(opt.value)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const CardGridSelectCard: WireAIComponent = {\n name: \"CardGridSelectCard\",\n description:\n \"Use for VISUAL, icon-led choices shown as a 2-column grid of tappable cards (icon on top, \" +\n \"short label beneath). Ideal for 2–6 concrete options that each have an obvious icon — \" +\n \"occasions, channels, goals, categories — e.g. 'What brings you here?' or 'Where did you \" +\n \"hear about us?'. Multi-select by default. Every option should carry an `icon`. Use \" +\n \"SelectionCard instead when options need descriptions or have no natural icon; use \" +\n \"ChipSelectCard for many short word-like tags.\",\n component: React.memo(_CardGridSelectCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Continue\", multiSelect: true },\n};\n\nconst styles = StyleSheet.create({\n grid: { flexDirection: \"row\", flexWrap: \"wrap\" },\n // Two per row: ~47% basis leaves room for the gap, flexGrow fills the remainder exactly.\n cell: { flexBasis: \"47%\", flexGrow: 1 },\n card: { borderWidth: 1.5, alignItems: \"flex-start\", overflow: \"hidden\" },\n selectedOverlay: { borderWidth: 1.5 },\n});\n","/**\n * Themed StatusCard — drop-in for the OSS SDK's StatusCard. Same `name`,\n * `propsSchema`, and the onContinue/onPress/onSubmit callback fallback chain.\n * The terminal StatusCard is what OnboardingFlow treats as \"flow complete\".\n * Status colors read from the theme's semantic palette.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 14, 16): the status glyph pops in\n * with a spring (scale 0.4→1, overshoot) and the copy fades up 80ms behind it.\n * Reduce motion: final frame instantly. (The terminal payoff with the burst is\n * CompletionView; this card is the inline status treatment.)\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n STATUS_COPY_MS,\n STATUS_COPY_STAGGER_MS,\n STATUS_POP_SCALE_FROM,\n STATUS_POP_SPRING,\n WIRE_BEZIER,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n status: z.enum([\"success\", \"warning\", \"error\", \"info\"]).describe(\"Status type\"),\n title: z.string().describe(\"Status title\"),\n message: z.string().optional().describe(\"Supporting message\"),\n ctaLabel: z\n .string()\n .optional()\n .describe(\n \"Optional call-to-action button label. Always include this on success status to keep the conversation going.\",\n ),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onContinue?: () => void;\n onPress?: (label: string) => void;\n onSubmit?: (value: string) => void;\n };\n\nconst STATUS_ICONS: Record<string, string> = {\n success: \"✓\",\n warning: \"⚠\",\n error: \"✗\",\n info: \"ℹ\",\n};\n\nconst _StatusCard: React.FC<Props> = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const [submitted, setSubmitted] = useState(false);\n\n const color = useMemo(() => {\n switch (status) {\n case \"success\":\n return t.colors.success;\n case \"warning\":\n return t.colors.warning;\n case \"error\":\n return t.colors.error;\n default:\n return t.colors.info;\n }\n }, [status, t.colors]);\n\n // Glyph pop + copy fade-up (final frame under reduce motion).\n const popT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const copyT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n useEffect(() => {\n if (reduced) {\n popT.setValue(1);\n copyT.setValue(1);\n return;\n }\n const anims = [\n Animated.spring(popT, {\n toValue: 1,\n friction: STATUS_POP_SPRING.friction,\n tension: STATUS_POP_SPRING.tension,\n useNativeDriver: true,\n }),\n Animated.timing(copyT, {\n toValue: 1,\n duration: scaledMs(STATUS_COPY_MS),\n delay: scaledMs(STATUS_COPY_STAGGER_MS),\n easing: easeWire,\n useNativeDriver: true,\n }),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, popT, copyT]);\n\n const popScale = popT.interpolate({ inputRange: [0, 1], outputRange: [STATUS_POP_SCALE_FROM, 1] });\n const copyRise = copyT.interpolate({ inputRange: [0, 1], outputRange: [10, 0] });\n\n const handleContinue = useCallback(() => {\n if (!submitted) {\n setSubmitted(true);\n if (onContinue) onContinue();\n else if (onPress && ctaLabel) onPress(ctaLabel);\n else if (onSubmit) onSubmit(\"continue\");\n }\n }, [submitted, onContinue, onPress, onSubmit, ctaLabel]);\n\n return (\n <CardLayout\n align=\"center\"\n footer={\n ctaLabel ? (\n <Button title={ctaLabel} onPress={handleContinue} variant=\"primary\" disabled={submitted} />\n ) : undefined\n }\n >\n <View style={[styles.center, { gap: t.spacing.sm }]}>\n <View style={[styles.titleRow, { gap: t.spacing.sm }]}>\n <Animated.Text\n style={[\n headingStyle(t.fonts),\n { color, opacity: popT, transform: [{ scale: popScale }] },\n ]}\n >\n {STATUS_ICONS[status] ?? \"·\"}\n </Animated.Text>\n <Animated.Text\n style={[\n headingStyle(t.fonts),\n { color, textAlign: \"center\", opacity: copyT, transform: [{ translateY: copyRise }] },\n ]}\n >\n {title}\n </Animated.Text>\n </View>\n {message ? (\n <Animated.Text\n style={[\n bodyStyle(t.fonts),\n {\n color: t.colors.textMuted,\n textAlign: \"center\",\n opacity: copyT,\n transform: [{ translateY: copyRise }],\n },\n ]}\n >\n {message}\n </Animated.Text>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const StatusCard: WireAIComponent = {\n name: \"StatusCard\",\n description:\n \"Use ONLY for real outcomes: booking confirmed, data saved, action completed. NEVER for 'you just viewed X' acknowledgments. Always include ctaLabel so the user can continue after seeing the status.\",\n component: React.memo(_StatusCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n};\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n titleRow: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * Themed NumberStepperCard — drop-in for the OSS SDK's NumberStepperCard. Same\n * `name`, `propsSchema`, `defaultProps`, and `onSubmit(value: number)` contract.\n * Keeps the SDK's defensive numeric coercion so a malformed LLM payload can never\n * feed NaN/Infinity into layout math.\n */\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { captionStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\n\nconst schema = z.object({\n label: z.string().describe(\"What is being counted, e.g. 'Number of days' or 'Travellers'\"),\n min: z.number().optional().describe(\"Minimum value, default 1\"),\n max: z.number().optional().describe(\"Maximum value, default 30\"),\n defaultValue: z.number().optional().describe(\"Starting value\"),\n step: z.number().optional().describe(\"Increment per tap, default 1\"),\n unit: z.string().optional().describe(\"Unit label shown next to value, e.g. 'days' or 'people'\"),\n submitLabel: z.string().optional().describe(\"Confirm button label, default: Confirm\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: number) => void;\n };\n\nconst safeNum = (n: unknown, fallback: number): number =>\n typeof n === \"number\" && Number.isFinite(n) ? n : fallback;\n\nconst _NumberStepperCard: React.FC<Props> = ({\n label,\n min,\n max,\n defaultValue,\n step,\n unit,\n submitLabel = \"Confirm\",\n onSubmit,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n\n const safeMin = safeNum(min, 1);\n const safeMaxRaw = safeNum(max, 30);\n const safeMax = safeMaxRaw < safeMin ? safeMin : safeMaxRaw;\n const safeStepRaw = safeNum(step, 1);\n const safeStep = safeStepRaw > 0 ? safeStepRaw : 1;\n const safeDefault = safeNum(defaultValue, safeMin);\n\n const [value, setValue] = useState(Math.min(Math.max(safeDefault, safeMin), safeMax));\n const [submitted, setSubmitted] = useState(false);\n\n const handleDecrement = useCallback(() => {\n if (!submitted) setValue((v) => Math.max(v - safeStep, safeMin));\n }, [submitted, safeStep, safeMin]);\n\n const handleIncrement = useCallback(() => {\n if (!submitted) setValue((v) => Math.min(v + safeStep, safeMax));\n }, [submitted, safeStep, safeMax]);\n\n const handleSubmit = useCallback(() => {\n if (!submitted) {\n setSubmitted(true);\n onSubmit?.(value);\n }\n }, [submitted, onSubmit, value]);\n\n const atMin = value <= safeMin;\n const atMax = value >= safeMax;\n\n const stepBtnStyle = (disabled: boolean) => [\n styles.stepBtn,\n { borderRadius: t.radius.full, backgroundColor: t.colors.background, borderColor: disabled ? t.colors.border : t.colors.primary },\n ];\n\n return (\n <CardLayout\n title={label}\n align=\"center\"\n footer={\n <Button title={submitLabel} onPress={handleSubmit} variant=\"primary\" disabled={submitted} />\n }\n >\n <View style={styles.wrap}>\n <View style={[styles.stepper, { gap: t.spacing.lg }]}>\n <Pressable onPress={atMin || submitted ? undefined : handleDecrement} disabled={atMin || submitted} style={stepBtnStyle(atMin)}>\n <Text style={[headingStyle(t.fonts), { color: atMin ? t.colors.textMuted : t.colors.primary }]}>{\"−\"}</Text>\n </Pressable>\n <View style={styles.valueBox}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.primary }]}>{String(value)}</Text>\n {unit ? <Text style={[captionStyle(t.fonts), { color: t.colors.textMuted }]}>{unit}</Text> : null}\n </View>\n <Pressable onPress={atMax || submitted ? undefined : handleIncrement} disabled={atMax || submitted} style={stepBtnStyle(atMax)}>\n <Text style={[headingStyle(t.fonts), { color: atMax ? t.colors.textMuted : t.colors.primary }]}>{\"+\"}</Text>\n </Pressable>\n </View>\n <Text style={[captionStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {`${safeMin} – ${safeMax}${unit ? ` ${unit}` : \"\"}`}\n </Text>\n </View>\n </CardLayout>\n );\n};\n\nexport const NumberStepperCard: WireAIComponent = {\n name: \"NumberStepperCard\",\n description:\n \"Use for any bounded numeric input: days, people, portions, budget tiers, ratings. Best for ranges 1–99. Set unit (e.g. 'days', 'people') for clarity.\",\n component: React.memo(_NumberStepperCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { min: 1, max: 30, defaultValue: 1, step: 1, submitLabel: \"Confirm\" },\n};\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n wrap: { gap: t.spacing.md, alignItems: \"center\" },\n stepper: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"center\" },\n stepBtn: { width: 44, height: 44, borderWidth: 2, alignItems: \"center\", justifyContent: \"center\" },\n valueBox: { alignItems: \"center\", minWidth: 80 },\n });\n}\n","/**\n * InterstitialCard — a mid-flow \"value\" screen (the Duolingo / Cal-AI beat): an\n * illustration + a short motivational line + a single Continue button. It is NOT a\n * question — it builds momentum and reinforces what the user is committing to,\n * which is one of the biggest retention levers in great onboarding.\n *\n * Artwork resolves in order so the screen is NEVER a blank box: the host's named\n * `illustration` (brand SVG/Lottie, keeping the kit dependency-free) → a\n * backend-supplied `imageUrl` via RN <Image> (which self-heals to art on load\n * error) → a named `illustrationFallback` (defaults to \"momentum\", always present\n * in the kit's default registry).\n *\n * A minimum display window keeps the momentum beat from flashing past when the next\n * card is already cached: Continue is disabled for MIN_DISPLAY_MS after mount.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 11-13): art and title fade-up in\n * sequence (500ms ease-wire, 100ms stagger); the optional `items` (short lines\n * referencing what the user already said) tick on one by one (90ms stagger),\n * each check popping 200ms after its row — \"work being done\", not a slideshow.\n * Reduce motion: everything rendered at its final frame at once.\n *\n * On Continue it sends \"continue\" back to the backend so the flow advances; the\n * submitted-state guard makes the tap idempotent.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Image, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { useIllustration } from \"../components/Illustration\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n CHECK_SPRING,\n INTERSTITIAL_CHECK_SCALE_FROM,\n INTERSTITIAL_HEAD_MS,\n INTERSTITIAL_HEAD_STAGGER_MS,\n INTERSTITIAL_ITEM_MS,\n WIRE_BEZIER,\n interstitialCheckDelay,\n scaledMs,\n interstitialItemDelay,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\nconst RISE_PX = 10;\n\nconst schema = z.object({\n title: z.string().describe(\"Short, warm headline for the value/momentum moment\"),\n body: z\n .string()\n .optional()\n .describe(\"One or two supporting lines that reflect the user's answers back and build momentum\"),\n items: z\n .array(z.string())\n .max(4)\n .optional()\n .describe(\n \"2-3 very short 'work being done' lines that each reference something the user already answered (e.g. 'Sized for a small team'). Shown as ticked items appearing in sequence. Prefer these over `body` when you have concrete answers to reflect back.\",\n ),\n illustration: z\n .string()\n .optional()\n .describe(\n \"Name of an app-provided illustration to show (the app's registry decides the artwork). Prefer this over imageUrl.\",\n ),\n imageUrl: z\n .string()\n .url()\n .refine((v) => v.startsWith(\"https://\"), \"imageUrl must be an https URL\")\n .optional()\n .describe(\n \"Fallback remote HTTPS image URL, used only when no named illustration is registered. A non-https or malformed value is rejected and degrades to the named-illustration fallback.\",\n ),\n illustrationFallback: z\n .string()\n .optional()\n .describe(\n \"Named illustration to show when neither `illustration` nor `imageUrl` resolves (or the image fails to load). Defaults to the kit's always-present 'momentum' art so the screen is never blank.\",\n ),\n ctaLabel: z.string().optional().describe(\"Continue button label, default: Continue\"),\n});\n\n// Minimum time the momentum screen stays interactive-locked, so it never flashes past\n// when the next card is already prefetched/cached.\nconst MIN_DISPLAY_MS = 500;\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: string) => void;\n onPress?: (label: string) => void;\n };\n\n/** One ticked \"work\" row: fades up on its stagger slot, then the check pops. */\nconst _WorkItem: React.FC<{ text: string; index: number; reduced: boolean }> = ({\n text,\n index,\n reduced,\n}) => {\n const t = useOnboardingTheme();\n const rowT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const checkT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n\n useEffect(() => {\n if (reduced) {\n rowT.setValue(1);\n checkT.setValue(1);\n return;\n }\n const anims = [\n Animated.timing(rowT, {\n toValue: 1,\n duration: scaledMs(INTERSTITIAL_ITEM_MS),\n delay: scaledMs(interstitialItemDelay(index)),\n easing: easeWire,\n useNativeDriver: true,\n }),\n Animated.spring(checkT, {\n toValue: 1,\n delay: scaledMs(interstitialCheckDelay(index)),\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n }),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, index, rowT, checkT]);\n\n const rise = rowT.interpolate({ inputRange: [0, 1], outputRange: [RISE_PX, 0] });\n const checkScale = checkT.interpolate({\n inputRange: [0, 1],\n outputRange: [INTERSTITIAL_CHECK_SCALE_FROM, 1],\n });\n\n return (\n <Animated.View\n style={[styles.itemRow, { gap: t.spacing.sm + t.spacing.xs, opacity: rowT, transform: [{ translateY: rise }] }]}\n >\n <View\n style={[\n styles.itemBadge,\n { backgroundColor: t.colors.primarySoft, borderRadius: t.radius.full },\n ]}\n >\n <Animated.Text\n style={[\n styles.itemCheck,\n { color: t.colors.primary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n </View>\n <Text style={[bodyStyle(t.fonts), styles.itemText, { color: t.colors.text }]}>{text}</Text>\n </Animated.View>\n );\n};\nconst WorkItem = React.memo(_WorkItem);\n\nconst _InterstitialCard: React.FC<Props> = ({\n title,\n body,\n items,\n illustration,\n imageUrl,\n illustrationFallback,\n ctaLabel = \"Continue\",\n onSubmit,\n onPress,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const node = useIllustration(illustration);\n const fallbackNode = useIllustration(illustrationFallback);\n const [submitted, setSubmitted] = useState(false);\n const [imgFailed, setImgFailed] = useState(false);\n // Keep the momentum beat on screen for at least MIN_DISPLAY_MS before Continue is tappable.\n const [canAdvance, setCanAdvance] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => setCanAdvance(true), MIN_DISPLAY_MS);\n return () => clearTimeout(timer);\n }, []);\n\n // Head reveal: art then title (then body) fade-up, 500ms ease-wire, 100ms stagger.\n // Reduce motion: final frame immediately (the shell handoff supplies the short fade).\n const artT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const titleT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const bodyT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n useEffect(() => {\n if (reduced) {\n artT.setValue(1);\n titleT.setValue(1);\n bodyT.setValue(1);\n return;\n }\n const rise = (value: Animated.Value, delay: number) =>\n Animated.timing(value, {\n toValue: 1,\n duration: scaledMs(INTERSTITIAL_HEAD_MS),\n delay,\n easing: easeWire,\n useNativeDriver: true,\n });\n const anims = [\n rise(artT, 0),\n rise(titleT, scaledMs(INTERSTITIAL_HEAD_STAGGER_MS)),\n rise(bodyT, scaledMs(INTERSTITIAL_HEAD_STAGGER_MS * 2)),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, artT, titleT, bodyT]);\n\n const riseStyle = (value: Animated.Value) => ({\n opacity: value,\n transform: [{ translateY: value.interpolate({ inputRange: [0, 1], outputRange: [RISE_PX, 0] }) }],\n });\n\n const handleContinue = useCallback(() => {\n if (submitted || !canAdvance) return;\n setSubmitted(true);\n if (onSubmit) onSubmit(\"continue\");\n else if (onPress) onPress(ctaLabel);\n }, [submitted, canAdvance, onSubmit, onPress, ctaLabel]);\n\n // Resolution order — a broken/missing image must never leave a blank box:\n // named illustration → remote image (until it errors) → named fallback art.\n const showImage = !node && !!imageUrl && !imgFailed;\n const art = node ?? (showImage ? undefined : fallbackNode);\n\n return (\n <CardLayout\n align=\"center\"\n footer={\n <Button\n title={ctaLabel}\n onPress={handleContinue}\n variant=\"primary\"\n disabled={submitted || !canAdvance}\n />\n }\n >\n <View style={[styles.center, { gap: t.spacing.md }]}>\n <Animated.View style={[styles.fullWidth, riseStyle(artT)]}>\n {showImage ? (\n <Image\n source={{ uri: imageUrl }}\n style={styles.image}\n resizeMode=\"contain\"\n onError={() => setImgFailed(true)}\n />\n ) : art ? (\n <View style={styles.art}>{art}</View>\n ) : null}\n </Animated.View>\n\n <Animated.View style={riseStyle(titleT)}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>{title}</Text>\n </Animated.View>\n\n {items?.length ? (\n <View style={[styles.items, { gap: t.spacing.md, marginTop: t.spacing.sm }]}>\n {items.map((item, i) => (\n <WorkItem key={`${item}-${i}`} text={item} index={i} reduced={reduced} />\n ))}\n </View>\n ) : body ? (\n <Animated.View style={riseStyle(bodyT)}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>{body}</Text>\n </Animated.View>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const InterstitialCard: WireAIComponent = {\n name: \"InterstitialCard\",\n description:\n \"Use ONCE mid-flow (never first, never last) as a momentum/value screen between questions — an illustration + a warm line that reflects answers back, like Duolingo/Cal-AI. NOT a question; the user just taps Continue. Set `illustration` to an app-registered artwork name. Prefer `items` (2-3 short ticked lines, each reflecting a real answer) when you have the signal. Skip it if you don't have enough signal to make the line specific.\",\n component: React.memo(_InterstitialCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { ctaLabel: \"Continue\", illustrationFallback: \"momentum\" },\n};\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n fullWidth: { width: \"100%\", alignItems: \"center\" },\n art: { alignItems: \"center\", justifyContent: \"center\" },\n image: { width: \"100%\", height: 200 },\n items: { width: \"100%\", alignSelf: \"stretch\" },\n itemRow: { flexDirection: \"row\", alignItems: \"center\" },\n itemBadge: { width: 24, height: 24, alignItems: \"center\", justifyContent: \"center\" },\n itemCheck: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n itemText: { flex: 1 },\n});\n","/**\n * onboardingComponents — the constrained set of themed cards the kit registers\n * with the SDK. The backend's `allowed_components` must be a subset of these\n * names so every card the agent asks for has a themed renderer.\n */\nimport type { WireAIComponent } from \"wireai-rn\";\nimport { ChipSelectCard } from \"./ChipSelectCard\";\nimport { TextInputCard } from \"./TextInputCard\";\nimport { SelectionCard } from \"./SelectionCard\";\nimport { CardGridSelectCard } from \"./CardGridSelectCard\";\nimport { StatusCard } from \"./StatusCard\";\nimport { NumberStepperCard } from \"./NumberStepperCard\";\nimport { InterstitialCard } from \"./InterstitialCard\";\n\nexport {\n ChipSelectCard,\n TextInputCard,\n SelectionCard,\n CardGridSelectCard,\n StatusCard,\n NumberStepperCard,\n InterstitialCard,\n};\nexport { normalizeOptions, optionsField, optionObjectSchema } from \"./optionSchema\";\nexport type { CardOption } from \"./optionSchema\";\n\nexport const onboardingComponents: WireAIComponent[] = [\n ChipSelectCard,\n TextInputCard,\n SelectionCard,\n CardGridSelectCard,\n StatusCard,\n NumberStepperCard,\n InterstitialCard,\n];\n","/**\n * appVersion — best-effort, DEPENDENCY-FREE auto-detection of the host app's version string.\n *\n * WHY this exists: analytics segments the funnel `by_app_version`, but that breakdown is only\n * populated when a `device.appVersion` rides the event. `config.appVersion` (see types.ts) has\n * always been the way to supply it — but it is easy for a host to forget, and then the release\n * breakdown is silently empty. This module fills that gap: when the host does NOT pass a version,\n * the kit makes a best-effort read of the app version the host already ships in its Expo config,\n * so the breakdown works out of the box. An explicit `config.appVersion` always WINS over this.\n *\n * WHY it adds NO dependency (the kit's hard rule): `expo-constants` / `expo-application` are read\n * through a GUARDED require with a STRING-LITERAL specifier, inside a try/catch. Both halves are\n * required: the literal is what lets Metro COLLECT the dep, and the try/catch is what marks it\n * OPTIONAL, so an absent module becomes a `null` dependencyMap entry whose require throws \"Cannot\n * find module\" straight into the catch. (`withWireOnboarding` in metro/index.js adds a stub-to-\n * empty-module safety net for hosts that disable Metro's `allowOptionalDependencies`.) Nothing is\n * added to `package.json`; nothing is forced on the host.\n *\n * The specifier MUST stay a literal. A variable specifier (`const req = require; req(name)`) is not\n * \"lazier\" — it is broken: Metro collects dependencies statically, so a variable collects NOTHING,\n * the module never enters the bundle, and the aliased `require` is Metro's own numeric-id-keyed\n * `metroRequire`, which can never resolve a package-name string. That shape is why this function\n * returned `undefined` on every host despite `expo-constants` being installed, which silently\n * emptied the `by_app_version` breakdown this module exists to fill. See icons/expoIcons.ts for\n * the full autopsy, and reviews/storeReview.ts for the literal-specifier counter-example.\n *\n * PRIVACY: an app version string is not PII and identifies no user or device, so surfacing it\n * changes no App Privacy / Data Safety declaration (same guarantee as the rest of deviceContext).\n *\n * NEVER THROWS: every read is guarded; a missing/odd value yields `undefined`, never an exception.\n * Analytics must never be able to break onboarding.\n */\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime. Declared locally so\n// this type-checks without ambient Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded runtime require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/** Trim + reject non-strings/empties so we only ever emit a real version string. */\nexport const coerceVersion = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Guarded runtime require.\n *\n * Every specifier below is a STRING LITERAL, because that is the only shape Metro's dependency\n * collector matches (callee literally `require`, argument literally a string). The `moduleName`\n * parameter exists only to keep the `OptionalRequire` seam shape for tests; an unrecognised name\n * resolves to undefined. See the header for why the old variable-specifier shape could not work.\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (typeof require !== \"function\") return undefined;\n try {\n switch (moduleName) {\n case \"expo-constants\":\n return require(\"expo-constants\");\n case \"expo-application\":\n return require(\"expo-application\");\n default:\n return undefined;\n }\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return mod as Record<string, unknown>;\n};\n\n/** Resolve a module namespace, swallowing a throwing require (an uninstalled module throws). */\nconst safeInterop = (\n requireModule: OptionalRequire,\n moduleName: string,\n): Record<string, unknown> | undefined => {\n try {\n return interop(requireModule(moduleName));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Detect the host app version, preferring `expo-constants` (`expoConfig.version`, then\n * `nativeAppVersion`) and finally `expo-application` (`nativeApplicationVersion`). Returns the\n * first real string, or `undefined` when none of those are available. Pure and never throws.\n *\n * `requireModule` is injectable so tests can exercise the \"found\" path without the native modules;\n * production defaults to the guarded runtime require above.\n */\nexport const detectAppVersion = (\n requireModule: OptionalRequire = runtimeRequire,\n): string | undefined => {\n try {\n const constants = safeInterop(requireModule, \"expo-constants\");\n if (constants) {\n const expoConfig = constants.expoConfig;\n if (expoConfig && typeof expoConfig === \"object\") {\n const fromExpoConfig = coerceVersion((expoConfig as { version?: unknown }).version);\n if (fromExpoConfig) return fromExpoConfig;\n }\n const fromNative = coerceVersion(constants.nativeAppVersion);\n if (fromNative) return fromNative;\n }\n\n const application = safeInterop(requireModule, \"expo-application\");\n if (application) {\n const fromApplication = coerceVersion(application.nativeApplicationVersion);\n if (fromApplication) return fromApplication;\n }\n } catch {\n // Any unexpected read error → \"unknown\"; analytics must never crash onboarding.\n }\n return undefined;\n};\n","/**\n * deviceModel — best-effort, DEPENDENCY-FREE detection of the device MODEL on iOS.\n *\n * WHY this exists (the asymmetry it closes): `collectDeviceContext` already reports `device.model`\n * on Android straight from `Platform.constants.Model` (e.g. \"SM-G991B\"), but iOS `Platform.constants`\n * exposes NO model — only `osVersion` / `interfaceIdiom`. So the analytics `by_model` breakdown was\n * Android-only. This module fills the iOS gap with the SAME zero-dependency technique the kit already\n * uses for `appVersion` (see device/appVersion.ts): a GUARDED, STRING-LITERAL `require` of the common\n * Expo `expo-device` module, inside a try/catch — the literal is what lets Metro COLLECT the dep and\n * the try/catch is what marks it OPTIONAL, so an absent module degrades instead of failing the build.\n * (`withWireOnboarding` in metro/index.js adds a stub-to-empty-module safety net for hosts that\n * disable Metro's `allowOptionalDependencies`.) If the host has it, iOS gets a model out of the box;\n * if not, the read yields `undefined` and iOS `model` stays omitted — nothing is forced, and nothing\n * is added to `package.json`.\n *\n * The specifier MUST stay a literal. A variable specifier (`const req = require; req(name)`) collects\n * NOTHING under Metro's static dependency collector, so the module never enters the bundle and the\n * aliased `require` — really Metro's numeric-id-keyed `metroRequire` — can never resolve a package\n * name. See icons/expoIcons.ts for the full autopsy.\n *\n * WHY it is NOT PII: `expo-device`'s `modelName` (\"iPhone 14 Pro\") and `modelId` (\"iPhone15,2\") are a\n * device CLASS shared by millions of units — the same privacy category as the Android `Model` the kit\n * already sends. It is NOT a unique device id / IDFA / fingerprint, so surfacing it changes no App\n * Privacy / Data Safety declaration (identical guarantee to the rest of deviceContext). It deliberately\n * does NOT read `expo-device`'s `deviceName` (that is the user-set name, e.g. \"Malik's iPhone\", and IS\n * personal data).\n *\n * NEVER THROWS: every read is guarded; a missing/odd value yields `undefined`, never an exception.\n */\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime. Declared locally so\n// this type-checks without ambient Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded runtime require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/** Trim + reject non-strings/empties so we only ever emit a real model string. */\nconst coerceModel = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Guarded runtime require.\n *\n * The specifier is a STRING LITERAL, because that is the only shape Metro's dependency collector\n * matches (callee literally `require`, argument literally a string). The `moduleName` parameter\n * exists only to keep the `OptionalRequire` seam shape for tests; an unrecognised name resolves to\n * undefined. (See the twin guard in ./appVersion.ts.)\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (moduleName !== \"expo-device\") return undefined;\n if (typeof require !== \"function\") return undefined;\n try {\n return require(\"expo-device\");\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are often consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return mod as Record<string, unknown>;\n};\n\n/** Resolve a module namespace, swallowing a throwing require (an uninstalled module throws). */\nconst safeInterop = (\n requireModule: OptionalRequire,\n moduleName: string,\n): Record<string, unknown> | undefined => {\n try {\n return interop(requireModule(moduleName));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Detect the device model via `expo-device`, preferring the human-readable `modelName`\n * (\"iPhone 14 Pro\") and falling back to the identifier `modelId` (\"iPhone15,2\"). Returns the first\n * real string, or `undefined` when `expo-device` is absent. Pure and never throws.\n *\n * `requireModule` is injectable so tests can exercise the \"found\" path without the native module;\n * production defaults to the guarded runtime require above.\n */\nexport const detectNativeModel = (\n requireModule: OptionalRequire = runtimeRequire,\n): string | undefined => {\n try {\n const device = safeInterop(requireModule, \"expo-device\");\n if (device) {\n const modelName = coerceModel(device.modelName);\n if (modelName) return modelName;\n const modelId = coerceModel(device.modelId);\n if (modelId) return modelId;\n }\n } catch {\n // Any unexpected read error → undefined; analytics must never crash onboarding.\n }\n return undefined;\n};\n","/**\n * deviceContext — collect a small, privacy-label-neutral snapshot of the device so\n * onboarding analytics can segment the funnel (platform / form factor / locale) WITHOUT\n * adding a single dependency to the kit or changing a host app's App Privacy / Data Safety\n * declarations.\n *\n * HARD RULE (why this file adds no dependency):\n * The kit stays dependency-free. Everything here comes from `Platform`, `Dimensions`,\n * `I18nManager`, and the standard `Intl` global — plus a best-effort `appVersion` read via\n * `detectAppVersion()`, which itself adds NO dependency (it reaches for `expo-constants` /\n * `expo-application` through a guarded, variable-specifier require that a host without them\n * simply never resolves — see device/appVersion.ts). There are NO advertising IDs, NO\n * `getUniqueId`/IDFA/GAID/fingerprinting APIs, and nothing that would require a new\n * privacy-label entry. A host can adopt this without touching its store declarations.\n *\n * DEFENSIVE BY DESIGN: `collectDeviceContext()` never throws. Every read is guarded and\n * a missing/unavailable field is simply omitted (Hermes may ship without full `Intl`,\n * `Platform.constants` differs per OS and RN version, etc.). Analytics must never be able\n * to break onboarding.\n */\nimport { Dimensions, I18nManager, Platform } from \"react-native\";\n\nimport { detectAppVersion } from \"./appVersion\";\nimport { detectNativeModel } from \"./deviceModel\";\n\n/** Coarse device class. iOS uses the reported interface idiom; else a screen-size heuristic. */\nexport type DeviceFormFactor = \"phone\" | \"tablet\";\n\n/**\n * A privacy-label-neutral device snapshot. ALL fields except `platform` are optional and are\n * omitted when unavailable. Nothing here identifies a user or device uniquely.\n */\nexport type DeviceContext = {\n /** `Platform.OS` — \"ios\" | \"android\" | \"windows\" | \"macos\" | \"web\". Always present. */\n platform: typeof Platform.OS;\n /** OS version string (iOS `osVersion`/`Platform.Version`, Android `Release`). */\n osVersion?: string;\n /** Android device brand (e.g. \"samsung\"). Android only. */\n brand?: string;\n /**\n * Device model. On Android it is read directly from `Platform.constants.Model` (e.g. \"SM-G991B\").\n * iOS `Platform.constants` exposes NO model, so on iOS it is a BEST-EFFORT read of `expo-device`'s\n * `modelName` (\"iPhone 14 Pro\"), falling back to `modelId` (\"iPhone15,2\") — dependency-free via a\n * guarded require (see device/deviceModel.ts). ASYMMETRY: without `expo-device` installed, iOS\n * `model` is omitted (there is no dependency-free iOS model in the already-used RN surface, and the\n * kit will not add a native dep for it); Android needs no extra module. Not PII (a device class,\n * not a unique id), so it changes no privacy-label declaration.\n */\n model?: string;\n /** iOS interface idiom (\"phone\" | \"pad\" | …), when reported. iOS only. */\n interfaceIdiom?: string;\n /** Derived device class. */\n formFactor?: DeviceFormFactor;\n /** `Dimensions.get('screen')` width in dp. */\n screenWidth?: number;\n /** `Dimensions.get('screen')` height in dp. */\n screenHeight?: number;\n /** Screen pixel density (`scale`). */\n screenScale?: number;\n /** Right-to-left layout (`I18nManager.isRTL`). */\n isRTL?: boolean;\n /** Resolved locale (e.g. \"en-US\"), from `Intl` when available. */\n locale?: string;\n /** IANA time zone (e.g. \"Europe/Berlin\"), from `Intl` when available. */\n timeZone?: string;\n /**\n * Host app version (e.g. \"1.4.2\"). BEST-EFFORT auto-detected here via `detectAppVersion()`\n * (reads `expo-constants` / `expo-application` when present; adds no dependency — see\n * device/appVersion.ts). An explicit host-injected `config.appVersion` always WINS: the merge\n * sites (`WireOnboarding`, the session-analytics hooks, the context envelope) overwrite this\n * with the host value when one is supplied. Omitted when neither source yields a version.\n */\n appVersion?: string;\n};\n\n/** iOS idiom wins; otherwise the shortest side in dp (>= 600 → tablet) picks the class. */\nconst deriveFormFactor = (\n iosIdiom: string | undefined,\n width: number | undefined,\n height: number | undefined,\n): DeviceFormFactor | undefined => {\n if (iosIdiom === \"pad\") return \"tablet\";\n if (iosIdiom === \"phone\") return \"phone\";\n if (typeof width === \"number\" && typeof height === \"number\") {\n return Math.min(width, height) >= 600 ? \"tablet\" : \"phone\";\n }\n return undefined;\n};\n\n/**\n * Collect the device snapshot. Pure, synchronous, and never throws — call it once per\n * onboarding session. Missing fields are omitted rather than sent as null/undefined so the\n * payload (and the server's stored dict) stays compact.\n */\nexport const collectDeviceContext = (): DeviceContext => {\n const ctx: DeviceContext = { platform: Platform.OS };\n\n // OS version (fallback; per-OS constants below may refine it).\n try {\n const version = Platform.Version;\n if (version !== undefined && version !== null && String(version)) {\n ctx.osVersion = String(version);\n }\n } catch {\n // ignore\n }\n\n // `Platform.constants` shape differs by OS and RN version — read every field defensively.\n let constants: Record<string, unknown> = {};\n try {\n constants = (Platform.constants ?? {}) as Record<string, unknown>;\n } catch {\n constants = {};\n }\n\n let iosIdiom: string | undefined;\n try {\n if (Platform.OS === \"android\") {\n const brand = constants.Brand;\n const model = constants.Model;\n const release = constants.Release;\n if (typeof brand === \"string\" && brand) ctx.brand = brand;\n if (typeof model === \"string\" && model) ctx.model = model;\n if (release !== undefined && release !== null && String(release)) {\n ctx.osVersion = String(release);\n }\n } else if (Platform.OS === \"ios\") {\n const osVersion = constants.osVersion;\n const idiom = constants.interfaceIdiom;\n if (osVersion !== undefined && osVersion !== null && String(osVersion)) {\n ctx.osVersion = String(osVersion);\n }\n if (typeof idiom === \"string\" && idiom) {\n ctx.interfaceIdiom = idiom;\n iosIdiom = idiom;\n }\n // iOS has no model in `Platform.constants`; best-effort via `expo-device` (adds no dep,\n // omitted when the module is absent — see device/deviceModel.ts).\n const iosModel = detectNativeModel();\n if (iosModel) ctx.model = iosModel;\n }\n } catch {\n // ignore per-OS constant reads\n }\n\n // Screen dimensions + derived form factor.\n try {\n const screen = Dimensions.get(\"screen\");\n if (screen) {\n if (typeof screen.width === \"number\") ctx.screenWidth = screen.width;\n if (typeof screen.height === \"number\") ctx.screenHeight = screen.height;\n if (typeof screen.scale === \"number\") ctx.screenScale = screen.scale;\n const formFactor = deriveFormFactor(iosIdiom, screen.width, screen.height);\n if (formFactor) ctx.formFactor = formFactor;\n }\n } catch {\n // ignore\n }\n\n // Layout direction.\n try {\n ctx.isRTL = I18nManager.isRTL;\n } catch {\n // ignore\n }\n\n // Locale + time zone via the standard Intl global. Hermes may ship without full Intl,\n // so referencing it can throw ReferenceError — the try/catch covers that too.\n try {\n const resolved = Intl.DateTimeFormat().resolvedOptions();\n if (resolved.locale) ctx.locale = resolved.locale;\n if (resolved.timeZone) ctx.timeZone = resolved.timeZone;\n } catch {\n // Intl unavailable — omit locale/timeZone.\n }\n\n // Best-effort host app version (adds no dependency; omitted when unavailable). An explicit\n // `config.appVersion` overrides this downstream at the merge sites.\n const appVersion = detectAppVersion();\n if (appVersion) ctx.appVersion = appVersion;\n\n return ctx;\n};\n","/**\n * currentSession — a tiny registry of the CURRENT per-open `session_id`.\n *\n * WHY it exists (kills the phantom-session): the per-open emitters (`reportSessionStart` and the\n * `useSessionStart` / `useLifecycleEvents` hooks) mint a fresh `session_id` for each app-open and\n * post `app.session_started` with it — so the SERVER knows that id. But other client paths\n * (`identify`, host `app_event`s through the analytics façade) used to reference a DIFFERENT id\n * (a frozen per-instance id), which the server had never seen, so it back-filled a synthetic\n * `session_started` — inflating session counts (the \"phantom-session\" bug).\n *\n * This registry is the single seam that lets those paths reuse the LIVE per-open session id the\n * server already ingested. `reportSessionStart` writes the current id here on every open; the façade\n * reads it so `identify`/app-events correlate to the real session instead of minting a phantom.\n *\n * ── WHY A globalThis SLOT, NOT A PLAIN MODULE VARIABLE ────────────────────────────────────────\n * This module is exported from TWO package entry points — the main `.` bundle (`src/index.ts`) and\n * the `./analytics` subpath (`src/analytics/index.ts`). Under `dist` resolution (node `import`/\n * `require`, which is how tests, SSR and some tooling load the kit) tsup inlines a SEPARATE copy of\n * this module into each bundle, so a plain `let` would give the SETTER (reached via `.` →\n * `reportSessionStart`) and the READER (reached via `./analytics` → façade / `userIdentity`) TWO\n * different variables: the reader would see `undefined` even after an open set the id, and gating\n * would fire under a null session id. On-device this was masked only because Metro's `react-native`\n * export condition resolves both subpaths back to this one `src/` file (a single instance) — a\n * bundler accident, not a guarantee.\n *\n * The bundler-agnostic fix: keep the ONE live value in a well-known `globalThis` slot keyed by a\n * `Symbol.for(...)`. `Symbol.for` uses the runtime-global symbol registry, so every inlined copy of\n * this module resolves the SAME symbol and reads/writes the SAME slot — one identity no matter how\n * many times the module is duplicated across bundles. `globalThis` is present and identical in\n * Hermes/React Native, Node and SSR (we never touch `window`), so this is safe on every host.\n *\n * PROCESS-LOCAL, NOT PERSISTED: the slot lives on the runtime global, so it tracks the CURRENT\n * process's open and a fresh open overwrites it. There is no cross-launch state.\n * `resetCurrentSessionId` clears the slot so a unit test starts from a clean registry.\n */\n\n/**\n * Well-known key into the runtime-global symbol registry. `Symbol.for` (NOT a plain `Symbol()`) is\n * what makes this cross-bundle: it returns the SAME symbol for the same string across every copy of\n * this module, so duplicated inlined copies all address one slot.\n */\nconst CURRENT_SESSION_ID_SLOT: unique symbol = Symbol.for(\n \"@wireai/activation:currentSessionId\",\n);\n\ntype GlobalWithSlot = typeof globalThis & {\n [CURRENT_SESSION_ID_SLOT]?: string | undefined;\n};\n\nconst globalSlot = globalThis as GlobalWithSlot;\n\n/**\n * Record the current per-open `session_id`. Called by `reportSessionStart` when it emits an\n * app-open. A blank / non-string id is ignored (the previous id stays current). Idempotent.\n */\nexport const setCurrentSessionId = (id: string | undefined): void => {\n if (typeof id === \"string\" && id.length > 0) {\n globalSlot[CURRENT_SESSION_ID_SLOT] = id;\n }\n};\n\n/** The current per-open `session_id`, or `undefined` when no app-open has been registered yet. */\nexport const getCurrentSessionId = (): string | undefined =>\n globalSlot[CURRENT_SESSION_ID_SLOT];\n\n/** Test-only: forget the current session id so a unit test starts from a clean registry. */\nexport const resetCurrentSessionId = (): void => {\n globalSlot[CURRENT_SESSION_ID_SLOT] = undefined;\n};\n","/**\n * Session-id persistence — the kit caching its OWN correlation seed across app kills.\n *\n * WHY: the session id is minted per mount and forwarded to the backend as the A2A\n * `contextId` (see WireOnboarding). Without persistence, an app KILL mid-onboarding\n * mints a NEW id on relaunch — the server counts a second `session_started` and the\n * orphaned first session reads as a phantom \"drop\", inflating the funnel's `started`\n * denominator. Persisting `{ id, ts }` and reusing a still-fresh id keeps a\n * kill-and-relaunch a SINGLE session in analytics.\n *\n * SCOPE: this persists the correlation seed ONLY — never answers. Answer persistence\n * stays a host concern via `onComplete` (the kit/host boundary is unchanged).\n *\n * The host injects the storage via the `storage` prop (an AsyncStorage-compatible\n * subset), keeping the kit dependency-free: an MMKV wrapper and AsyncStorage itself\n * both fit. Every operation is best-effort — a broken or hung storage must NEVER\n * break (or indefinitely gate) onboarding: reads race a short timeout, writes and\n * removes swallow all errors.\n */\nimport { makeSessionId } from \"../analytics/reportClientEvent\";\n\n/**\n * The storage the host injects. Deliberately the AsyncStorage-compatible subset so\n * `@react-native-async-storage/async-storage` can be passed as-is, and an MMKV (or\n * any other) wrapper is three one-line methods.\n */\nexport type WireOnboardingStorage = {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n};\n\n/**\n * Matches the backend's session TTL (SESSION_TTL_SECONDS = 3600): an id older than\n * this can't be resumed server-side anyway, so the client mints fresh past it.\n */\nexport const DEFAULT_SESSION_TTL_MS = 3_600_000;\n\n/** Ceiling on the storage read — a hung adapter degrades to a fresh mint, never a stuck gate. */\nconst READ_TIMEOUT_MS = 1_500;\n\n/** Storage key for an app's cached session, e.g. `wireai:session:acme`. */\nexport const sessionStorageKey = (appId: string): string => `wireai:session:${appId}`;\n\ntype PersistedSession = { id: string; ts: number };\n\n/** Resolved session for a mount: the id to use + whether it was restored from storage. */\nexport type LoadedSession = {\n id: string;\n /** True when a stored, still-fresh id was reused — the flow resumes instead of starting. */\n resumed: boolean;\n};\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n // Clear the timer once the race settles, so a won read doesn't leave a ≤ms no-op\n // timer holding the closure alive.\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\nconst parsePersisted = (raw: string | null | undefined): PersistedSession | undefined => {\n if (!raw) return undefined;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n typeof (parsed as PersistedSession).id === \"string\" &&\n typeof (parsed as PersistedSession).ts === \"number\"\n ) {\n return parsed as PersistedSession;\n }\n } catch {\n // Corrupt entry → treat as absent; the caller mints fresh and overwrites it.\n }\n return undefined;\n};\n\n/**\n * Resolve the session id for this mount: reuse the stored one while it's fresh\n * (→ `resumed: true`), else mint via `makeSessionId`, persist it, and start clean.\n * Never throws; never hangs past the read timeout.\n */\nexport const loadPersistedSession = async (\n storage: WireOnboardingStorage,\n key: string,\n ttlMs: number = DEFAULT_SESSION_TTL_MS,\n): Promise<LoadedSession> => {\n let stored: PersistedSession | undefined;\n try {\n stored = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n } catch {\n stored = undefined;\n }\n if (stored && Date.now() - stored.ts < ttlMs) {\n return { id: stored.id, resumed: true };\n }\n const id = makeSessionId();\n savePersistedSession(storage, key, id);\n return { id, resumed: false };\n};\n\n/**\n * Read the persisted session WITHOUT minting a fresh one (unlike `loadPersistedSession`).\n * Returns the stored `{ id, ts }` or `undefined` when absent/corrupt/timed-out. Used by the\n * post-onboarding `identifyOnboarding` helper to recover the contextId to bind a user to.\n * Never throws; never hangs past the read timeout.\n */\nexport const peekPersistedSession = async (\n storage: WireOnboardingStorage,\n key: string,\n): Promise<{ id: string; ts: number } | undefined> => {\n try {\n return parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n } catch {\n return undefined;\n }\n};\n\n/** Persist `{ id, ts }` under `key` — fire-and-forget, all errors swallowed. */\nexport const savePersistedSession = (\n storage: WireOnboardingStorage,\n key: string,\n id: string,\n): void => {\n try {\n void storage.setItem(key, JSON.stringify({ id, ts: Date.now() })).catch(() => {});\n } catch {\n // Best-effort: a failed write just means the next launch starts a fresh session.\n }\n};\n\n/** Remove the cached id (fired on completion) — fire-and-forget, all errors swallowed. */\nexport const clearPersistedSession = (storage: WireOnboardingStorage, key: string): void => {\n try {\n void storage.removeItem(key).catch(() => {});\n } catch {\n // Best-effort.\n }\n};\n\n/**\n * The opt-in decision for `WireOnboarding.handleComplete`: given the host's\n * `retainSessionOnComplete` opt-in, whether a completion should CLEAR the persisted seed.\n * (The caller still gates on `storage` being present — this only encodes the opt-in axis, so the\n * legacy `if (storage) clearPersistedSession(...)` guard stays byte-for-byte for a host that does\n * not opt in.)\n *\n * - undefined / false (the default) → `true`: clear on completion, so the NEXT onboarding on this\n * device mints a fresh session. This is the legacy single-stage behavior (e.g. Myelino).\n * - true → `false`: LEAVE the seed in place so a same-signup re-entry/remount within the TTL\n * resumes the SAME session (one funnel start) instead of minting a phantom second `started`.\n * Freshness for a genuinely new run is then governed by the TTL (past `sessionTtlMs` → fresh\n * mint) and an explicit new-run signal (a changed `persistKey`).\n */\nexport const shouldClearOnComplete = (retainSessionOnComplete: boolean | undefined): boolean =>\n !retainSessionOnComplete;\n","/**\n * User identity — bind an onboarding session to the HOST's own user id so the funnel can\n * be reconciled to real users later (console sessions ↔ your user table / GA4 users).\n *\n * The id is an OPAQUE PSEUDONYMOUS STRING the host owns — its internal user id, NOT an\n * email/name/phone. Same host-injection philosophy as `storage` and `userContext`: the kit\n * mints nothing and reads nothing; the host passes what it wants. Dependency-free.\n *\n * Three binding moments (see WireOnboarding + the README \"User identity\" section):\n * 1. MOUNT — pass `userId` and it rides the A2A session-start metadata; the server\n * binds it when it creates the session.\n * 2. MID-SESSION— the user registers DURING onboarding: change the `userId` prop and the\n * kit emits an `identify` client event that attaches the id to the live\n * session (late binding — the key scenario).\n * 3. POST-FLOW — the user registers AFTER onboarding: call `identifyOnboarding(...)` with\n * the same host storage (it recovers the persisted contextId, before completion\n * clears it) or, more reliably, the `contextId` you captured from the\n * `started`/`resumed` `onEvent` (both events carry a `contextId` field).\n *\n * ⚠️ NO PII. Pass an opaque id (or a hash), never a raw email/name/phone. The id is capped at\n * {@link USER_ID_MAX_LENGTH} chars (longer ids are truncated, not rejected).\n */\nimport { getCurrentSessionId } from \"../analytics/currentSession\";\nimport { reportClientEvent } from \"../analytics/reportClientEvent\";\nimport {\n peekPersistedSession,\n sessionStorageKey,\n type WireOnboardingStorage,\n} from \"../session/persistedSession\";\n\n/** Max accepted user-id length. Longer strings are truncated (never rejected). Keep in sync\n * with the server's `USER_ID_MAX_LENGTH` (analytics/events.py). */\nexport const USER_ID_MAX_LENGTH = 128;\n\n/**\n * Normalize a host-supplied user id: trim, drop empty, and cap at {@link USER_ID_MAX_LENGTH}.\n * Returns `undefined` for a missing/blank/non-string value so callers can `if (id)`-gate.\n * PII is a host concern — this only bounds length, it does not (and cannot) detect an email.\n */\nexport const sanitizeUserId = (raw: unknown): string | undefined => {\n if (typeof raw !== \"string\") return undefined;\n const trimmed = raw.trim();\n if (!trimmed) return undefined;\n return trimmed.length > USER_ID_MAX_LENGTH ? trimmed.slice(0, USER_ID_MAX_LENGTH) : trimmed;\n};\n\n/** Options for {@link identifyOnboarding}. */\nexport type IdentifyOnboardingOptions = {\n /** Tenant transport, same shape as `WireOnboardingConfig` (only these two fields are used). */\n config: { serverUrl: string; apiKey: string };\n /** The host's opaque user id to bind. Trimmed + capped; NO PII. */\n userId: string;\n /**\n * The onboarding session id to bind to (the A2A contextId) — the `contextId` field carried on\n * the `started`/`resumed` `onEvent`. Pass this when you captured it there. Required after the\n * flow COMPLETED, since completion clears the persisted session. Wins over the storage lookup.\n */\n contextId?: string;\n /**\n * The SAME host storage you passed to `<WireOnboarding storage={…} />`. When `contextId` is\n * omitted, the helper reads the persisted contextId from it (works while the session is still\n * persisted — i.e. dropped or mid-flow, before completion clears it).\n */\n storage?: WireOnboardingStorage;\n /** App id, to derive the default storage key `wireai:session:<appId>` when reading from storage. */\n appId?: string;\n /** Storage key override — pass the same `persistKey` you gave `<WireOnboarding>`, if any. */\n persistKey?: string;\n};\n\n/**\n * Attach a host user id to an onboarding session AFTER the fact (post-registration), by sending\n * an `identify` client event to `/v1/events`. Resolves the contextId from an explicit\n * `contextId` or, failing that, from the persisted session in the host `storage`.\n *\n * Fire-and-forget under the hood (never throws, never blocks onboarding). Resolves to `true`\n * when an identify event was dispatched, `false` when it couldn't (no user id, no server url,\n * or no resolvable contextId).\n */\nexport const identifyOnboarding = async (\n opts: IdentifyOnboardingOptions,\n): Promise<boolean> => {\n const userId = sanitizeUserId(opts.userId);\n if (!userId || !opts.config?.serverUrl) return false;\n\n let contextId = opts.contextId?.trim() || undefined;\n if (!contextId && opts.storage) {\n const key = opts.persistKey ?? (opts.appId ? sessionStorageKey(opts.appId) : undefined);\n if (key) {\n const stored = await peekPersistedSession(opts.storage, key);\n contextId = stored?.id;\n }\n }\n // Last resort: bind to the LIVE per-open session (registered by `reportSessionStart`) so a\n // post-flow identify with no captured contextId still attaches to a session the server saw,\n // instead of no-oping. The onboarding contextId (above) is still preferred when available.\n if (!contextId) contextId = getCurrentSessionId();\n if (!contextId) return false;\n\n reportClientEvent(\n { serverUrl: opts.config.serverUrl, apiKey: opts.config.apiKey },\n { event_type: \"identify\", session_id: contextId, user_id: userId },\n );\n return true;\n};\n","/**\n * WireOnboarding — the public host component. Drop it into a screen and it runs\n * the whole AI onboarding: builds the A2A transport from `config`, wires the SDK\n * provider with the themed cards, applies the theme, and renders the flow.\n *\n * <WireOnboarding\n * config={{ apiKey, serverUrl, appId }}\n * theme={myBrandTheme}\n * validators={{ username: checkUsernameAvailable }}\n * onComplete={persist}\n * onSkip={skip}\n * />\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { WireAIProvider, type LocalLLMConfig } from \"wireai-rn\";\nimport { OnboardingThemeProvider } from \"./theme/ThemeContext\";\nimport { IllustrationProvider } from \"./components/Illustration\";\nimport { defaultIllustrations } from \"./illustrations/defaultIllustrations\";\nimport { IconRegistryProvider } from \"./icons/IconRegistry\";\nimport { LoadingScreen } from \"./components/LoadingScreen\";\nimport { OnboardingFlow, DEFAULT_COPY } from \"./OnboardingFlow\";\nimport { onboardingComponents } from \"./cards\";\nimport { makeSessionId, reportClientEvent, type ClientEventTarget } from \"./analytics/reportClientEvent\";\nimport { collectDeviceContext, type DeviceContext } from \"./device/deviceContext\";\nimport { sanitizeUserId } from \"./identity/userIdentity\";\nimport {\n clearPersistedSession,\n loadPersistedSession,\n sessionStorageKey,\n shouldClearOnComplete,\n DEFAULT_SESSION_TTL_MS,\n type LoadedSession,\n} from \"./session/persistedSession\";\nimport type { OnboardingResult, WireOnboardingProps } from \"./types\";\n\nexport const WireOnboarding: React.FC<WireOnboardingProps> = ({\n config,\n theme,\n components,\n illustrations,\n icons,\n validators,\n onComplete,\n onSkip,\n onError,\n onEvent,\n copy,\n approxScreens,\n startMessage = \"start\",\n startTimeoutMs = 15_000,\n fallbackFlow,\n maxRetries = 1,\n storage,\n sessionTtlMs = DEFAULT_SESSION_TTL_MS,\n persistKey,\n retainSessionOnComplete,\n userContext,\n userId,\n}) => {\n // The host's own opaque user id (trimmed + capped, NO PII) so onboarding sessions can be\n // reconciled to real users later. `sanitizeUserId` is a pure string transform → the memoized\n // result is a stable primitive, safe to feed the `llm` / `clientContext` memos directly (unlike\n // the raw object props). Bound at three moments: session-start metadata (mount), an `identify`\n // event on a mid-session change (late binding), and the `identifyOnboarding` helper post-flow.\n const boundUserId = useMemo(() => sanitizeUserId(userId), [userId]);\n\n // Privacy-label-neutral device snapshot, collected once per mount (no advertising IDs, no\n // fingerprinting — see device/deviceContext.ts). `collectDeviceContext` already carries a\n // best-effort auto-detected `appVersion`; an explicit host `config.appVersion` overrides it.\n // Attached to BOTH the A2A session metadata and every client event so the backend can segment\n // the funnel by device (and by app version).\n const device = useMemo<DeviceContext>(() => {\n const collected = collectDeviceContext();\n return config.appVersion ? { ...collected, appVersion: config.appVersion } : collected;\n }, [config.appVersion]);\n\n // Stable serialization of `userContext`. Hosts pass it INLINE (`userContext={{ … }}`, the\n // documented usage), so the raw object identity changes every render. Feeding that raw object\n // into the `llm` / `clientContext` memos below would make them unstable, and wireai-rn recreates\n // its A2A adapter whenever the llmConfig identity changes — the adapter ctor resets `contextId`\n // (node_modules/wireai-rn: `this.contextId = void 0`), so the server-learned session id is\n // dropped and correlation breaks. We key both memos on the JSON string (compared by value) and\n // reuse ONE normalized reference in the metadata + client-event paths.\n const userContextKey = userContext ? JSON.stringify(userContext) : \"\";\n const userContextStable = useMemo<Record<string, string | number | boolean> | undefined>(\n () => (userContextKey ? (JSON.parse(userContextKey) as Record<string, string | number | boolean>) : undefined),\n [userContextKey],\n );\n\n // The context payload shared by the A2A metadata + client-event paths. `userContext` +\n // `userId` are host-injected and forwarded verbatim (the server sanitizes them). Omitted keys\n // stay absent, so `dropped`/`client_fallback` events carry the user id when it's known.\n const clientContext = useMemo(\n () => ({ device, userContext: userContextStable, userId: boundUserId }),\n [device, userContextStable, boundUserId],\n );\n // One stable session id per onboarding SESSION (not per mount). It's used as the\n // client event `session_id` AND forwarded to the backend as `metadata.sessionId` so\n // the server can adopt it as the A2A `contextId` — making client-reported events\n // (`dropped`) correlate to the same session the server keys its own events by. See\n // the SDK-correlation note in analytics/reportClientEvent.ts.\n //\n // Without `storage`: minted synchronously per mount (the original behavior).\n // With `storage`: hydrated from the host-injected storage BEFORE the provider mounts\n // (loader-gate below), so an app KILL mid-onboarding resumes the SAME backend session\n // instead of minting a new one — which would count a phantom second `started` + a\n // false \"drop\" in the analytics funnel. See session/persistedSession.ts.\n const [session, setSession] = useState<LoadedSession | null>(() =>\n storage ? null : { id: makeSessionId(), resumed: false },\n );\n const storageKey = persistKey ?? sessionStorageKey(config.appId);\n\n useEffect(() => {\n if (!storage || session) return;\n // StrictMode/dev double-effect safe: the cancel flag drops the stale resolution.\n // Dev-only caveat: on a brand-new first mint, StrictMode's double-invoke can persist\n // then read the id back, surfacing a spurious `resumed: true`. Production is unaffected\n // (double-invoke is dev-only) and it self-heals on the next mount.\n let cancelled = false;\n void loadPersistedSession(storage, storageKey, sessionTtlMs).then((loaded) => {\n if (!cancelled) setSession(loaded);\n });\n return () => {\n cancelled = true;\n };\n }, [storage, storageKey, sessionTtlMs, session]);\n\n // By DEFAULT, clear the cached id the moment the flow completes, so the next onboarding on\n // this device starts a fresh session. Dropped/degraded paths deliberately do NOT clear —\n // a dropped session must stay resumable within the TTL.\n //\n // OPT-IN (`retainSessionOnComplete`): a multi-stage / replay-after-complete signup re-enters\n // (often via a `key=` remount) WITHIN one signup. If we cleared, that re-entry would find no\n // seed and mint a fresh `metadata.sessionId` → a phantom second `session_started` on the same\n // funnel. When the host opts in, we LEAVE the seed in place so the re-entry resumes the SAME\n // session (one funnel start); freshness for a genuinely new run then rides the TTL (past\n // `sessionTtlMs` → fresh mint) and an explicit new-run signal (a changed `persistKey`).\n // `shouldClearOnComplete` is the pure, unit-tested seam; the `storage` guard is unchanged, so a\n // host that does not opt in lands on the byte-for-byte legacy clear-on-complete path.\n const handleComplete = useCallback(\n (result: OnboardingResult) => {\n if (storage && shouldClearOnComplete(retainSessionOnComplete)) clearPersistedSession(storage, storageKey);\n onComplete(result);\n },\n [storage, storageKey, retainSessionOnComplete, onComplete],\n );\n\n const sessionId = session?.id ?? \"\";\n\n // Session-start snapshot of the bound user id. It seeds the A2A `metadata.userId` so the\n // adapter is built ONCE with whatever id was known at session start. A mid-session userId\n // change must NOT flow through this memo — recreating `llm` recreates the A2A adapter,\n // whose ctor resets `contextId` (see the userContext note above) and drops the server-\n // learned session id. Later changes ride EXCLUSIVELY on the `identify` effect below, which\n // mutates the live session in place. `useRef` captures the first-render value once.\n const startupUserIdRef = useRef<string | undefined>(boundUserId);\n\n // Build the A2A LocalLLMConfig from the friendlier kit config. The backend\n // resolves the app from the API key, so `model` (appId) is informational.\n const metadataKey = config.metadata ? JSON.stringify(config.metadata) : \"\";\n const metadataStable = useMemo(() => (metadataKey ? JSON.parse(metadataKey) : undefined), [metadataKey]);\n const componentNamesKey = (components ?? onboardingComponents).map((c) => c.name).join(\",\");\n const componentsStable = useMemo(() => components ?? onboardingComponents, [componentNamesKey]);\n\n const llm = useMemo<LocalLLMConfig>(() => {\n const baseUrl = config.serverUrl.replace(/\\/$/, \"\");\n return {\n provider: \"a2a\",\n baseUrl: `${baseUrl}/a2a`,\n model: config.appId,\n apiKey: config.apiKey,\n // Carry the kit session id alongside any host attribution so it reaches the A2A\n // request's `params.metadata` (the correlation seed; see note above), plus the\n // names of the components this device can actually render — so the backend only\n // emits cards the kit knows how to draw.\n metadata: {\n ...metadataStable,\n sessionId,\n supportedComponents: componentsStable.map((c) => c.name),\n // Device snapshot + host-injected user context ride the session-start metadata so the\n // backend can segment the funnel. Old servers ignore these unknown keys (backward compat).\n device,\n ...(userContextStable ? { userContext: userContextStable } : {}),\n // The session-start user id (from the ref) rides the session-start metadata so the\n // server binds the session to a real user at creation. Reading the ref — not\n // `boundUserId` — keeps this memo off the userId dependency, so a mid-session change\n // does NOT recreate the adapter; it's bound by the `identify` effect below instead.\n ...(startupUserIdRef.current ? { userId: startupUserIdRef.current } : {}),\n },\n timeoutMs: 60_000,\n };\n }, [config.serverUrl, config.appId, config.apiKey, metadataStable, sessionId, componentsStable, device, userContextStable]);\n\n // Where client-reported events are POSTed (`/v1/events`). Same tenant creds as the flow.\n const reportTarget = useMemo<ClientEventTarget>(\n () => ({ serverUrl: config.serverUrl, apiKey: config.apiKey }),\n [config.serverUrl, config.apiKey],\n );\n\n // LATE BINDING (mid-session): the user often registers DURING onboarding. When `userId`\n // becomes known (or changes) after the session already started, emit an `identify` client\n // event that attaches the id to the LIVE session, so the backend can map this in-flight\n // session to the real user. On a FRESH mount the initial id already rode the session-start\n // metadata, so we seed the \"already bound\" ref with it and only react to later CHANGES. On a\n // RESUMED session the server-side record predates this mount and won't re-read start metadata,\n // so we leave the seed empty to force an identify when a userId is present. Fire-and-forget.\n const identifiedRef = useRef<string | undefined>(undefined);\n const identifySeededRef = useRef(false);\n useEffect(() => {\n if (!session || !sessionId) return;\n if (!identifySeededRef.current) {\n identifySeededRef.current = true;\n identifiedRef.current = session.resumed ? undefined : boundUserId;\n }\n if (!boundUserId || boundUserId === identifiedRef.current) return;\n identifiedRef.current = boundUserId;\n reportClientEvent(reportTarget, {\n event_type: \"identify\",\n session_id: sessionId,\n user_id: boundUserId,\n });\n }, [session, sessionId, boundUserId, reportTarget]);\n\n const cards = components ?? onboardingComponents;\n\n // Loader-gate (hydration approach A): hold the entire provider subtree until the\n // stored id resolves. `sessionId` is a dependency of the `llm` memo above, so mounting\n // the provider with a throwaway id and swapping later would re-init it mid-flight.\n // The read is timeout-capped in loadPersistedSession, so this gate is one storage\n // read (~a frame), never an indefinite hold.\n if (!session) {\n return (\n <OnboardingThemeProvider theme={theme}>\n <LoadingScreen\n title={copy?.restoringTitle ?? DEFAULT_COPY.restoringTitle}\n hint={copy?.restoringHint ?? DEFAULT_COPY.restoringHint}\n />\n </OnboardingThemeProvider>\n );\n }\n\n return (\n <OnboardingThemeProvider theme={theme}>\n <IllustrationProvider registry={{ ...defaultIllustrations, ...illustrations }}>\n <IconRegistryProvider registry={icons}>\n <WireAIProvider llm={llm} components={cards}>\n <OnboardingFlow\n validators={validators}\n onComplete={handleComplete}\n onSkip={onSkip}\n onError={onError}\n onEvent={onEvent}\n copy={copy}\n approxScreens={approxScreens}\n startMessage={startMessage}\n startTimeoutMs={startTimeoutMs}\n fallbackFlow={fallbackFlow}\n maxRetries={maxRetries}\n reportTarget={reportTarget}\n sessionId={sessionId}\n resumed={session.resumed}\n clientContext={clientContext}\n />\n </WireAIProvider>\n </IconRegistryProvider>\n </IllustrationProvider>\n </OnboardingThemeProvider>\n );\n};\n","/**\n * DemoOnboarding — a drop-in dev/QA trigger that runs the onboarding flow ON\n * DEMAND in a modal, then closes. No loop, no account, no navigation side-effects:\n * re-runnable infinitely with the same logged-in user. Place it anywhere a host\n * wants (e.g. a __DEV__ row in Settings). If `config` is null (the app hasn't\n * integrated Wire AI yet), it shows a hint instead of the flow.\n *\n * {__DEV__ && (\n * <DemoOnboarding config={wireConfigFromEnv({ appId: \"my-app\" })} theme={myTheme} />\n * )}\n *\n * It does NOT persist by default (a demo, not a real run) — pass `onComplete` if\n * you want to observe the captured answers.\n */\nimport { useCallback, useMemo, useState, type ReactNode } from \"react\";\nimport { Modal, Pressable, StyleSheet, Text, View } from \"react-native\";\n\nimport { WireOnboarding } from \"./WireOnboarding\";\nimport { mergeTheme } from \"./theme/defaultTheme\";\nimport type { OnboardingTheme } from \"./theme/types\";\nimport type { OnboardingResult, WireOnboardingConfig, WireOnboardingProps } from \"./types\";\n\nexport type DemoOnboardingProps = {\n /** The Wire AI config, or `null` when the app hasn't integrated Wire AI yet. */\n config: WireOnboardingConfig | null;\n theme?: WireOnboardingProps[\"theme\"];\n illustrations?: WireOnboardingProps[\"illustrations\"];\n validators?: WireOnboardingProps[\"validators\"];\n copy?: WireOnboardingProps[\"copy\"];\n /** Trigger button label. Default \"Demo onboarding\". */\n label?: string;\n /** Observe the demo result. By default the demo just closes (no persistence). */\n onComplete?: (result: OnboardingResult) => void;\n /** Render your own trigger instead of the default button: `(open) => <YourButton onPress={open} />`. */\n renderTrigger?: (open: () => void) => ReactNode;\n};\n\nexport function DemoOnboarding({\n config,\n theme,\n illustrations,\n validators,\n copy,\n label = \"Demo onboarding\",\n onComplete,\n renderTrigger,\n}: DemoOnboardingProps) {\n const [open, setOpen] = useState(false);\n const [runId, setRunId] = useState(0);\n const t = useMemo(() => mergeTheme(theme ?? {}), [theme]);\n const styles = useMemo(() => makeStyles(t), [t]);\n\n const openDemo = useCallback(() => {\n setRunId((n) => n + 1); // remount WireOnboarding → a fresh A2A session each open\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n const finish = useCallback(\n (result: OnboardingResult) => {\n onComplete?.(result);\n setOpen(false);\n },\n [onComplete],\n );\n\n return (\n <>\n {renderTrigger ? (\n renderTrigger(openDemo)\n ) : (\n <Pressable onPress={openDemo} style={styles.trigger} accessibilityRole=\"button\">\n <Text style={styles.triggerText}>{label}</Text>\n </Pressable>\n )}\n\n <Modal\n visible={open}\n animationType=\"slide\"\n presentationStyle=\"fullScreen\"\n onRequestClose={close}\n >\n <View style={styles.modal}>\n {config ? (\n <WireOnboarding\n key={runId}\n config={config}\n theme={theme}\n illustrations={illustrations}\n validators={validators}\n copy={copy}\n onComplete={finish}\n onSkip={close}\n onError={close}\n />\n ) : (\n <View style={styles.notice}>\n <Text style={styles.noticeTitle}>Wire AI not configured</Text>\n <Text style={styles.noticeBody}>\n Set the Wire AI key + server URL (e.g. via wireConfigFromEnv) to demo the AI\n onboarding here.\n </Text>\n <Pressable onPress={close} style={styles.trigger} accessibilityRole=\"button\">\n <Text style={styles.triggerText}>Close</Text>\n </Pressable>\n </View>\n )}\n </View>\n </Modal>\n </>\n );\n}\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n trigger: {\n backgroundColor: t.colors.primary,\n borderRadius: t.button.radius,\n paddingVertical: 14,\n paddingHorizontal: 20,\n alignItems: \"center\",\n },\n triggerText: { color: t.colors.onPrimary, fontFamily: t.fonts.medium, fontSize: 16 },\n modal: { flex: 1, backgroundColor: t.colors.background },\n notice: { flex: 1, alignItems: \"center\", justifyContent: \"center\", padding: 24, gap: 12 },\n noticeTitle: { color: t.colors.text, fontFamily: t.fonts.bold, fontSize: 20 },\n noticeBody: {\n color: t.colors.textMuted,\n fontFamily: t.fonts.regular,\n fontSize: 15,\n textAlign: \"center\",\n },\n });\n}\n","/**\n * themeFromBrand — the fastest path to a branded flow. Give it a primary brand\n * color (and optionally a background + a font), and it derives a sensible full\n * `Partial<OnboardingTheme>` over the neutral `defaultOnboardingTheme` (via\n * `mergeTheme`): a tinted soft wash for selected states, a readable on-primary\n * label, and matching success/info accents left at the neutral default.\n *\n * theme={themeFromBrand({ primary: \"#15B0B0\" })}\n *\n * It stays intentionally small: it only touches the values that flow from a brand\n * color. Anything else (radius, spacing, button shape) keeps the default; pass\n * `extra` to override those without re-authoring the palette.\n */\nimport { defaultOnboardingTheme, mergeTheme } from \"./defaultTheme\";\nimport type { OnboardingTheme } from \"./types\";\n\nexport type ThemeFromBrandInput = {\n /** Brand / accent color — drives selected states, primary buttons, progress fill. */\n primary: string;\n /** App background behind the whole flow. Default: the neutral light background. */\n background?: string;\n /** Card / elevated surface background. Default: the neutral surface. */\n surface?: string;\n /** Primary body text color. Default: the neutral near-black. */\n text?: string;\n /** Text/icon color on top of `primary`. Default: white. */\n onPrimary?: string;\n /**\n * A single font family applied to regular/medium/bold (the kit derives weight\n * from size when a family isn't weight-split). Pass `fonts` in `extra` for\n * per-weight families.\n */\n font?: string;\n /** Any further theme overrides, deep-merged last (radius/spacing/button/fonts/colors). */\n extra?: Partial<OnboardingTheme>;\n};\n\n/** Parse a #RGB or #RRGGBB hex into [r,g,b]; returns null for anything else (e.g. rgba()). */\nconst hexToRgb = (hex: string): [number, number, number] | null => {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());\n if (!m) return null;\n let h = m[1] as string;\n if (h.length === 3) h = h[0]! + h[0]! + h[1]! + h[1]! + h[2]! + h[2]!;\n const int = parseInt(h, 16);\n return [(int >> 16) & 255, (int >> 8) & 255, int & 255];\n};\n\n/** A low-alpha wash of the primary for selected backgrounds, falling back gracefully. */\nconst softFromPrimary = (primary: string): string => {\n const rgb = hexToRgb(primary);\n if (!rgb) return defaultOnboardingTheme.colors.primarySoft;\n const [r, g, b] = rgb;\n return `rgba(${r},${g},${b},0.10)`;\n};\n\nexport const themeFromBrand = (input: ThemeFromBrandInput): Partial<OnboardingTheme> => {\n const { primary, background, surface, text, onPrimary, font, extra } = input;\n\n const derived: Partial<OnboardingTheme> = {\n colors: {\n ...defaultOnboardingTheme.colors,\n primary,\n primarySoft: softFromPrimary(primary),\n onPrimary: onPrimary ?? defaultOnboardingTheme.colors.onPrimary,\n ...(background ? { background } : {}),\n ...(surface ? { surface } : {}),\n ...(text ? { text } : {}),\n },\n ...(font\n ? {\n fonts: {\n ...defaultOnboardingTheme.fonts,\n regular: font,\n medium: font,\n bold: font,\n },\n }\n : {}),\n };\n\n // mergeTheme resolves the derived palette over the neutral default into a full\n // theme. Then deep-merge `extra` per sub-object so callers can override\n // radius/spacing/button/fonts/colors without re-authoring the palette.\n const base = mergeTheme(derived);\n if (!extra) return base;\n return {\n colors: { ...base.colors, ...extra.colors },\n fonts: { ...base.fonts, ...extra.fonts },\n radius: { ...base.radius, ...extra.radius },\n spacing: { ...base.spacing, ...extra.spacing },\n button: { ...base.button, ...extra.button },\n };\n};\n","/**\n * DoneBlock — a brief themed \"all set\" state shown when the flow completes, while\n * the host persists results and navigates away. Purely cosmetic; the real\n * terminal signal is the SDK's StatusCard (handled in OnboardingFlow).\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\n\nexport type DoneBlockProps = {\n title?: string;\n message?: string;\n};\n\nconst _DoneBlock: React.FC<DoneBlockProps> = ({\n title = \"You're all set\",\n message = \"Personalizing your experience…\",\n}) => {\n const t = useOnboardingTheme();\n return (\n <View style={[styles.center, { gap: t.spacing.sm, padding: t.spacing.lg }]}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.success, textAlign: \"center\" }]}>\n {title}\n </Text>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n </View>\n );\n};\n\nexport const DoneBlock = React.memo(_DoneBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * centeredModalMotion - the pure entrance spec for the content-agnostic CenteredModal shell.\n *\n * WHY split out: the shell UI (CenteredModal) is RN and cannot run under the kit's node:test\n * runner, but the entrance math is pure and worth pinning. Keep the animation spec here so both\n * the component and the tests read one source, and so any module (reviews, questionnaire) can\n * reuse the shell without depending on another feature module.\n *\n * The centered popup uses RN's built-in `Animated` (native driver), the same idiom as\n * CompletionView/CardHandoff, so the shell stays dependency-free (no reanimated).\n *\n * NOTE: `reviews/presentation.ts` re-exports these under their original names\n * (`REVIEW_MODAL_ANIM`, `entranceFrame`) for back-compat with the reviews public API.\n */\n\n/**\n * The entrance spec for the centered popup. Values chosen to match the boilerplate's\n * `animated-modal` feel (a springy zoom-in) with the kit's own native-driver idiom:\n * • backdrop fades 0 -> `backdropOpacity`\n * • card springs from `scaleFrom` -> 1 and fades 0 -> 1\n */\nexport const CENTERED_MODAL_ANIM = {\n /** Spring config for the card scale/opacity entrance (mirrors CompletionView's pop). */\n enterSpring: { friction: 7, tension: 80 },\n /** Exit timing in ms (fade + shrink back out before unmount). */\n exitMs: 160,\n /** Card scale at rest (progress 0); grows to 1 at progress 1. */\n scaleFrom: 0.9,\n /** Peak dim of the backdrop at progress 1. */\n backdropOpacity: 0.55,\n} as const;\n\n/** A single frame of the entrance, for a progress value in [0..1] (clamped). Pure, testable. */\nexport const centeredModalFrame = (\n progress: number,\n backdropMax: number = CENTERED_MODAL_ANIM.backdropOpacity,\n): { cardOpacity: number; cardScale: number; backdropOpacity: number } => {\n const p = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const { scaleFrom } = CENTERED_MODAL_ANIM;\n return {\n cardOpacity: p,\n cardScale: scaleFrom + (1 - scaleFrom) * p,\n backdropOpacity: backdropMax * p,\n };\n};\n","/**\n * CenteredModal - the content-agnostic centered-popup shell.\n *\n * Renders its children as an alert-style card in the MIDDLE of the screen, over a dimmed\n * backdrop, with a spring/fade entrance. It knows nothing about what it presents: the reviews\n * gate uses it (via the `ReviewModal` back-compat re-export) and the questionnaire module reuses\n * the same shell, neither depends on the other.\n *\n * Adapted from the mobile-launcher boilerplate's `animated-modal` (transparent RN Modal +\n * centered container + backdrop-tap dismiss + content stop-propagation + springy zoom-in), but\n * reimplemented on RN's built-in `Animated` (native driver) so the shell stays dependency-free:\n * the boilerplate uses react-native-reanimated, which the kit does not.\n *\n * Dismissal (backdrop tap / Android back / the imperative `close()` handle) animates the card\n * out, then fires `onDismiss`. It never auto-closes on resolve: the host keeps the card showing\n * whatever payoff it wants (a thank-you, a summary) until the user taps the backdrop to close,\n * exactly like CompletionView.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { Animated, BackHandler, Easing, Modal, Pressable, StyleSheet } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\n\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { REDUCED_FADE_MS } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\nimport { CENTERED_MODAL_ANIM } from \"../motion/centeredModalMotion\";\n\n/** Imperative handle so an in-card \"Not now\"/\"Skip\" link can trigger the exit animation. */\nexport type CenteredModalHandle = { close: () => void };\n\nexport type CenteredModalProps = {\n /** The (already merged) active theme - card surface/radius/spacing come from here. */\n theme: OnboardingTheme;\n /** Whether a backdrop tap / back press dismisses. Default true (never a dead end). */\n dismissible?: boolean;\n /** Fired once, AFTER the exit animation, on any dismiss. Wire to the host's resolve. */\n onDismiss: () => void;\n children: React.ReactNode;\n};\n\nconst _CenteredModal = forwardRef<CenteredModalHandle, CenteredModalProps>(\n ({ theme, dismissible = true, onDismiss, children }, ref) => {\n const progress = useRef(new Animated.Value(0)).current;\n const [open, setOpen] = useState(true);\n const closingRef = useRef(false);\n const reduced = useReducedMotion();\n\n // Entrance: spring the card in (scale + fade); the backdrop fades up in lock-step.\n // Reduce motion: a short fade to the settled card, no spring/scale.\n useEffect(() => {\n const anim = reduced\n ? Animated.timing(progress, {\n toValue: 1,\n duration: REDUCED_FADE_MS,\n useNativeDriver: true,\n })\n : Animated.spring(progress, {\n toValue: 1,\n useNativeDriver: true,\n friction: CENTERED_MODAL_ANIM.enterSpring.friction,\n tension: CENTERED_MODAL_ANIM.enterSpring.tension,\n });\n anim.start();\n return () => anim.stop();\n }, [progress, reduced]);\n\n const close = useCallback(() => {\n if (closingRef.current) return;\n closingRef.current = true;\n Animated.timing(progress, {\n toValue: 0,\n duration: reduced ? REDUCED_FADE_MS : CENTERED_MODAL_ANIM.exitMs,\n easing: Easing.in(Easing.cubic),\n useNativeDriver: true,\n }).start(() => {\n setOpen(false);\n onDismiss();\n });\n }, [progress, onDismiss, reduced]);\n\n useImperativeHandle(ref, () => ({ close }), [close]);\n\n // Android hardware back -> dismiss (when allowed). Always consume so it never pops a route.\n useEffect(() => {\n const sub = BackHandler.addEventListener(\"hardwareBackPress\", () => {\n if (dismissible) close();\n return true;\n });\n return () => sub.remove();\n }, [dismissible, close]);\n\n const onBackdrop = useCallback(() => {\n if (dismissible) close();\n }, [dismissible, close]);\n\n const backdropOpacity = progress.interpolate({\n inputRange: [0, 1],\n outputRange: [0, CENTERED_MODAL_ANIM.backdropOpacity],\n });\n // Reduce motion: the card fades in already settled (no zoom).\n const cardScale = reduced\n ? 1\n : progress.interpolate({\n inputRange: [0, 1],\n outputRange: [CENTERED_MODAL_ANIM.scaleFrom, 1],\n });\n\n return (\n <Modal\n visible={open}\n transparent\n animationType=\"none\"\n statusBarTranslucent\n onRequestClose={dismissible ? close : undefined}\n >\n {/* Dimmed backdrop (fades with the entrance). */}\n <Animated.View\n style={[styles.backdrop, { opacity: backdropOpacity }]}\n pointerEvents=\"none\"\n />\n\n {/* Full-screen tap target: a tap outside the card dismisses. */}\n <Pressable\n style={styles.fill}\n onPress={onBackdrop}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Dismiss\"\n >\n <SafeAreaView style={styles.center} pointerEvents=\"box-none\">\n {/* Inner Pressable swallows taps so the card itself never dismisses. */}\n <Pressable onPress={() => {}} style={styles.cardWrap}>\n <Animated.View\n accessibilityViewIsModal\n accessibilityRole=\"alert\"\n style={[\n styles.card,\n {\n backgroundColor: theme.colors.surface,\n borderRadius: theme.radius.lg,\n padding: theme.spacing.lg,\n gap: theme.spacing.md,\n opacity: progress,\n transform: [{ scale: cardScale }],\n },\n ]}\n >\n {children}\n </Animated.View>\n </Pressable>\n </SafeAreaView>\n </Pressable>\n </Modal>\n );\n },\n);\n\n_CenteredModal.displayName = \"CenteredModal\";\n\nexport const CenteredModal = React.memo(_CenteredModal);\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n backdrop: { position: \"absolute\", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: \"#000\" },\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\", padding: 24 },\n cardWrap: { width: \"100%\", maxWidth: 420 },\n card: {\n width: \"100%\",\n // Soft elevation so the popup reads as lifted above the app in both themes.\n shadowColor: \"#000\",\n shadowOffset: { width: 0, height: 8 },\n shadowOpacity: 0.28,\n shadowRadius: 24,\n elevation: 12,\n },\n});\n\nexport default CenteredModal;\n","/**\n * The fail-open defaults + a tolerant parser for the server's flags payload.\n *\n * THE CONTRACT: fail-open, never fail-dark. An absent server object, a missing module key, a\n * malformed value, or an unreachable endpoint must resolve to the MOST PERMISSIVE state — every\n * module ON, onboarding `ai` — so a control-plane outage can only ever be more permissive than\n * the dashboard intends. It can never dark a tenant's activation. Matches the server's own\n * documented fail-open default (FEATURES.md: \"local defaults — every module on, onboarding ai\").\n */\nimport type { OnboardingMode, WireFeatures } from \"./types\";\n\n/**\n * ALL ON, onboarding `ai`. Frozen + module-level so its reference is stable across every call\n * (consumers that list resolved flags in an effect dep array never loop on a fresh identity).\n */\nexport const defaultWireFeatures: WireFeatures = Object.freeze({\n coachmarks: Object.freeze({ enabled: true }),\n showcase: Object.freeze({ enabled: true }),\n onboarding: Object.freeze({ mode: \"ai\" as OnboardingMode }),\n review: Object.freeze({ enabled: true }),\n questionnaire: Object.freeze({ enabled: true }),\n announcements: Object.freeze({ enabled: true }),\n}) as WireFeatures;\n\nconst VALID_MODES: readonly OnboardingMode[] = [\"ai\", \"static\", \"off\"];\n\n/** Read a `{ enabled: boolean }` module, defaulting to ON when absent/malformed (fail-open). */\nconst readEnabled = (raw: unknown): { enabled: boolean } => {\n if (raw && typeof raw === \"object\" && typeof (raw as { enabled?: unknown }).enabled === \"boolean\") {\n return { enabled: (raw as { enabled: boolean }).enabled };\n }\n return { enabled: true };\n};\n\n/**\n * Narrow the server's (untrusted) JSON to a complete `WireFeatures`. Every field is filled with\n * its fail-open default when the server omits it or sends the wrong type, so a partial or\n * malformed payload degrades PERMISSIVELY rather than throwing. A non-object input (null, array,\n * string) → the full defaults. Never throws.\n */\nexport const parseWireFeatures = (raw: unknown): WireFeatures => {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return defaultWireFeatures;\n const src = raw as Record<string, unknown>;\n const modeRaw = (src.onboarding as { mode?: unknown } | undefined)?.mode;\n const mode: OnboardingMode =\n typeof modeRaw === \"string\" && VALID_MODES.includes(modeRaw as OnboardingMode)\n ? (modeRaw as OnboardingMode)\n : \"ai\";\n return {\n coachmarks: readEnabled(src.coachmarks),\n showcase: readEnabled(src.showcase),\n onboarding: { mode },\n review: readEnabled(src.review),\n questionnaire: readEnabled(src.questionnaire),\n announcements: readEnabled(src.announcements),\n };\n};\n\n/** Value-equality of two resolved flags — lets the hook hold a stable reference across churn. */\nexport const featuresEqual = (a: WireFeatures, b: WireFeatures): boolean =>\n a === b ||\n (a.coachmarks.enabled === b.coachmarks.enabled &&\n a.showcase.enabled === b.showcase.enabled &&\n a.onboarding.mode === b.onboarding.mode &&\n a.review.enabled === b.review.enabled &&\n a.questionnaire.enabled === b.questionnaire.enabled &&\n a.announcements.enabled === b.announcements.enabled);\n","/**\n * The last-known-flags cache — persisted through the host's optional `storage`.\n *\n * WHY: the fetch is best-effort and fail-open. When the control plane is unreachable we serve the\n * LAST value we saw rather than snapping to defaults, so a tenant that intentionally disabled a\n * module during an incident keeps it disabled across an outage instead of flapping back on. That\n * is \"stale-while-error\": a fresh cache (< TTL) is trusted, and on a fetch error even a STALE\n * cache is served (any age beats a guess). Every operation is best-effort — a broken/hung storage\n * degrades to defaults, never a throw and never a stuck gate (mirrors persistedSession).\n */\nimport { parseWireFeatures } from \"./defaults\";\nimport type { WireFeatures } from \"./types\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\n/**\n * TTL for a cached flags entry, aligned to the server's `Cache-Control: private, max-age=300`.\n * A cache younger than this is \"fresh\"; older is \"stale\" (still served on a fetch error).\n */\nexport const DEFAULT_FEATURES_TTL_MS = 300_000;\n\n/** Ceiling on the storage read so a hung adapter degrades to defaults, never a stuck resolve. */\nconst READ_TIMEOUT_MS = 1_500;\n\n/** Storage key for a tenant's cached flags, e.g. `wireai:features:acme`. */\nexport const featuresCacheKey = (appId?: string): string =>\n `wireai:features:${appId && appId.length > 0 ? appId : \"default\"}`;\n\n/** A cached flags entry: the resolved flags + the epoch-ms they were fetched. */\nexport interface CachedFeatures {\n features: WireFeatures;\n /** Age of the entry in ms at read time. */\n ageMs: number;\n}\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n/** Whether a cache entry is still within the TTL (server max-age aligned). */\nexport const isFeaturesFresh = (ageMs: number, ttlMs: number = DEFAULT_FEATURES_TTL_MS): boolean =>\n ageMs >= 0 && ageMs < ttlMs;\n\n/**\n * Read the cached flags for `key`, or `undefined` when absent/corrupt/timed-out. Returns the\n * value AND its age so a caller can apply a TTL (fresh) or ignore it (stale-while-error). Never\n * throws; never hangs past the read timeout. The stored value is re-parsed through\n * `parseWireFeatures`, so a partially-corrupt entry still degrades fail-open.\n */\nexport const readCachedFeatures = async (\n storage: WireOnboardingStorage,\n key: string,\n): Promise<CachedFeatures | undefined> => {\n let raw: string | null | undefined;\n try {\n raw = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);\n } catch {\n return undefined;\n }\n if (!raw) return undefined;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && typeof (parsed as { ts?: unknown }).ts === \"number\") {\n const ts = (parsed as { ts: number }).ts;\n return {\n features: parseWireFeatures((parsed as { features?: unknown }).features),\n ageMs: Date.now() - ts,\n };\n }\n } catch {\n // Corrupt entry → treat as absent; the caller falls back to defaults / a fresh fetch.\n }\n return undefined;\n};\n\n/** Persist `{ features, ts }` under `key` — fire-and-forget, all errors swallowed. */\nexport const writeCachedFeatures = (\n storage: WireOnboardingStorage,\n key: string,\n features: WireFeatures,\n): void => {\n try {\n void storage\n .setItem(key, JSON.stringify({ features, ts: Date.now() }))\n .catch(() => {});\n } catch {\n // Best-effort: a failed write just means the next launch has no cache to fall back to.\n }\n};\n","/**\n * fetchWireFeatures — read the per-module kill switches from `GET {serverUrl}/v1/features`.\n *\n * Contract (server: chohra-med/wireai-onboarding-server, routers/onboarding.py):\n * GET {serverUrl}/v1/features\n * Authorization: Bearer {apiKey}\n * 200 → { coachmarks:{enabled}, showcase:{enabled}, onboarding:{mode}, review:{enabled},\n * announcements:{enabled} } (Cache-Control: private, max-age=300)\n *\n * THE CONTRACT — fail-open, never fail-dark. Unreachable, timed-out, unauthorized (401),\n * server-error (5xx), or malformed JSON all resolve to the LAST CACHED value, else the\n * all-on defaults. No throw ever reaches the host: this is timeout-capped and swallows every\n * error, exactly like the session's best-effort reads. A control-plane outage can only ever be\n * MORE permissive than the dashboard intends — it can never dark a tenant's activation.\n */\nimport { readCachedFeatures, featuresCacheKey, writeCachedFeatures } from \"./cache\";\nimport { defaultWireFeatures, parseWireFeatures } from \"./defaults\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\nconst DEFAULT_TIMEOUT_MS = 4_000;\n\n/** The fail-open fallback: last cached value (any age — stale-while-error), else defaults. */\nconst failOpen = async (\n storage: WireOnboardingStorage | undefined,\n key: string,\n): Promise<WireFeatures> => {\n if (!storage) return defaultWireFeatures;\n const cached = await readCachedFeatures(storage, key);\n return cached?.features ?? defaultWireFeatures;\n};\n\n/** GET with a hard timeout via AbortController (falls back to no-abort where unsupported). */\nconst fetchWithTimeout = async (\n url: string,\n apiKey: string,\n timeoutMs: number,\n): Promise<Response> => {\n const controller =\n typeof AbortController !== \"undefined\" ? new AbortController() : undefined;\n const timer = setTimeout(() => controller?.abort(), timeoutMs);\n try {\n return await fetch(url, {\n method: \"GET\",\n headers: { Accept: \"application/json\", Authorization: `Bearer ${apiKey}` },\n signal: controller?.signal,\n });\n } finally {\n clearTimeout(timer);\n }\n};\n\n/**\n * Resolve the tenant's feature flags. Attempts the network once; on ANY failure returns the\n * cached value (any age), else the all-on defaults. On success, persists the fresh value to the\n * cache (fire-and-forget) and returns it. Never throws.\n *\n * const flags = await fetchWireFeatures({ serverUrl, apiKey, appId, storage });\n * if (!flags.coachmarks.enabled) { /* skip the tour * / }\n */\nexport const fetchWireFeatures = async (\n config?: WireFeaturesConfig,\n): Promise<WireFeatures> => {\n const key = featuresCacheKey(config?.appId);\n const storage = config?.storage;\n\n // Nothing to fetch (no creds) → cache, else defaults. Lets a host mount the provider before\n // its config is ready without ever darking.\n if (!config?.serverUrl || !config?.apiKey) return failOpen(storage, key);\n\n const url = `${config.serverUrl.replace(/\\/$/, \"\")}/v1/features`;\n const timeoutMs = config.timeoutMs && config.timeoutMs > 0 ? config.timeoutMs : DEFAULT_TIMEOUT_MS;\n\n try {\n const res = await fetchWithTimeout(url, config.apiKey, timeoutMs);\n // 401 (bad/rotated key), 5xx, any non-2xx → last-known, never dark.\n if (!res || !res.ok) return failOpen(storage, key);\n const json: unknown = await res.json(); // throws on malformed body → caught below\n const features = parseWireFeatures(json);\n if (storage) writeCachedFeatures(storage, key, features);\n return features;\n } catch {\n // Timeout/abort, network error, missing fetch, or malformed JSON — all fail open.\n return failOpen(storage, key);\n }\n};\n","/**\n * useWireFeatures — resolve the tenant's feature flags for a component tree, once per mount.\n *\n * Returns the all-on defaults immediately (fail-open), then swaps to the fetched value when the\n * network resolves. When no `serverUrl`+`apiKey` is supplied it never fetches and just returns\n * defaults, so a host that never adopts flags sees ZERO behavior change and ZERO network calls.\n *\n * frequent_rules #11 (unstable inline props): the config is idiomatically passed inline\n * (`config={{ serverUrl, apiKey }}`), a fresh identity every render. We stabilize the fetch key\n * by VALUE so the effect fires once per real credential change, and we only swap the returned\n * flags object when its VALUES change — so a host that lists the returned flags in an effect dep\n * array settles in a bounded number of commits instead of looping (enforced by the canary suite).\n */\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { defaultWireFeatures, featuresEqual } from \"./defaults\";\nimport { fetchWireFeatures } from \"./fetchWireFeatures\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\n\n/** Hold a stable reference for a value while its CONTENT is unchanged (see reviews/equality.ts). */\nconst useStableValue = <T,>(value: T, isEqual: (a: T, b: T) => boolean): T => {\n const ref = useRef(value);\n if (!isEqual(ref.current, value)) ref.current = value;\n return ref.current;\n};\n\n/** The credential slice that actually drives a refetch — stabilized by value. */\nconst sameFetchKey = (a: WireFeaturesConfig | undefined, b: WireFeaturesConfig | undefined): boolean =>\n a?.serverUrl === b?.serverUrl && a?.apiKey === b?.apiKey && a?.appId === b?.appId;\n\nexport const useWireFeatures = (config?: WireFeaturesConfig): WireFeatures => {\n const stableConfig = useStableValue(config, sameFetchKey);\n const [flags, setFlags] = useState<WireFeatures>(defaultWireFeatures);\n\n const canFetch = !!stableConfig?.serverUrl && !!stableConfig?.apiKey;\n\n useEffect(() => {\n if (!canFetch) {\n // No creds → stay on the all-on defaults (and reset if creds were removed).\n setFlags((prev) => (featuresEqual(prev, defaultWireFeatures) ? prev : defaultWireFeatures));\n return;\n }\n let alive = true;\n // fetchWireFeatures never throws — the .then always runs with a fail-open value.\n void fetchWireFeatures(stableConfig).then((next) => {\n if (!alive) return;\n // Only adopt a NEW reference on a real value change, so a host effect keyed on the\n // returned flags doesn't loop (frequent_rules #11).\n setFlags((prev) => (featuresEqual(prev, next) ? prev : next));\n });\n return () => {\n alive = false;\n };\n }, [canFetch, stableConfig]);\n\n return flags;\n};\n","/**\n * WireFeaturesProvider + useResolvedFeatures — the OPTIONAL one-fetch-serves-all-modules layer.\n *\n * Mount `WireFeaturesProvider` once near your app root with the tenant `config` and it fetches the\n * flags ONCE; every gated surface below it (coachmarks / showcase / reviews) reads the same\n * resolved value from context instead of each fetching its own. It is entirely optional: with no\n * provider, every surface falls back to its own lazy fetch (when given a config) or to the all-on\n * defaults, so modules work with zero setup and a host that never adopts flags is unchanged.\n *\n * NOTE on the built npm subpaths: React context is shared across the kit's subpath entries in the\n * SOURCE-consumption path (the monorepo apps) and in this test suite — one module instance, one\n * context. If you consume the built `@wireai/activation/*` subpaths as separate bundles, pass the\n * resolved flags (or a `featuresConfig`) to each surface explicitly instead of relying on context.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nimport { defaultWireFeatures } from \"./defaults\";\nimport { useWireFeatures } from \"./useWireFeatures\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\n\nconst CONTEXT_SYMBOL = Symbol.for(\"wireai.features.context\");\nconst globalObj = global as any;\n\nif (!globalObj[CONTEXT_SYMBOL]) {\n globalObj[CONTEXT_SYMBOL] = createContext<WireFeatures | null>(null);\n}\nconst WireFeaturesContext = globalObj[CONTEXT_SYMBOL];\n\nexport interface WireFeaturesProviderProps {\n /** Tenant creds (+ optional storage) to fetch the flags once for the whole tree. */\n config?: WireFeaturesConfig;\n /**\n * Pre-resolved flags to provide directly instead of fetching (e.g. you already have them, or\n * you drive them from your own remote-config). Takes precedence over `config`.\n */\n flags?: WireFeatures;\n children: React.ReactNode;\n}\n\n/**\n * Fetch (or accept) the flags once and broadcast them to descendants. The provider VALUE is\n * memoized (performance rule #6) so a fresh object each render doesn't re-render every consumer.\n */\nexport const WireFeaturesProvider: React.FC<WireFeaturesProviderProps> = ({\n config,\n flags,\n children,\n}) => {\n // Always call the hook (rules of hooks); when `flags` is supplied we pass no config so it\n // never fetches and the explicit flags win below.\n const fetched = useWireFeatures(flags ? undefined : config);\n const value = flags ?? fetched;\n const stable = useMemo(() => value, [value]);\n return <WireFeaturesContext.Provider value={stable}>{children}</WireFeaturesContext.Provider>;\n};\n\nWireFeaturesProvider.displayName = \"WireFeaturesProvider\";\n\n/** Raw context read — `null` when no `WireFeaturesProvider` is mounted above. */\nexport const useWireFeaturesContext = (): WireFeatures | null =>\n useContext(WireFeaturesContext);\n\n/** Options for `useResolvedFeatures`: an explicit override and/or a lazy-fetch config. */\nexport interface ResolveFeaturesOptions {\n /** Explicit flags — win over everything (a surface's own `features` prop). */\n flags?: WireFeatures;\n /** Lazy-fetch config, used ONLY when there is no explicit `flags` and no provider above. */\n config?: WireFeaturesConfig;\n}\n\n/**\n * The resolution every gated surface uses. Precedence:\n * 1. explicit `options.flags` (a surface's own prop) →\n * 2. the nearest `WireFeaturesProvider` (context) →\n * 3. a lazy fetch from `options.config` (serverUrl + apiKey) →\n * 4. the all-on defaults.\n * Always fail-open, always a stable reference for a given value (so it's safe in effect deps).\n */\nexport const useResolvedFeatures = (options?: ResolveFeaturesOptions): WireFeatures => {\n const ctx = useWireFeaturesContext();\n // Only lazily fetch when nothing else provides the flags — otherwise pass no config so the\n // hook stays inert (defaults, no network). The hook is always called (rules of hooks).\n const shouldFetch = !options?.flags && ctx == null;\n const fetched = useWireFeatures(shouldFetch ? options?.config : undefined);\n return options?.flags ?? ctx ?? fetched ?? defaultWireFeatures;\n};\n","/**\n * wireConfigFromEnv — stop re-authoring env gating in every app. Reads the Wire AI\n * tenant key + server URL from the standard Expo public env vars and returns a\n * ready `WireOnboardingConfig`, or `null` when the key/URL are missing (so a host\n * can fall through to a static onboarding without writing the `if (!key)` itself).\n *\n * EXPO_PUBLIC_WIREAI_API_KEY=... (required)\n * EXPO_PUBLIC_WIREAI_SERVER_URL=... (required)\n *\n * const config = wireConfigFromEnv({ appId: \"morrow\" });\n * if (!config) return <StaticOnboarding />;\n * return <WireOnboarding config={config} ... />;\n *\n * `appId` defaults to `EXPO_PUBLIC_WIREAI_APP_ID` (or \"default\"); pass overrides to\n * set `appId`/`metadata` or to substitute the key/URL programmatically.\n */\nimport type { WireOnboardingConfig } from \"../types\";\n\nexport type WireConfigOverrides = Partial<WireOnboardingConfig>;\n\n/**\n * Minimal `process.env` declaration so the kit stays RN-pure (no `@types/node`).\n * In RN/Expo, `process.env.EXPO_PUBLIC_*` is provided/inlined by Metro at build\n * time; we only read string env vars here.\n *\n * IMPORTANT: read each var via STATIC member access (`process.env.EXPO_PUBLIC_FOO`).\n * Expo's `babel-preset-expo` `inline-env-vars` plugin ONLY inlines static\n * `process.env.EXPO_PUBLIC_*` member expressions. Aliasing (`const env = process.env`)\n * or computed access (`process.env[name]`) is left `undefined` in the Metro bundle, so\n * the value reads fine in Jest (Node) but is null on a real device. Do not refactor\n * these to an alias.\n */\ndeclare const process: { env: Record<string, string | undefined> };\n\nexport const wireConfigFromEnv = (\n overrides?: WireConfigOverrides,\n): WireOnboardingConfig | null => {\n const apiKey = overrides?.apiKey ?? process.env.EXPO_PUBLIC_WIREAI_API_KEY;\n const serverUrl = overrides?.serverUrl ?? process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;\n const appId =\n overrides?.appId ?? process.env.EXPO_PUBLIC_WIREAI_APP_ID ?? \"default\";\n\n // Missing transport → null, so the host gates on one falsy check.\n if (!apiKey || !serverUrl) return null;\n\n return {\n apiKey,\n serverUrl,\n appId,\n ...(overrides?.metadata ? { metadata: overrides.metadata } : {}),\n };\n};\n","/**\n * isOnboardingEnabled — the ONE standard gate for AI onboarding, so every app stops\n * re-authoring `flag && hasConfig` (one app had `isAiOnboardingEnabled`, another had\n * `isWireBackendConfigured` — same idea, two shapes).\n *\n * The gate is **transport presence**: `wireConfigFromEnv()` is non-null (the key + URL are\n * set), and that is it. There is no separate on/off env flag — a missing key already means\n * \"off\", so a second `EXPO_PUBLIC_AI_ONBOARDING_ENABLED` flag was redundant (and, read via\n * computed access, it didn't even inline on device). An optional `remote` kill-switch lets an\n * app turn it off without a release; the kit stays dependency-free (the app owns the remote\n * read and hands us the boolean).\n *\n * Enabled ⇔ transport present AND `(remote ?? true)`.\n *\n * if (!isOnboardingEnabled()) return goToStaticOnboarding();\n * // or, with a remote kill-switch the app already read:\n * if (!isOnboardingEnabled({ remote: remoteKillSwitchOn })) return goToStaticOnboarding();\n */\nimport { wireConfigFromEnv } from \"./wireConfigFromEnv\";\nimport type { WireConfigOverrides } from \"./wireConfigFromEnv\";\n\nexport type OnboardingFlagOptions = {\n /**\n * Optional remote kill-switch the app already read (Firebase/LD/etc.). When `false`, it\n * disables onboarding even though transport is present. Omit (or `true`) to leave it on.\n */\n remote?: boolean;\n /**\n * Config overrides forwarded to `wireConfigFromEnv` for the transport-present check\n * (e.g. a programmatic `apiKey`/`serverUrl`). Usually omitted.\n */\n config?: WireConfigOverrides;\n};\n\nexport const isOnboardingEnabled = (opts?: OnboardingFlagOptions): boolean => {\n const transportPresent = wireConfigFromEnv(opts?.config) !== null;\n if (!transportPresent) return false;\n return opts?.remote ?? true;\n};\n","/**\n * Canonical analytics names for the onboarding funnel. The kit already emits a typed\n * `OnboardingEvent` (`started | turn | error | retry | fallback`) — but one app logged them as\n * `onboarding_*` and another as `AI_ONBOARDING_*`, so the same funnel reads differently per app.\n * This maps the kit event to ONE canonical `wire_onboarding_*` name + params, and the app logs\n * it through whatever transport it already has (Firebase, Amplitude, console). The app still\n * owns the logger; only the NAMES are standardized.\n *\n * <WireOnboarding\n * onEvent={(e) => { const a = toAnalyticsEvent(e); logEvent(a.name, a.params); }}\n * onComplete={(r) => { logEvent(WIRE_ONBOARDING_EVENTS.completed, { answers: Object.keys(r.answers).length }); persist(r); }}\n * />\n *\n * `completed` has no kit `OnboardingEvent` (the kit signals completion via `onComplete`, not\n * `onEvent`) — the app logs it explicitly on `onComplete` using the constant below, so the\n * funnel name stays canonical.\n */\nimport type { OnboardingEvent } from \"../types\";\n\nexport const WIRE_ONBOARDING_EVENTS = {\n started: \"wire_onboarding_started\",\n /** A persisted session was restored after an app kill (fires instead of `started`). */\n resumed: \"wire_onboarding_resumed\",\n turn: \"wire_onboarding_turn\",\n error: \"wire_onboarding_error\",\n retry: \"wire_onboarding_retry\",\n fallback: \"wire_onboarding_fallback\",\n /** Logged by the host on `onComplete` (no matching kit `OnboardingEvent`). */\n completed: \"wire_onboarding_completed\",\n} as const;\n\nexport type WireOnboardingEventName =\n (typeof WIRE_ONBOARDING_EVENTS)[keyof typeof WIRE_ONBOARDING_EVENTS];\n\nexport type AnalyticsEvent = {\n name: WireOnboardingEventName;\n params?: Record<string, unknown>;\n};\n\n/**\n * Map a kit `OnboardingEvent` to its canonical `{ name, params }`. Exhaustive over the union\n * (the `never` default makes a new event type a compile error here — intentional).\n */\nexport const toAnalyticsEvent = (event: OnboardingEvent): AnalyticsEvent => {\n switch (event.type) {\n case \"started\":\n return { name: WIRE_ONBOARDING_EVENTS.started };\n case \"resumed\":\n return { name: WIRE_ONBOARDING_EVENTS.resumed };\n case \"turn\":\n return {\n name: WIRE_ONBOARDING_EVENTS.turn,\n params: { step: event.step, component: event.component },\n };\n case \"error\":\n return { name: WIRE_ONBOARDING_EVENTS.error, params: { reason: event.reason } };\n case \"retry\":\n return {\n name: WIRE_ONBOARDING_EVENTS.retry,\n params: { reason: event.reason, attempt: event.attempt },\n };\n case \"fallback\":\n return { name: WIRE_ONBOARDING_EVENTS.fallback, params: { reason: event.reason } };\n default: {\n const _exhaustive: never = event;\n return _exhaustive;\n }\n }\n};\n","/**\n * attribution — forward install/ad attribution to the onboarding agent so it can tailor the\n * first question by acquisition source (e.g. a paid-campaign install vs an organic one). The\n * channel already exists: `WireOnboardingConfig.metadata` is merged into every A2A request by\n * `WireOnboarding`. No production app populated it before; this gives every app a standard shape.\n *\n * The app reads its raw attribution (AppsFlyer / Branch / deferred deep link — an app concern,\n * not the kit's) and passes the normalized result as `metadata`:\n *\n * const config = wireConfigFromEnv({\n * appId: \"morrow-self\",\n * metadata: attributionMetadata({ source: conv.mediaSource, campaign: conv.campaign, isOrganic: conv.isOrganic }),\n * });\n *\n * The backend sees `metadata.attribution = { source, campaign, ... }`.\n */\n\n/** Normalized acquisition attribution. All fields optional — pass what the SDK gives you. */\nexport type OnboardingAttribution = {\n /** Media source / network, e.g. \"appsflyer\", \"branch\", \"organic\". */\n source?: string;\n campaign?: string;\n adset?: string;\n ad?: string;\n /** Deferred deep-link slug / path that routed the install. */\n deepLink?: string;\n isFirstLaunch?: boolean;\n isOrganic?: boolean;\n /** Escape hatch for SDK-specific fields not covered above. */\n raw?: Record<string, unknown>;\n};\n\n/**\n * Wrap attribution into the `{ attribution: {...} }` metadata the agent reads. Drops `undefined`\n * fields so the request payload stays compact. Returns `{ attribution: {} }` for empty input\n * (still a valid, harmless metadata object).\n */\nexport const attributionMetadata = (\n a: OnboardingAttribution,\n): { attribution: Record<string, unknown> } => {\n const attribution: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(a)) {\n if (value !== undefined) attribution[key] = value;\n }\n return { attribution };\n};\n","/**\n * userContext — the ONE extensible object a host passes once and the kit flows into every\n * analytics event's `user_context` (plus the top-level opaque `user_id`).\n *\n * WHY it exists: hosts already hand the kit fragments of \"who this user is\" — `config.appVersion`,\n * `useSessionStart({ deviceKey, userId })`, `<WireOnboarding userContext={…} />` — but there was no\n * single object that carries app version + device key + user id + (opt-in) email + arbitrary extras\n * together, with one precedence rule, into every event. `WireUserContext` is that object;\n * `resolveUserContext` is the pure merge that turns it into the wire shape.\n *\n * PRECEDENCE (the one rule): an explicit `WireUserContext` field WINS over the #42 auto-detected\n * `device`/`appVersion`. A missing field is OMITTED, never sent empty.\n *\n * WHERE EACH FIELD LANDS (deliberate separation so nothing leaks across buckets):\n * • `userId` → the event's TOP-LEVEL opaque `user_id` (via `sanitizeUserId`). NEVER the bucket.\n * • `userEmail` → its OWN key `user_context.user_email`. NEVER merged into `userId`. OPT-IN PII.\n * • `deviceKey` → `user_context.device_key` (the server's `_event_device_key` reads it there).\n * • `appVersion`→ `user_context.app_version` (and returned as `appVersion` for `device.appVersion`).\n * • `extra` → NAMESPACED under a `custom.` key prefix, coerced to scalars, so a host extra can\n * never collide with a reserved `user_context` key.\n *\n * DEPENDENCY-FREE: the only import is the kit's own `sanitizeUserId`. The optional email hash is a\n * dependency-free FNV-1a fold (see {@link hashEmailFnv1a}) — no crypto library, no async.\n */\nimport { sanitizeUserId } from \"../identity/userIdentity\";\n\n/**\n * The single, extensible user-context object. A host passes it ONCE (at analytics init) and may\n * update it post-mount (e.g. attach `userId`/`userEmail` at login) via `setUserContext(partial)`.\n * Every field is optional; missing fields are omitted from the wire payload.\n */\nexport interface WireUserContext {\n /**\n * Host app version, e.g. \"1.4.2\". EXPLICIT — wins over the #42 auto-detected `device.appVersion`.\n * Lands in `user_context.app_version`. Omitted when neither this nor auto-detect yields a version.\n */\n appVersion?: string;\n /**\n * A stable, non-PII device id the host owns. Lands in `user_context.device_key` (NOT `session_id`),\n * where the server groups a device's sessions. Host-supplied; the kit never mints or reads one.\n */\n deviceKey?: string;\n /**\n * The host's OPAQUE PSEUDONYMOUS user id (their internal id — NOT an email/name/phone). Sanitized +\n * capped (see `sanitizeUserId`) and placed on the event's top-level `user_id`. NEVER the bucket.\n */\n userId?: string;\n /**\n * OPT-IN PII. The user's email, its OWN field (`user_context.user_email`) — NEVER merged into\n * `userId`. The kit NEVER auto-collects this; a host passes it only WITH the user's consent (EU\n * users: treat as personal data). For a non-reversible form, set {@link hashEmail} `true` (the kit\n * folds it with a dependency-free hash and stamps `user_context.user_email_hashed: true`), OR\n * pre-hash host-side with a cryptographic digest and pass that here with `hashEmail` falsy.\n */\n userEmail?: string;\n /**\n * When `true`, {@link userEmail} is folded with the kit's dependency-free {@link hashEmailFnv1a}\n * before it leaves the device, and `user_context.user_email_hashed` is set `true`. NOTE: FNV-1a is\n * a lightweight NON-cryptographic fold (obfuscation, not a secure digest). For a cryptographic\n * hash, compute it host-side (e.g. SHA-256 via `expo-crypto`) and pass the digest as `userEmail`\n * with `hashEmail` falsy. Default: raw email is sent as-is (opt-in already gated it upstream).\n */\n hashEmail?: boolean;\n /**\n * Arbitrary host context (signup method, referral, plan tier…). Each value is coerced to a scalar\n * (`string | number | boolean`; non-scalars and non-finite numbers are DROPPED) and NAMESPACED\n * under a `custom.` key prefix in `user_context` (e.g. `user_context[\"custom.referral\"]`) so it can\n * never collide with a reserved key. No raw PII — use {@link userEmail} for email.\n */\n extra?: Record<string, string | number | boolean>;\n}\n\n/**\n * The wire-shaped result of {@link resolveUserContext}. `userContext` is the non-PII/opt-in-PII\n * bucket stamped onto the event; `userId` is the top-level opaque id; `appVersion`/`deviceKey` are\n * echoed for callers that also place them elsewhere (e.g. `device.appVersion`). Absent fields are\n * omitted so a caller can spread this without sending empties.\n */\nexport interface ResolvedUserContext {\n /** The opaque, sanitized user id → the event's top-level `user_id`. Omitted when unset/blank. */\n userId?: string;\n /** The stable device id → `user_context.device_key`. Omitted when unset. */\n deviceKey?: string;\n /** The effective app version (explicit > auto-detected) → `user_context.app_version`. */\n appVersion?: string;\n /** The `user_context` bucket (device_key, app_version, user_email[+ _hashed], custom.*). */\n userContext?: Record<string, string | number | boolean>;\n}\n\n/** Reserved `user_context` keys the kit itself writes; host `extra` is namespaced away from these. */\nexport const RESERVED_USER_CONTEXT_KEYS = [\n \"device_key\",\n \"app_version\",\n \"app_build\",\n \"network_type\",\n \"session_count\",\n \"returning\",\n \"platform\",\n \"user_email\",\n \"user_email_hashed\",\n] as const;\n\n/** The prefix applied to every host `extra` key so it can never collide with a reserved key. */\nexport const EXTRA_KEY_PREFIX = \"custom.\" as const;\n\n/** A finite scalar the wire accepts. Non-finite numbers (NaN/Infinity) are NOT scalars here. */\nexport const isWireScalar = (value: unknown): value is string | number | boolean => {\n const t = typeof value;\n if (t === \"string\" || t === \"boolean\") return true;\n if (t === \"number\") return Number.isFinite(value as number);\n return false;\n};\n\n/**\n * Fold an email to a stable, dependency-free 32-bit FNV-1a hex token (lowercased + trimmed first so\n * the same address always folds identically). This is OBFUSCATION, not a cryptographic digest — it\n * is not collision-resistant. For a real hash, pre-hash host-side and pass the digest as `userEmail`.\n */\nexport const hashEmailFnv1a = (email: string): string => {\n const normalized = email.trim().toLowerCase();\n let hash = 0x811c9dc5; // FNV offset basis (32-bit)\n for (let i = 0; i < normalized.length; i++) {\n hash ^= normalized.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193); // FNV prime (32-bit), kept in 32-bit via imul\n }\n return (hash >>> 0).toString(16).padStart(8, \"0\");\n};\n\n/** Trim a candidate string; return `undefined` for a non-string / blank so callers can `if`-gate. */\nconst cleanString = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Coerce a host `extra` map into the namespaced, scalar-only bucket shape. Every kept value is\n * placed under `custom.<key>`; non-scalar values (objects, arrays, null, functions, NaN/Infinity)\n * are DROPPED. Returns an object (possibly empty).\n */\nexport const namespaceExtra = (\n extra: Record<string, unknown> | undefined,\n): Record<string, string | number | boolean> => {\n const out: Record<string, string | number | boolean> = {};\n if (!extra || typeof extra !== \"object\") return out;\n for (const [key, value] of Object.entries(extra)) {\n const cleanKey = cleanString(key);\n if (!cleanKey) continue;\n if (!isWireScalar(value)) continue; // drop anything that isn't a finite scalar\n out[`${EXTRA_KEY_PREFIX}${cleanKey}`] = value;\n }\n return out;\n};\n\n/** Options for {@link resolveUserContext}. */\nexport interface ResolveUserContextOptions {\n /**\n * The kit's best-effort auto-detected app version (#42; from `detectAppVersion()`/the device\n * snapshot). Used ONLY when the explicit `WireUserContext.appVersion` is absent — explicit wins.\n */\n autoAppVersion?: string;\n}\n\n/**\n * Merge a {@link WireUserContext} into the wire shape with the precedence rule (explicit field >\n * auto-detected). Pure, never throws. Missing fields are omitted so the result can be spread onto an\n * event without sending empties.\n */\nexport const resolveUserContext = (\n ctx: WireUserContext = {},\n opts: ResolveUserContextOptions = {},\n): ResolvedUserContext => {\n const result: ResolvedUserContext = {};\n const bucket: Record<string, string | number | boolean> = {};\n\n // userId → top-level opaque id (NEVER the bucket). Sanitized + capped host-side.\n const userId = sanitizeUserId(ctx.userId);\n if (userId) result.userId = userId;\n\n // deviceKey → user_context.device_key (NOT session_id).\n const deviceKey = cleanString(ctx.deviceKey);\n if (deviceKey) {\n result.deviceKey = deviceKey;\n bucket.device_key = deviceKey;\n }\n\n // appVersion → explicit wins over auto-detected (#42); echoed for device.appVersion callers.\n const appVersion = cleanString(ctx.appVersion) ?? cleanString(opts.autoAppVersion);\n if (appVersion) {\n result.appVersion = appVersion;\n bucket.app_version = appVersion;\n }\n\n // userEmail → its OWN key. OPT-IN PII, optionally folded. NEVER touches userId.\n const email = cleanString(ctx.userEmail);\n if (email) {\n if (ctx.hashEmail) {\n bucket.user_email = hashEmailFnv1a(email);\n bucket.user_email_hashed = true;\n } else {\n bucket.user_email = email;\n }\n }\n\n // extra → namespaced + scalar-coerced.\n Object.assign(bucket, namespaceExtra(ctx.extra));\n\n if (Object.keys(bucket).length > 0) result.userContext = bucket;\n return result;\n};\n","/**\n * deviceId — mint a stable, NON-PII, per-install device id the kit owns when the host supplies\n * none. This is the headline of \"device fully automatic\": the analytics façade auto-mints ONE id,\n * persists it via the host's `storage` abstraction, and reuses it on every subsequent open — so\n * `user_context.device_key` is ALWAYS present and the server's review/questionnaire gating +\n * A/B stickiness (both key on `device_key`) work out of the box, with zero host wiring.\n *\n * WHY it is NOT PII and adds NO dependency (the kit's hard rules):\n * The id is a random token generated from `Date.now()` + `Math.random()` — it carries NO hardware\n * identifier, NO IDFA/GAID, NO fingerprint. It is a first-party per-install correlation key, the\n * same privacy category as a first-party cookie: it groups a single install's sessions and cannot\n * identify a person or be joined across apps. There is NO `uuid` (or any) dependency — a\n * time+random scheme is sufficient because the id is minted ONCE and then persisted, so global\n * uniqueness across the fleet is not required (a per-install collision is astronomically unlikely\n * and inconsequential — worst case two installs share a bucket).\n *\n * A host that wants its OWN device id still wins: pass `WireUserContext.deviceKey` and the kit uses\n * that verbatim and never mints/persists an auto id.\n */\n\n/** Prefix so an auto-minted id is visibly the kit's (distinguishable from a host-supplied `deviceKey`). */\nexport const AUTO_DEVICE_ID_PREFIX = \"wdev_\";\n\n/** The storage key the façade persists the auto-minted id under (namespaced per `appId`). */\nexport const deviceIdStorageKey = (appId?: string): string =>\n `wireai:analytics:deviceKey:${appId ?? \"default\"}`;\n\n/** One 32-bit base-36 chunk of randomness. Two chunks are concatenated for a wider token. */\nconst randomChunk = (): string =>\n Math.floor(Math.random() * 0x100000000)\n .toString(36)\n .padStart(6, \"0\");\n\n/**\n * Mint a fresh per-install device id. Dependency-free (`Date.now()` + `Math.random()`), never\n * throws, and returns a NEW value on every call — the façade mints ONCE and persists, so this is\n * called at most once per install (then the persisted value is reused). Two random chunks plus the\n * timestamp keep the token wide enough that a per-install collision is not a practical concern.\n */\nexport const mintDeviceId = (): string => {\n const time = Date.now().toString(36);\n return `${AUTO_DEVICE_ID_PREFIX}${time}_${randomChunk()}${randomChunk()}`;\n};\n","/**\n * activation revalidation — a tiny kit-owned pub/sub the review / questionnaire decision fetches\n * subscribe to, so they RE-FETCH their server decision AFTER a trigger action, not only on mount.\n *\n * WHY THIS EXISTS (subsumes Morrow's hand-rolled `activation-revalidation.ts`): a host mounts the\n * review / questionnaire gate on the home screen and fetches its `/decision` verdict once, in a\n * mount-scoped effect. But the screen stays mounted while the user goes elsewhere to perform the\n * triggering action (journal a win, complete a task); the server's firing rule is trigger-based AND\n * session-scoped, so the mount fetch ran BEFORE the trigger event existed and never re-runs. Bumping\n * this store after the action POSTs re-runs the gate's decision fetch (it lists the version in its\n * deps) → the server now sees the trigger → `{fire:true}`.\n *\n * `wire.track()` bumps this automatically on a successful POST, so a consumer no longer hand-rolls\n * an await-then-bump: it subscribes (via {@link useActivationRevalidation} in `useWireActivation`)\n * and re-fetches when the version changes.\n *\n * ── WHY A globalThis SLOT, NOT MODULE-LOCAL STATE (same reasoning as currentSession) ─────────────\n * This module can be reached from more than one package entry (the main `.` barrel exposes the\n * revalidation surface; the gates live under the `./reviews` / `./questionnaire` subpaths). Under\n * `dist` resolution tsup inlines a SEPARATE copy of a module into each bundle, so plain module-local\n * `version` + `listeners` would give the BUMPER (main entry, via `wire.track`) and a SUBSCRIBER a\n * different store — the bump would never reach the listener, exactly the defect-B failure mode. So\n * the ONE store lives in a `globalThis` slot keyed by `Symbol.for(...)`: every inlined copy resolves\n * the same symbol and shares one store, on Hermes/RN, Node and SSR alike.\n */\n\n/** Well-known key into the runtime-global symbol registry — one shared store across every bundle. */\nconst REVALIDATION_SLOT: unique symbol = Symbol.for(\n \"@wireai/activation:activationRevalidation\",\n);\n\n/** The shared store: a monotonic version + the set of subscriber callbacks. */\ntype RevalidationStore = { version: number; listeners: Set<() => void> };\n\ntype GlobalWithSlot = typeof globalThis & {\n [REVALIDATION_SLOT]?: RevalidationStore;\n};\n\nconst globalSlot = globalThis as GlobalWithSlot;\n\n/** The one shared store, lazily created on the runtime global (never a second copy per bundle). */\nconst store = (): RevalidationStore => {\n const existing = globalSlot[REVALIDATION_SLOT];\n if (existing) return existing;\n const created: RevalidationStore = { version: 0, listeners: new Set() };\n globalSlot[REVALIDATION_SLOT] = created;\n return created;\n};\n\n/**\n * Signal every activation subscriber to re-fetch its server decision. `wire.track()` calls this on a\n * successful POST (await the post first so the re-fetch sees the event). A throwing subscriber never\n * breaks the notify loop — each listener is isolated.\n */\nexport const bumpActivationRevalidation = (): void => {\n const s = store();\n s.version += 1;\n // Iterate a snapshot so a listener that (un)subscribes during notify never corrupts the walk.\n for (const listener of Array.from(s.listeners)) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others (fail-safe).\n }\n }\n};\n\n/**\n * Subscribe to revalidation. Returns an unsubscribe fn. Shaped for `useSyncExternalStore`\n * (see {@link useActivationRevalidation} in `useWireActivation`).\n */\nexport const subscribeActivationRevalidation = (listener: () => void): (() => void) => {\n const s = store();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n};\n\n/** The current revalidation version — include it in a decision-fetch effect's deps to re-fetch on bump. */\nexport const getActivationRevalidationVersion = (): number => store().version;\n\n/** Test-only: reset the shared store between cases (clears version + listeners). */\nexport const resetActivationRevalidation = (): void => {\n const s = store();\n s.version = 0;\n s.listeners.clear();\n};\n","/**\n * wireActivation — the kit-owned `wire.track()` + session accessor + revalidation surface.\n *\n * WHAT IT CONSOLIDATES (subsumes Morrow's workarounds): a consumer used to hand-roll three things\n * because the kit didn't own them — an awaitable action POST (`wireTrackActionAwait`), its OWN\n * per-open session id (`getWireSessionId`, minted because the kit's `getCurrentSessionId` desynced\n * cross-bundle — defect B), and an await-then-bump revalidation dance (`bumpActivationDecision`).\n * Defect B is fixed (PR #48: `getCurrentSessionId` is a `globalThis` singleton, reliable under\n * `dist`), so the kit can now own all three behind one thin surface:\n *\n * const wire = createWireActivation({ serverUrl, apiKey }); // or useWireActivation(...)\n * await wire.track(\"journal_done\"); // awaitable POST + auto-revalidate\n *\n * `track` POSTs `event_type='app_event'`, `question_key=<name>` (the EXACT string a review /\n * questionnaire firing TRIGGER matches on) under the CURRENT `getCurrentSessionId()` — the same id\n * the gates pass to their `/decision` fetch, so the server's session-scoped trigger rule agrees —\n * with `user_context.device_key` for the min-sessions / arm-assignment lookups. On a successful POST\n * it bumps decision revalidation so a subscribed gate re-fetches and can fire.\n *\n * ADDITIVE + built on existing primitives: it reuses the events transport\n * (`reportClientEventAwait`, the awaitable sibling of `reportClientEvents` — ONE `/v1/events` path)\n * and `getCurrentSessionId` — it introduces NO second session concept and duplicates no POST path.\n * React-free (the optional React glue is the thin `useWireActivation` hook).\n */\nimport { getCurrentSessionId } from \"../analytics/currentSession\";\nimport {\n reportClientEventAwait,\n type ClientEvent,\n type ClientEventTarget,\n} from \"../analytics/reportClientEvent\";\nimport { deviceIdStorageKey, mintDeviceId } from \"../context/deviceId\";\nimport { resolveUserContext, type WireUserContext } from \"../context/userContext\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport {\n bumpActivationRevalidation,\n getActivationRevalidationVersion,\n subscribeActivationRevalidation,\n} from \"./revalidation\";\n\n/** Trim a candidate string; return `undefined` for a non-string / blank so callers can `if`-gate. */\nconst clean = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Tenant transport + context inputs for {@link createWireActivation}. `serverUrl`/`apiKey` are the\n * SAME creds as onboarding (never a second key); everything else is optional.\n */\nexport type WireActivationConfig = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n /**\n * A stable, non-PII device id → `user_context.device_key` (the server's review/questionnaire\n * gating + A/B stickiness key on it). When omitted, the kit auto-mints ONE per-install id, persists\n * it via `storage` when given, and reuses it — so `device_key` is ALWAYS present. Host-supplied wins.\n */\n deviceKey?: string;\n /**\n * Optional rich context stamped onto every tracked event's `user_context` (opaque `userId` →\n * top-level `user_id`, opt-in `userEmail`, namespaced `extra`). `deviceKey` here is equivalent to\n * the top-level one (top-level wins). Same shape the analytics façade accepts.\n */\n userContext?: WireUserContext;\n /** Tenant/app id — namespaces the auto-minted device-key storage slot. */\n appId?: string;\n /** Host app version → `user_context.app_version` when no explicit `userContext.appVersion` is set. */\n appVersion?: string;\n /** Host persistence (AsyncStorage-compatible subset) so the auto-minted device key survives launches. */\n storage?: WireOnboardingStorage;\n};\n\n/** The kit-owned activation surface. `sessionId` is a live getter (reads `getCurrentSessionId()`). */\nexport type WireActivation = {\n /**\n * Awaitable action report: POST `event_type='app_event'`, `question_key=<name>`, optional `meta`,\n * under the CURRENT session id + `user_context.device_key`. Resolves `true` once the server has\n * stored it (2xx) and THEN bumps decision revalidation; resolves `false` (no bump) when there is no\n * current session, a blank name, or the POST fails. Never throws.\n */\n track(name: string, meta?: Record<string, unknown>): Promise<boolean>;\n /** The CURRENT per-open session id (the kit's canonical `getCurrentSessionId()`), or `undefined`. */\n readonly sessionId: string | undefined;\n /** Subscribe to decision revalidation (bumped by a successful `track`). Returns an unsubscribe fn. */\n subscribeRevalidation(listener: () => void): () => void;\n /** The current revalidation version — include in a decision-fetch effect's deps to re-fetch on bump. */\n getRevalidationVersion(): number;\n};\n\n/**\n * Create a bound activation instance for a tenant transport. Resolves the device key once (explicit >\n * `userContext.deviceKey` > auto-minted + persisted). Pure + React-free.\n */\nexport const createWireActivation = (config: WireActivationConfig): WireActivation => {\n const target: ClientEventTarget = { serverUrl: config.serverUrl, apiKey: config.apiKey };\n\n // Device key: an explicit id (top-level or in userContext) wins and is never overwritten; otherwise\n // auto-mint ONE and persist via storage (reused every open) so `device_key` is always present.\n const explicitDeviceKey = clean(config.deviceKey) ?? clean(config.userContext?.deviceKey);\n let autoDeviceKey = explicitDeviceKey ?? mintDeviceId();\n if (config.storage && !explicitDeviceKey) {\n const storage = config.storage;\n const key = deviceIdStorageKey(config.appId);\n void storage\n .getItem(key)\n .then((saved) => {\n const persisted = clean(saved ?? undefined);\n if (persisted) autoDeviceKey = persisted;\n else void storage.setItem(key, autoDeviceKey).catch(() => {});\n })\n .catch(() => {});\n }\n\n // Stamp the resolved rich context onto the event: `user_context` bucket (device_key always, plus any\n // app_version / opt-in user_email / namespaced extra) and the top-level opaque `user_id`.\n const applyContext = (event: ClientEvent): void => {\n const resolved = resolveUserContext(\n { ...(config.userContext ?? {}), deviceKey: explicitDeviceKey ?? autoDeviceKey },\n { autoAppVersion: config.appVersion },\n );\n if (resolved.userContext) {\n event.user_context = { ...resolved.userContext, ...(event.user_context ?? {}) };\n }\n if (resolved.userId && !event.user_id) event.user_id = resolved.userId;\n };\n\n const track = async (name: string, meta?: Record<string, unknown>): Promise<boolean> => {\n const sessionId = getCurrentSessionId();\n // No current session (no app-open registered yet) or a blank name → nothing to correlate; bail\n // WITHOUT bumping (a bump with no posted event would only make the gate re-fetch for nothing).\n if (!clean(name) || !sessionId) return false;\n const event: ClientEvent = {\n event_type: \"app_event\",\n session_id: sessionId,\n question_key: name,\n };\n if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);\n applyContext(event);\n const ok = await reportClientEventAwait(target, event);\n // Only revalidate once the event is actually in the stream — a failed POST leaves the gate as-is.\n if (ok) bumpActivationRevalidation();\n return ok;\n };\n\n return {\n track,\n get sessionId() {\n return getCurrentSessionId();\n },\n subscribeRevalidation: subscribeActivationRevalidation,\n getRevalidationVersion: getActivationRevalidationVersion,\n };\n};\n","/**\n * useWireActivation — a THIN optional React hook over {@link createWireActivation}.\n *\n * One import gives a consumer everything the activation consolidation owns: `track` (awaitable POST\n * that auto-revalidates), the CURRENT `sessionId`, and a `revalidation` counter that ticks whenever\n * a `track()` (from anywhere) succeeds — subscribe to re-render, then re-fetch your gate decision.\n *\n * const { track, sessionId, revalidation } = useWireActivation({ serverUrl, apiKey });\n * // fetch the gate decision on mount AND whenever revalidation ticks:\n * useEffect(() => { fetchReviewDecision(target, { sessionId, deviceKey }).then(setDecision); },\n * [revalidation]);\n * // on the trigger action:\n * await track(\"journal_done\");\n *\n * Mirrors the existing `createAnalytics` / `useAnalytics` (and `createScreenTracker` /\n * `useScreenTracking`) split: the factory stays React-free; this is the glue. The instance is built\n * once per mount and held in a ref, so re-renders never rebuild it or re-resolve the device key.\n */\nimport { useRef, useSyncExternalStore } from \"react\";\n\nimport {\n getActivationRevalidationVersion,\n subscribeActivationRevalidation,\n} from \"./revalidation\";\nimport {\n createWireActivation,\n type WireActivation,\n type WireActivationConfig,\n} from \"./wireActivation\";\n\n/**\n * Subscribe a component to decision revalidation. Returns the current version; list it in a\n * decision-fetch effect's deps so a `bumpActivationRevalidation()` (which a successful `track` does)\n * re-runs the fetch. The kit-owned replacement for a host's hand-rolled `useActivationRevalidation`.\n */\nexport const useActivationRevalidation = (): number =>\n useSyncExternalStore(\n subscribeActivationRevalidation,\n getActivationRevalidationVersion,\n getActivationRevalidationVersion,\n );\n\n/** What {@link useWireActivation} returns: the awaitable `track`, the live `sessionId`, and the tick. */\nexport type UseWireActivation = {\n /** Awaitable action report that auto-revalidates on success (see {@link WireActivation.track}). */\n track: WireActivation[\"track\"];\n /** The CURRENT per-open session id (read fresh each render), or `undefined`. */\n sessionId: string | undefined;\n /** Monotonic counter that increments on every successful `track()` — a re-fetch trigger. */\n revalidation: number;\n};\n\n/**\n * Build a per-mount activation instance. `config` is read once at first render (the instance is\n * stable for the component's lifetime, keyed on the transport creds + device key); the returned\n * `revalidation` re-renders the component whenever any `track()` succeeds.\n */\nexport const useWireActivation = (config: WireActivationConfig): UseWireActivation => {\n const ref = useRef<WireActivation | undefined>(undefined);\n const prevKeys = useRef<string>(\"\");\n\n const currentKeys = `${config.serverUrl}|${config.apiKey}|${config.appId}|${config.deviceKey}`;\n if (!ref.current || prevKeys.current !== currentKeys) {\n prevKeys.current = currentKeys;\n ref.current = createWireActivation(config);\n }\n\n const revalidation = useActivationRevalidation();\n return { track: ref.current.track, sessionId: ref.current.sessionId, revalidation };\n};\n","/**\n * reportSessionStart — the ONE standard emitter for \"the user opened the app again\".\n *\n * Every app-open posts a single `app.session_started` event to the Wire analytics backend\n * (`POST {serverUrl}/v1/events`). That event does two jobs at once, with ZERO server changes:\n *\n * 1. SESSION MAPPING. It carries the host's opaque `userId` + a stable `deviceKey`, so the\n * backend can group a user's (or a pre-auth device's) opens over time — \"when did this\n * user last use the app, and how many times\". The device_key links the pre-auth opens to\n * the user once `userId` arrives (here or via `identifyOnboarding`).\n * 2. QUESTIONNAIRE / RETENTION FIRING. It flows into the SAME event stream the server's\n * decision engines read, so a questionnaire trigger `{event:\"app.session_started\", min_count:N}`\n * (matched within a session) or a questionnaire `min_sessions:N` (distinct device sessions)\n * fires on the user's Nth open with no new server endpoint.\n *\n * WIRE CONTRACT (server: analytics/events.py + routers/onboarding.py `POST /v1/events`):\n * The event is stored as `event_type='app_event'`, `question_key='app.session_started'` — the\n * generic app.* namespace the reviews wave shipped. The server's `_event_name(ev)` returns the\n * `question_key` for an `app_event`, which is what a trigger's `event` string matches. We do NOT\n * send `event_type:'app.session_started'` — that name is not in the server's EVENT_TYPES and\n * would be rejected. `device_key` rides in the non-PII `user_context` bucket, where the server's\n * `_event_device_key(ev)` reads it to group a device's sessions. `app_id` + `environment` are\n * filled server-side from the resolving key (never sent here).\n *\n * SESSION ID DISTINCTION (important): the `session_id` on this event is a PER-OPEN id (a fresh\n * `makeSessionId()` each app-open) — it is NOT the onboarding A2A `contextId`. Onboarding runs\n * ONCE (first launch) and owns its own context id; session-start fires on EVERY open, so it needs\n * its own per-open id. Grouping over time is done by `device_key`/`user_id`, not by session_id.\n *\n * Fire-and-forget: like every analytics path in the kit, this never throws into the UI, never\n * awaits, and swallows a missing target / bad URL / missing fetch / network error. Analytics must\n * never be able to break the app.\n */\nimport { setCurrentSessionId } from \"../analytics/currentSession\";\nimport { makeSessionId, type ClientEvent, type ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport type { DeviceContext } from \"../device/deviceContext\";\nimport { sanitizeUserId } from \"../identity/userIdentity\";\n\n/** The canonical event name for an app-open. A trigger keys off this exact string. */\nexport const SESSION_STARTED_EVENT = \"app.session_started\" as const;\n\n/** Options for {@link reportSessionStart}. Everything except `target` is optional so a pre-auth\n * open (no user yet) is a valid, device-only session. */\nexport interface ReportSessionStartOptions {\n /** Where to POST — the tenant transport (`serverUrl` + `apiKey`), same as `WireOnboardingConfig`. */\n target: ClientEventTarget | undefined;\n /**\n * The per-open session id. Defaults to a fresh `makeSessionId()`. Pass your own ONLY to\n * dedupe re-renders of the same open (the {@link useSessionStart} hook does exactly that).\n * This is NOT the onboarding contextId — see the file header.\n */\n sessionId?: string;\n /** The host's OPAQUE pseudonymous user id (their internal id, NOT an email/PII). Sanitized +\n * capped here; omitted on a pre-auth open (device-only session). */\n userId?: string;\n /** A stable, non-PII device id the host owns. Rides in `user_context.device_key` so the server\n * groups this device's sessions (the min_sessions signal). Host-supplied, same as reviews. */\n deviceKey?: string;\n /** The host's own local open-counter value for this open (1 on the first ever open). Drives the\n * `returning` flag and lets analytics read \"Nth session\" without server-side counting. */\n sessionCount?: number;\n /** Host app version (e.g. \"1.4.2\"), if cheaply available. Segments retention by release. */\n appVersion?: string;\n /** Platform string (e.g. \"ios\"), if cheaply available. */\n platform?: string;\n /** An optional richer device snapshot (from `collectDeviceContext()`); the hook fills this. */\n device?: DeviceContext;\n /** Small non-PII extras, stored as a JSON string in the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to bypass the once-per-open guard (default on). See {@link resetSessionStartGuard}. */\n once?: boolean;\n /**\n * OPTIONAL transport sink. When provided, the built `app.session_started` event is routed HERE\n * (e.g. the offline-first event queue's `enqueue`) INSTEAD of this emitter's own direct `fetch`,\n * while KEEPING the once-per-open guard above. This is how the lifecycle wiring\n * (`useLifecycleEvents` / `wireLifecycleEvents`) offline-buffers session-start WITHOUT adding a\n * second session emitter: one emitter, one guard, now durable. Omit it for the direct-POST path.\n * A throwing sink is swallowed — analytics must never surface into the UI.\n */\n sink?: (event: ClientEvent) => void;\n}\n\n// ── Once-per-open guard ──────────────────────────────────────────────────────\n// A re-render (or a host that lists the emitter in an effect) must never double-fire the SAME\n// open. We remember the session ids already emitted; a repeat call with a seen id is a no-op.\n// Bounded so a long-lived app never grows this unboundedly — a fresh open always mints a fresh\n// id, so evicting old ids can never cause a real re-fire.\nconst _emitted = new Set<string>();\nconst _GUARD_MAX = 128;\n\n/** Test-only: forget every emitted session id so a unit test starts from a clean guard. */\nexport const resetSessionStartGuard = (): void => {\n _emitted.clear();\n};\n\n/**\n * Emit one `app.session_started` event for this app-open. Fire-and-forget; returns immediately.\n * Idempotent per `sessionId` (unless `once:false`) so a re-render can never double-fire.\n */\nexport const reportSessionStart = (opts: ReportSessionStartOptions): void => {\n const target = opts.target;\n // A wired sink is a valid transport on its own — it owns the target (the queue's serverUrl), so\n // this emitter needs its own `target` ONLY for the direct-fetch fallback.\n if (!opts.sink && !target?.serverUrl) return;\n\n const sessionId = opts.sessionId ?? makeSessionId();\n\n // Register this open as the CURRENT per-open session so the analytics façade's `identify` /\n // app-events reuse the id the server sees here (via `app.session_started`) instead of minting a\n // fresh one it would back-fill into a phantom session. Idempotent; set before the once-guard so\n // even a guard-deduped repeat keeps the current id pointing at this open.\n setCurrentSessionId(sessionId);\n\n // Once-per-open guard: skip a repeat emit for a session id we already sent.\n if (opts.once !== false) {\n if (_emitted.has(sessionId)) return;\n if (_emitted.size >= _GUARD_MAX) {\n // Evict the oldest insertion (Set preserves insertion order).\n const oldest = _emitted.values().next().value;\n if (oldest !== undefined) _emitted.delete(oldest);\n }\n _emitted.add(sessionId);\n }\n\n try {\n // Non-PII correlation bucket. device_key is read by the server to group a device's sessions;\n // session_count / returning / app_version / platform feed per-user retention analytics.\n const userContext: Record<string, string | number | boolean> = {};\n if (opts.deviceKey) userContext.device_key = opts.deviceKey;\n if (typeof opts.sessionCount === \"number\" && Number.isFinite(opts.sessionCount)) {\n userContext.session_count = opts.sessionCount;\n userContext.returning = opts.sessionCount > 1;\n }\n if (opts.appVersion) userContext.app_version = opts.appVersion;\n if (opts.platform) userContext.platform = opts.platform;\n\n const event: Record<string, unknown> = {\n event_type: \"app_event\",\n question_key: SESSION_STARTED_EVENT,\n session_id: sessionId,\n };\n const userId = sanitizeUserId(opts.userId);\n if (userId) event.user_id = userId;\n if (Object.keys(userContext).length > 0) event.user_context = userContext;\n if (opts.device) event.device = opts.device;\n if (opts.meta && Object.keys(opts.meta).length > 0) event.meta = JSON.stringify(opts.meta);\n\n // Preferred transport: an injected sink (the offline-first event queue's `enqueue`), which\n // buffers + persists + retries. The once-guard above already ran, so this stays the single\n // session emitter with a single guard — now durable.\n if (opts.sink) {\n opts.sink(event as ClientEvent);\n return;\n }\n\n // Fallback: this emitter's own direct POST when no sink is wired.\n if (!target?.serverUrl) return;\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n void fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ events: [event] }),\n }).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // URL construction, JSON serialization, a throwing sink, or a missing fetch — swallow.\n }\n};\n","/**\n * useSessionStart — the optional convenience hook that fires {@link reportSessionStart} for you.\n *\n * Two firing moments, mirroring the reference apps' session-counter semantics:\n * • ON MOUNT — the app opened (cold start or the provider first rendered).\n * • ON FOREGROUND after a real background — when AppState returns to `active` having been\n * backgrounded for at least {@link BACKGROUND_SESSION_MS} (30 min), that's a NEW open, so a\n * fresh session fires. A quick app-switch (under the threshold) does NOT count as a new open.\n *\n * Each firing mints its OWN per-open `session_id` (held in a ref so a re-render never re-fires),\n * so grouping over time is by `deviceKey`/`userId`, never by session_id (see reportSessionStart).\n *\n * The hook is OPTIONAL. A host that already owns a session counter (most hosts do) can skip\n * the hook and call `reportSessionStart(...)` directly from its own \"app opened\" path — BOTH\n * paths are first-class. This hook is the batteries-included option for a host that has none.\n *\n * Dependency policy: `AppState` + `Platform` are React Native built-ins (no new dep); the device\n * snapshot comes from the kit's own dependency-free `collectDeviceContext()`.\n */\nimport { useEffect, useRef } from \"react\";\nimport { AppState, Platform, type AppStateStatus } from \"react-native\";\n\nimport type { ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport { collectDeviceContext } from \"../device/deviceContext\";\nimport { reportSessionStart } from \"./reportSessionStart\";\n\n/** A foreground after at least this long in the background counts as a NEW app-open (30 min). */\nexport const BACKGROUND_SESSION_MS = 30 * 60 * 1000;\n\n/** Tenant transport + optional host app version. Same creds as `WireOnboardingConfig`. */\nexport interface SessionStartConfig {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl?: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey?: string;\n /** Host app version (e.g. \"1.4.2\"), forwarded for release segmentation. Optional. */\n appVersion?: string;\n}\n\n/** Per-open identity the host supplies. All optional: a pre-auth open is device-only. */\nexport interface UseSessionStartOptions {\n /** The host's opaque pseudonymous user id (NOT PII). Omitted before the user authenticates. */\n userId?: string;\n /** The host's local open-counter value for this open. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** A stable, non-PII device id the host owns. Groups this device's sessions server-side. */\n deviceKey?: string;\n /** Small non-PII extras forwarded on the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to disable firing (e.g. behind a consent gate). Default enabled. */\n enabled?: boolean;\n}\n\n/**\n * Fire `app.session_started` on mount and on every real foreground-after-background. Returns\n * nothing — it is a side-effecting hook. Safe to call with inline options (values are read\n * through a ref, so changing `userId`/`sessionCount` never re-fires a session).\n */\nexport const useSessionStart = (\n config: SessionStartConfig | undefined,\n options: UseSessionStartOptions = {},\n): void => {\n // Latest options/config through a ref so the mount/resume fires read fresh values without\n // listing them as effect deps (which would re-fire a session on every prop change).\n const latest = useRef({ config, options });\n latest.current = { config, options };\n\n useEffect(() => {\n const fire = () => {\n const { config: cfg, options: opts } = latest.current;\n if (!cfg?.serverUrl) return;\n if (opts.enabled === false) return;\n const target: ClientEventTarget = { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" };\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg.appVersion) device.appVersion = cfg.appVersion;\n reportSessionStart({\n target,\n // A fresh per-open id each fire; the emitter's once-guard dedupes within the open.\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n };\n\n // 1) Mount = an app-open.\n fire();\n\n // 2) Foreground after a real background = a new app-open.\n let backgroundedAt: number | null = null;\n const onChange = (state: AppStateStatus) => {\n if (state === \"background\" || state === \"inactive\") {\n // Record the first moment we left the foreground (don't overwrite inactive→background).\n if (backgroundedAt == null) backgroundedAt = Date.now();\n return;\n }\n if (state === \"active\") {\n const since = backgroundedAt;\n backgroundedAt = null;\n if (since != null && Date.now() - since >= BACKGROUND_SESSION_MS) fire();\n }\n };\n const sub = AppState.addEventListener(\"change\", onChange);\n return () => {\n // RN >= 0.65 returns a subscription with remove(); guard for older shims.\n if (sub && typeof (sub as { remove?: () => void }).remove === \"function\") sub.remove();\n };\n // Mount-only effect: firing reads fresh values via `latest`, so no reactive deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n","/**\n * lifecycle — the TOP-OF-FUNNEL app lifecycle events that sit ABOVE onboarding: `app.first_open`\n * (once ever per install) and `app.session_started` (per app-open). They compose with, and never\n * duplicate, the events the funnel already records.\n *\n * WHERE THIS FITS (one funnel, no double counting):\n * • `app.first_open` → THIS module, once ever (persisted flag). The in-app \"install\" proxy.\n * • `app.session_started` → the EXISTING {@link reportSessionStart} emitter (per app-open). This\n * module REUSES it (routed through the offline queue), never re-emits.\n * • onboarding started / completed / activated → ALREADY recorded: the server writes\n * `session_started` + `completed` during the A2A flow, and the client reports `dropped` /\n * `client_fallback` / `identify` via `reportClientEvent`. This module does NOT touch them —\n * emitting them here would double-count. It only ADDS the two lifecycle events above them.\n *\n * WIRE CONTRACT (identical to `app.session_started`): both lifecycle events are stored as\n * `event_type='app_event'` with the name in `question_key` (the server's `_event_name` returns\n * `question_key` for an `app_event`, which a trigger matches). `app.first_open` uses the SAME\n * `app.*` namespace + the SAME event shape as `app.session_started` — no bespoke `event_type`,\n * no invented contract. `device_key` rides in the non-PII `user_context` bucket; `app_id` +\n * `environment` are filled server-side.\n *\n * TWO FIRST-CLASS ENTRY POINTS (mirrors reportSessionStart vs useSessionStart):\n * • `reportFirstOpen(...)` / `wireLifecycleEvents(...)` — pure, React-free, for a host that owns\n * its own app-open path.\n * • `useLifecycleEvents(...)` — the batteries-included React hook (in `useLifecycleEvents.ts`).\n *\n * OFFLINE-FIRST: pass the Brief-01 event queue's `enqueue` as the `sink` and every lifecycle event\n * is buffered + persisted + retried instead of a blind fetch. Without a sink they degrade to a\n * direct fire-and-forget POST.\n *\n * PRIVACY (hard rule, same as the rest of the kit): NO GPS/location, NO advertising id. Nothing\n * here carries a coordinate or an ad id — a host adopting it changes no store privacy declaration.\n *\n * FIRE-AND-FORGET: like every analytics path in the kit, nothing here throws into the UI, awaits\n * in the caller, or hangs the app — storage reads race a short timeout, writes swallow errors.\n */\nimport { makeSessionId, type ClientEvent, type ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport type { DeviceContext } from \"../device/deviceContext\";\nimport { sanitizeUserId } from \"../identity/userIdentity\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport { reportSessionStart, SESSION_STARTED_EVENT } from \"./reportSessionStart\";\n\n/** The canonical event name for the first-ever app open. Same `app.*` namespace as\n * {@link SESSION_STARTED_EVENT}; a trigger keys off this exact string. */\nexport const FIRST_OPEN_EVENT = \"app.first_open\" as const;\n\n/** Storage key for the once-ever first-open flag, e.g. `wireai:first_open:acme`. Mirrors the\n * `wireai:<concern>:<appId>` namespacing of {@link sessionStorageKey}. */\nexport const firstOpenStorageKey = (appId: string): string => `wireai:first_open:${appId}`;\n\n/** Ceiling on the flag read — a hung adapter degrades to the in-memory latch, never a stuck gate. */\nconst READ_TIMEOUT_MS = 1_500;\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n// ── First-open in-memory latch ───────────────────────────────────────────────\n// Covers TWO cases the persisted flag can't: (1) two near-simultaneous calls in one process (the\n// flag read is async, so a synchronous latch is what guarantees at-most-one before any await), and\n// (2) the documented DEGRADED no-storage mode (fires once per process). Keyed by appId.\nconst _firstOpenLatched = new Set<string>();\n\n/** Test-only: forget the first-open latch so a unit test starts from a clean process state. */\nexport const resetFirstOpenLatch = (): void => {\n _firstOpenLatched.clear();\n};\n\n/** Shared inputs for a lifecycle event. Everything is optional except a transport (`target` for the\n * direct-POST fallback, or a `sink`). A pre-auth open (no user yet) is a valid device-only event. */\nexport interface LifecycleEventInput {\n /** Where to POST if no `sink` is wired (the tenant transport, same as `WireOnboardingConfig`). */\n target?: ClientEventTarget;\n /** Preferred transport: route the built event HERE (the offline queue's `enqueue`). */\n sink?: (event: ClientEvent) => void;\n /** The per-open session id. Defaults to a fresh `makeSessionId()`. */\n sessionId?: string;\n /** The host's OPAQUE pseudonymous user id (NOT PII). Sanitized + capped; omitted pre-auth. */\n userId?: string;\n /** A stable, non-PII device id the host owns. Rides in `user_context.device_key`. */\n deviceKey?: string;\n /** The host's local open-counter value. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** Host app version (e.g. \"1.4.2\"), if cheaply available. */\n appVersion?: string;\n /** Platform string (e.g. \"ios\"), if cheaply available. */\n platform?: string;\n /** An optional richer device snapshot (from `collectDeviceContext()`); the hook fills this. */\n device?: DeviceContext;\n /** Small non-PII extras, stored as a JSON string in the event `meta`. */\n meta?: Record<string, unknown>;\n}\n\n/** Options for {@link reportFirstOpen}. Adds the once-ever persistence inputs on top of the shared\n * lifecycle inputs. Without `storage` it degrades to the in-memory latch (once per process). */\nexport interface ReportFirstOpenOptions extends LifecycleEventInput {\n /** Host persistence (AsyncStorage subset). The once-ever flag lives here — it is what survives an\n * app kill. Omit it for the documented degraded (in-memory, once-per-process) mode. */\n storage?: WireOnboardingStorage;\n /** Tenant/app id — namespaces the persisted flag (`wireai:first_open:<appId>`). */\n appId?: string;\n}\n\n/**\n * Build the `app_event` payload shared by `app.first_open` and `app.session_started`. This is a\n * BYTE-FOR-BYTE mirror of the field logic in {@link reportSessionStart} — same `event_type`, same\n * `question_key`-as-name contract, same `user_context` bucket, same optional fields — so the two\n * lifecycle events are one contract with two names. Do NOT let these diverge (see lifecycle.test).\n */\nconst buildLifecycleEvent = (questionKey: string, opts: LifecycleEventInput): Record<string, unknown> => {\n const userContext: Record<string, string | number | boolean> = {};\n if (opts.deviceKey) userContext.device_key = opts.deviceKey;\n if (typeof opts.sessionCount === \"number\" && Number.isFinite(opts.sessionCount)) {\n userContext.session_count = opts.sessionCount;\n userContext.returning = opts.sessionCount > 1;\n }\n if (opts.appVersion) userContext.app_version = opts.appVersion;\n if (opts.platform) userContext.platform = opts.platform;\n\n const event: Record<string, unknown> = {\n event_type: \"app_event\",\n question_key: questionKey,\n session_id: opts.sessionId ?? makeSessionId(),\n };\n const userId = sanitizeUserId(opts.userId);\n if (userId) event.user_id = userId;\n if (Object.keys(userContext).length > 0) event.user_context = userContext;\n if (opts.device) event.device = opts.device;\n if (opts.meta && Object.keys(opts.meta).length > 0) event.meta = JSON.stringify(opts.meta);\n return event;\n};\n\n/** Route a built event to the wired sink, else a direct fire-and-forget POST. Never throws. */\nconst routeLifecycleEvent = (event: Record<string, unknown>, opts: LifecycleEventInput): void => {\n try {\n if (opts.sink) {\n opts.sink(event as ClientEvent);\n return;\n }\n const target = opts.target;\n if (!target?.serverUrl) return;\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n void fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ events: [event] }),\n }).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // A throwing sink, URL/JSON error, or a missing fetch — swallow.\n }\n};\n\nconst emitFirstOpen = (opts: ReportFirstOpenOptions): void => {\n routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);\n};\n\n/**\n * Emit `app.first_open` EXACTLY ONCE EVER per install. Fire-and-forget; returns immediately.\n *\n * • With `storage`: reads the persisted flag (`wireai:first_open:<appId>`). Absent → emit, then\n * write the flag (survives app kills, so a second launch is a no-op). Present → no-op.\n * • Race guard: an in-memory latch is set SYNCHRONOUSLY before the async read, so two\n * near-simultaneous calls fire at most once.\n * • Without `storage`: degraded mode — fires once per PROCESS via the latch only (documented).\n */\nexport const reportFirstOpen = (opts: ReportFirstOpenOptions): void => {\n const appId = opts.appId ?? \"default\";\n\n // Synchronous latch FIRST: guarantees at-most-one before any await (same-process race guard) and\n // is the sole guard in the no-storage degraded mode.\n if (_firstOpenLatched.has(appId)) return;\n _firstOpenLatched.add(appId);\n\n const storage = opts.storage;\n if (!storage) {\n // Degraded: no persistence to survive a kill → the latch fires it once per process.\n emitFirstOpen(opts);\n return;\n }\n\n const key = firstOpenStorageKey(appId);\n void (async () => {\n try {\n const seen = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);\n // A prior launch already fired + wrote the flag → once-ever satisfied, no-op.\n if (seen) return;\n emitFirstOpen(opts);\n try {\n // Best-effort persist: a failed write just means the next launch may re-fire once.\n void storage.setItem(key, JSON.stringify({ ts: Date.now() })).catch(() => {});\n } catch {\n // Missing/broken storage write — swallow.\n }\n } catch {\n // Unreadable flag → the in-memory latch still caps us at one fire this process.\n emitFirstOpen(opts);\n }\n })();\n};\n\n/** Options for {@link wireLifecycleEvents}: the shared lifecycle inputs + first-open persistence. */\nexport interface WireLifecycleOptions extends ReportFirstOpenOptions {}\n\n/**\n * Wire BOTH lifecycle events in one call for a host that owns its own app-open path (the non-hook\n * counterpart to {@link useLifecycleEvents}). Fires `app.first_open` (once ever) and one\n * `app.session_started` for THIS open through the EXISTING {@link reportSessionStart} emitter (so\n * the once-per-open guard still applies — pass the same `sessionId` and it never double-fires).\n * Route both through the same `sink` (the offline queue) to buffer them. Fire-and-forget.\n */\nexport const wireLifecycleEvents = (opts: WireLifecycleOptions): void => {\n reportFirstOpen(opts);\n reportSessionStart({\n target: opts.target,\n sink: opts.sink,\n sessionId: opts.sessionId,\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: opts.appVersion,\n platform: opts.platform,\n device: opts.device,\n meta: opts.meta,\n });\n};\n\n// Re-exported so callers wiring lifecycle events have the session name alongside the first-open one.\nexport { SESSION_STARTED_EVENT };\n","/**\n * eventQueue — the OFFLINE-FIRST, persistent transport buffer for client analytics events.\n *\n * The existing `reportClientEvents` is a blind fire-and-forget POST: it returns `void`, has no\n * success signal, and drops events when the network is down. The analytics data story depends on\n * NEVER losing an event offline, so this queue adds the missing durability layer on top of the\n * same `POST {serverUrl}/v1/events` contract:\n *\n * • Persists pending events to the host-injected `WireOnboardingStorage` (survives app kills).\n * • Batches them into one request body `{ events: [...] }`.\n * • Owns its OWN awaited `fetch` that reads `res.ok` — the only way to drive retry + dequeue,\n * since `reportClientEvents` cannot ack. A 2xx dequeues the batch; a non-ok / rejected / thrown\n * response keeps it and schedules an exponential backoff retry.\n * • Flushes on `enqueue`, on an explicit `flush()`, and on `notifyOnline()` (host reconnect).\n * • Caps the buffer (drop-OLDEST under pressure) and de-dups identical pending events.\n * • Stamps the current context envelope (device + host scalars) onto every event before send.\n *\n * FIRE-AND-FORGET (load-bearing): `enqueue` returns immediately and NEVER throws into the UI. A\n * missing `fetch`, a hung/broken storage, a rejecting network, or a JSON error is swallowed and\n * degrades gracefully — analytics must never be able to break the app. In-memory fallback covers\n * the no-storage case (survives re-renders, not app kills).\n *\n * DEPENDENCY-FREE: no network-detection or persistence library. Connectivity is host-driven via\n * `notifyOnline()`; persistence is the host-injected AsyncStorage-compatible subset.\n */\nimport type { ContextEnvelope } from \"./contextEnvelope\";\nimport type { ClientEvent, ClientEventTarget } from \"./reportClientEvent\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\n/** Envelope source: a fixed envelope or a provider evaluated at enqueue time (fresh network type). */\nexport type EnvelopeSource = ContextEnvelope | (() => ContextEnvelope | undefined);\n\n/** Options for {@link createEventQueue}. Only `target` is conceptually required to actually send. */\nexport type EventQueueOptions = {\n /** Where to POST — the tenant transport (`serverUrl` + `apiKey`), same as `WireOnboardingConfig`. */\n target: ClientEventTarget | undefined;\n /**\n * Host persistence (AsyncStorage-compatible subset). When omitted, the queue runs in the\n * documented DEGRADED in-memory mode — it survives re-renders but not an app kill.\n */\n storage?: WireOnboardingStorage;\n /** Tenant/app id used to namespace the default storage key (`wireai:evtq:<appId>`). */\n appId?: string;\n /** Explicit storage key override (wins over the `appId`-derived default). */\n storageKey?: string;\n /** The context envelope stamped onto every event before send (device + host scalars). */\n envelope?: EnvelopeSource;\n /** Max pending events; enqueuing past this DROPS THE OLDEST first (default 200). */\n maxSize?: number;\n /** Events per POST batch (default 20). */\n batchSize?: number;\n /** First retry delay in ms; doubles each failed attempt (default 1000). */\n baseBackoffMs?: number;\n /** Backoff ceiling in ms (default 30000). */\n maxBackoffMs?: number;\n /** Max AUTOMATIC backoff retries before pausing (default 6); `notifyOnline()`/`flush()` re-arm it. */\n maxRetries?: number;\n};\n\n/** The queue's public surface. `enqueue` is fire-and-forget (returns immediately, never throws). */\nexport type EventQueue = {\n /** Buffer one event (envelope-stamped), persist, and schedule a flush. Never throws. */\n enqueue(event: ClientEvent): void;\n /** Attempt an immediate drain of the pending buffer. Fire-and-forget. */\n flush(): void;\n /** Host reconnect signal: reset backoff and drain immediately. Fire-and-forget. */\n notifyOnline(): void;\n /** Current pending (in-memory) count. */\n size(): number;\n};\n\nconst DEFAULTS = {\n maxSize: 200,\n batchSize: 20,\n baseBackoffMs: 1000,\n maxBackoffMs: 30000,\n maxRetries: 6,\n} as const;\n\n/** Ceiling on the persisted-backlog read — a hung adapter degrades to an empty start, never a stall. */\nconst READ_TIMEOUT_MS = 1500;\n\n/** Internal buffered item. `id` is a local monotonic handle for deterministic dequeue-after-ack;\n * it is NEVER sent to the server. `sig` is the de-dup signature (serialized stamped event). */\ntype QueuedItem = { id: number; event: ClientEvent; sig: string };\n\n/** Persisted shape — the local id + the (already envelope-stamped) event. `sig` is recomputed on load. */\ntype PersistedItem = { id: number; event: ClientEvent };\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n/** Detach a timer from the event loop where the runtime supports it (Node test process / some RNs). */\nconst unrefTimer = (timer: ReturnType<typeof setTimeout>): void => {\n const t = timer as unknown as { unref?: () => void };\n if (typeof t.unref === \"function\") t.unref();\n};\n\nconst parsePersisted = (raw: string | null | undefined): PersistedItem[] => {\n if (!raw) return [];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n const items: PersistedItem[] = [];\n for (const entry of parsed) {\n if (\n entry &&\n typeof entry === \"object\" &&\n typeof (entry as PersistedItem).id === \"number\" &&\n (entry as PersistedItem).event &&\n typeof (entry as PersistedItem).event === \"object\"\n ) {\n items.push(entry as PersistedItem);\n }\n }\n return items;\n } catch {\n // Corrupt backlog → start empty; the next persist overwrites it.\n return [];\n }\n};\n\n/**\n * Create an offline-first event queue. Loads any persisted backlog on creation so a\n * killed-and-relaunched app resumes where it left off. Returns the {@link EventQueue} surface.\n */\nexport const createEventQueue = (options: EventQueueOptions): EventQueue => {\n const target = options.target;\n const storage = options.storage;\n const key = options.storageKey ?? `wireai:evtq:${options.appId ?? \"default\"}`;\n const maxSize = options.maxSize ?? DEFAULTS.maxSize;\n const batchSize = options.batchSize ?? DEFAULTS.batchSize;\n const baseBackoffMs = options.baseBackoffMs ?? DEFAULTS.baseBackoffMs;\n const maxBackoffMs = options.maxBackoffMs ?? DEFAULTS.maxBackoffMs;\n const maxRetries = options.maxRetries ?? DEFAULTS.maxRetries;\n\n let pending: QueuedItem[] = [];\n let nextId = 0;\n let flushing = false;\n let attempt = 0;\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n\n const resolveEnvelope = (): ContextEnvelope | undefined => {\n try {\n return typeof options.envelope === \"function\" ? options.envelope() : options.envelope;\n } catch {\n return undefined;\n }\n };\n\n // Stamp the current envelope onto a COPY of the event (never mutate the caller's object):\n // device → event.device (when the event has none)\n // sessionId → event.session_id (when the event has none)\n // appVersion / appBuild / networkType → event.user_context (the non-PII bucket the server\n // sanitizes), never overwriting a key the caller already set.\n const stamp = (event: ClientEvent): ClientEvent => {\n const env = resolveEnvelope();\n const stamped: ClientEvent = { ...event };\n if (!env) return stamped;\n if (!stamped.device && env.device) stamped.device = env.device;\n if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;\n const uc: Record<string, string | number | boolean> = { ...(stamped.user_context ?? {}) };\n if (env.appVersion && uc.app_version === undefined) uc.app_version = env.appVersion;\n if (env.appBuild && uc.app_build === undefined) uc.app_build = env.appBuild;\n if (env.networkType && uc.network_type === undefined) uc.network_type = env.networkType;\n if (Object.keys(uc).length > 0) stamped.user_context = uc;\n return stamped;\n };\n\n const persist = (): void => {\n if (!storage) return;\n try {\n if (pending.length === 0) {\n void storage.removeItem(key).catch(() => {});\n return;\n }\n const payload: PersistedItem[] = pending.map((item) => ({ id: item.id, event: item.event }));\n void storage.setItem(key, JSON.stringify(payload)).catch(() => {});\n } catch {\n // Best-effort: a failed write just means the backlog is not durable this launch.\n }\n };\n\n const enforceSizeCap = (): void => {\n // Drop the OLDEST first so the newest events are never the ones lost under pressure.\n if (pending.length > maxSize) pending.splice(0, pending.length - maxSize);\n };\n\n const safeSig = (event: ClientEvent): string => {\n try {\n return JSON.stringify(event);\n } catch {\n // Non-serializable event → give it a unique signature so it is never wrongly de-duped.\n return `__nosig_${nextId}_${Math.random()}`;\n }\n };\n\n // Load any persisted backlog. Anything enqueued before this settles stays in memory; we merge\n // persisted (older) ahead of it and reassign monotonic ids so dequeue-after-ack is deterministic.\n const loadPromise: Promise<void> = (async () => {\n if (!storage) return;\n try {\n const persistedItems = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n if (persistedItems.length === 0) return;\n const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];\n pending = [];\n nextId = 0;\n const seen = new Set<string>();\n for (const event of events) {\n const sig = safeSig(event);\n if (seen.has(sig)) continue; // collapse duplicates carried across the merge\n seen.add(sig);\n pending.push({ id: nextId++, event, sig });\n }\n enforceSizeCap();\n persist();\n } catch {\n // Unreadable backlog → start empty; nothing enqueued in-memory is lost.\n }\n })();\n\n // The queue's OWN awaited POST. Reads `res.ok` to drive retry/dequeue. NEVER throws — a missing\n // fetch, a rejecting network, or a JSON error resolves to `false` (batch stays, retry schedules).\n const postBatch = async (events: ClientEvent[]): Promise<boolean> => {\n if (!target?.serverUrl || events.length === 0) return false;\n const controller = typeof AbortController !== \"undefined\" ? new AbortController() : undefined;\n const timer = setTimeout(() => controller?.abort(), 15_000);\n try {\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n const res = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ events }),\n signal: controller?.signal,\n });\n return !!(res && (res as { ok?: boolean }).ok);\n } catch {\n return false;\n } finally {\n clearTimeout(timer);\n }\n };\n\n const clearRetry = (): void => {\n if (retryTimer !== undefined) {\n clearTimeout(retryTimer);\n retryTimer = undefined;\n }\n };\n\n const scheduleRetry = (): void => {\n // Bounded automatic retry. Past the cap the backlog simply waits for the next\n // `notifyOnline()` / `flush()` (both re-arm attempt), so events are paused, never dropped.\n if (attempt >= maxRetries) return;\n const delay = Math.min(baseBackoffMs * 2 ** attempt, maxBackoffMs);\n attempt++;\n clearRetry();\n retryTimer = setTimeout(() => {\n retryTimer = undefined;\n void drain();\n }, delay);\n unrefTimer(retryTimer);\n };\n\n const drain = async (): Promise<void> => {\n try {\n await loadPromise;\n } catch {\n // load already swallows; guard the await defensively.\n }\n if (flushing) return;\n flushing = true;\n try {\n while (pending.length > 0) {\n const batch = pending.slice(0, batchSize);\n const ok = await postBatch(batch.map((item) => item.event));\n if (!ok) {\n scheduleRetry();\n return;\n }\n // Dequeue exactly the acked batch by id (pending may have grown while in flight).\n const acked = new Set(batch.map((item) => item.id));\n pending = pending.filter((item) => !acked.has(item.id));\n persist();\n attempt = 0;\n clearRetry();\n }\n } finally {\n flushing = false;\n }\n };\n\n const flush = (): void => {\n try {\n void drain();\n } catch {\n // drain never throws synchronously, but guard the kick anyway.\n }\n };\n\n const enqueue = (event: ClientEvent): void => {\n try {\n const stamped = stamp(event);\n const sig = safeSig(stamped);\n // Collapse a redundant re-enqueue of an identical pending event.\n for (const item of pending) {\n if (item.sig === sig) return;\n }\n pending.push({ id: nextId++, event: stamped, sig });\n enforceSizeCap();\n persist();\n // Only kick a drain when no retry is already pending — avoids hammering fetch while offline.\n if (retryTimer === undefined) flush();\n } catch {\n // Fire-and-forget: nothing in enqueue may surface to the UI.\n }\n };\n\n const notifyOnline = (): void => {\n // Host reconnected: reset the backoff and drain now.\n attempt = 0;\n clearRetry();\n flush();\n };\n\n const size = (): number => pending.length;\n\n return { enqueue, flush, notifyOnline, size };\n};\n","/**\n * useLifecycleEvents — the batteries-included React hook that wires the TOP-OF-FUNNEL lifecycle\n * events in ONE place: `app.first_open` (once ever) on mount, and `app.session_started` on every\n * real app-open, both offline-buffered through the Brief-01 event queue.\n *\n * ONE emitter, one guard, no double-emit: session-start goes through the EXISTING\n * {@link reportSessionStart} emitter (routed via a `sink`), NOT a second session emitter — so a\n * host must use EITHER this hook OR `useSessionStart`, never both (both would fire an app-open).\n * The once-per-open guard dedupes re-renders within this hook.\n *\n * Firing moments mirror {@link useSessionStart} exactly:\n * • ON MOUNT — the app opened (cold start / provider first render). `app.first_open` fires here\n * too (once ever, gated by the persisted flag in `reportFirstOpen`).\n * • ON FOREGROUND after a real background of at least {@link BACKGROUND_SESSION_MS} (30 min) — a\n * new app-open, so a fresh `app.session_started` fires. A quick app-switch does NOT count.\n *\n * OFFLINE-FIRST by default: pass your shared {@link EventQueue}'s `enqueue` as `options.sink` to\n * route both events through your one queue. If you pass no sink, the hook lazily creates its OWN\n * offline queue (dedicated storage key, so it never collides with your main queue) from the config\n * + storage. Either way lifecycle events are buffered + persisted + retried, never lost offline.\n *\n * Dependency policy: `AppState` + `Platform` are RN built-ins (no new dep); the device snapshot is\n * the kit's own dependency-free `collectDeviceContext()`; the queue is the dependency-free Brief-01\n * `createEventQueue`. The pure `reportFirstOpen` / `wireLifecycleEvents` (in lifecycle.ts) import no\n * React — this hook is the only React surface.\n */\nimport { useEffect, useRef } from \"react\";\nimport { AppState, Platform, type AppStateStatus } from \"react-native\";\n\nimport { createEventQueue, type EnvelopeSource, type EventQueue } from \"../analytics/eventQueue\";\nimport type { ClientEvent, ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport { collectDeviceContext } from \"../device/deviceContext\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport { reportFirstOpen } from \"./lifecycle\";\nimport { reportSessionStart } from \"./reportSessionStart\";\nimport { BACKGROUND_SESSION_MS } from \"./useSessionStart\";\n\n/** Tenant transport + host persistence for the lifecycle wiring. Same creds as `WireOnboardingConfig`. */\nexport interface LifecycleConfig {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl?: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey?: string;\n /** Host app version (e.g. \"1.4.2\"), forwarded for release segmentation. Optional. */\n appVersion?: string;\n /** Tenant/app id — namespaces the first-open flag AND the hook's internal queue storage key. */\n appId?: string;\n /** Host storage (AsyncStorage subset). Enables the persisted once-ever first-open flag AND the\n * offline durability of the hook's internal queue. Omit it and both degrade to in-memory. */\n storage?: WireOnboardingStorage;\n}\n\n/** Per-open identity + wiring the host supplies. All optional: a pre-auth open is device-only. */\nexport interface UseLifecycleEventsOptions {\n /** The host's opaque pseudonymous user id (NOT PII). Omitted before the user authenticates. */\n userId?: string;\n /** The host's local open-counter value for this open. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** A stable, non-PII device id the host owns. Groups this device's sessions server-side. */\n deviceKey?: string;\n /** Small non-PII extras forwarded on the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to disable firing (e.g. behind a consent gate). Default enabled. */\n enabled?: boolean;\n /**\n * Explicit transport sink (e.g. an existing shared `EventQueue.enqueue`). When provided, BOTH\n * lifecycle events route here and the hook does NOT create its own queue — pass this to share ONE\n * offline queue across the kit's analytics (screen tracking + lifecycle).\n */\n sink?: (event: ClientEvent) => void;\n /**\n * Context envelope (or provider) for the hook's internally-created queue. Ignored when `sink` is\n * supplied (the host's queue owns envelope stamping).\n */\n envelope?: EnvelopeSource;\n}\n\n/**\n * Fire `app.first_open` (once ever) + `app.session_started` (per open), offline-buffered. Returns\n * nothing — a side-effecting hook. Safe to call with inline options (read through a ref, so\n * changing `userId`/`sessionCount` never re-fires a session).\n */\nexport const useLifecycleEvents = (\n config: LifecycleConfig | undefined,\n options: UseLifecycleEventsOptions = {},\n): void => {\n // Latest options/config through a ref so the mount/resume fires read fresh values without listing\n // them as effect deps (which would re-fire a session on every prop change).\n const latest = useRef({ config, options });\n latest.current = { config, options };\n\n // The resolved sink is created at most once and reused for every fire this mount.\n const queueRef = useRef<EventQueue | undefined>(undefined);\n\n useEffect(() => {\n const resolveSink = (): ((event: ClientEvent) => void) | undefined => {\n const { config: cfg, options: opts } = latest.current;\n // Host-owned shared queue wins — one queue across the whole kit.\n if (opts.sink) return opts.sink;\n // No transport → no sink (events no-op rather than buffer forever against a dead target).\n if (!cfg?.serverUrl) return undefined;\n if (!queueRef.current) {\n queueRef.current = createEventQueue({\n target: { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" },\n storage: cfg.storage,\n // Dedicated key so the hook's internal queue never collides with a host's main queue.\n storageKey: `wireai:evtq:lifecycle:${cfg.appId ?? \"default\"}`,\n envelope: opts.envelope,\n });\n }\n return queueRef.current.enqueue;\n };\n\n const targetOf = (cfg: LifecycleConfig | undefined): ClientEventTarget | undefined =>\n cfg?.serverUrl ? { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" } : undefined;\n\n // 1) first_open — once ever (persisted flag + in-memory latch inside reportFirstOpen).\n {\n const { config: cfg, options: opts } = latest.current;\n if (opts.enabled !== false) {\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg?.appVersion) device.appVersion = cfg.appVersion;\n reportFirstOpen({\n target: targetOf(cfg),\n sink: resolveSink(),\n storage: cfg?.storage,\n appId: cfg?.appId,\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg?.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n }\n }\n\n // 2) session_start — the EXISTING emitter routed through the sink (offline-buffered, one guard).\n const fireSession = () => {\n const { config: cfg, options: opts } = latest.current;\n if (opts.enabled === false) return;\n if (!cfg?.serverUrl && !opts.sink) return;\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg?.appVersion) device.appVersion = cfg.appVersion;\n reportSessionStart({\n target: targetOf(cfg),\n sink: resolveSink(),\n // A fresh per-open id each fire; the emitter's once-guard dedupes within the open.\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg?.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n };\n\n // Mount = an app-open.\n fireSession();\n\n // Foreground after a real background = a new app-open.\n let backgroundedAt: number | null = null;\n const onChange = (state: AppStateStatus) => {\n if (state === \"background\" || state === \"inactive\") {\n if (backgroundedAt == null) backgroundedAt = Date.now();\n return;\n }\n if (state === \"active\") {\n const since = backgroundedAt;\n backgroundedAt = null;\n if (since != null && Date.now() - since >= BACKGROUND_SESSION_MS) fireSession();\n }\n };\n const sub = AppState.addEventListener(\"change\", onChange);\n return () => {\n // RN >= 0.65 returns a subscription with remove(); guard for older shims.\n if (sub && typeof (sub as { remove?: () => void }).remove === \"function\") sub.remove();\n };\n // Mount-only effect: firing reads fresh values via `latest`, so no reactive deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/expo-modules-core/src/errors/CodedError.ts","../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts","../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../node_modules/expo-modules-core/src/requireNativeModule.ts","../node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts","../node_modules/expo-modules-core/src/registerWebModule.ts","../node_modules/expo-modules-core/src/TypedArrays.types.ts","../node_modules/expo-modules-core/src/PermissionsInterface.ts","../node_modules/expo-modules-core/src/PermissionsHook.ts","../node_modules/expo-modules-core/src/Refs.ts","../node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts","../node_modules/expo-modules-core/src/reload.ts","../node_modules/expo-modules-core/src/index.ts","../node_modules/expo-constants/src/Constants.types.ts","../node_modules/expo-constants/src/ExponentConstants.ts","../node_modules/expo-constants/src/Constants.ts","../src/theme/defaultTheme.ts","../src/theme/ThemeContext.tsx","../src/components/Illustration.tsx","../src/illustrations/defaultIllustrations.tsx","../src/icons/IconRegistry.tsx","../src/theme/typography.ts","../src/motion/motionSpec.ts","../src/motion/useReducedMotion.ts","../src/components/AnimatedSparkle.tsx","../src/components/LoadingBlock.tsx","../src/components/LoadingScreen.tsx","../src/components/StepProgress.tsx","../src/components/OnboardingScaffold.tsx","../src/components/Button.tsx","../src/components/ErrorBlock.tsx","../src/components/CardLayout.tsx","../src/components/CompletionView.tsx","../src/components/CardHandoff.tsx","../src/utils/deriveAnswers.ts","../src/utils/readProgress.ts","../src/analytics/reportClientEvent.ts","../src/analytics/sendPreview.ts","../src/OnboardingFlow.tsx","../src/cards/ChipSelectCard.tsx","../src/cards/TextInputCard.tsx","../src/icons/expoIcons.ts","../src/icons/vocabulary.ts","../src/icons/WireIcon.tsx","../src/cards/optionSchema.ts","../src/cards/SelectionCard.tsx","../src/cards/CardGridSelectCard.tsx","../src/cards/StatusCard.tsx","../src/cards/NumberStepperCard.tsx","../src/cards/InterstitialCard.tsx","../src/cards/index.ts","../src/device/appVersion.ts","../src/device/deviceModel.ts","../src/device/deviceContext.ts","../src/analytics/currentSession.ts","../src/session/persistedSession.ts","../src/identity/userIdentity.ts","../src/WireOnboarding.tsx","../src/DemoOnboarding.tsx","../src/theme/themeFromBrand.ts","../src/components/DoneBlock.tsx","../src/motion/centeredModalMotion.ts","../src/components/CenteredModal.tsx","../src/features/defaults.ts","../src/features/cache.ts","../src/features/fetchWireFeatures.ts","../src/features/useWireFeatures.ts","../src/features/WireFeaturesProvider.tsx","../src/config/wireConfigFromEnv.ts","../src/config/onboardingFlag.ts","../src/analytics/analyticsEvent.ts","../src/attribution/attribution.ts","../src/context/userContext.ts","../src/context/deviceId.ts","../src/activation/revalidation.ts","../src/activation/wireActivation.ts","../src/activation/useWireActivation.ts","../src/session-analytics/reportSessionStart.ts","../src/session-analytics/useSessionStart.ts","../src/session-analytics/lifecycle.ts","../src/analytics/eventQueue.ts","../src/session-analytics/useLifecycleEvents.ts"],"names":["name","_a","TurboModuleRegistry","AppOwnership","ExecutionEnvironment","UserInterfaceIdiom","Platform","NativeModules","createContext","useMemo","useContext","jsx","View","Text","jsxs","StyleSheet","EMPTY_REGISTRY","useState","useEffect","AccessibilityInfo","useRef","Animated","Easing","styles","React","SafeAreaView","TouchableOpacity","useCallback","Pressable","makeStyles","KeyboardAvoidingView","ScrollView","easeWire","Fragment","useWireAIThread","useWireAIAction","_b","_c","_d","step","_e","_f","ComponentRenderer","z","schema","useWindowDimensions","TextInput","Image","runtimeRequire","interop","constants","safeInterop","Dimensions","I18nManager","WireAIProvider","Modal","forwardRef","useImperativeHandle","BackHandler","READ_TIMEOUT_MS","withTimeout","cached","globalSlot","useSyncExternalStore","AppState","parsePersisted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAKa,UAAA;AALb,IAAA,eAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yDAAA,GAAA;AAKO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,MAIpC,WAAA,CAAY,MAAc,OAAA,EAAiB;AACzC,QAAA,KAAA,CAAM,OAAO,CAAA;AACb,QAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,MACd;AAAA,KACF;AAAA,EAAA;AAAA,CAAA,CAAA;;;ACbA,IAQO,0BAAA;AARP,IAAA,uBAAA,GAAA,KAAA,CAAA;AAAA,EAAA,0DAAA,GAAA;AAQA,IAAO,6BAAQ,EAAC;AAAA,EAAA;AAAA,CAAA,CAAA;;;ACLT,SAAS,4BAAA,CAA6B,aAAiCA,KAAAA,EAAc;AAC1F,EAAA,OAAO,IAAA;AACT;AALA,IAAA,iCAAA,GAAA,KAAA,CAAA;AAAA,EAAA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AAA,IAAS,uBAAuB,WAAA,EAAY;AAAA,MAChF;AAAA,IACF,CAAA;AACA,IAAA,MAAM,GAAA,GAAM0D,oBAAAA,CAAS,gBAAA,CAAiB,QAAA,EAAU,QAAQ,CAAA;AACxD,IAAA,OAAO,MAAM;AAEX,MAAA,IAAI,OAAO,OAAQ,GAAA,CAAgC,MAAA,KAAW,UAAA,MAAgB,MAAA,EAAO;AAAA,IACvF,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AACP","file":"index.js","sourcesContent":["/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as Record<string, ProxyNativeModule>;\n","// Copyright © 2024 650 Industries.\nimport type { TurboModule } from 'react-native';\n\nexport function createTurboModuleToExpoProxy(turboModule: TurboModule | null, name: string) {\n return null;\n}\n","// Installs the expo global on web\nimport './polyfill';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n // No-op on web\n}\n","import { TurboModuleRegistry } from 'react-native';\n\nimport NativeModulesProxy from './NativeModulesProxy';\nimport { createTurboModuleToExpoProxy } from './TurboModuleToExpoModuleProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n try {\n return (\n globalThis.expo?.modules?.[moduleName] ??\n NativeModulesProxy[moduleName] ??\n createTurboModuleToExpoProxy(TurboModuleRegistry.get(moduleName), moduleName) ??\n null\n );\n } catch (e) {\n const error = e as Error;\n console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);\n return null;\n }\n}\n","import { CodedError } from '../errors/CodedError';\nimport { requireOptionalNativeModule } from '../requireNativeModule';\n\ntype LogListener = {\n action: (...data: any[]) => void;\n eventName: string;\n};\n\nif (\n __DEV__ &&\n typeof window !== 'undefined' &&\n (process.env.EXPO_OS === 'android' || process.env.EXPO_OS === 'ios')\n) {\n const NativeJSLogger = requireOptionalNativeModule('ExpoModulesCoreJSLogger');\n if (NativeJSLogger) {\n const onNewException: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewError',\n action: console.error,\n };\n\n const onNewWarning: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewWarning',\n action: console.warn,\n };\n\n const onNewDebug: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewDebug',\n action: console.debug,\n };\n\n const onNewInfo: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewInfo',\n action: console.info,\n };\n\n const onNewTrace: LogListener = {\n eventName: 'ExpoModulesCoreJSLogger.onNewTrace',\n action: console.trace,\n };\n\n const listeners: LogListener[] = [\n onNewException,\n onNewWarning,\n onNewDebug,\n onNewInfo,\n onNewTrace,\n ];\n\n for (const listener of listeners) {\n NativeJSLogger.addListener(listener.eventName, ({ message }: { message: string }) => {\n listener.action(message);\n });\n }\n }\n}\n\ndeclare namespace globalThis {\n let ExpoModulesCore_CodedError: undefined | typeof CodedError;\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\nimport type { NativeModule } from './ts-declarations/NativeModule';\n\n/**\n * Registers a web module.\n * @param moduleImplementation A class that extends `NativeModule`. The class is registered under `globalThis.expo.modules[className]`.\n * @param moduleName A name to register the module under `globalThis.expo.modules[className]`.\n * @returns A singleton instance of the class passed into arguments.\n */\n\nexport function registerWebModule<\n EventsMap extends Record<never, never>,\n ModuleType extends typeof NativeModule<EventsMap>,\n>(moduleImplementation: ModuleType, moduleName: string): ModuleType {\n ensureNativeModulesAreInstalled();\n\n moduleName = moduleName ?? moduleImplementation.name;\n if (!moduleName) {\n throw new Error(\n 'Web module implementation is missing a name - it is either not a class or has been minified. Pass the name as a second argument to the `registerWebModule` function.'\n );\n }\n if (!globalThis?.expo?.modules) {\n globalThis.expo.modules = {};\n }\n if (globalThis.expo.modules[moduleName]) {\n return globalThis.expo.modules[moduleName];\n }\n globalThis.expo.modules[moduleName] = new moduleImplementation();\n return globalThis.expo.modules[moduleName];\n}\n","/** A union type for all integer based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type IntBasedTypedArray = Int8Array | Int16Array | Int32Array;\n\n/** A union type for all unsigned integer based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type UintBasedTypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;\n\n/** A union type for all floating point based [`TypedArray` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects). */\nexport type FloatBasedTypedArray = Float32Array | Float64Array;\n\n/** A [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) describes an array-like view of an underlying binary data buffer. */\nexport type TypedArray = IntBasedTypedArray | UintBasedTypedArray | FloatBasedTypedArray;\n","export enum PermissionStatus {\n /**\n * User has granted the permission.\n */\n GRANTED = 'granted',\n /**\n * User hasn't granted or denied the permission yet.\n */\n UNDETERMINED = 'undetermined',\n /**\n * User has denied the permission.\n */\n DENIED = 'denied',\n}\n\n/**\n * Permission expiration time. Currently, all permissions are granted permanently.\n */\nexport type PermissionExpiration = 'never' | number;\n\n/**\n * An object obtained by permissions get and request functions.\n */\nexport type PermissionResponse = {\n /**\n * Determines the status of the permission.\n */\n status: PermissionStatus;\n /**\n * Determines time when the permission expires.\n */\n expires: PermissionExpiration;\n /**\n * A convenience boolean that indicates if the permission is granted.\n */\n granted: boolean;\n /**\n * Indicates if user can be asked again for specific permission.\n * If not, one should be directed to the Settings app\n * in order to enable/disable the permission.\n */\n canAskAgain: boolean;\n};\n","// Copyright © 2024 650 Industries.\n\n'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { PermissionResponse } from './PermissionsInterface';\n\n// These types are identical, but improves the readability for suggestions in editors\ntype RequestPermissionMethod<Permission extends PermissionResponse> = () => Promise<Permission>;\ntype GetPermissionMethod<Permission extends PermissionResponse> = () => Promise<Permission>;\n\ntype PermissionHookMethods<Permission extends PermissionResponse, Options = never> = {\n /** The permission method that requests the user to grant permission. */\n requestMethod: (options?: Options) => Promise<Permission>;\n /** The permission method that only fetches the current permission status. */\n getMethod: (options?: Options) => Promise<Permission>;\n};\n\ntype PermissionHookBehavior = {\n /** If the hook should automatically fetch the current permission status, without asking the user. */\n get?: boolean;\n /** If the hook should automatically request the user to grant permission. */\n request?: boolean;\n};\n\nexport type PermissionHookOptions<Options extends object> = PermissionHookBehavior & Options;\n\n/**\n * Get or request permission for protected functionality within the app.\n * It uses separate permission requesters to interact with a single permission.\n * By default, the hook will only retrieve the permission status.\n */\nfunction usePermission<Permission extends PermissionResponse, Options extends object>(\n methods: PermissionHookMethods<Permission, Options>,\n options?: PermissionHookOptions<Options>\n): [Permission | null, RequestPermissionMethod<Permission>, GetPermissionMethod<Permission>] {\n const isMounted = useRef(true);\n const [status, setStatus] = useState<Permission | null>(null);\n const { get = true, request = false, ...permissionOptions } = options || {};\n\n const getPermission = useCallback(async () => {\n let response: Permission;\n if (Object.keys(permissionOptions).length > 0) {\n response = await methods.getMethod(permissionOptions as Options);\n } else {\n response = await methods.getMethod();\n }\n if (isMounted.current) setStatus(response);\n return response;\n }, [methods.getMethod]);\n\n const requestPermission = useCallback(async () => {\n let response: Permission;\n if (Object.keys(permissionOptions).length > 0) {\n response = await methods.requestMethod(permissionOptions as Options);\n } else {\n response = await methods.requestMethod();\n }\n if (isMounted.current) setStatus(response);\n return response;\n }, [methods.requestMethod]);\n\n useEffect(\n function runMethods() {\n if (request) requestPermission();\n if (!request && get) getPermission();\n },\n [get, request, requestPermission, getPermission]\n );\n\n // Workaround for unmounting components receiving state updates\n useEffect(function didMount() {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return [status, requestPermission, getPermission];\n}\n\n/**\n * Create a new permission hook with the permission methods built-in.\n * This can be used to quickly create specific permission hooks in every module.\n */\nexport function createPermissionHook<Permission extends PermissionResponse, Options extends object>(\n methods: PermissionHookMethods<Permission, Options>\n) {\n return (options?: PermissionHookOptions<Options>) =>\n usePermission<Permission, Options>(methods, options);\n}\n","import { createRef, type RefObject } from 'react';\n\n/**\n * Create a React ref object that is friendly for snapshots.\n * It will be represented as `[React.ref]` in snapshots.\n * @returns A React ref object.\n */\nexport function createSnapshotFriendlyRef<T>(): RefObject<T | null> {\n return createRef<T>();\n}\n","'use client';\n\nimport type { DependencyList } from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport type { SharedObject } from '../ts-declarations/SharedObject';\n\n/**\n * Returns a shared object, which is automatically cleaned up when the component is unmounted.\n */\nexport function useReleasingSharedObject<TSharedObject extends SharedObject>(\n factory: () => TSharedObject,\n dependencies: DependencyList\n): TSharedObject {\n const objectRef = useRef<TSharedObject | null>(null);\n const objectRefToRelease = useRef<TSharedObject | null>(null);\n const isFastRefresh = useRef(false);\n const previousDependencies = useRef<DependencyList>(dependencies);\n\n if (objectRef.current == null) {\n objectRef.current = factory();\n }\n\n const object = useMemo(() => {\n let newObject = objectRef.current;\n const dependenciesAreEqual =\n previousDependencies.current?.length === dependencies.length &&\n dependencies.every((value, index) => value === previousDependencies.current[index]);\n\n // If the dependencies have changed, schedule the previous object for release and create a new one,\n // otherwise this has been called because of an unrelated fast refresh, and we don't want to release the object.\n if (!newObject || !dependenciesAreEqual) {\n objectRefToRelease.current = objectRef.current;\n newObject = factory();\n objectRef.current = newObject;\n previousDependencies.current = dependencies;\n }\n return newObject;\n }, dependencies);\n\n useEffect(() => {\n // When the object changes, release the previous one - it is important to do this in a useEffect, so that we don't release\n // the object during render.\n if (objectRefToRelease.current) {\n objectRefToRelease.current.release();\n objectRefToRelease.current = null;\n }\n }, [object]);\n\n useMemo(() => {\n isFastRefresh.current = true;\n }, []);\n\n useEffect(() => {\n isFastRefresh.current = false;\n\n return () => {\n // This will be called on every fast refresh and on unmount, but we only want to release the object on unmount.\n if (!isFastRefresh.current && objectRef.current) {\n objectRef.current.release();\n }\n };\n }, []);\n\n return object;\n}\n","/**\n * Reloads the app. This method works for both release and debug builds.\n *\n * Unlike [`Updates.reloadAsync()`](/versions/latest/sdk/updates/#updatesreloadasync),\n * this function does not use a new update even if one is available. It only reloads the app using the same JavaScript bundle that is currently running.\n *\n * @param reason The reason for reloading the app. This is used only for some platforms.\n */\nexport async function reloadAppAsync(reason: string = 'Reloaded from JS call'): Promise<void> {\n await globalThis.expo?.reloadAppAsync(reason);\n}\n","import './ts-declarations/global';\nimport './sweet/setUpJsLogger.fx';\nimport './polyfill';\n\nexport type * from './ts-declarations/global';\n\nexport { EventEmitter, type EventSubscription } from './EventEmitter';\nexport { NativeModule } from './NativeModule';\nexport { SharedObject } from './SharedObject';\nexport { SharedRef } from './SharedRef';\n\nexport { default as Platform } from './Platform';\nexport { default as uuid } from './uuid';\n\nexport type { ProxyNativeModule } from './NativeModulesProxy.types';\nexport { requireNativeViewManager } from './NativeViewManagerAdapter';\n\nexport * from './requireNativeModule';\nexport * from './registerWebModule';\nexport * from './TypedArrays.types';\n\nexport * from './PermissionsInterface';\nexport * from './PermissionsHook';\n\nexport * from './Refs';\n\nexport * from './hooks/useReleasingSharedObject';\nexport * from './reload';\n\n// Errors\nexport { CodedError } from './errors/CodedError';\nexport { UnavailabilityError } from './errors/UnavailabilityError';\n\n// Deprecated\nexport { LegacyEventEmitter } from './LegacyEventEmitter';\nexport { default as NativeModulesProxy } from './NativeModulesProxy';\n\nexport { installOnUIRuntime } from './worklets';\n","import type { ExpoConfig } from 'expo/config';\nimport type {\n EASConfig as ManifestsEASConfig,\n ExpoGoConfig as ManifestsExpoGoConfig,\n ExpoUpdatesManifest,\n EmbeddedManifest,\n ManifestAsset as ManifestAssetForReExport,\n ManifestExtra as ManifestExtraForReExport,\n ClientScopingConfig as ClientScopingConfigForReExport,\n ExpoGoPackagerOpts as ExpoGoPackagerOptsForReExport,\n // @ts-ignore -- optional interface, will gracefully degrade to `any` not installed\n} from 'expo-manifests';\n\nexport enum AppOwnership {\n /**\n * The experience is running inside the Expo Go app.\n * @deprecated Use [`Constants.executionEnvironment`](#executionenvironment) instead.\n */\n Expo = 'expo',\n}\n\n/**\n * Identifies where the app's JavaScript bundle is currently running.\n */\nexport enum ExecutionEnvironment {\n /** A project that includes native project directories that you maintain directly in your\n * [existing React Native project](/bare/overview/).\n */\n Bare = 'bare',\n /** Production/release build created with or without EAS Build. */\n Standalone = 'standalone',\n /** Expo Go or a development build built with `expo-dev-client`. */\n StoreClient = 'storeClient',\n}\n\n// @needsAudit\n/**\n * Current supported values are `handset`, `tablet`, `desktop` and `tv`. CarPlay will show up\n * as `unsupported`.\n */\nexport enum UserInterfaceIdiom {\n Handset = 'handset',\n Tablet = 'tablet',\n Desktop = 'desktop',\n TV = 'tv',\n Unsupported = 'unsupported',\n}\n\n// @needsAudit\n/**\n * @platform ios\n */\nexport type IOSManifest = {\n /**\n * The build number specified in the embedded **Info.plist** value for `CFBundleVersion` in this app.\n * In a standalone app, you can set this with the `ios.buildNumber` value in **app.json**. This\n * may differ from the value in `Constants.expoConfig.ios.buildNumber` because the manifest\n * can be updated, whereas this value will never change for a given native binary.\n * The value is set to `null` in case you run your app in Expo Go.\n */\n buildNumber: string | null;\n /**\n * The Apple internal model identifier for this device.\n * @example\n * `iPhone1,1`\n * @deprecated Use `expo-device`'s [`Device.modelId`](./device/#devicemodelid).\n */\n platform: string;\n /**\n * The human-readable model name of this device. For example, `\"iPhone 7 Plus\"` if it can be determined,\n * otherwise will be `null`.\n * @deprecated Moved to `expo-device` as [`Device.modelName`](./device/#devicemodelname).\n */\n model: string | null;\n /**\n * The user interface idiom of the current device, such as whether the app is running on an iPhone, iPad, Mac or Apple TV.\n * @deprecated Use `expo-device`'s [`Device.getDeviceTypeAsync()`](./device/#devicegetdevicetypeasync).\n */\n userInterfaceIdiom: UserInterfaceIdiom;\n /**\n * The version of iOS running on this device.\n * @example\n * `10.3`\n * @deprecated Use `expo-device`'s [`Device.osVersion`](./device/#deviceosversion).\n */\n systemVersion: string;\n} & Record<string, any>;\n\n// @needsAudit\n/**\n * @platform android\n */\nexport type AndroidManifest = {\n /**\n * The version code set by `android.versionCode` in app.json.\n * The value is set to `null` in case you run your app in Expo Go.\n * @deprecated Use `expo-application`'s [`Application.nativeBuildVersion`](./application/#applicationnativebuildversion).\n */\n versionCode: number;\n} & Record<string, any>;\n\n/**\n * @platform web\n */\nexport type WebManifest = Record<string, any>;\n\n// type re-exports to prevent breaking change\n\nexport type ManifestAsset = ManifestAssetForReExport;\nexport type Manifest = ExpoUpdatesManifest;\nexport type ManifestExtra = ManifestExtraForReExport;\nexport type EASConfig = ManifestsEASConfig;\nexport type ClientScopingConfig = ClientScopingConfigForReExport;\nexport type ExpoGoConfig = ManifestsExpoGoConfig;\nexport type ExpoGoPackagerOpts = ExpoGoPackagerOptsForReExport;\n\n// @needsAudit @docsMissing\nexport type PlatformManifest = {\n ios?: IOSManifest;\n android?: AndroidManifest;\n web?: WebManifest;\n detach?: {\n scheme?: string;\n [key: string]: any;\n };\n scheme?: string;\n hostUri?: string;\n developer?: string;\n} & Record<string, any>;\n\n// @needsAudit @docsMissing\nexport type NativeConstants = {\n /**\n * @hidden\n */\n name: 'ExponentConstants';\n /**\n * Returns `expo` when running in Expo Go, otherwise `null`.\n * @deprecated Use [`Constants.executionEnvironment`](#executionenvironment) instead.\n */\n appOwnership: AppOwnership | null;\n /**\n * Returns `true` when the app is running in debug mode (`__DEV__`). Otherwise, returns `false`.\n */\n debugMode: boolean;\n /**\n * A human-readable name for the device type.\n */\n deviceName?: string;\n /**\n * The [device year class](https://github.com/facebook/device-year-class) of this device.\n * @deprecated Moved to `expo-device` as [`Device.deviceYearClass`](./device/#deviceyearclass).\n */\n deviceYearClass: number | null;\n /**\n * Returns the current execution environment.\n */\n executionEnvironment: ExecutionEnvironment;\n experienceUrl: string;\n /**\n * Nullable only on the web.\n */\n expoRuntimeVersion: string | null;\n /**\n * The version string of the Expo Go app currently running.\n * Returns `null` in existing React Native projects and on web.\n */\n expoVersion: string | null;\n isDetached?: boolean;\n intentUri?: string;\n /**\n * Returns `true` if the app is running in headless mode. Otherwise, returns `false`.\n */\n isHeadless: boolean;\n linkingUri: string;\n\n /**\n * @hidden\n * Manifest embedded in the build. Returns `null` when `manifest2` is non-null.\n * @deprecated Use `Constants.expoConfig` instead, which behaves more consistently across EAS Build\n * and EAS Update.\n */\n manifest: EmbeddedManifest | null;\n /**\n * Manifest for Expo apps using modern Expo Updates from a remote source, such as apps that\n * use EAS Update. `Constants.expoConfig` should be used for accessing the Expo config object.\n */\n manifest2: ExpoUpdatesManifest | null;\n /**\n * The standard Expo config object defined in **app.json** and **app.config.js** files. For both\n * classic and modern manifests, whether they are embedded or remote.\n */\n expoConfig:\n | (ExpoConfig & {\n /**\n * Only present during development using @expo/cli.\n */\n hostUri?: string;\n })\n | null;\n /**\n * The standard Expo Go config object populated when running in Expo Go.\n */\n expoGoConfig: ManifestsExpoGoConfig | null;\n /**\n * The standard EAS config object populated when using EAS.\n */\n easConfig: ManifestsEASConfig | null;\n /**\n * A string that is unique to the current session of your app. It is different across apps and\n * across multiple launches of the same app.\n */\n sessionId: string;\n /**\n * The default status bar height for the device. Does not factor in changes when location tracking\n * is in use or a phone call is active.\n */\n statusBarHeight: number;\n /**\n * A list of the system font names available on the current device.\n */\n systemFonts: string[];\n systemVersion?: number;\n /**\n * @hidden\n */\n supportedExpoSdks?: string[];\n /**\n * Returns the specific platform manifest object.\n *\n * > **Note**: This is distinct from the `manifest` and `manifest2`.\n */\n platform?: PlatformManifest;\n /**\n * Gets the user agent string which would be included in requests sent by a web view running on\n * this device. This is probably not the same user agent you might be providing in your JS `fetch`\n * requests.\n */\n getWebViewUserAgentAsync: () => Promise<string | null>;\n} & Record<string, any>;\n\n/**\n * @hidden\n */\nexport type Constants = NativeConstants & {\n /**\n * > **Warning**: Do not use this property. Use `manifest` by default.\n *\n * In certain cases accessing manifest via this property\n * suppresses important warning about missing manifest.\n */\n __unsafeNoWarnManifest?: EmbeddedManifest;\n /**\n * > **Warning**: Do not use this property. Use `manifest2` by default.\n *\n * In certain cases accessing manifest via this property\n * suppresses important warning about missing manifest.\n */\n __unsafeNoWarnManifest2?: ExpoUpdatesManifest;\n};\n","import { requireOptionalNativeModule } from 'expo-modules-core';\n\nexport default requireOptionalNativeModule('ExponentConstants');\n","// TODO(@kitten): Add missing optional peers\n\nimport type { ExpoConfig } from 'expo/config';\n// @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\nimport type {\n EmbeddedManifest,\n EASConfig,\n ExpoGoConfig,\n ExpoUpdatesManifest,\n // @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\n} from 'expo-manifests';\nimport { CodedError, requireOptionalNativeModule } from 'expo-modules-core';\n// @ts-ignore -- optional interface, will gracefully degrade to `any` if not installed\nimport type { Manifest as UpdatesManifest, ExpoUpdatesModule } from 'expo-updates';\nimport { Platform, NativeModules } from 'react-native';\n\nimport { type Constants, ExecutionEnvironment } from './Constants.types';\nimport ExponentConstants from './ExponentConstants';\ntype DevLauncherManifest = ExpoUpdatesManifest;\n\nexport {\n type AndroidManifest,\n AppOwnership,\n type Constants,\n ExecutionEnvironment,\n type IOSManifest,\n type NativeConstants,\n type PlatformManifest,\n UserInterfaceIdiom,\n type WebManifest,\n} from './Constants.types';\n\nif (!ExponentConstants) {\n console.warn(\n \"No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?\"\n );\n}\n\nconst ExpoUpdates = requireOptionalNativeModule<ExpoUpdatesModule>('ExpoUpdates');\n\nlet rawUpdatesManifest: UpdatesManifest | null = null;\n// If expo-updates defines a non-empty manifest, prefer that one\nif (ExpoUpdates) {\n let updatesManifest: object | undefined;\n if (ExpoUpdates.manifest) {\n updatesManifest = ExpoUpdates.manifest;\n } else if (ExpoUpdates.manifestString) {\n updatesManifest = JSON.parse(ExpoUpdates.manifestString);\n }\n if (updatesManifest && Object.keys(updatesManifest).length > 0) {\n rawUpdatesManifest = updatesManifest as any;\n }\n}\n\n// If dev-launcher defines a non-empty manifest, prefer that one\nlet rawDevLauncherManifest: DevLauncherManifest | null = null;\nif (NativeModules.EXDevLauncher) {\n let devLauncherManifest;\n if (NativeModules.EXDevLauncher.manifestString) {\n devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);\n }\n\n if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {\n rawDevLauncherManifest = devLauncherManifest as any;\n }\n}\n\n// Fall back to ExponentConstants.manifest if we don't have one from Updates\nlet rawAppConfig: ExpoConfig | null = null;\nif (ExponentConstants && ExponentConstants.manifest) {\n const appConfig: object | string = ExponentConstants.manifest;\n\n // On Android we pass the manifest in JSON form so this step is necessary\n if (typeof appConfig === 'string') {\n rawAppConfig = JSON.parse(appConfig);\n } else {\n rawAppConfig = appConfig as any;\n }\n}\n\ntype RawManifest = UpdatesManifest | DevLauncherManifest | ExpoConfig;\nlet rawManifest: RawManifest | null = rawUpdatesManifest ?? rawDevLauncherManifest ?? rawAppConfig;\n\nconst { name, appOwnership, ...nativeConstants } = (ExponentConstants || {}) as any;\n\nconst constants: Constants = {\n ...nativeConstants,\n // Ensure this is null in bare workflow\n appOwnership: appOwnership ?? null,\n};\n\nObject.defineProperties(constants, {\n /**\n * Use `manifest` property by default.\n * This property is only used for internal purposes.\n * It behaves similarly to the original one, but suppresses warning upon no manifest available.\n * `expo-asset` uses it to prevent users from seeing mentioned warning.\n */\n __unsafeNoWarnManifest: {\n get(): EmbeddedManifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n __unsafeNoWarnManifest2: {\n get(): ExpoUpdatesManifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n manifest: {\n get(): EmbeddedManifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n manifest2: {\n get(): ExpoUpdatesManifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n expoConfig: {\n get():\n | (ExpoConfig & {\n /**\n * Only present during development using @expo/cli.\n */\n hostUri?: string;\n })\n | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n // if running an embedded update, maybeManifest is a EmbeddedManifest which doesn't have\n // the expo config. Instead, the embedded expo-constants app.config should be used.\n if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {\n return rawAppConfig;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.expoClient ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n expoGoConfig: {\n get(): ExpoGoConfig | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.expoGo ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n easConfig: {\n get(): EASConfig | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n if (isExpoUpdatesManifest(maybeManifest)) {\n return maybeManifest.extra?.eas ?? null;\n } else if (isEmbeddedManifest(maybeManifest)) {\n return maybeManifest as any;\n }\n\n return null;\n },\n enumerable: true,\n },\n __rawManifest_TEST: {\n get(): RawManifest | null {\n return rawManifest;\n },\n set(value: RawManifest | null) {\n rawManifest = value;\n },\n enumerable: false,\n },\n});\n\nfunction isEmbeddedManifest(manifest: RawManifest): manifest is EmbeddedManifest {\n return !isExpoUpdatesManifest(manifest);\n}\n\nfunction isExpoUpdatesManifest(manifest: RawManifest): manifest is ExpoUpdatesManifest {\n return 'metadata' in manifest;\n}\n\nfunction getManifest(suppressWarning = false): RawManifest | null {\n if (!rawManifest) {\n const invalidManifestType = rawManifest === null ? 'null' : 'undefined';\n if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.Bare &&\n Platform.OS !== 'web'\n ) {\n if (!suppressWarning) {\n console.warn(\n `Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`\n );\n }\n } else if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient ||\n nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone\n ) {\n // If we somehow get here, this is a truly exceptional state to be in.\n // Constants.manifest should *always* be defined in those contexts.\n throw new CodedError(\n 'ERR_CONSTANTS_MANIFEST_UNAVAILABLE',\n `Constants.manifest is ${invalidManifestType}, must be an object.`\n );\n }\n }\n return rawManifest;\n}\n\nexport default constants as Constants;\n","/**\n * defaultOnboardingTheme — a neutral, light, brand-agnostic baseline. Consumers\n * pass a `Partial<OnboardingTheme>` that is deep-merged over this (see\n * `mergeTheme`), so they only override what differs from neutral.\n */\nimport type { OnboardingTheme } from \"./types\";\n\nexport const defaultOnboardingTheme: OnboardingTheme = {\n colors: {\n background: \"#FFFFFF\",\n surface: \"#F7F7F8\",\n text: \"#101114\",\n textMuted: \"#6B7280\",\n primary: \"#111111\",\n onPrimary: \"#FFFFFF\",\n primarySoft: \"rgba(17,17,17,0.06)\",\n border: \"#E4E4E7\",\n borderStrong: \"#C7C7CC\",\n disabled: \"#EBEBEB\",\n success: \"#16A34A\",\n warning: \"#D97706\",\n error: \"#DC2626\",\n info: \"#2563EB\",\n },\n fonts: {\n regular: undefined,\n medium: undefined,\n bold: undefined,\n baseSize: 16,\n scale: 1,\n },\n radius: {\n sm: 8,\n md: 12,\n lg: 16,\n full: 9999,\n },\n spacing: {\n xs: 4,\n sm: 8,\n md: 16,\n lg: 24,\n xl: 32,\n },\n // Circled (pill) CTA by default; an app can pass `button: { radius: 12 }` for\n // a rounded rectangle, or override height/paddingX to match its design system.\n button: {\n radius: 9999,\n height: 52,\n paddingX: 24,\n },\n};\n\n/**\n * Deep-merge a partial theme over the default. Two levels deep is enough — the\n * theme is intentionally shallow (colors/fonts/radius/spacing), so we merge each\n * known sub-object and leave scalars to overwrite.\n */\nexport const mergeTheme = (\n override?: Partial<OnboardingTheme>,\n): OnboardingTheme => {\n if (!override) return defaultOnboardingTheme;\n return {\n colors: { ...defaultOnboardingTheme.colors, ...override.colors },\n fonts: { ...defaultOnboardingTheme.fonts, ...override.fonts },\n radius: { ...defaultOnboardingTheme.radius, ...override.radius },\n spacing: { ...defaultOnboardingTheme.spacing, ...override.spacing },\n button: { ...defaultOnboardingTheme.button, ...override.button },\n };\n};\n","/**\n * ThemeContext — provides the resolved OnboardingTheme to every shell element and\n * themed card via `useOnboardingTheme()`. WHY a context rather than prop-drilling:\n * the cards are mounted by the SDK's ComponentRenderer (not by us), so we can't\n * pass them props directly — they must read the theme from context.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport { mergeTheme } from \"./defaultTheme\";\nimport type { OnboardingTheme } from \"./types\";\n\nconst OnboardingThemeContext = createContext<OnboardingTheme | null>(null);\n\nexport type OnboardingThemeProviderProps = {\n /** Partial overrides merged over the neutral default theme. */\n theme?: Partial<OnboardingTheme>;\n children: React.ReactNode;\n};\n\nexport const OnboardingThemeProvider: React.FC<OnboardingThemeProviderProps> = ({\n theme,\n children,\n}) => {\n const resolved = useMemo(() => mergeTheme(theme), [theme]);\n return (\n <OnboardingThemeContext.Provider value={resolved}>\n {children}\n </OnboardingThemeContext.Provider>\n );\n};\n\n/**\n * Read the active theme. Falls back to the default theme when used outside a\n * provider so a stray card never crashes — it just renders neutral.\n */\nexport const useOnboardingTheme = (): OnboardingTheme => {\n const ctx = useContext(OnboardingThemeContext);\n return ctx ?? mergeTheme();\n};\n","/**\n * Illustration registry — lets the host app supply brand artwork (SVG / Lottie /\n * Image nodes) keyed by name, which the backend references from an InterstitialCard\n * by `illustration`. Keeping the registry in React context (rather than as a card\n * prop) is what keeps the kit dependency-free: the kit never imports react-native-svg\n * or Lottie — the app brings its own nodes and the kit just slots the matching one.\n *\n * <WireOnboarding illustrations={{ \"before-after\": <BeforeAfter/> }} ... />\n *\n * When the backend names an illustration the registry doesn't have, the\n * InterstitialCard falls back to its `imageUrl` (a plain RN <Image>).\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nexport type IllustrationRegistry = Record<string, React.ReactNode>;\n\n/** One shared empty registry so an unconfigured provider never allocates a fresh {} per render. */\nconst EMPTY_REGISTRY: IllustrationRegistry = {};\n\nconst IllustrationContext = createContext<IllustrationRegistry>(EMPTY_REGISTRY);\n\nexport type IllustrationProviderProps = {\n registry?: IllustrationRegistry;\n children: React.ReactNode;\n};\n\nexport const IllustrationProvider: React.FC<IllustrationProviderProps> = ({\n registry,\n children,\n}) => {\n const value = useMemo(() => registry ?? EMPTY_REGISTRY, [registry]);\n return <IllustrationContext.Provider value={value}>{children}</IllustrationContext.Provider>;\n};\n\n/** Look up an app-supplied illustration node by name. Returns undefined if absent. */\nexport const useIllustration = (name?: string): React.ReactNode | undefined => {\n const registry = useContext(IllustrationContext);\n if (!name) return undefined;\n return registry[name];\n};\n","/**\n * defaultIllustrations — a tiny, dependency-free fallback registry so an app can\n * render `InterstitialCard` with ZERO illustration code. These are plain\n * <View>/<Text> glyphs (NO react-native-svg, NO Lottie, NO image assets) themed\n * from the active OnboardingTheme, covering the common backend-emitted names.\n *\n * Spread it under your own artwork — your named nodes win:\n *\n * illustrations={{ ...defaultIllustrations, ...myIllustrations }}\n *\n * Names match what the onboarding backend commonly emits via an InterstitialCard's\n * `illustration`: `momentum` (forward-motion arc) and `before-after` (two states).\n * Add more by spreading your own — these are only sensible defaults.\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\n\n/** A soft tinted disc with a centered glyph — the shared frame for every default. */\nconst Glyph: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const t = useOnboardingTheme();\n return (\n <View\n style={[\n styles.disc,\n { backgroundColor: t.colors.primarySoft, borderRadius: t.radius.full },\n ]}\n >\n <Text style={[styles.glyphText, { color: t.colors.primary }]} allowFontScaling={false}>\n {children}\n </Text>\n </View>\n );\n};\n\n/** Forward-motion / momentum: an upward arrow. */\nconst MomentumGlyph: React.FC = () => <Glyph>{\"↗\"}</Glyph>;\n\n/** Before → after: two states with an arrow between. */\nconst BeforeAfterGlyph: React.FC = () => {\n const t = useOnboardingTheme();\n return (\n <View style={styles.row}>\n <View\n style={[\n styles.chip,\n { borderColor: t.colors.border, borderRadius: t.radius.md },\n ]}\n />\n <Text style={[styles.arrow, { color: t.colors.primary }]} allowFontScaling={false}>\n {\"→\"}\n </Text>\n <View\n style={[\n styles.chip,\n { backgroundColor: t.colors.primarySoft, borderColor: t.colors.primary, borderRadius: t.radius.md },\n ]}\n />\n </View>\n );\n};\n\n/**\n * The default registry. `WireOnboarding`'s `illustrations` prop is\n * `Record<string, ReactNode>`, so these are concrete element nodes.\n */\nexport const defaultIllustrations: Record<string, React.ReactNode> = {\n momentum: <MomentumGlyph />,\n \"before-after\": <BeforeAfterGlyph />,\n};\n\nconst styles = StyleSheet.create({\n disc: {\n width: 96,\n height: 96,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n glyphText: {\n fontSize: 44,\n fontWeight: \"700\",\n lineHeight: 52,\n },\n row: {\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 12,\n },\n chip: {\n width: 56,\n height: 56,\n borderWidth: 2,\n },\n arrow: {\n fontSize: 28,\n fontWeight: \"700\",\n },\n});\n","/**\n * Icon registry — the host's escape hatch, and the FIRST step of icon resolution.\n *\n * Deliberately the same shape and philosophy as the `illustrations` registry\n * (components/Illustration.tsx): name → ReactNode, held in context, so an app can ship brand\n * SVG / Lottie / Image nodes the kit never imports. Here it means a host can:\n *\n * • override any vocabulary name with its own brand mark (`{ instagram: <MyIgGlyph/> }`), or\n * • supply icons WITHOUT installing `@expo/vector-icons` at all, or\n * • extend the vocabulary with names of its own — the AI emits `\"my-thing\"`, the host renders\n * it, and the kit needs no release.\n *\n * <WireOnboarding icons={{ instagram: <BrandIg/> }} ... />\n *\n * A name the registry doesn't have falls through to `@expo/vector-icons`, then to no icon at\n * all. See `WireIcon`.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nexport type WireIconRegistry = Record<string, React.ReactNode>;\n\n/** One shared empty registry so an unconfigured provider never allocates a fresh {} per render. */\nconst EMPTY_REGISTRY: WireIconRegistry = {};\n\nconst IconContext = createContext<WireIconRegistry>(EMPTY_REGISTRY);\n\nexport type IconRegistryProviderProps = {\n registry?: WireIconRegistry;\n children: React.ReactNode;\n};\n\nexport const IconRegistryProvider: React.FC<IconRegistryProviderProps> = ({\n registry,\n children,\n}) => {\n const value = useMemo(() => registry ?? EMPTY_REGISTRY, [registry]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n};\n\n/**\n * Look up a host-supplied icon node by name. Returns undefined if absent.\n *\n * The OWN-property check matters here for the same reason it does in `vocabulary.ts`: the name\n * is LLM-authored, and a bare `registry[name]` answers `\"toString\"` with an inherited function\n * — which is truthy, so it would be handed to React as a child and blow up the card. An icon\n * name must never be able to do that.\n */\nexport const useHostIcon = (name?: string): React.ReactNode | undefined => {\n const registry = useContext(IconContext);\n if (!name) return undefined;\n if (!Object.prototype.hasOwnProperty.call(registry, name)) return undefined;\n return registry[name];\n};\n","/**\n * typography — derive concrete RN text styles from the theme's font config, so\n * every label/title/caption in the kit scales from one `baseSize` + `scale` and\n * picks the right family. Cards call these instead of hardcoding fontSize/weight.\n */\nimport type { TextStyle } from \"react-native\";\nimport type { OnboardingFonts } from \"./types\";\n\nconst round = (n: number) => Math.round(n);\n\n/** Body text — the reference size. */\nexport const bodyStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.regular,\n fontSize: round(f.baseSize * f.scale),\n lineHeight: round(f.baseSize * f.scale * 1.5),\n});\n\n/** Slightly smaller secondary/hint text. */\nexport const captionStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.regular,\n fontSize: round(f.baseSize * 0.8125 * f.scale),\n lineHeight: round(f.baseSize * 0.8125 * f.scale * 1.5),\n});\n\n/** Emphasised label (e.g. a card question). */\nexport const labelStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.medium ?? f.bold,\n fontSize: round(f.baseSize * f.scale),\n lineHeight: round(f.baseSize * f.scale * 1.4),\n fontWeight: f.medium ? undefined : (\"600\" as const),\n});\n\n/** Heading (status title, done block). */\nexport const headingStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.bold,\n fontSize: round(f.baseSize * 1.25 * f.scale),\n lineHeight: round(f.baseSize * 1.25 * f.scale * 1.3),\n fontWeight: f.bold ? undefined : (\"700\" as const),\n});\n\n/** Button label. */\nexport const buttonLabelStyle = (f: OnboardingFonts): TextStyle => ({\n fontFamily: f.bold ?? f.medium,\n fontSize: round(f.baseSize * f.scale),\n fontWeight: f.bold ? undefined : (\"600\" as const),\n});\n","/**\n * motionSpec — the single source of truth for every animation value in the kit,\n * extracted 1:1 from the Wire Activation card-interactions design canvas\n * (see design-refs/EXTRACTED-SPEC.md for the row-by-row mapping).\n *\n * Pure constants + pure helpers only — NO react-native import — so the spec is\n * unit-testable under node:test and components can't drift from the design\n * without a red test.\n */\n\n/** The design system's \"ease-wire\" curve: cubic-bezier(0.16, 1, 0.3, 1). */\nexport const WIRE_BEZIER = [0.16, 1, 0.3, 1] as const;\n\n/** Design-system duration tokens (colors_and_type.css --duration-*). */\nexport const DURATION_FAST_MS = 150;\nexport const DURATION_BASE_MS = 300;\nexport const DURATION_SLOW_MS = 500;\n\n/** Reduce-motion fallback: a short fade to the final frame, never a frozen mid-state. */\nexport const REDUCED_FADE_MS = 120;\n\n// ── Press feedback (spec rows 1, 4, 20) ─────────────────────────────────────\nexport const ROW_PRESS_SCALE = 0.975;\nexport const CHIP_PRESS_SCALE = 0.94;\nexport const BUTTON_PRESS_SCALE = 0.975;\n/** Reduce-motion press feedback: opacity dip instead of scale. */\nexport const REDUCED_PRESS_OPACITY = 0.85;\nexport const PRESS_SPRING = { friction: 8, tension: 220 } as const;\nexport const BUTTON_PRESS_SPRING = { friction: 8, tension: 240 } as const;\n\n// ── Selection state changes (spec rows 2, 3, 5, 6) ──────────────────────────\nexport const SELECT_FILL_MS = 180;\nexport const CHIP_FILL_MS = 160;\nexport const CHECK_SPRING = { friction: 6, tension: 180 } as const;\nexport const CHECK_SCALE_FROM = 0.6;\n\n// ── Card-to-card handoff (spec rows 7-10) ───────────────────────────────────\nexport const CARD_ENTER_MS = 220;\nexport const CARD_EXIT_MS = 180;\n/** The exit starts this long BEFORE the enter (enter is delayed by this). */\nexport const CARD_EXIT_LEAD_MS = 80;\nexport const CARD_SLIDE_PX = 26;\nexport const CARD_ENTER_SCALE_FROM = 0.96;\n/** The interstitial keeps the shell's springier value-beat (AnimatedCard idiom). */\nexport const CARD_SPRING = { damping: 14, stiffness: 180, mass: 1 } as const;\n/** Loader-to-card handoff: the loader just fades out. */\nexport const LOADER_HANDOFF_FADE_MS = 120;\n\n// ── InterstitialCard reveal (spec rows 11-13) ───────────────────────────────\nexport const INTERSTITIAL_HEAD_MS = 500;\nexport const INTERSTITIAL_HEAD_STAGGER_MS = 100;\nexport const INTERSTITIAL_ITEM_MS = 300;\nexport const INTERSTITIAL_ITEM_STAGGER_MS = 90;\nexport const INTERSTITIAL_ITEM_BASE_DELAY_MS = 200;\nexport const INTERSTITIAL_CHECK_DELAY_MS = 200;\nexport const INTERSTITIAL_CHECK_SCALE_FROM = 0.4;\n\n/** Delay before work item `index` begins its reveal (row lands after the head). */\nexport const interstitialItemDelay = (index: number): number =>\n INTERSTITIAL_ITEM_BASE_DELAY_MS + index * INTERSTITIAL_ITEM_STAGGER_MS;\n\n/** Delay before work item `index`'s check pops (200ms after its row starts). */\nexport const interstitialCheckDelay = (index: number): number =>\n interstitialItemDelay(index) + INTERSTITIAL_CHECK_DELAY_MS;\n\n// ── Status / completion payoff (spec rows 14-16) ────────────────────────────\nexport const STATUS_POP_SPRING = { friction: 6, tension: 200 } as const;\nexport const STATUS_POP_SCALE_FROM = 0.4;\nexport const STATUS_BURST_MS = 500;\nexport const STATUS_BURST_SCALE_FROM = 0.4;\nexport const STATUS_BURST_SCALE_TO = 1.5;\nexport const STATUS_BURST_OPACITY_FROM = 0.5;\nexport const STATUS_COPY_MS = 300;\nexport const STATUS_COPY_STAGGER_MS = 80;\n/** Copy starts settling once the badge pop is visibly underway. */\nexport const STATUS_COPY_BASE_DELAY_MS = 200;\n\n/** Delay before payoff copy line `index` fades up. */\nexport const statusCopyDelay = (index: number): number =>\n STATUS_COPY_BASE_DELAY_MS + index * STATUS_COPY_STAGGER_MS;\n\n// ── Loading treatment (spec rows 17-19) ─────────────────────────────────────\nexport const LOADER_PULSE_MS = 1600;\nexport const LOADER_PULSE_MIN_OPACITY = 0.35;\nexport const LOADER_ORBIT_MS = 2400;\n/** Skeleton lines appear only when the fetch runs past this. */\nexport const SKELETON_DELAY_MS = 300;\nexport const SKELETON_PULSE_MS = 1500;\nexport const SKELETON_MIN_OPACITY = 0.45;\n\n// ── Progress bar (spec row 21) ──────────────────────────────────────────────\nexport const PROGRESS_MS = 400;\n\n// ── Dev/QA duration scale (slow-mo for judging motion) ──────────────────────\n// A module-level multiplier applied to every timing DURATION (and stagger\n// delay) at animation start. 1 = design speed; 2 = half-speed slow-mo. Springs\n// are physics-based (friction/tension) and do NOT scale. This is a dev/QA tool\n// (the playground's tweak panel drives it) — production code never calls the\n// setter, so the default 1 keeps shipped motion exactly on spec.\n\nlet durationScale = 1;\n\n/** Set the global duration multiplier (clamped to 0.1-10; invalid resets to 1). */\nexport const setMotionDurationScale = (scale: number): void => {\n durationScale = Number.isFinite(scale) && scale > 0 ? Math.min(10, Math.max(0.1, scale)) : 1;\n};\n\nexport const getMotionDurationScale = (): number => durationScale;\n\n/** Apply the current duration scale to a spec duration/delay (rounded ms). */\nexport const scaledMs = (ms: number): number => Math.round(ms * durationScale);\n\n// ── Reduce-motion helpers (pure, shared by every animated component) ────────\n\nexport type EntranceSpec = {\n /** Duration to animate with (falls back to the short fade under reduce motion). */\n duration: number;\n /** Whether transforms (translate/scale) may move; false = opacity-only fade. */\n useTransform: boolean;\n};\n\n/** Entrances: full motion normally; a 120ms opacity-only fade under reduce motion. */\nexport const entranceSpec = (reduced: boolean, durationMs: number): EntranceSpec =>\n reduced\n ? { duration: REDUCED_FADE_MS, useTransform: false }\n : { duration: durationMs, useTransform: true };\n\n/** State changes (select fills etc.): snap instantly under reduce motion. */\nexport const stateChangeDuration = (reduced: boolean, durationMs: number): number =>\n reduced ? 0 : durationMs;\n\n/** Looping/ambient animations run only when motion is allowed. */\nexport const loopEnabled = (reduced: boolean): boolean => !reduced;\n","/**\n * useReducedMotion — the kit's ONE reduce-motion gate. Reads the OS setting via\n * AccessibilityInfo and stays subscribed to `reduceMotionChanged`, so every\n * animated component lands on its final frame (or a ~120ms fade) the moment the\n * user flips the setting — no restart needed.\n *\n * This closes the gap documented in ai_rules/rules/performance.md §3: every\n * animation in the kit must consume this hook (usually through the pure helpers\n * in motionSpec.ts: `entranceSpec` / `stateChangeDuration` / `loopEnabled`).\n */\nimport { useEffect, useState } from \"react\";\nimport { AccessibilityInfo } from \"react-native\";\n\n// Last-known value, module-level: cards remount every turn (keyed on message id),\n// and a `useState(false)` default would flash one animated frame per turn for a\n// reduce-motion user before the async read resolves.\nlet lastKnown = false;\n\nexport const useReducedMotion = (): boolean => {\n const [reduced, setReduced] = useState(lastKnown);\n\n useEffect(() => {\n let mounted = true;\n AccessibilityInfo.isReduceMotionEnabled()\n .then((value) => {\n lastKnown = value;\n if (mounted) setReduced(value);\n })\n .catch(() => {\n // Unavailable (e.g. some test envs): keep the last-known value.\n });\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", (value) => {\n lastKnown = value;\n setReduced(value);\n });\n return () => {\n mounted = false;\n sub?.remove();\n };\n }, []);\n\n return reduced;\n};\n","/**\n * AnimatedSparkle — the themed \"AI is thinking\" glyph (✦), animated with RN's\n * built-in `Animated` (native driver) so the kit needs neither reanimated nor a\n * vector-icon dependency.\n *\n * Variants:\n * - \"spin\" (default, unchanged): continuous rotation — the original loader.\n * - \"pulse\": the Wire Activation loading treatment — the mark breathes\n * (opacity 0.35 ↔ 1, 1600ms loop) instead of rotating.\n *\n * Reduce motion: no loop at all — the glyph renders static at full opacity\n * (final frame), per design-refs/EXTRACTED-SPEC.md row 17.\n */\nimport React, { useEffect, useRef } from \"react\";\nimport { Animated, Easing, StyleSheet, Text } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { LOADER_PULSE_MIN_OPACITY, LOADER_PULSE_MS, loopEnabled, scaledMs } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst ROTATION_MS = 1800;\n\nexport type AnimatedSparkleProps = {\n /** Glyph size in px. */\n size?: number;\n /** Override color; defaults to the theme primary. */\n color?: string;\n /** \"spin\" rotates (default, the original), \"pulse\" breathes (the loader treatment). */\n variant?: \"spin\" | \"pulse\";\n};\n\nconst _AnimatedSparkle: React.FC<AnimatedSparkleProps> = ({ size = 30, color, variant = \"spin\" }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const progress = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n if (!loopEnabled(reduced)) {\n // Static final frame: no rotation, full opacity.\n progress.setValue(0);\n return;\n }\n const loop =\n variant === \"pulse\"\n ? Animated.loop(\n Animated.sequence([\n Animated.timing(progress, {\n toValue: 1,\n duration: scaledMs(LOADER_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(progress, {\n toValue: 0,\n duration: scaledMs(LOADER_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n )\n : Animated.loop(\n Animated.timing(progress, {\n toValue: 1,\n duration: scaledMs(ROTATION_MS),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n );\n loop.start();\n return () => loop.stop();\n }, [progress, variant, reduced]);\n\n const rotate = progress.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] });\n const pulse = progress.interpolate({\n inputRange: [0, 1],\n outputRange: [1, LOADER_PULSE_MIN_OPACITY],\n });\n\n const animatedStyle = reduced\n ? undefined\n : variant === \"pulse\"\n ? { opacity: pulse }\n : { transform: [{ rotate }] };\n\n // The glyph lives in a fixed size×size box (alignItems/justifyContent:center) so the\n // font's side-bearing and Android includeFontPadding can't shove the visible mark off\n // center. The box carries the transform too, so a spinning box still rotates around its\n // own center → the ✦ spins in place, optically centered on both axes.\n return (\n <Animated.View style={[styles.box, { width: size, height: size }, animatedStyle]}>\n <Text\n accessibilityElementsHidden\n importantForAccessibility=\"no\"\n style={[\n styles.glyph,\n {\n width: size,\n fontSize: size,\n lineHeight: size,\n color: color ?? t.colors.primary,\n },\n ]}\n >\n ✦\n </Text>\n </Animated.View>\n );\n};\n\nexport const AnimatedSparkle = React.memo(_AnimatedSparkle);\n\nconst styles = StyleSheet.create({\n box: { alignItems: \"center\", justifyContent: \"center\" },\n glyph: {\n textAlign: \"center\",\n textAlignVertical: \"center\",\n includeFontPadding: false,\n },\n});\n","/**\n * LoadingBlock — the \"AI is thinking\" indicator, shown before the first card and\n * between every turn (each round-trip to the backend). The Wire Activation\n * loading treatment: no generic spinner — the brand mark breathes inside a\n * dashed ring while an accent dot orbits it, and skeleton lines appear (softly\n * pulsing) only when the fetch runs past 300ms so a fast turn never flashes\n * placeholder chrome (design-refs/EXTRACTED-SPEC.md rows 17-19).\n *\n * Reduce motion: static mark + copy, no orbit, no pulse.\n */\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { AnimatedSparkle } from \"./AnimatedSparkle\";\nimport {\n LOADER_ORBIT_MS,\n SKELETON_DELAY_MS,\n SKELETON_MIN_OPACITY,\n SKELETON_PULSE_MS,\n loopEnabled,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst STAGE_SIZE = 96;\nconst ORBIT_DOT = 9;\n\nexport type LoadingBlockProps = {\n /** Primary line, e.g. \"Thinking…\". */\n title?: string;\n /** Supporting line under the title. */\n hint?: string;\n};\n\n/** The orbiting accent dot: a full-stage rotating layer with the dot at 12 o'clock. */\nconst OrbitDot: React.FC<{ color: string; reduced: boolean }> = ({ color, reduced }) => {\n const spin = useRef(new Animated.Value(0)).current;\n useEffect(() => {\n if (!loopEnabled(reduced)) return;\n const loop = Animated.loop(\n Animated.timing(spin, {\n toValue: 1,\n duration: scaledMs(LOADER_ORBIT_MS),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n );\n loop.start();\n return () => loop.stop();\n }, [spin, reduced]);\n\n if (reduced) return null;\n const rotate = spin.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] });\n return (\n <Animated.View pointerEvents=\"none\" style={[StyleSheet.absoluteFill, { transform: [{ rotate }] }]}>\n <View style={[styles.orbitDot, { backgroundColor: color }]} />\n </Animated.View>\n );\n};\n\n/** A skeleton line that softly pulses (static under reduce motion). */\nconst SkeletonLine: React.FC<{ width: `${number}%`; delay: number; color: string; reduced: boolean }> = ({\n width,\n delay,\n color,\n reduced,\n}) => {\n const pulse = useRef(new Animated.Value(1)).current;\n useEffect(() => {\n if (!loopEnabled(reduced)) return;\n const loop = Animated.loop(\n Animated.sequence([\n Animated.delay(delay),\n Animated.timing(pulse, {\n toValue: SKELETON_MIN_OPACITY,\n duration: scaledMs(SKELETON_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(pulse, {\n toValue: 1,\n duration: scaledMs(SKELETON_PULSE_MS / 2),\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n );\n loop.start();\n return () => loop.stop();\n }, [pulse, delay, reduced]);\n\n return (\n <Animated.View\n style={[styles.skeletonLine, { width, backgroundColor: color, opacity: reduced ? 1 : pulse }]}\n />\n );\n};\n\nconst _LoadingBlock: React.FC<LoadingBlockProps> = ({\n title = \"Thinking…\",\n hint = \"Personalizing your experience\",\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n // The loader fills its parent (flex:1) and centers in it. In the flow that parent is the\n // scaffold BODY (the same content region the cards render into), so the loader lands at the\n // content-area center — visually consistent with the cards it hands off to. Standalone\n // (LoadingScreen / a playground CardFrame) it centers in whatever bounds it. No screen-inset\n // math and no transform: it inherits the content area it is dropped into, so it is centered\n // in every context by construction.\n\n // Skeleton lines are gated behind the 300ms window: a fast fetch never shows them.\n const [showSkeleton, setShowSkeleton] = useState(false);\n useEffect(() => {\n const timer = setTimeout(() => setShowSkeleton(true), SKELETON_DELAY_MS);\n return () => clearTimeout(timer);\n }, []);\n\n return (\n <View style={[styles.center, { padding: t.spacing.lg }]}>\n {/*\n * The stage is the ANCHOR: it's the only in-flow child, so `justifyContent:\n * center` lands the icon at the true center of the flow area. Title, hint and\n * the (300ms-gated) skeleton hang BELOW it in an absolutely-positioned column,\n * so they never displace the icon — previously they lived in the same centered\n * column, which re-balanced (and jumped the icon UP ~½ its height) the moment\n * the skeleton lines mounted at 300ms.\n */}\n <View style={styles.stage}>\n <View style={[styles.ring, { borderColor: t.colors.border, borderRadius: t.radius.full }]} />\n <OrbitDot color={t.colors.primary} reduced={reduced} />\n <AnimatedSparkle size={40} variant=\"pulse\" />\n </View>\n <View\n style={[\n styles.labels,\n { marginTop: STAGE_SIZE / 2 + t.spacing.lg, gap: t.spacing.md, paddingHorizontal: t.spacing.lg },\n ]}\n pointerEvents=\"none\"\n >\n {title ? (\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n ) : null}\n {hint ? (\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {hint}\n </Text>\n ) : null}\n {showSkeleton ? (\n <View style={[styles.skeleton, { gap: t.spacing.sm, marginTop: t.spacing.sm }]}>\n <SkeletonLine width=\"80%\" delay={0} color={t.colors.surface} reduced={reduced} />\n <SkeletonLine width=\"60%\" delay={200} color={t.colors.surface} reduced={reduced} />\n </View>\n ) : null}\n </View>\n </View>\n );\n};\n\nexport const LoadingBlock = React.memo(_LoadingBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n // Absolutely-positioned label column, pinned just under the centered stage: its top\n // edge starts at the flow center (top: 50%) and the inline marginTop (STAGE_SIZE/2 +\n // a gap) drops it below the stage. Out of flow → it never moves the stage, so the\n // 300ms skeleton reveal grows DOWNWARD only and the icon stays centered.\n labels: { position: \"absolute\", top: \"50%\", left: 0, right: 0, alignItems: \"center\" },\n stage: {\n width: STAGE_SIZE,\n height: STAGE_SIZE,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n ring: {\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n borderWidth: 1.5,\n borderStyle: \"dashed\",\n },\n orbitDot: {\n position: \"absolute\",\n top: -ORBIT_DOT / 2 + 1,\n left: STAGE_SIZE / 2 - ORBIT_DOT / 2,\n width: ORBIT_DOT,\n height: ORBIT_DOT,\n borderRadius: ORBIT_DOT / 2,\n },\n skeleton: { width: \"100%\", alignItems: \"center\" },\n skeletonLine: { height: 12, borderRadius: 6 },\n});\n","/**\n * LoadingScreen — the STANDALONE loader surface: a full-area safe frame that centers a\n * LoadingBlock dead in the middle of the screen. Used for the loader slots that render on\n * their own (no OnboardingScaffold around them): the cold-start \"getting started\" wait, the\n * resumed-session \"restoring\" wait, and the transient error/timeout retry beat.\n *\n * WHY a dedicated frame: those slots used to return a bare <LoadingBlock/>, whose flex:1 only\n * fills whatever the host happened to give it — with no safe area and, if the host didn't\n * bound it, no height at all (top-anchored). This wraps them in the same SafeAreaView the flow\n * uses, so the standalone loaders center exactly like the between-turns loader (both fill their\n * parent flex:1 region and center in it — here the SafeAreaView, in the flow the scaffold body).\n * One consistent centered look.\n */\nimport React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { LoadingBlock, type LoadingBlockProps } from \"./LoadingBlock\";\n\nconst _LoadingScreen: React.FC<LoadingBlockProps> = ({ title, hint }) => {\n const t = useOnboardingTheme();\n return (\n <SafeAreaView\n edges={[\"top\", \"bottom\"]}\n style={[styles.flex, { backgroundColor: t.colors.background }]}\n >\n <LoadingBlock title={title} hint={hint} />\n </SafeAreaView>\n );\n};\n\nexport const LoadingScreen = React.memo(_LoadingScreen);\n\nconst styles = StyleSheet.create({\n flex: { flex: 1 },\n});\n","/**\n * StepProgress — a single themed progress bar that conveys forward motion. It never\n * shows a \"Step X of N\" number (the count would read as a promise the model may not\n * keep), but it can be *paced* two ways:\n *\n * - Default (no `approxScreens`): an asymptotic curve of the step index — always\n * advances, never reaches the end until the flow actually completes.\n * - With `approxScreens`: when the host knows roughly how many screens the flow\n * runs (e.g. the backend's screen budget), the fill tracks `step / approxScreens`\n * (capped below 100% until `complete`). More truthful pacing, still no number.\n */\nimport React, { useEffect, useRef } from \"react\";\nimport { Animated, Easing, StyleSheet, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { PROGRESS_MS, WIRE_BEZIER, scaledMs, stateChangeDuration } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nexport type StepProgressProps = {\n /** 1-based index of the current step. Drives the fill. */\n step: number;\n /** When true, fill to 100% (flow finished). */\n complete?: boolean;\n /**\n * Approximate total number of screens, if known (e.g. the backend screen budget).\n * Paces the bar as `step / approxScreens` instead of the asymptotic curve. Never\n * shown as a number — it only shapes the fill. Omit for the asymptotic default.\n */\n approxScreens?: number;\n};\n\n// Asymptotic default: each step closes ~38% of the remaining gap, so the bar always\n// moves but never hits the end on its own: step1≈38%, step2≈62%, step3≈76%…\nconst DECAY = 0.62;\nconst MIN_FILL = 0.08;\n// When pacing by an approximate total, never look finished until `complete`.\nconst APPROX_CAP = 0.95;\n\nconst targetFor = (step: number, complete?: boolean, approxScreens?: number): number => {\n if (complete) return 1;\n const s = Number.isFinite(step) && step > 0 ? Math.floor(step) : 1;\n if (approxScreens && approxScreens > 0) {\n return Math.max(MIN_FILL, Math.min(APPROX_CAP, s / approxScreens));\n }\n return Math.max(MIN_FILL, 1 - DECAY ** s);\n};\n\nconst _StepProgress: React.FC<StepProgressProps> = ({ step, complete, approxScreens }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const fill = useRef(new Animated.Value(targetFor(step, complete, approxScreens))).current;\n\n // 400ms ease-wire per the design spec (design-refs/EXTRACTED-SPEC.md row 21).\n // A growing total re-targets the same value, so the fill eases forward and never\n // snaps back. Reduce motion: jump straight to the ratio.\n useEffect(() => {\n Animated.timing(fill, {\n toValue: targetFor(step, complete, approxScreens),\n duration: scaledMs(stateChangeDuration(reduced, PROGRESS_MS)),\n easing: easeWire,\n useNativeDriver: false, // animating width %\n }).start();\n }, [fill, step, complete, approxScreens, reduced]);\n\n const width = fill.interpolate({ inputRange: [0, 1], outputRange: [\"0%\", \"100%\"] });\n\n return (\n <View style={[styles.track, { backgroundColor: t.colors.border, borderRadius: t.radius.full }]}>\n <Animated.View\n style={[\n styles.fill,\n { width, backgroundColor: t.colors.primary, borderRadius: t.radius.full },\n ]}\n />\n </View>\n );\n};\n\nexport const StepProgress = React.memo(_StepProgress);\n\nconst styles = StyleSheet.create({\n track: { height: 6, width: \"100%\", overflow: \"hidden\" },\n fill: { height: 6 },\n});\n","/**\n * OnboardingScaffold — the themed shell that wraps every step:\n * [ safe area ]\n * header -> StepProgress (a numberless fill — never \"Step X of N\") + optional Skip\n * body -> the rendered card (children), full-screen (flex: 1)\n * footer -> optional Back link\n *\n * WHY a single scaffold: the body content changes every turn (it's an\n * SDK-rendered card), but the chrome — progress, skip, back, padding, safe area —\n * stays constant. Keeping it here means cards never re-implement the frame.\n *\n * The body no longer centers/scrolls the card: each card fills the body via the\n * shared CardLayout, which owns its own scroll + bottom-pinned CTA (Cal-AI style).\n * The safe area uses `react-native-safe-area-context` (top + bottom edges) — the\n * RN core SafeAreaView is deprecated and iOS-only, so the kit takes the standard\n * Expo/RN peer instead of shipping cropped layouts on Android + notched devices.\n */\nimport React, { useMemo } from \"react\";\nimport { StyleSheet, Text, TouchableOpacity, View } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle } from \"../theme/typography\";\nimport { StepProgress } from \"./StepProgress\";\n\nexport type OnboardingScaffoldProps = {\n /** 1-based index of the current step; drives the (countless) progress bar. */\n step: number;\n /** When true, the progress bar fills to 100% (flow finished). */\n complete?: boolean;\n /** Approximate total screens, if known — paces the bar (never shown). */\n approxScreens?: number;\n /** Optional Back action — hidden when omitted (e.g. on the first step). */\n onBack?: () => void;\n /** Optional Skip action — hidden when omitted. */\n onSkip?: () => void;\n skipLabel?: string;\n backLabel?: string;\n children: React.ReactNode;\n};\n\nconst _OnboardingScaffold: React.FC<OnboardingScaffoldProps> = ({\n step,\n complete,\n approxScreens,\n onBack,\n onSkip,\n skipLabel = \"Skip\",\n backLabel = \"Back\",\n children,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const hit = { top: 12, bottom: 12, left: 12, right: 12 };\n\n return (\n <SafeAreaView\n edges={[\"top\", \"bottom\"]}\n style={[styles.flex, { backgroundColor: t.colors.background }]}\n >\n <View style={[styles.header, { paddingHorizontal: t.spacing.md, paddingTop: t.spacing.md }]}>\n <View style={styles.progressWrap}>\n <StepProgress step={step} complete={complete} approxScreens={approxScreens} />\n </View>\n {onSkip ? (\n <TouchableOpacity onPress={onSkip} hitSlop={hit} style={styles.skip}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted }]}>{skipLabel}</Text>\n </TouchableOpacity>\n ) : null}\n </View>\n\n {/* Full-screen body (flex:1): the card (via CardLayout) fills this and pins its own CTA,\n and the between-turns LoadingBlock fills+centers in this SAME region — so the loader\n lands at the content-area center, consistent with the cards, not the full-screen center. */}\n <View\n style={[styles.body, { paddingHorizontal: t.spacing.md, paddingTop: t.spacing.md }]}\n >\n {children}\n </View>\n\n {onBack ? (\n <View style={[styles.footer, { paddingHorizontal: t.spacing.md, paddingBottom: t.spacing.sm }]}>\n <TouchableOpacity onPress={onBack} hitSlop={hit}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted }]}>{backLabel}</Text>\n </TouchableOpacity>\n </View>\n ) : null}\n </SafeAreaView>\n );\n};\n\nexport const OnboardingScaffold = React.memo(_OnboardingScaffold);\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n flex: { flex: 1 },\n header: { flexDirection: \"row\", alignItems: \"center\" },\n progressWrap: { flex: 1 },\n body: { flex: 1 },\n footer: { flexDirection: \"row\", justifyContent: \"flex-start\" },\n skip: { marginLeft: t.spacing.md },\n });\n}\n","/**\n * Button — the kit's themed primary/outline button, replacing the SDK's hardcoded\n * `Btn`. Every color/radius/font comes from the active theme.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md row 20): \"a footer button that answers\n * the tap\" — scale 1→0.975 spring on press-in, back on release, native driver.\n * Reduce motion: an opacity dip to 0.85 while pressed, no scale. Disabled keeps\n * the `disabled` token fill with no press handler (unchanged).\n */\nimport React, { useCallback, useRef } from \"react\";\nimport { Animated, Pressable, StyleSheet, Text } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { buttonLabelStyle } from \"../theme/typography\";\nimport {\n BUTTON_PRESS_SCALE,\n BUTTON_PRESS_SPRING,\n REDUCED_FADE_MS,\n REDUCED_PRESS_OPACITY,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\ntype Variant = \"primary\" | \"outline\";\n\ntype ButtonProps = {\n title: string;\n onPress?: () => void;\n variant?: Variant;\n disabled?: boolean;\n /** Stretch to the container width — for form-style CTAs (e.g. the review form's\n * \"Send feedback\"). Default false keeps the content-width pill used by cards. */\n fullWidth?: boolean;\n};\n\nconst _Button: React.FC<ButtonProps> = ({\n title,\n onPress,\n variant = \"primary\",\n disabled = false,\n fullWidth = false,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const isPrimary = variant === \"primary\";\n\n // 0 = at rest, 1 = pressed. Scale normally; opacity dip under reduce motion.\n const pressT = useRef(new Animated.Value(0)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) {\n Animated.timing(pressT, {\n toValue: to,\n duration: scaledMs(REDUCED_FADE_MS),\n useNativeDriver: true,\n }).start();\n return;\n }\n Animated.spring(pressT, {\n toValue: to,\n friction: BUTTON_PRESS_SPRING.friction,\n tension: BUTTON_PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressT, reduced],\n );\n const lastPress = useRef<number>(0);\n const handlePress = useCallback(() => {\n if (!onPress) return;\n const now = Date.now();\n if (now - lastPress.current < 500) return;\n lastPress.current = now;\n onPress();\n }, [onPress]);\n\n const handlePressIn = useCallback(() => pressTo(1), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(0), [pressTo]);\n\n const scale = pressT.interpolate({\n inputRange: [0, 1],\n outputRange: [1, reduced ? 1 : BUTTON_PRESS_SCALE],\n });\n const opacity = pressT.interpolate({\n inputRange: [0, 1],\n outputRange: [1, reduced ? REDUCED_PRESS_OPACITY : 1],\n });\n\n return (\n <Pressable\n onPress={disabled ? undefined : handlePress}\n onPressIn={disabled ? undefined : handlePressIn}\n onPressOut={disabled ? undefined : handlePressOut}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityState={{ disabled }}\n style={fullWidth ? styles.fill : undefined}\n >\n <Animated.View\n style={[\n styles.base,\n fullWidth && styles.fill,\n {\n borderRadius: t.button.radius,\n minHeight: t.button.height,\n paddingHorizontal: t.button.paddingX,\n opacity,\n transform: [{ scale }],\n },\n isPrimary\n ? { backgroundColor: disabled ? t.colors.disabled : t.colors.primary }\n : { borderWidth: 1.5, borderColor: disabled ? t.colors.border : t.colors.primary },\n ]}\n >\n <Text\n style={[\n buttonLabelStyle(t.fonts),\n {\n color: disabled\n ? t.colors.textMuted\n : isPrimary\n ? t.colors.onPrimary\n : t.colors.primary,\n },\n ]}\n >\n {title}\n </Text>\n </Animated.View>\n </Pressable>\n );\n};\n\nexport const Button = React.memo(_Button);\n\nconst styles = StyleSheet.create({\n base: { alignItems: \"center\", justifyContent: \"center\" },\n fill: { width: \"100%\" },\n});\n","/**\n * ErrorBlock — shown on backend error/timeout. Carries a retry action so the flow\n * never dead-ends. The host decides what retry does (re-send start, or fall back).\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"./Button\";\n\nexport type ErrorBlockProps = {\n title?: string;\n message?: string;\n retryLabel?: string;\n onRetry?: () => void;\n};\n\nconst _ErrorBlock: React.FC<ErrorBlockProps> = ({\n title = \"Something went wrong\",\n message = \"We couldn't load this step. You can try again.\",\n retryLabel = \"Try again\",\n onRetry,\n}) => {\n const t = useOnboardingTheme();\n return (\n <View style={[styles.center, { gap: t.spacing.md, padding: t.spacing.lg }]}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n {onRetry ? <Button title={retryLabel} onPress={onRetry} variant=\"outline\" /> : null}\n </View>\n );\n};\n\nexport const ErrorBlock = React.memo(_ErrorBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * CardLayout — the shared full-screen card body every card renders into. It owns\n * the Cal-AI style vertical rhythm so no card re-implements layout:\n *\n * [ title ] ← fixed at top (small gap → subtitle)\n * [ subtitle / hint ]\n * [ ─ scrollable content ─ ]← options / chips / input; a flex:1 ScrollView that\n * fills the gap, so it scrolls only when tall and\n * otherwise just pushes the footer down\n * [ footer / CTA ] ← the submit button, ANCHORED to the bottom\n *\n * The middle ScrollView (flex:1) IS the flexible spacer: when the content is short\n * it grows to fill, pinning the footer to the bottom of the screen; when the\n * content is many/tall options it scrolls while the CTA stays put. Everything\n * reads from the theme tokens — no hardcoded spacing or color.\n *\n * `align=\"center\"` vertically centers the content (used by the value/status beats:\n * InterstitialCard / StatusCard), keeping the same pinned-CTA footer.\n *\n * The whole column sits in a KeyboardAvoidingView (behavior=\"padding\") so the pinned\n * footer rides above the soft keyboard on text questions (TextInputCard). On hosts\n * whose window already resizes for the keyboard the computed overlap is ~0, so the\n * padding is a no-op — safe on both iOS and Android, edge-to-edge or not.\n */\nimport React, { useMemo } from \"react\";\nimport { KeyboardAvoidingView, ScrollView, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle, labelStyle } from \"../theme/typography\";\n\nexport type CardLayoutProps = {\n /** Fixed question/label shown at the top. Omit for a header-less centered beat. */\n title?: string;\n /** Optional supporting line under the title (small gap between them). */\n subtitle?: string;\n /** The options / chips / input area — the scrollable middle. */\n children: React.ReactNode;\n /** The pinned bottom CTA (usually a <Button/>). Omitted → no footer. */\n footer?: React.ReactNode;\n /** Vertical alignment of the middle content. \"top\" (questions) | \"center\" (beats). */\n align?: \"top\" | \"center\";\n /** Custom title node (e.g. StatusCard's icon+title row) rendered in place of `title`. */\n titleNode?: React.ReactNode;\n};\n\nconst _CardLayout: React.FC<CardLayoutProps> = ({\n title,\n subtitle,\n children,\n footer,\n align = \"top\",\n titleNode,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const hasHeader = !!title || !!subtitle || !!titleNode;\n\n return (\n <KeyboardAvoidingView style={styles.fill} behavior=\"padding\">\n {hasHeader ? (\n <View style={styles.header}>\n {titleNode ??\n (title ? (\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{title}</Text>\n ) : null)}\n {subtitle ? (\n <Text\n style={[\n bodyStyle(t.fonts),\n { color: t.colors.textMuted, marginTop: t.spacing.xs },\n ]}\n >\n {subtitle}\n </Text>\n ) : null}\n </View>\n ) : null}\n\n <ScrollView\n style={styles.fill}\n contentContainerStyle={[\n styles.scrollContent,\n align === \"center\" && styles.center,\n ]}\n keyboardShouldPersistTaps=\"handled\"\n keyboardDismissMode=\"on-drag\"\n showsVerticalScrollIndicator={false}\n >\n {children}\n </ScrollView>\n\n {footer ? <View style={styles.footer}>{footer}</View> : null}\n </KeyboardAvoidingView>\n );\n};\n\nexport const CardLayout = React.memo(_CardLayout);\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n fill: { flex: 1 },\n header: { marginBottom: t.spacing.lg },\n footer: { paddingTop: t.spacing.lg },\n // flexGrow lets a short content block grow to fill (pinning the footer) while a\n // tall one scrolls past the visible area.\n scrollContent: { flexGrow: 1 },\n center: { justifyContent: \"center\" },\n });\n}\n","/**\n * CompletionView — the terminal \"you're all set\" screen, shown when the flow\n * reaches its final StatusCard. It surfaces the backend's recap (what the app\n * will do for the user, derived from their answers) and a single clear CTA.\n *\n * WHY a dedicated screen (not an instant hand-off): the backend spends the last\n * turn summarizing the user's tastes and what their experience will now look\n * like. The user should actually SEE that payoff and tap to continue — so\n * `onContinue` fires only on the button press, never automatically.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 14-16, the peak-end beat): the\n * badge pops in with a spring (scale 0.4→1, slight overshoot), ONE soft accent\n * burst radiates once behind it (scale 0.4→1.5, opacity 0.5→0, 500ms) —\n * celebratory without confetti — and the copy fades up 80ms apart. Everything\n * settles well under a second. Reduce motion: final frame, no burst.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"./Button\";\nimport { CardLayout } from \"./CardLayout\";\nimport {\n STATUS_BURST_MS,\n STATUS_BURST_OPACITY_FROM,\n STATUS_BURST_SCALE_FROM,\n STATUS_BURST_SCALE_TO,\n STATUS_COPY_MS,\n STATUS_POP_SCALE_FROM,\n STATUS_POP_SPRING,\n WIRE_BEZIER,\n scaledMs,\n statusCopyDelay,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\nconst BADGE_SIZE = 64;\nconst BURST_SIZE = 104;\n\nexport type CompletionViewProps = {\n title: string;\n message?: string;\n ctaLabel?: string;\n onContinue: () => void;\n};\n\nconst _CompletionView: React.FC<CompletionViewProps> = ({\n title,\n message,\n ctaLabel = \"Let's go\",\n onContinue,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const [submitted, setSubmitted] = useState(false);\n\n const pop = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const burst = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const titleT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const messageT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n\n useEffect(() => {\n if (reduced) {\n // Final frame: badge + copy settled, burst already faded out.\n pop.setValue(1);\n burst.setValue(1);\n titleT.setValue(1);\n messageT.setValue(1);\n return;\n }\n const rise = (value: Animated.Value, delay: number) =>\n Animated.timing(value, {\n toValue: 1,\n duration: scaledMs(STATUS_COPY_MS),\n delay,\n easing: easeWire,\n useNativeDriver: true,\n });\n const anims = [\n Animated.spring(pop, {\n toValue: 1,\n friction: STATUS_POP_SPRING.friction,\n tension: STATUS_POP_SPRING.tension,\n useNativeDriver: true,\n }),\n // One-shot celebratory burst: fires once, never loops.\n Animated.timing(burst, {\n toValue: 1,\n duration: scaledMs(STATUS_BURST_MS),\n easing: Easing.out(Easing.ease),\n useNativeDriver: true,\n }),\n rise(titleT, scaledMs(statusCopyDelay(0))),\n rise(messageT, scaledMs(statusCopyDelay(1))),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, pop, burst, titleT, messageT]);\n\n const handlePress = useCallback(() => {\n if (submitted) return;\n setSubmitted(true);\n onContinue();\n }, [submitted, onContinue]);\n\n const scale = pop.interpolate({ inputRange: [0, 1], outputRange: [STATUS_POP_SCALE_FROM, 1] });\n const burstScale = burst.interpolate({\n inputRange: [0, 1],\n outputRange: [STATUS_BURST_SCALE_FROM, STATUS_BURST_SCALE_TO],\n });\n const burstOpacity = burst.interpolate({\n inputRange: [0, 1],\n outputRange: [STATUS_BURST_OPACITY_FROM, 0],\n });\n const riseStyle = (value: Animated.Value) => ({\n opacity: value,\n transform: [{ translateY: value.interpolate({ inputRange: [0, 1], outputRange: [10, 0] }) }],\n });\n\n return (\n <CardLayout\n align=\"center\"\n footer={<Button title={ctaLabel} onPress={handlePress} variant=\"primary\" disabled={submitted} />}\n >\n <View style={[styles.center, { gap: t.spacing.md }]}>\n <View style={styles.badgeStage}>\n {/* Soft accent burst behind the badge: primarySoft keeps the tint calm. */}\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.burst,\n {\n backgroundColor: t.colors.primarySoft,\n borderRadius: t.radius.full,\n opacity: burstOpacity,\n transform: [{ scale: burstScale }],\n },\n ]}\n />\n <Animated.View\n style={[\n styles.badge,\n {\n backgroundColor: t.colors.primarySoft,\n borderRadius: t.radius.full,\n transform: [{ scale }],\n opacity: pop,\n },\n ]}\n >\n <Text style={[styles.check, { color: t.colors.primary }]}>✓</Text>\n </Animated.View>\n </View>\n\n <Animated.View style={riseStyle(titleT)}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>\n {title}\n </Text>\n </Animated.View>\n {message ? (\n <Animated.View style={riseStyle(messageT)}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n </Animated.View>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const CompletionView = React.memo(_CompletionView);\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n badgeStage: {\n width: BURST_SIZE,\n height: BURST_SIZE,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n burst: { position: \"absolute\", width: BURST_SIZE, height: BURST_SIZE },\n badge: { width: BADGE_SIZE, height: BADGE_SIZE, alignItems: \"center\", justifyContent: \"center\" },\n check: { fontSize: 34, fontWeight: \"800\" },\n});\n","/**\n * CardHandoff — the card-to-card transition from the Wire Activation design:\n * \"cards hand off, they don't cut\". When `transitionKey` changes, the outgoing\n * child leaves left (translateX 0→-26, fade, 180ms) in an absolute layer while\n * the incoming child arrives from the right (translateX +26→0, fade, 220ms)\n * delayed by the 80ms exit lead — one moving surface, ~300ms total.\n *\n * Variants (per child):\n * - \"slide\": questions — the directional stepper motion above.\n * - \"spring\": the InterstitialCard value beat — scale 0.96→1 spring pop\n * (the shell's springier variant, kept from AnimatedCard).\n * - \"fade\": loaders — enter/exit as a plain 120ms fade so the \"thinking\"\n * state hands off to the first card without a hard cut.\n *\n * `direction` mirrors the whole slide for BACK navigation, so a step the user\n * returns to comes back from the side it left toward. Spatial consistency: if\n * \"next\" pushes left, \"back\" must pull right, or the stack loses its geography.\n *\n * `layout` picks how the moving surface is sized. \"fill\" (default) is the\n * full-screen flow, where the pane owns the viewport. \"auto\" is for a pane\n * inside an auto-height container (the CenteredModal card): `flex: 1` there\n * resolves to a ZERO-height child under Yoga — flex-basis 0 with no free space\n * to grow into — so the in-flow layer must size to its own content instead.\n *\n * Reduce motion: every handoff becomes a 120ms crossfade, no translate/scale.\n * All values run on the native driver (transform/opacity only); in-flight\n * animations are stopped when superseded and on unmount.\n *\n * This SUPERSEDES the enter-only AnimatedCard: same keyed-remount contract from\n * OnboardingFlow (the child renderer stays keyed on the message id), plus the\n * paired exit layer the design calls for.\n */\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet } from \"react-native\";\nimport {\n CARD_ENTER_MS,\n CARD_ENTER_SCALE_FROM,\n CARD_EXIT_LEAD_MS,\n CARD_EXIT_MS,\n CARD_SLIDE_PX,\n CARD_SPRING,\n LOADER_HANDOFF_FADE_MS,\n REDUCED_FADE_MS,\n WIRE_BEZIER,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nexport type CardHandoffVariant = \"slide\" | \"spring\" | \"fade\";\n\n/** Which way the stack is moving. \"backward\" mirrors the slide (see the header note). */\nexport type CardHandoffDirection = \"forward\" | \"backward\";\n\n/** How the moving surface is sized. \"auto\" = a pane in an auto-height container. */\nexport type CardHandoffLayout = \"fill\" | \"auto\";\n\nexport type CardHandoffProps = {\n /** Identity of the current child (e.g. the message id). A change runs the handoff. */\n transitionKey: string;\n /** How the CURRENT child enters (and, snapshotted, how it will later exit). */\n variant?: CardHandoffVariant;\n /** Travel direction of THIS transition. Default \"forward\". */\n direction?: CardHandoffDirection;\n /** Sizing mode. Default \"fill\" (the full-screen flow). */\n layout?: CardHandoffLayout;\n children: React.ReactNode;\n};\n\ntype Snapshot = { key: string; node: React.ReactNode; variant: CardHandoffVariant };\n\nconst _CardHandoff: React.FC<CardHandoffProps> = ({\n transitionKey,\n variant = \"slide\",\n direction = \"forward\",\n layout = \"fill\",\n children,\n}) => {\n const reduced = useReducedMotion();\n const [leaving, setLeaving] = useState<Snapshot | null>(null);\n\n const enterT = useRef(new Animated.Value(0)).current;\n const exitT = useRef(new Animated.Value(0)).current;\n // The previous render's child, snapshotted so it can play the exit layer.\n const prev = useRef<Snapshot>({ key: transitionKey, node: children, variant });\n const running = useRef<{ enter?: Animated.CompositeAnimation; exit?: Animated.CompositeAnimation }>({});\n const mounted = useRef(false);\n\n // One orchestration effect, run every render: refresh the snapshot while the key\n // is stable; on a key change, snapshot the old child into the exit layer and run\n // the paired exit+enter. (No deps array on purpose — `children` is a fresh node\n // every parent render and must keep the snapshot current.)\n useEffect(() => {\n const last = prev.current;\n prev.current = { key: transitionKey, node: children, variant };\n\n // First mount: enter only (the design's initial reveal), nothing exits.\n if (!mounted.current) {\n mounted.current = true;\n running.current.enter = startEnter(enterT, variant, reduced, 0);\n return;\n }\n if (last.key === transitionKey) return;\n\n running.current.enter?.stop();\n running.current.exit?.stop();\n setLeaving(last);\n enterT.setValue(0);\n exitT.setValue(0);\n\n const exitDuration = reduced\n ? REDUCED_FADE_MS\n : last.variant === \"fade\"\n ? LOADER_HANDOFF_FADE_MS\n : CARD_EXIT_MS;\n const exit = Animated.timing(exitT, {\n toValue: 1,\n duration: scaledMs(exitDuration),\n easing: easeWire,\n useNativeDriver: true,\n });\n running.current.exit = exit;\n exit.start();\n\n const enter = startEnter(enterT, variant, reduced, reduced ? 0 : CARD_EXIT_LEAD_MS, () =>\n setLeaving(null),\n );\n running.current.enter = enter;\n });\n\n // Stop anything in flight on unmount (leaked animations drain the JS thread).\n useEffect(\n () => () => {\n running.current.enter?.stop();\n running.current.exit?.stop();\n },\n [],\n );\n\n const enterStyle = {\n opacity: enterT,\n transform: transformFor(variant, enterT, reduced, \"enter\", direction),\n };\n\n return (\n <>\n {leaving ? (\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n {\n opacity: exitT.interpolate({ inputRange: [0, 1], outputRange: [1, 0] }),\n // The CURRENT direction drives BOTH layers: one transition, one geography.\n transform: transformFor(leaving.variant, exitT, reduced, \"exit\", direction),\n },\n ]}\n >\n {leaving.node}\n </Animated.View>\n ) : null}\n <Animated.View key={variant} style={[layout === \"fill\" ? styles.fill : null, enterStyle]}>\n {children}\n </Animated.View>\n </>\n );\n};\n\n/** Kick off the enter animation for a variant (spring for the value beat, timing otherwise). */\nconst startEnter = (\n value: Animated.Value,\n variant: CardHandoffVariant,\n reduced: boolean,\n delay: number,\n onDone?: () => void,\n): Animated.CompositeAnimation => {\n value.setValue(0);\n const anim =\n !reduced && variant === \"spring\"\n ? Animated.spring(value, {\n toValue: 1,\n delay: scaledMs(delay),\n damping: CARD_SPRING.damping,\n stiffness: CARD_SPRING.stiffness,\n mass: CARD_SPRING.mass,\n useNativeDriver: true,\n })\n : Animated.timing(value, {\n toValue: 1,\n delay: scaledMs(delay),\n duration: scaledMs(\n reduced\n ? REDUCED_FADE_MS\n : variant === \"fade\"\n ? LOADER_HANDOFF_FADE_MS\n : CARD_ENTER_MS,\n ),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start(({ finished }) => {\n if (finished) onDone?.();\n });\n return anim;\n};\n\n/**\n * Transform track per variant/layer; reduce motion = opacity-only crossfade.\n *\n * `travel` mirrors the X axis: forward pushes the stack left (new arrives from the\n * right), backward pulls it right (new arrives from the left).\n */\nconst transformFor = (\n variant: CardHandoffVariant,\n t: Animated.Value,\n reduced: boolean,\n layer: \"enter\" | \"exit\",\n travel: CardHandoffDirection,\n) => {\n if (reduced || variant === \"fade\") return [];\n if (variant === \"spring\" && layer === \"enter\") {\n return [{ scale: t.interpolate({ inputRange: [0, 1], outputRange: [CARD_ENTER_SCALE_FROM, 1] }) }];\n }\n const slide = travel === \"forward\" ? CARD_SLIDE_PX : -CARD_SLIDE_PX;\n return [\n {\n translateX: t.interpolate({\n inputRange: [0, 1],\n outputRange: layer === \"enter\" ? [slide, 0] : [0, -slide],\n }),\n },\n ];\n};\n\nexport const CardHandoff = React.memo(_CardHandoff);\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n});\n","/**\n * deriveAnswers — read the user's structured choices off the thread.\n *\n * The cards send answers back as natural-language strings (the SDK's\n * useWireAIAction wraps them, e.g. `I selected: [\"Food\",\"Travel\"]`,\n * `My answer is: \"Casablanca\"`). We pair each rendered question with the reply\n * that followed it and key the answer by the backend's progress `key` when\n * present (so `username`/`interests`/`city` come back under their real keys),\n * else by the question text. No second LLM call — the values ARE the data.\n */\nimport type { Message } from \"wireai-rn\";\n\nconst stripPrefix = (s: string): string =>\n s.replace(/^(I selected:|My answer is:|I tapped:)\\s*/i, \"\").trim();\n\nconst tryParse = (s: string): unknown => {\n try {\n return JSON.parse(s);\n } catch {\n return s;\n }\n};\n\nexport const deriveAnswers = (messages: Message[]): Record<string, unknown> => {\n const out: Record<string, unknown> = {};\n for (let i = 0; i < messages.length; i++) {\n const m = messages[i];\n const r = m?.response;\n if (!m || m.role !== \"assistant\" || !r || r.action !== \"render\") continue;\n\n const props = (r.props ?? {}) as Record<string, unknown>;\n const progress = props.progress as { key?: string } | undefined;\n const questionText =\n (props.title as string) ?? (props.label as string) ?? (props.question as string);\n const key = progress?.key || questionText;\n\n const reply = messages[i + 1];\n if (key && reply?.role === \"user\") {\n out[key] = tryParse(stripPrefix(reply.content));\n }\n }\n return out;\n};\n","/**\n * readProgress — pull the backend's progress metadata off a render response.\n *\n * The managed backend rides `{ step, total, key }` inside the Wire envelope's\n * `props.progress`. That's the only field that survives the SDK's strict client\n * validation (extra top-level keys get folded into props; the card's own schema\n * silently strips `progress` from its render props, but it stays readable on\n * `response.props`). All fields are optional so an older backend just falls back\n * to the local counter.\n */\nimport type { WireAIResponse } from \"wireai-rn\";\nimport type { OnboardingProgress } from \"../types\";\n\ntype PartialProgress = {\n step?: number;\n total?: number;\n key?: string;\n skippable?: boolean;\n};\n\nexport const readProgress = (response?: WireAIResponse): PartialProgress => {\n if (!response || response.action !== \"render\") return {};\n const props = (response.props ?? {}) as Record<string, unknown>;\n const raw = props.progress;\n if (!raw || typeof raw !== \"object\") return {};\n const p = raw as Partial<OnboardingProgress>;\n return {\n step: typeof p.step === \"number\" ? p.step : undefined,\n total: typeof p.total === \"number\" ? p.total : undefined,\n key: typeof p.key === \"string\" ? p.key : undefined,\n skippable: typeof p.skippable === \"boolean\" ? p.skippable : undefined,\n };\n};\n","/**\n * reportClientEvent — forward DEVICE-ONLY onboarding events to the Wire AI analytics\n * backend (`POST {serverUrl}/v1/events`), completing the funnel for events the server\n * can't observe on its own.\n *\n * The backend already records the server-observable funnel during the A2A flow\n * (`session_started`, `screen_shown`, `answer_submitted`, `completed`, `llm_fallback`,\n * and even `screen_skipped` — it derives that from the kit's skip sentinel). The one\n * event no server request can capture is `dropped`: the user closing the app / unmounting\n * the flow without finishing. That's what this reporter is for.\n *\n * Contract (server: routers/onboarding.py → analytics/events.py):\n * POST {serverUrl}/v1/events\n * Authorization: Bearer {apiKey}\n * { \"events\": [ { event_type, session_id, screen_index?, component?, question_key?,\n * latency_ms?, meta?, device?, user_context? } ] }\n * The server fills `app_id` + `environment` from the resolving key (never send app_id),\n * and silently skips malformed events — one bad payload never fails the batch.\n *\n * ⚠️ Correlation: `session_id` MUST equal the A2A `contextId` the server uses to key the\n * server-side events, or the funnel report (which groups by `session_id`) treats this as a\n * phantom session. See `makeSessionId` + WireOnboarding for how the kit seeds it.\n *\n * Fire-and-forget: this never throws into the UI and never awaits — analytics must never\n * be able to break onboarding.\n */\nimport type { DeviceContext } from \"../device/deviceContext\";\n\n/** Event types a CLIENT may report. The rest of the funnel is server-side; sending those\n * here would double-count. `screen_skipped` is included for completeness, but the kit does\n * NOT emit it — the backend already derives it from the skip sentinel (see OnboardingFlow).\n * `client_fallback` is emitted by the kit when the AI flow degrades to the static fallback,\n * so the dashboard's fallback-rate counts the whole-flow case (distinct from the server's\n * per-turn `llm_fallback`). The server back-fills a `session_started` for it if unseen.\n * This is the SINGLE fallback signal — hosts must NOT also report their own.\n * `identify` binds the host's opaque `user_id` to this `session_id` (late binding — the user\n * registered during/after onboarding). It carries no funnel weight; the server maps the\n * session to the user and back-fills a `session_started` if it never saw the session.\n * `app_event` is the host's own in-app event (the `createAnalytics` façade's `track`/`screen`\n * route through the offline queue as first-class `ClientEvent`s). The server already ingests\n * it — `reportAppEvent` (reviews/transport) has fired `event_type='app_event'` all along; this\n * widening just lets the same shape flow through the durable queue instead of a blind POST. */\nexport type ClientEventType =\n | \"screen_skipped\"\n | \"dropped\"\n | \"client_fallback\"\n | \"identify\"\n | \"app_event\";\n\n/** One client-reported event. Mirrors the server's `OnboardingEvent` (client-settable fields). */\nexport type ClientEvent = {\n event_type: ClientEventType;\n /** Must match the server-side A2A contextId for this onboarding (see makeSessionId). */\n session_id: string;\n /** 0-based index of the screen the event refers to (matches server `screen_shown`). */\n screen_index?: number;\n component?: string;\n question_key?: string;\n latency_ms?: number;\n /** JSON-stringified extras; the server stores it verbatim. */\n meta?: string;\n /**\n * Privacy-label-neutral device snapshot (platform / form factor / locale / host appVersion).\n * Sent as an object; the server sanitizes + persists it and derives a coarse country. Old\n * servers ignore this unknown field — fully backward compatible. See device/deviceContext.ts.\n */\n device?: DeviceContext;\n /**\n * Host-injected, non-PII context (signup method, referral, plan, hashed user id). Old servers\n * ignore it. MUST NOT contain PII like raw emails — see the README `userContext` section.\n */\n user_context?: Record<string, string | number | boolean>;\n /**\n * The host's OPAQUE PSEUDONYMOUS user id (their internal id, NOT an email/name). Required on\n * `identify`, optional (rides along) on other events. Trimmed + capped at 128 chars host-side.\n * Lets the backend reconcile onboarding sessions to real users. Old servers ignore it.\n */\n user_id?: string;\n /**\n * Client-stamped epoch-ms timestamp of when the event was ENQUEUED on the device. Optional and\n * ADDITIVE: the offline queue stamps it at enqueue time (see `createEventQueue`) so two otherwise\n * byte-identical events fired seconds apart (a genuine repeat, e.g. the user taps \"share\" twice)\n * are NOT collapsed by the queue's identical-JSON de-dup — while two truly simultaneous\n * re-enqueues of the same instant (a redundant re-render) still share a `ts` and collapse. A raw\n * `Date.now()`, never a wall-clock the server trusts (the server derives its own receive time);\n * an old/strict server that does not model it simply ignores the unknown field.\n */\n ts?: number;\n};\n\n/** Where to POST. Derived from `WireOnboardingConfig` (`serverUrl` + `apiKey`). */\nexport type ClientEventTarget = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n};\n\n/**\n * A unique-per-onboarding session id. Used both as the client event `session_id` AND as the\n * seed the kit forwards to the backend so the SERVER adopts it as the A2A `contextId` — making\n * client and server agree (see WireOnboarding + the SDK-correlation note in the kit docs).\n * No crypto dependency: timestamp + random is collision-safe for a single device's onboarding.\n */\nexport const makeSessionId = (): string =>\n `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * The ONE place the `/v1/events` POST is described (url + method + headers + body). Both the\n * fire-and-forget {@link reportClientEvents} and the awaitable {@link reportClientEventsAwait}\n * build their request here so there is a SINGLE definition of the events transport — no second\n * copy of the endpoint path, headers, or envelope shape to drift. Returns `null` when there is\n * nothing to send (no target / no events) or serialization throws, so callers just bail.\n */\nexport const buildEventsRequest = (\n target: { serverUrl: string; apiKey?: string } | undefined,\n events: ClientEvent[],\n): { url: string; init: RequestInit } | null => {\n if (!target?.serverUrl || events.length === 0) return null;\n try {\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n return { url, init: { method: \"POST\", headers, body: JSON.stringify({ events }) } };\n } catch {\n // URL construction or JSON serialization failed — nothing to send.\n return null;\n }\n};\n\n/**\n * POST one or more client events, fire-and-forget. A missing/invalid target, a build error,\n * a missing `fetch`, or a network failure is swallowed — the call returns immediately and the\n * request (if any) runs in the background.\n */\nexport const reportClientEvents = (\n target: ClientEventTarget | undefined,\n events: ClientEvent[],\n): void => {\n try {\n const req = buildEventsRequest(target, events);\n if (!req) return;\n void fetch(req.url, req.init).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // A missing `fetch` — swallow.\n }\n};\n\n/** Convenience single-event wrapper around {@link reportClientEvents}. */\nexport const reportClientEvent = (\n target: ClientEventTarget | undefined,\n event: ClientEvent,\n): void => reportClientEvents(target, [event]);\n\n/**\n * AWAITABLE sibling of {@link reportClientEvents}: POST one or more client events through the SAME\n * `/v1/events` path, but resolve only once the server has RESPONDED — so a decision re-fetch fired\n * immediately after is guaranteed to see the event in the session stream (this is the guarantee\n * `wire.track` needs before it triggers decision revalidation). Never throws: a missing/invalid\n * target, a missing `fetch`, a network error, or a non-2xx status all resolve to `false`. Resolves\n * `true` only on a 2xx response.\n */\nexport const reportClientEventsAwait = async (\n target: ClientEventTarget | undefined,\n events: ClientEvent[],\n): Promise<boolean> => {\n try {\n const req = buildEventsRequest(target, events);\n if (!req) return false;\n const res = await fetch(req.url, req.init);\n return Boolean(res && res.ok);\n } catch {\n // Unreachable / missing-fetch / network — best-effort, report failure.\n return false;\n }\n};\n\n/** Convenience single-event wrapper around {@link reportClientEventsAwait}. */\nexport const reportClientEventAwait = (\n target: ClientEventTarget | undefined,\n event: ClientEvent,\n): Promise<boolean> => reportClientEventsAwait(target, [event]);\n","/**\n * sendPreview — fire-and-forget PREFETCH of the next A2A turn, so the backend can warm\n * its generation cache during a moment the user isn't waiting.\n *\n * Two callers, both firing the SAME text the real commit will send (the backend keys the\n * preview cache on the raw message string, so a mismatch just misses harmlessly):\n * 1. InterstitialCard — its answer is always \"continue\" (SDK-wrapped `My answer is: \"continue\"`),\n * warmed while the user reads the momentum screen.\n * 2. Choice cards (Selection/ChipSelect) — warmed on selection-change with the exact\n * `I selected: ${JSON.stringify(value)}` the Continue tap will send, so the perceptibly-slow\n * first LLM question returns from cache. See OnboardingFlow.previewOnSelect.\n *\n * Contract (mirrors the A2A `message/send` shape, but a distinct `method`):\n * POST {serverUrl}/a2a\n * Authorization: Bearer {apiKey}\n * { jsonrpc:\"2.0\", id:<rand>, method:\"message/preview\",\n * params:{ message:{ role:\"user\", parts:[{ text }] }, contextId:<sessionId>,\n * metadata:{ sessionId } } }\n *\n * Fire-and-forget, exactly like reportClientEvent: never awaits, never throws into the UI —\n * a prefetch that fails just means the real turn generates normally.\n */\n\n/** Where to POST the preview. Same tenant creds as the flow (`serverUrl` + `apiKey`). */\nexport type PreviewTarget = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/a2a` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n};\n\n/** What to preview: the session to warm and the message the user is about to send. */\nexport type PreviewArgs = {\n /** A2A contextId for this onboarding (the kit session id). */\n sessionId: string;\n /** The message that will be committed next (for interstitials, always \"continue\"). */\n userMessage: string;\n};\n\n/**\n * Warm the next turn's cache, fire-and-forget. A missing/invalid target, a build error,\n * a missing `fetch`, or a network failure is swallowed — the call returns immediately and\n * the request (if any) runs in the background.\n */\nexport const sendPreview = (\n target: PreviewTarget | undefined,\n { sessionId, userMessage }: PreviewArgs,\n): void => {\n if (!target?.serverUrl) return;\n try {\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/a2a`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n void fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: Math.floor(Math.random() * 1e9),\n method: \"message/preview\",\n params: {\n message: { role: \"user\", parts: [{ text: userMessage }] },\n contextId: sessionId,\n metadata: { sessionId },\n },\n }),\n }).catch(() => {\n // Network/transport error — prefetch is best-effort, swallow.\n });\n } catch {\n // URL construction, JSON serialization, or a missing fetch — swallow.\n }\n};\n","/**\n * OnboardingFlow — the inner engine. Mirrors the proven production-app usage of the SDK\n * (useWireAIThread + useWireAIAction + ComponentRenderer) and layers on the kit's\n * shell, progress, and per-step validators.\n *\n * Lifecycle per turn:\n * 1. Auto-send `startMessage` once → backend returns the first card.\n * 2. Show LoadingBlock until the first card arrives AND between every turn\n * (while `isLoading`); on error/timeout, auto-retry up to `maxRetries`, then\n * degrade to the host's static `fallbackFlow` (preferred), else `onError`, else\n * an inline ErrorBlock — so a generation failure never breaks onboarding.\n * 3. Render the latest card inside OnboardingScaffold. The progress bar follows\n * an asymptotic curve of the step index — it never reveals a total.\n * 4. Before any answer is sent, if the current screen's question key has a\n * validator, run it; on failure show the error inline and DON'T advance.\n * 5. On the terminal StatusCard, show CompletionView (the recap of what the app\n * will do for the user) and fire onComplete only when they tap its CTA.\n *\n * Lifecycle events (started / per-turn / error) are surfaced via `onEvent` so a\n * host can keep its analytics even though the kit owns the thread loop.\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n ComponentRenderer,\n useWireAIAction,\n useWireAIThread,\n type Message,\n} from \"wireai-rn\";\nimport { OnboardingScaffold } from \"./components/OnboardingScaffold\";\nimport { LoadingBlock } from \"./components/LoadingBlock\";\nimport { LoadingScreen } from \"./components/LoadingScreen\";\nimport { ErrorBlock } from \"./components/ErrorBlock\";\nimport { CompletionView } from \"./components/CompletionView\";\nimport { CardHandoff } from \"./components/CardHandoff\";\nimport { deriveAnswers } from \"./utils/deriveAnswers\";\nimport { readProgress } from \"./utils/readProgress\";\nimport { reportClientEvent, type ClientEventTarget } from \"./analytics/reportClientEvent\";\nimport { sendPreview } from \"./analytics/sendPreview\";\nimport type { DeviceContext } from \"./device/deviceContext\";\nimport type { OnboardingCopy, OnboardingEvent, OnboardingResult, StepValidator } from \"./types\";\n\ntype OnboardingFlowProps = {\n validators?: Record<string, StepValidator>;\n onComplete: (result: OnboardingResult) => void;\n onSkip?: () => void;\n onError?: (err: unknown) => void;\n onEvent?: (event: OnboardingEvent) => void;\n copy?: Partial<OnboardingCopy>;\n approxScreens?: number;\n startMessage: string;\n startTimeoutMs: number;\n /** Static onboarding rendered when the AI flow fails and retries are exhausted. */\n fallbackFlow?: React.ReactNode;\n /** Consecutive failures to auto-retry before degrading. */\n maxRetries: number;\n /** Where to POST device-only client events (`dropped`). Omit to disable reporting. */\n reportTarget?: ClientEventTarget;\n /** Session id shared with the backend (A2A contextId), so `dropped` correlates. */\n sessionId: string;\n /**\n * Device snapshot + host-injected user context, attached to every client event so the\n * backend can segment the funnel by device. Old servers ignore the extra fields.\n */\n clientContext?: {\n device?: DeviceContext;\n userContext?: Record<string, string | number | boolean>;\n /** The host's opaque user id (see WireOnboarding `userId`), rides `dropped`/`client_fallback`. */\n userId?: string;\n };\n /**\n * True when `sessionId` was restored from persisted storage (app killed mid-flow).\n * The kickoff then sends the skip sentinel instead of `startMessage` — the server\n * would record the literal start text as the ANSWER to the pending question, while\n * the sentinel advances one card recording nothing — and fires `resumed` instead of\n * `started` so host funnels don't double-count the session.\n */\n resumed?: boolean;\n};\n\n// The kit's per-question Skip sends this sentinel; the backend skips ONE question\n// (advances one card, no answer recorded). Must match the backend's SKIP_ONE_SENTINEL.\nconst SKIP_ONE_SENTINEL = \"__wireai_skip__\";\n\n// Callbacks that carry the user's ANSWER (and so must pass validation first).\nconst ANSWER_CALLBACKS = [\"onSubmit\", \"onSelect\", \"onConfirm\", \"onPress\"] as const;\n\nexport const DEFAULT_COPY: OnboardingCopy = {\n startingTitle: \"Getting started…\",\n startingHint: \"Setting up your onboarding\",\n restoringTitle: \"Picking up where you left off…\",\n restoringHint: \"Restoring your session\",\n thinkingTitle: \"Personalizing…\",\n thinkingHint: \"Tailoring your next question\",\n checkingTitle: \"Checking…\",\n checkingHint: \"One moment\",\n completeTitle: \"You're all set\",\n completeCta: \"Let's go\",\n};\n\nexport const OnboardingFlow: React.FC<OnboardingFlowProps> = ({\n validators,\n onComplete,\n onError,\n onEvent,\n copy,\n approxScreens,\n startMessage,\n startTimeoutMs,\n fallbackFlow,\n maxRetries,\n reportTarget,\n sessionId,\n resumed = false,\n clientContext,\n}) => {\n const { messages, error, isLoading, sendMessage, reset } = useWireAIThread();\n const makeActions = useWireAIAction(sendMessage);\n\n const c = useMemo<OnboardingCopy>(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);\n\n // Hold the latest event/error callbacks in refs so the lifecycle effects below\n // stay stable (and fire exactly once) regardless of the host re-passing closures.\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onCompleteRef = useRef(onComplete);\n onCompleteRef.current = onComplete;\n const validatorsRef = useRef(validators);\n validatorsRef.current = validators;\n\n // Client-event reporting refs, captured so the unmount cleanup (which runs once, with a\n // stale closure) reads current values.\n const reportTargetRef = useRef(reportTarget);\n reportTargetRef.current = reportTarget;\n const sessionIdRef = useRef(sessionId);\n sessionIdRef.current = sessionId;\n // Device + user context, held in a ref so the mount-once unmount cleanup (the `dropped`\n // reporter, which runs with a stale closure) reads the current snapshot.\n const clientContextRef = useRef(clientContext);\n clientContextRef.current = clientContext;\n // Last 0-based screen index we showed the user (matches the server's `screen_shown`\n // index). Used as the `dropped` event's screen_index. -1 = nothing shown yet.\n const lastScreenIndexRef = useRef(-1);\n // Trailing-edge debounce timer for prefetch-on-select (see previewOnSelect below).\n const previewTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const started = useRef(false);\n const finished = useRef(false);\n const errored = useRef(false);\n const attempts = useRef(0);\n // Mirror of the `degraded` state for the unmount cleanup: a degrade to the static\n // fallback is NOT a drop, so `dropped` must not fire after it.\n const degradedRef = useRef(false);\n const [degraded, setDegraded] = useState(false);\n const [timedOut, setTimedOut] = useState(false);\n const [validationError, setValidationError] = useState<string | undefined>();\n const [validating, setValidating] = useState(false);\n\n const lastCard = useMemo<Message | undefined>(\n () => [...messages].reverse().find((m) => m.role === \"assistant\" && m.response?.action === \"render\"),\n [messages],\n );\n\n // Local fallback counter — how many distinct rendered cards we've seen.\n const renderedCount = useMemo(\n () => messages.filter((m) => m.role === \"assistant\" && m.response?.action === \"render\").length,\n [messages],\n );\n\n const progress = useMemo(() => readProgress(lastCard?.response), [lastCard]);\n\n // 1. Auto-start: the backend treats the first inbound message as \"begin\".\n // On a RESUMED session (persisted id restored after an app kill) the kickoff is\n // the skip sentinel instead: the server has this session mid-flow with a pending\n // question, and would record `startMessage`'s literal text as its ANSWER — the\n // sentinel advances one card recording nothing (a `screen_skipped`). On a session\n // the server no longer knows (restart/expiry), the sentinel degrades cleanly to a\n // normal kickoff under the same id. Retries re-send the same kickoff.\n useEffect(() => {\n if (started.current) return;\n started.current = true;\n sendMessage(resumed ? SKIP_ONE_SENTINEL : startMessage);\n // Surface the session id (the A2A contextId) on the start event so a host can capture it\n // and bind a user AFTER the flow via `identifyOnboarding({ contextId })` — completion clears\n // the persisted session, so the in-flight event is the reliable post-flow handle. sessionId\n // is stable for the whole session (minted before this subtree mounts), so this stays mount-once.\n onEventRef.current?.(\n resumed\n ? { type: \"resumed\", contextId: sessionId }\n : { type: \"started\", contextId: sessionId },\n );\n }, [sendMessage, startMessage, resumed, sessionId]);\n\n // 2. Startup watchdog.\n useEffect(() => {\n if (lastCard) return;\n const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);\n return () => clearTimeout(timer);\n }, [lastCard, startTimeoutMs]);\n\n // A new card arrived → clear any prior inline validation error + emit a turn event.\n useEffect(() => {\n setValidationError(undefined);\n if (!lastCard?.id) return;\n const step = progress.step ?? renderedCount;\n // Remember the latest screen we showed (0-based) for a possible `dropped` event.\n lastScreenIndexRef.current = Math.max(0, step - 1);\n onEventRef.current?.({\n type: \"turn\",\n step,\n component: lastCard.response?.component,\n });\n // Prefetch: an InterstitialCard's answer is always \"continue\", so we can warm the next\n // turn's cache during the momentum window — by the time the user taps Continue the following\n // card is already generated. The preview MUST use the exact text the real Continue tap sends,\n // or the backend's message-keyed preview cache misses. The card's onSubmit(\"continue\") is\n // wrapped by the SDK as `My answer is: ${JSON.stringify(value)}`, so mirror that here.\n // Fire-and-forget; a failed/missed preview just means the real turn generates normally.\n if (lastCard.response?.component === \"InterstitialCard\") {\n sendPreview(reportTargetRef.current, {\n sessionId: sessionIdRef.current,\n userMessage: `My answer is: ${JSON.stringify(\"continue\")}`,\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastCard?.id]);\n\n // `dropped`: the user abandoned onboarding. No backend request fires on unmount, so the\n // server can't see this — the client must report it. Fire ONLY on a true unmount that\n // did NOT complete (`onComplete` never ran) and did NOT degrade to the static fallback\n // (a degrade is a reliability fallback, not a user drop). Refs keep this effect mount-once.\n useEffect(() => {\n return () => {\n if (finished.current || degradedRef.current) return;\n reportClientEvent(reportTargetRef.current, {\n event_type: \"dropped\",\n session_id: sessionIdRef.current,\n screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : undefined,\n device: clientContextRef.current?.device,\n user_context: clientContextRef.current?.userContext,\n user_id: clientContextRef.current?.userId,\n });\n };\n }, []);\n\n // Silently restart the thread from turn one (shared by auto-retry + manual retry).\n // Does NOT clear the attempt counter or the degraded flag — the caller decides that.\n const restartThread = useCallback(() => {\n setTimedOut(false);\n started.current = false;\n errored.current = false;\n reset();\n }, [reset]);\n\n // 3. Error/timeout → auto-retry a transient blip, then degrade to the static flow.\n // Each failure: log `error`; if we have retries left, restart the thread silently\n // (`retry`); once exhausted, mark `degraded` so the render falls through to the\n // host's `fallbackFlow`/`onError` (`fallback`). Counter is a ref → survives the\n // reset()-driven re-renders. This is the \"AI fails → static onboarding, never a\n // broken screen\" guarantee.\n useEffect(() => {\n if (errored.current) return;\n if (!error && !timedOut) return;\n errored.current = true;\n const reason: \"backend\" | \"timeout\" = error ? \"backend\" : \"timeout\";\n onEventRef.current?.({ type: \"error\", reason });\n attempts.current += 1;\n if (attempts.current <= maxRetries) {\n onEventRef.current?.({ type: \"retry\", reason, attempt: attempts.current });\n restartThread();\n } else {\n onEventRef.current?.({ type: \"fallback\", reason });\n // Report the degrade to the backend so the dashboard's fallback-rate reflects it.\n // Server-side `llm_fallback` fires per single degraded turn; this `client_fallback`\n // captures the whole-flow case (AI gave up, the user got static onboarding). The server\n // ingests it idempotently and back-fills a `session_started` if it never saw the session,\n // so even a device that dropped straight to its static manifest shows as a counted\n // fallback session. This is the ONE fallback signal — hosts must NOT also report it.\n reportClientEvent(reportTargetRef.current, {\n event_type: \"client_fallback\",\n session_id: sessionIdRef.current,\n screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : undefined,\n meta: JSON.stringify({ reason }),\n device: clientContextRef.current?.device,\n user_context: clientContextRef.current?.userContext,\n user_id: clientContextRef.current?.userId,\n });\n degradedRef.current = true;\n setDegraded(true);\n onErrorRef.current?.(error ?? new Error(\"Onboarding timed out\"));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [error, timedOut, maxRetries]);\n\n // 5. Completion: the terminal StatusCard is rendered as CompletionView; we fire\n // onComplete only when the user taps its CTA (guarded so it fires once).\n const handleFinish = useCallback(() => {\n if (finished.current) return;\n finished.current = true;\n onCompleteRef.current({ answers: deriveAnswers(messages), raw: messages });\n }, [messages]);\n\n // Manual retry (the no-fallback ErrorBlock button): clear the degrade + counter so\n // the user gets a fresh set of attempts.\n const handleRetry = useCallback(() => {\n attempts.current = 0;\n degradedRef.current = false;\n setDegraded(false);\n restartThread();\n }, [restartThread]);\n\n // Per-question Skip: tell the backend to skip THIS question only and advance to the\n // next card (no answer recorded) — distinct from finishing the flow. Rendered only\n // when the current card is `skippable` (see the scaffold below).\n //\n // NOTE: we deliberately do NOT report a client `screen_skipped` here. The backend already\n // emits `screen_skipped` (correctly correlated by its own contextId, with screen_index +\n // question_key) when it processes this SKIP_ONE_SENTINEL — see the server engine. A client\n // emission would double-count. The reporter supports `screen_skipped` for clients whose skip\n // never reaches the server, which is not the case for this kit.\n const skipQuestion = useCallback(() => {\n if (isLoading) return;\n sendMessage(SKIP_ONE_SENTINEL);\n }, [isLoading, sendMessage]);\n\n // Prefetch on SELECT — the fix for \"the first AI question is always the slowest\". Q1 is a\n // deterministic base card (instant); Q2 is the first LLM turn, and neither cache protects it\n // (flow-cache misses a novel answer combo, the provider prompt-cache is cold on the first\n // call). Choice cards hold their selection LOCALLY and only commit on Continue, so there's a\n // real gap we can use: as the user picks, fire a debounced `message/preview` keyed on the\n // EXACT text the Continue tap will send (`I selected: ${JSON.stringify(value)}`), so the\n // backend generates Q2 during the pick→Continue window. By the time they tap Continue it's\n // already cached → the slow question returns instantly. Fire-and-forget: if they change the\n // selection after the last preview, the real turn just generates normally (never worse than\n // today). Trailing-edge debounced so rapid multi-select toggles warm at most once.\n const previewOnSelect = useCallback((value: string | string[]) => {\n const target = reportTargetRef.current;\n if (!target?.serverUrl) return;\n if (Array.isArray(value) ? value.length === 0 : !value) return;\n if (previewTimer.current) clearTimeout(previewTimer.current);\n previewTimer.current = setTimeout(() => {\n sendPreview(target, {\n sessionId: sessionIdRef.current,\n userMessage: `I selected: ${JSON.stringify(value)}`,\n });\n }, 300);\n }, []);\n\n // Cancel any pending preview on unmount so a fired-but-unsent warm can't outlive the flow.\n useEffect(() => () => {\n if (previewTimer.current) clearTimeout(previewTimer.current);\n }, []);\n\n // 4. Wrap the SDK's action callbacks so an answer is validated before it's sent.\n const wrappedActions = useCallback(\n (messageId: string) => {\n const base = makeActions(messageId);\n const key = progress.key;\n const validator = key ? validatorsRef.current?.[key] : undefined;\n if (!validator) return base;\n\n const out: Record<string, (...args: unknown[]) => void> = { ...base };\n for (const name of ANSWER_CALLBACKS) {\n const original = base[name];\n if (!original) continue;\n out[name] = (...args: unknown[]) => {\n const value = args[0];\n // Only string answers are validatable (e.g. username). Pass others through.\n if (typeof value !== \"string\") return original(...args);\n setValidating(true);\n validator(value)\n .then((res) => {\n if (res.ok) {\n setValidationError(undefined);\n original(...args);\n } else {\n setValidationError(res.error ?? \"That value isn't available.\");\n }\n })\n .catch(() => {\n // A validator failure must never block the user — let them proceed.\n original(...args);\n })\n .finally(() => setValidating(false));\n };\n }\n return out;\n },\n [makeActions, progress.key],\n );\n\n // ── Render ────────────────────────────────────────────────────────────────\n // Degraded (retries exhausted): render the host's static onboarding in place —\n // the \"AI failed → your static flow, never a broken screen\" guarantee. If no\n // static flow was supplied, hand off to onError (host navigates away), else the\n // inline retry screen as a last resort.\n if (degraded) {\n if (fallbackFlow !== undefined) return <>{fallbackFlow}</>;\n if (onError) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n return (\n <ErrorBlock\n onRetry={handleRetry}\n message={\n timedOut\n ? \"This is taking longer than expected. Try again?\"\n : \"We couldn't reach the onboarding service. Try again?\"\n }\n />\n );\n }\n\n // Errored but not yet degraded → an auto-retry is in flight. Show a neutral loader\n // so a transient blip never flashes an error screen.\n if (error || timedOut) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n\n const response = lastCard?.response;\n\n // No card yet → the first \"thinking\" screen.\n if (!lastCard || !response) {\n return <LoadingScreen title={c.startingTitle} hint={c.startingHint} />;\n }\n\n // Step index drives the progress bar. A total (never shown) only paces the fill:\n // prefer a backend-supplied total, else the host's approximate prop, else asymptotic.\n const step = progress.step ?? renderedCount;\n const total = progress.total ?? approxScreens;\n const isTerminal = response.action === \"render\" && response.component === \"StatusCard\";\n\n // Terminal recap: show what the app will now do for the user (backend-authored),\n // and finish only when they tap the CTA.\n if (isTerminal) {\n const props = (response.props ?? {}) as {\n title?: string;\n message?: string;\n ctaLabel?: string;\n };\n return (\n <OnboardingScaffold step={step} complete approxScreens={total}>\n <CompletionView\n title={props.title ?? c.completeTitle}\n message={props.message}\n ctaLabel={props.ctaLabel ?? c.completeCta}\n onContinue={handleFinish}\n />\n </OnboardingScaffold>\n );\n }\n\n const overrides: Record<string, unknown> = {\n ...wrappedActions(lastCard.id),\n // Inject the inline error onto whichever card supports it (TextInputCard).\n validationError,\n // Choice cards (Selection/ChipSelect) call this as the live selection changes, so the flow\n // can prefetch the next turn before Continue. Non-committing; ignored by cards that don't use it.\n onSelectionChange: previewOnSelect,\n };\n\n return (\n <OnboardingScaffold\n step={step}\n onSkip={progress.skippable ? skipQuestion : undefined}\n approxScreens={total}\n >\n {/* CardHandoff pairs the exit with the enter (the design's \"cards hand off,\n they don't cut\"): the answered card leaves left while the next arrives\n from the right; loader states enter/exit as a short fade. transitionKey\n identifies WHAT is on screen — loader states get a stable key per state,\n cards key on the message id. */}\n <CardHandoff\n transitionKey={validating ? \"loader:checking\" : isLoading ? \"loader:thinking\" : lastCard.id}\n variant={\n validating || isLoading\n ? \"fade\"\n : lastCard.response?.component === \"InterstitialCard\"\n ? \"spring\"\n : \"slide\"\n }\n >\n {validating ? (\n <LoadingBlock title={c.checkingTitle} hint={c.checkingHint} />\n ) : isLoading ? (\n // Between turns: the answer was sent and we're waiting on the next card.\n // Show the \"thinking\" loader instead of leaving the old card on screen.\n <LoadingBlock title={c.thinkingTitle} hint={c.thinkingHint} />\n ) : (\n // key={lastCard.id} is load-bearing: cards (SelectionCard/ChipSelectCard)\n // hold internal `selected`/`submitted` state, and React reuses a component\n // instance across turns when the rendered type is identical (e.g. two\n // SelectionCards in a row). Without a per-turn key the second card inherits\n // the first's `submitted=true` and silently rejects all taps. Keying on the\n // message id forces a fresh mount every turn. (CardHandoff's transitionKey\n // shares the id, but this renderer key stays the state-isolation guarantee.)\n <ComponentRenderer\n key={lastCard.id}\n messageId={lastCard.id}\n response={response}\n callbackOverrides={overrides as never}\n />\n )}\n </CardHandoff>\n </OnboardingScaffold>\n );\n};\n","/**\n * Themed ChipSelectCard — drop-in replacement for the OSS SDK's ChipSelectCard.\n * Identical `name`, `propsSchema`, `defaultProps`, and `onSelect` callback contract\n * so the SDK's ComponentRenderer drives it transparently. Only the look is themed.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 4-6): chips tick on press (scale\n * 0.94 spring), the selected accent fill crossfades in over 160ms (native-driver\n * opacity overlay) with the label flipping to `onPrimary` and a check popping in.\n * Deselect reverses. Reduce motion: color swap only, check shown instantly.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { captionStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n CHECK_SCALE_FROM,\n CHECK_SPRING,\n CHIP_FILL_MS,\n CHIP_PRESS_SCALE,\n PRESS_SPRING,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\n// Mirror of the SDK schema — must stay identical so the registry + validator agree.\nconst schema = z.object({\n title: z.string().describe(\"Question or section header, e.g. 'Which season?'\"),\n chips: z\n .array(z.string())\n .min(1)\n .describe(\"List of option labels shown as chips, e.g. ['Spring','Summer','Autumn','Winter']\"),\n multiSelect: z.boolean().optional().describe(\"Allow multiple chips selected at once, default true\"),\n submitLabel: z.string().optional().describe(\"Confirm button label, default: Continue\"),\n maxSelections: z.number().optional().describe(\"Maximum number of chips the user can select at once\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype ChipItemProps = {\n chip: string;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (chip: string) => void;\n};\n\nconst _ChipItem: React.FC<ChipItemProps> = ({ chip, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(chip), [chip, onToggle]);\n\n // Press tick: scale 1→0.94, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(CHIP_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: full accent pill, crossfaded in over 160ms on a native-driver\n // opacity overlay (EXTRACTED-SPEC.md D7). Reduce motion: instant swap.\n const fillT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(fillT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, CHIP_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, fillT]);\n\n // Check pop on select (the width-slide of the canvas is a layout animation the\n // native driver can't express — see EXTRACTED-SPEC.md D4).\n const checkT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n if (!isSelected) {\n checkT.setValue(0);\n return;\n }\n if (reduced) {\n checkT.setValue(1);\n return;\n }\n checkT.setValue(0);\n const anim = Animated.spring(checkT, {\n toValue: 1,\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, checkT]);\n\n const checkScale = checkT.interpolate({ inputRange: [0, 1], outputRange: [CHECK_SCALE_FROM, 1] });\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={chip}\n >\n <Animated.View\n style={[\n styles.chip,\n {\n borderRadius: t.radius.full,\n paddingHorizontal: t.spacing.md,\n paddingVertical: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.background,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.fillOverlay,\n {\n borderRadius: t.radius.full,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primary,\n opacity: fillT,\n },\n ]}\n />\n {isSelected ? (\n <Animated.Text\n style={[\n styles.check,\n { color: t.colors.onPrimary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n ) : null}\n <Text\n style={[\n captionStyle(t.fonts),\n styles.chipLabel,\n { color: isSelected ? t.colors.onPrimary : t.colors.textMuted },\n ]}\n >\n {chip}\n </Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst ChipItem = React.memo(_ChipItem);\n\nconst _ChipSelectCard: React.FC<Props> = ({\n title,\n chips,\n multiSelect = true,\n submitLabel = \"Continue\",\n maxSelections,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (chip: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) => {\n if (prev.includes(chip)) return prev.filter((c) => c !== chip);\n if (maxSelections && prev.length >= maxSelections) return prev;\n return [...prev, chip];\n });\n } else {\n setSelected([chip]);\n }\n },\n [submitted, multiSelect, maxSelections],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n subtitle={maxSelections ? `Select up to ${maxSelections}` : undefined}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={[styles.chipsRow, { gap: t.spacing.sm + t.spacing.xs }]}>\n {chips.map((chip) => (\n <ChipItem\n key={chip}\n chip={chip}\n isSelected={selected.includes(chip)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const ChipSelectCard: WireAIComponent = {\n name: \"ChipSelectCard\",\n description:\n \"Use for compact short labels: seasons, activities, travel styles, moods, categories. Ideal for 4–12 single-word or two-word options. Use SelectionCard instead when options need descriptions; use CardGridSelectCard for a smaller set (2–6) of visual choices that each deserve an icon.\",\n component: React.memo(_ChipSelectCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { multiSelect: true, submitLabel: \"Continue\" },\n};\n\nconst styles = StyleSheet.create({\n chipsRow: { flexDirection: \"row\", flexWrap: \"wrap\" },\n chip: { borderWidth: 1.5, flexDirection: \"row\", alignItems: \"center\", gap: 6, overflow: \"hidden\" },\n fillOverlay: { borderWidth: 1.5 },\n chipLabel: { fontWeight: \"600\" },\n check: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n});\n","/**\n * Themed TextInputCard — drop-in for the OSS SDK's TextInputCard. Same `name`,\n * `propsSchema`, `defaultProps`, and `onSubmit(value: string)` contract. The input\n * is themed and supports an optional inline error string (used by the kit's\n * per-step validators — e.g. \"username taken\"), set via the `validationError` prop\n * which the OnboardingFlow injects through callbackOverrides.\n *\n * Open-ended answers (goals, notes, \"what would make this better\") render a tall\n * multi-line box by default so the user has room to actually write. Short fields\n * (a name, a username) set `multiline: false` for the compact single-line height.\n */\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, TextInput, View, useWindowDimensions } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { bodyStyle, captionStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\n\nconst schema = z.object({\n label: z.string().describe(\"Input field label / the question being asked\"),\n hint: z\n .string()\n .optional()\n .describe(\n \"One short line under the question giving context: what the answer is used for or why you ask. Add it whenever the question alone might be unclear.\"\n ),\n placeholder: z\n .string()\n .optional()\n .describe(\n 'A concrete example answer shown inside the box, phrased like a real user wrote it and starting with \"e.g. \". ALWAYS provide one for open-ended questions: it shows the expected answer shape and inspires the user.'\n ),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Submit\"),\n multiline: z\n .boolean()\n .optional()\n .describe(\n \"Tall multi-line box for open-ended answers (goals, notes, feedback). Default true. Set false for a single-line field like a name or username.\"\n ),\n lines: z\n .number()\n .optional()\n .describe(\"Approx visible rows when multiline (default 6). Height is capped at 40% of the screen.\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: string) => void;\n /**\n * Inline error injected by OnboardingFlow when a validator rejects the value\n * (e.g. username already taken). Re-enables the input so the user can edit.\n */\n validationError?: string;\n };\n\nconst _TextInputCard: React.FC<Props> = ({\n label,\n hint,\n placeholder,\n submitLabel = \"Submit\",\n onSubmit,\n validationError,\n multiline = true,\n lines = 6,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n const { height: screenHeight } = useWindowDimensions();\n const [value, setValue] = useState(\"\");\n const [submitted, setSubmitted] = useState(false);\n\n // A validator rejection arrives as `validationError`; reopen the field so the\n // user can fix their answer instead of being stuck on a submitted state.\n const locked = submitted && !validationError;\n\n // Multi-line free-text gets a generous box (~`lines` rows), capped at 40% of\n // screen height so it stays comfortable on small devices. Single-line fields\n // keep the compact 52pt height.\n const APPROX_ROW_HEIGHT = 26;\n const minHeight = multiline\n ? Math.min(Math.max(lines, 4) * APPROX_ROW_HEIGHT + t.spacing.md * 2, screenHeight * 0.4)\n : 52;\n\n const handleSubmit = useCallback(() => {\n if (value.trim() && onSubmit && !locked) {\n setSubmitted(true);\n onSubmit(value.trim());\n }\n }, [value, onSubmit, locked]);\n\n return (\n <CardLayout\n title={label}\n subtitle={hint}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={!value.trim() || locked}\n />\n }\n >\n <View style={styles.row}>\n <TextInput\n value={value}\n onChangeText={setValue}\n placeholder={placeholder ?? \"\"}\n placeholderTextColor={t.colors.textMuted}\n editable={!locked}\n multiline={multiline}\n numberOfLines={multiline ? lines : 1}\n textAlignVertical={multiline ? \"top\" : \"center\"}\n style={[\n bodyStyle(t.fonts),\n styles.input,\n {\n color: t.colors.text,\n backgroundColor: t.colors.surface,\n borderRadius: t.radius.md,\n borderColor: validationError ? t.colors.error : t.colors.border,\n padding: t.spacing.md,\n minHeight,\n },\n ]}\n />\n {validationError ? (\n <Text style={[captionStyle(t.fonts), { color: t.colors.error }]}>{validationError}</Text>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const TextInputCard: WireAIComponent = {\n name: \"TextInputCard\",\n description:\n \"Use when the user needs to type a free-text answer: an open-ended goal, notes, feedback, a name, a destination, a search query. Multi-line by default (great for open-ended goals); set multiline:false for a short single-line field like a name. Use NumberStepperCard for numeric ranges with known bounds.\",\n component: React.memo(_TextInputCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Submit\", multiline: true, lines: 6 },\n};\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n row: { gap: t.spacing.sm },\n input: { borderWidth: 1 },\n });\n}\n","/**\n * expoIcons — resolve an `@expo/vector-icons` family, lazily and optionally.\n *\n * ── WHY THIS DOES NOT BREAK THE NO-NATIVE-DEPENDENCY POLICY ──────────────────────────────\n *\n * The policy (see `questionnaire/QuestionnaireGate.tsx`'s back-chevron note, `AnimatedSparkle`,\n * `coachmarks/GestureHint`, `cards/StatusCard`'s Unicode STATUS_ICONS) says: no vector library\n * is worth FORCING EVERY HOST INTO A NATIVE REBUILD. Read it precisely — what it forbids is\n * forcing hosts, not the existence of an icon.\n *\n * `@expo/vector-icons` is an OPTIONAL peer:\n *\n * • A host WITHOUT it installs the kit fine (optional peer → npm never fetches it) and renders\n * fine (icon → null, layout unchanged). To BUNDLE fine it must let Metro know the module is\n * allowed to be missing — see \"OPTIONALITY IS A BUILD-TIME CONTRACT\" below.\n * • A host WITH it gets real brand icons. Both live host apps already ship it\n * (`@expo/vector-icons ^15.0.3`), so neither needs a rebuild — which matters because\n * neither can be force-updated: both ship new store builds only and never OTA.\n * • A host that wants neither can override every name with its own artwork through the\n * `icons` registry, so the library is never on the critical path at all.\n *\n * ── THE SPECIFIER MUST BE A STRING LITERAL — THIS IS THE WHOLE BUG ───────────────────────\n *\n * DO NOT \"restore\" the old `const req = require; req(moduleName)` shape. It could never work,\n * and it shipped broken in 0.8.0. What that shape actually did, proven in a real `expo export`\n * bundle and in Expo SDK 55's runtime:\n *\n * 1. Metro collects dependencies STATICALLY, by matching a call whose callee is literally the\n * identifier `require` and whose argument is a STRING LITERAL. Aliasing `require` to a local\n * hid the call from the collector, so this module's dependencyMap was emitted EMPTY (`[]`)\n * and `@expo/vector-icons` was never put in the bundle at all.\n * 2. At runtime the alias did NOT point at Node's `require`. Metro renames the free `require`\n * identifier to the module factory's require param, so `req` WAS `metroRequire`, whose\n * module registry is keyed by NUMERIC module ids. Handing it the string \"@expo/vector-icons\"\n * could never match a key, so it threw `Requiring unknown module \"@expo/vector-icons\"` —\n * even in a bundle that contained the module.\n * 3. That throw never reached the `catch` below. Metro's own `guardedLoadModule` wraps the\n * load, catches the error FIRST, and routes it to `global.ErrorUtils.reportFatalError(e)`\n * instead of rethrowing (Expo SDK 55: `@expo/cli/build/metro-require/require.js:151-165`).\n * So the call returned `undefined` — icon silently null — AND logged a red fatal error. A\n * try/catch cannot guard a require that Metro never lets throw.\n *\n * A LITERAL `require(\"@expo/vector-icons\")` is collected, is bundled, and resolves SYNCHRONOUSLY\n * through the numeric dependencyMap — the same reason `reviews/storeReview.ts`'s literal\n * `await import(\"expo-store-review\")` has always worked. (The old comment here claimed the alias\n * worked \"exactly like expo-store-review\". It was the opposite: storeReview's specifier is a\n * literal, and that is precisely why it resolves and this one did not.)\n *\n * ── OPTIONALITY IS A BUILD-TIME CONTRACT, AND THE TRY/CATCH IS LOAD-BEARING ──────────────\n *\n * Metro has NO runtime resolution: every specifier is resolved when the bundle is built. It does\n * have a real optional-dependency mechanism, and it needs BOTH halves of what is written below:\n * a LITERAL specifier (so the dep is collected at all) AND the call inside a TRY/CATCH — that is\n * literally how Metro marks a dependency `isOptional`. When the peer is absent, Metro then puts\n * `null` in this module's dependencyMap and `metroRequire(null, \"@expo/vector-icons\")` throws\n * \"Cannot find module\" from its own `moduleId === null` branch, BEFORE `guardedLoadModule` — so\n * unlike the string-id path in the autopsy above, that throw really does land in the catch below.\n * So do NOT \"simplify\" the try/catch away: it is what keeps the peer optional, not just tidy.\n *\n * That mechanism rides on the transformer's `allowOptionalDependencies`, which Expo enables by\n * default but bare `metro-config` defaults to FALSE. For hosts in the second camp, the kit ships\n * a safety net: `withWireOnboarding` (metro/index.js) installs a `resolveRequest` that maps an\n * absent optional peer to an EMPTY module, landing on exactly the degradation path below (no\n * families on the namespace → `undefined` → icon renders null).\n */\nimport type { WireIconFamily } from \"./vocabulary\";\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime (the kit's own\n// tests run under `node --test` as ESM). Declared locally so this type-checks without ambient\n// Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded literal require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/**\n * The minimal shape the kit uses from a vector-icons family. A COMPONENT TYPE, not a plain\n * function: these are real React components (createIconSet output) and must be mounted via\n * JSX/createElement, never invoked directly — calling one bypasses the reconciler and breaks\n * the moment the family uses hooks or is a class.\n */\nexport type IconComponent = import(\"react\").ComponentType<{\n name: string;\n size?: number;\n color?: string;\n allowFontScaling?: boolean;\n}>;\n\n/**\n * The production resolver. The specifier is a LITERAL so Metro collects it (see the header); the\n * `moduleName` parameter exists only to keep the `OptionalRequire` seam shape, so anything other\n * than the one module this file owns resolves to undefined.\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (moduleName !== \"@expo/vector-icons\") return undefined;\n if (typeof require !== \"function\") return undefined;\n try {\n return require(\"@expo/vector-icons\");\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n // `@expo/vector-icons` exposes the families as NAMED exports; prefer the namespace when it\n // already carries them, and only fall back to `default` for a CJS-interop wrapper.\n const ns = mod as Record<string, unknown>;\n if (ns.MaterialCommunityIcons || ns.Ionicons) return ns;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return ns;\n};\n\n/**\n * Narrow an unknown export to something mountable. A vector-icons family is either a function\n * component or a class (`createIconSet` has returned both across versions), and React.memo /\n * forwardRef wrappers are objects — so accept an object carrying a `$$typeof` too, and reject\n * anything else rather than handing the reconciler a non-component.\n */\nconst asComponent = (value: unknown): IconComponent | undefined => {\n if (typeof value === \"function\") return value as IconComponent;\n if (value && typeof value === \"object\" && \"$$typeof\" in (value as object)) {\n return value as IconComponent;\n }\n return undefined;\n};\n\n/**\n * Module-level memo. `null` = \"we looked and it is not there\" (distinct from \"not looked yet\"),\n * so an absent peer costs exactly one failed require per process, not one per rendered icon.\n */\nlet cached: Record<string, unknown> | null | undefined;\n\n/** Reset the memo. TEST-ONLY seam — production never calls it. */\nexport const resetIconModuleCache = (): void => {\n cached = undefined;\n};\n\n/**\n * Resolve one icon family component, or undefined when the peer is absent/unresolvable.\n * Never throws: an icon is decorative, so it must never be able to break a card.\n *\n * `requireModule` is injectable so tests can exercise BOTH the found and absent paths without\n * installing the native peer (same convention as `detectAppVersion`).\n */\nexport const resolveIconFamily = (\n family: WireIconFamily,\n requireModule: OptionalRequire = runtimeRequire,\n): IconComponent | undefined => {\n try {\n if (cached === undefined || requireModule !== runtimeRequire) {\n const resolved = interop(requireModule(\"@expo/vector-icons\"));\n // Don't poison the module memo from an injected test require.\n if (requireModule === runtimeRequire) cached = resolved ?? null;\n if (!resolved) return undefined;\n return asComponent(resolved[family]);\n }\n if (cached === null) return undefined;\n return asComponent(cached[family]);\n } catch {\n return undefined;\n }\n};\n","/**\n * The Wire icon VOCABULARY — the stable, semantic contract between the AI and the kit.\n *\n * The model emits a plain semantic string (`\"instagram\"`, `\"friend\"`, `\"wedding\"`), never a\n * raw icon-library glyph name. That indirection is the whole point:\n *\n * • The model is never coupled to a library version. `@expo/vector-icons` renaming a glyph,\n * or a host swapping the library out for brand SVGs, changes THIS map — not the prompt,\n * not the server, and not a single stored answer.\n * • A host can override any name with its own artwork (see `IconRegistry`), so brand icons\n * need no kit change.\n * • An unknown name degrades to no icon (see `WireIcon`), which is why the vocabulary can\n * grow without a coordinated kit+server release.\n *\n * `WIRE_ICON_NAMES` is exported so the server/AI side can be taught the list verbatim — paste\n * it into the prompt as the allowed `icon` values. Keep names SEMANTIC (what the option means)\n * rather than visual (what the glyph looks like): the model reasons about meaning.\n *\n * Every glyph below was verified to exist in the `@expo/vector-icons` 15.0.3 glyphmaps that\n * both live host apps already ship. MaterialCommunityIcons is the default family (the broadest\n * single set); Ionicons covers the few brand logos MCI lacks (TikTok, Discord).\n */\n\n/** The icon families this kit resolves out of `@expo/vector-icons`. Both are root exports. */\nexport type WireIconFamily = \"MaterialCommunityIcons\" | \"Ionicons\";\n\n/** One vocabulary entry: the concrete glyph a semantic name resolves to. */\nexport interface WireIconGlyph {\n family: WireIconFamily;\n /** The library's own glyph name — an INTERNAL detail. The AI never sees or emits this. */\n name: string;\n}\n\n/**\n * The semantic name → concrete glyph map. Grouped by the onboarding questions these actually\n * serve: acquisition channels (\"where did you hear about us\"), intent/occasion (\"what brings\n * you here\"), and a general-purpose set for everything else.\n */\nexport const WIRE_ICON_GLYPHS = {\n // ── Acquisition channels (\"where did you hear about us?\") ──────────────────\n instagram: { family: \"MaterialCommunityIcons\", name: \"instagram\" },\n tiktok: { family: \"Ionicons\", name: \"logo-tiktok\" },\n youtube: { family: \"MaterialCommunityIcons\", name: \"youtube\" },\n facebook: { family: \"MaterialCommunityIcons\", name: \"facebook\" },\n twitter: { family: \"MaterialCommunityIcons\", name: \"twitter\" },\n reddit: { family: \"MaterialCommunityIcons\", name: \"reddit\" },\n linkedin: { family: \"MaterialCommunityIcons\", name: \"linkedin\" },\n discord: { family: \"Ionicons\", name: \"logo-discord\" },\n whatsapp: { family: \"MaterialCommunityIcons\", name: \"whatsapp\" },\n twitch: { family: \"MaterialCommunityIcons\", name: \"twitch\" },\n snapchat: { family: \"MaterialCommunityIcons\", name: \"snapchat\" },\n pinterest: { family: \"MaterialCommunityIcons\", name: \"pinterest\" },\n google: { family: \"MaterialCommunityIcons\", name: \"google\" },\n search: { family: \"MaterialCommunityIcons\", name: \"magnify\" },\n friend: { family: \"MaterialCommunityIcons\", name: \"account-heart\" },\n podcast: { family: \"MaterialCommunityIcons\", name: \"podcast\" },\n blog: { family: \"MaterialCommunityIcons\", name: \"post\" },\n newsletter: { family: \"MaterialCommunityIcons\", name: \"email-outline\" },\n news: { family: \"MaterialCommunityIcons\", name: \"newspaper\" },\n \"app-store\": { family: \"MaterialCommunityIcons\", name: \"apple\" },\n ad: { family: \"MaterialCommunityIcons\", name: \"bullhorn\" },\n\n // ── Intent / occasion (\"what brings you here?\") ────────────────────────────\n wedding: { family: \"MaterialCommunityIcons\", name: \"ring\" },\n birthday: { family: \"MaterialCommunityIcons\", name: \"cake-variant\" },\n baby: { family: \"MaterialCommunityIcons\", name: \"baby-carriage\" },\n travel: { family: \"MaterialCommunityIcons\", name: \"airplane\" },\n work: { family: \"MaterialCommunityIcons\", name: \"briefcase\" },\n celebration: { family: \"MaterialCommunityIcons\", name: \"party-popper\" },\n store: { family: \"MaterialCommunityIcons\", name: \"storefront\" },\n school: { family: \"MaterialCommunityIcons\", name: \"school\" },\n team: { family: \"MaterialCommunityIcons\", name: \"account-multiple\" },\n growth: { family: \"MaterialCommunityIcons\", name: \"trending-up\" },\n\n // ── General purpose ────────────────────────────────────────────────────────\n sparkle: { family: \"MaterialCommunityIcons\", name: \"star-four-points\" },\n heart: { family: \"MaterialCommunityIcons\", name: \"heart\" },\n star: { family: \"MaterialCommunityIcons\", name: \"star\" },\n fire: { family: \"MaterialCommunityIcons\", name: \"fire\" },\n target: { family: \"MaterialCommunityIcons\", name: \"target\" },\n trophy: { family: \"MaterialCommunityIcons\", name: \"trophy\" },\n rocket: { family: \"MaterialCommunityIcons\", name: \"rocket-launch\" },\n clock: { family: \"MaterialCommunityIcons\", name: \"clock-outline\" },\n calendar: { family: \"MaterialCommunityIcons\", name: \"calendar-star\" },\n camera: { family: \"MaterialCommunityIcons\", name: \"camera\" },\n image: { family: \"MaterialCommunityIcons\", name: \"image\" },\n video: { family: \"MaterialCommunityIcons\", name: \"video\" },\n mic: { family: \"MaterialCommunityIcons\", name: \"microphone\" },\n music: { family: \"MaterialCommunityIcons\", name: \"music\" },\n book: { family: \"MaterialCommunityIcons\", name: \"book-open-variant\" },\n food: { family: \"MaterialCommunityIcons\", name: \"silverware-fork-knife\" },\n coffee: { family: \"MaterialCommunityIcons\", name: \"coffee\" },\n fitness: { family: \"MaterialCommunityIcons\", name: \"dumbbell\" },\n health: { family: \"MaterialCommunityIcons\", name: \"heart-pulse\" },\n meditation: { family: \"MaterialCommunityIcons\", name: \"meditation\" },\n sleep: { family: \"MaterialCommunityIcons\", name: \"sleep\" },\n brain: { family: \"MaterialCommunityIcons\", name: \"brain\" },\n idea: { family: \"MaterialCommunityIcons\", name: \"lightbulb-on\" },\n money: { family: \"MaterialCommunityIcons\", name: \"cash\" },\n shopping: { family: \"MaterialCommunityIcons\", name: \"cart\" },\n gift: { family: \"MaterialCommunityIcons\", name: \"gift\" },\n home: { family: \"MaterialCommunityIcons\", name: \"home\" },\n car: { family: \"MaterialCommunityIcons\", name: \"car\" },\n pet: { family: \"MaterialCommunityIcons\", name: \"paw\" },\n plant: { family: \"MaterialCommunityIcons\", name: \"sprout\" },\n sun: { family: \"MaterialCommunityIcons\", name: \"white-balance-sunny\" },\n moon: { family: \"MaterialCommunityIcons\", name: \"weather-night\" },\n globe: { family: \"MaterialCommunityIcons\", name: \"earth\" },\n \"map-pin\": { family: \"MaterialCommunityIcons\", name: \"map-marker\" },\n compass: { family: \"MaterialCommunityIcons\", name: \"compass\" },\n flag: { family: \"MaterialCommunityIcons\", name: \"flag\" },\n bookmark: { family: \"MaterialCommunityIcons\", name: \"bookmark\" },\n bell: { family: \"MaterialCommunityIcons\", name: \"bell\" },\n mail: { family: \"MaterialCommunityIcons\", name: \"email\" },\n phone: { family: \"MaterialCommunityIcons\", name: \"phone\" },\n chat: { family: \"MaterialCommunityIcons\", name: \"chat\" },\n user: { family: \"MaterialCommunityIcons\", name: \"account\" },\n users: { family: \"MaterialCommunityIcons\", name: \"account-group\" },\n settings: { family: \"MaterialCommunityIcons\", name: \"cog\" },\n tools: { family: \"MaterialCommunityIcons\", name: \"tools\" },\n puzzle: { family: \"MaterialCommunityIcons\", name: \"puzzle\" },\n chart: { family: \"MaterialCommunityIcons\", name: \"chart-line\" },\n shield: { family: \"MaterialCommunityIcons\", name: \"shield-check\" },\n lock: { family: \"MaterialCommunityIcons\", name: \"lock\" },\n cloud: { family: \"MaterialCommunityIcons\", name: \"cloud\" },\n pencil: { family: \"MaterialCommunityIcons\", name: \"pencil\" },\n check: { family: \"MaterialCommunityIcons\", name: \"check-circle\" },\n plus: { family: \"MaterialCommunityIcons\", name: \"plus-circle\" },\n question: { family: \"MaterialCommunityIcons\", name: \"help-circle\" },\n other: { family: \"MaterialCommunityIcons\", name: \"dots-horizontal-circle\" },\n} as const satisfies Record<string, WireIconGlyph>;\n\n/** A name in the vocabulary. The card schemas accept any string and degrade — see `WireIcon`. */\nexport type WireIconName = keyof typeof WIRE_ICON_GLYPHS;\n\n/**\n * Every semantic name, as a plain array — the list to paste into the server/AI prompt as the\n * allowed `icon` values. Sorted for a stable, diffable prompt.\n */\nexport const WIRE_ICON_NAMES: readonly string[] = Object.keys(WIRE_ICON_GLYPHS).sort();\n\n/**\n * Look up a semantic name. Returns undefined for anything outside the vocabulary.\n *\n * The OWN-property check is load-bearing, not defensive noise: the name comes from an LLM, and\n * a plain object lookup answers `\"toString\"` / `\"constructor\"` / `\"valueOf\"` with an inherited\n * `Object.prototype` member. That would hand back a function where a `{family, name}` is\n * expected — a non-glyph masquerading as one. Caught by the vocabulary canary.\n */\nexport const lookupIconGlyph = (name: string | undefined): WireIconGlyph | undefined => {\n if (!name) return undefined;\n if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return undefined;\n return (WIRE_ICON_GLYPHS as Record<string, WireIconGlyph>)[name];\n};\n","/**\n * WireIcon — render one semantic icon name, or nothing at all.\n *\n * RESOLUTION ORDER (each step falls through to the next, never throws):\n * 1. the host `icons` registry — brand artwork, zero kit deps (IconRegistry.tsx)\n * 2. `@expo/vector-icons` — if the optional peer resolves (expoIcons.ts)\n * 3. NOTHING — render null\n *\n * Step 3 is a FEATURE, not a failure mode. The AI emits icon names from a vocabulary that will\n * keep growing, against production apps that ship on their own schedule (new store builds only,\n * never OTA, so they cannot be force-updated). So an unknown, misspelled, hallucinated, or\n * simply newer-than-this-client name MUST be a no-op: no crash, no broken-glyph tofu box, and\n * no layout shift. Returning `null` (rather than a spacer or a placeholder) is what gives the\n * last property — a row with an unresolvable icon lays out EXACTLY like a row with no icon,\n * because the parent's flex `gap` adds no space for a null child.\n *\n * An icon is always DECORATIVE: the label carries the meaning, so the icon is hidden from\n * assistive tech and never becomes the accessible name of its option.\n */\nimport React from \"react\";\nimport { StyleSheet, View } from \"react-native\";\n\nimport { resolveIconFamily, type OptionalRequire } from \"./expoIcons\";\nimport { useHostIcon } from \"./IconRegistry\";\nimport { lookupIconGlyph } from \"./vocabulary\";\n\nexport type WireIconProps = {\n /** A semantic name from the vocabulary (see vocabulary.ts). Unknown → renders nothing. */\n name?: string;\n /** Glyph size in px. */\n size?: number;\n /** Glyph color. Callers pass a THEME token — never a raw hex. */\n color?: string;\n /** Injectable resolver. TEST-ONLY seam; production uses the guarded runtime require. */\n requireModule?: OptionalRequire;\n};\n\nconst _WireIcon: React.FC<WireIconProps> = ({ name, size = 20, color, requireModule }) => {\n // 1) Host artwork wins — it can also cover names outside the vocabulary entirely.\n const hostIcon = useHostIcon(name);\n if (hostIcon) {\n return (\n <View\n style={styles.decorative}\n accessible={false}\n importantForAccessibility=\"no-hide-descendants\"\n >\n {hostIcon}\n </View>\n );\n }\n\n // 2) The vocabulary → a concrete glyph, then the optional peer. Both may miss; both degrade.\n const glyph = lookupIconGlyph(name);\n if (!glyph) return null;\n\n const Family = resolveIconFamily(glyph.family, requireModule);\n if (!Family) return null;\n\n return (\n <View\n style={styles.decorative}\n accessible={false}\n importantForAccessibility=\"no-hide-descendants\"\n >\n <Family\n name={glyph.name}\n size={size}\n color={color}\n // Icons are sized by the layout, not the text scale — a large accessibility font must\n // not blow up a card grid. The LABEL still scales, which is what carries the meaning.\n allowFontScaling={false}\n />\n </View>\n );\n};\n\nexport const WireIcon = React.memo(_WireIcon);\nWireIcon.displayName = \"WireIcon\";\n\nconst styles = StyleSheet.create({\n // No size/margin of its own: the glyph decides its footprint, so an absent icon and a\n // present one differ by exactly the glyph — never by a wrapper.\n decorative: {},\n});\n","/**\n * The shared option shape for the choice cards (SelectionCard, CardGridSelectCard).\n *\n * ── BACK-COMPAT, IN BOTH DIRECTIONS (the hard gate) ──────────────────────────────────────\n *\n * NEW option → OLD kit: `z.object` STRIPS unknown keys, and the SDK renderer mounts\n * `parsed.data` (not the raw props — see wireai-rn `renderer/ComponentRenderer.tsx`). So a\n * client on kit 0.7.x that receives `{value, label, icon}` silently drops `icon` and renders\n * the plain row it always did. No throw, no fallback card. This is what makes it safe to teach\n * the server `icon` before every host has re-pinned — and it MUST stay true, so never make\n * this schema `.strict()`.\n *\n * OLD option → NEW kit: the `preprocess` still coerces a bare `\"Spring\"` into\n * `{value:\"Spring\", label:\"Spring\"}`, exactly as before. A bare string and a bare\n * `{value,label}` both keep working untouched.\n *\n * `icon` is a plain `z.string()`, NOT a z.enum of the vocabulary. Deliberate: an unknown name\n * must degrade to no icon (WireIcon does that), never fail validation. If it were an enum, one\n * hallucinated or newer-than-this-client icon name would turn the whole card into a\n * LLM_SCHEMA_ERROR and cost the user their question — a catastrophic trade for a decoration.\n */\nimport { z } from \"zod\";\n\nimport { WIRE_ICON_NAMES } from \"../icons/vocabulary\";\n\n/**\n * The icon `.describe()` — an LLM ROUTING INSTRUCTION, not a type label (frequent_rules #4).\n * The vocabulary is inlined so the model reads the allowed values right where it fills the\n * field, and the list stays generated from the SSOT rather than drifting in a hand-typed copy.\n */\nexport const ICON_FIELD_DESCRIPTION =\n \"Optional icon for this option, making the choice scannable at a glance. Pick the ONE name \" +\n \"whose meaning matches the option (e.g. 'instagram' for an Instagram answer, 'friend' for \" +\n \"'A friend told me', 'wedding' for a wedding). Omit it when no name fits — a wrong icon is \" +\n `worse than none. Allowed values: ${WIRE_ICON_NAMES.join(\", \")}.`;\n\nexport const optionObjectSchema = z.object({\n value: z.string().describe(\"Option value\"),\n label: z.string().describe(\"Option display label\"),\n icon: z.string().optional().describe(ICON_FIELD_DESCRIPTION),\n});\n\nexport type CardOption = z.infer<typeof optionObjectSchema>;\n\n/** A bare string stays a valid option: coerce it to `{value, label}` before validating. */\nconst coerceOptions = (arr: unknown) =>\n Array.isArray(arr)\n ? arr.map((item) => (typeof item === \"string\" ? { value: item, label: item } : item))\n : arr;\n\n/** The `options` field, with its card-specific routing description. */\nexport const optionsField = (description: string) =>\n z.preprocess(coerceOptions, z.array(optionObjectSchema).min(1)).describe(description);\n\n/**\n * Component-level tolerance for the SAME coercion the schema does.\n *\n * WHY BOTH: in production the SDK renderer re-parses props and hands the card `parsed.data`, so\n * options arrive normalized. But a card is a plain exported component — the canary suite and any\n * host composing it directly mount it with raw props, where a bare string would otherwise read\n * `opt.value === undefined` and render an empty, unkeyed row. Cheap, total, and keeps the\n * component honest on its own contract instead of relying on a caller that may not exist.\n */\nexport const normalizeOptions = (options: ReadonlyArray<string | CardOption>): CardOption[] =>\n options.map((opt) => (typeof opt === \"string\" ? { value: opt, label: opt } : opt));\n","/**\n * Themed SelectionCard — drop-in for the OSS SDK's SelectionCard. Same `name`,\n * `propsSchema` (including the string|object option preprocess), `defaultProps`,\n * and `onSelect(string | string[])` contract. Radio/checkbox styling is themed.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 1-3): rows tick on press (scale\n * 0.975 spring), the selected fill/border eases in over 180ms ease-wire (a\n * native-driver opacity crossfade of a selected-style overlay), and the check\n * dot pops with a spring. All gated by useReducedMotion (snap, no spring).\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { labelStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport { WireIcon } from \"../icons/WireIcon\";\nimport { normalizeOptions, optionsField, type CardOption } from \"./optionSchema\";\nimport {\n CHECK_SCALE_FROM,\n CHECK_SPRING,\n PRESS_SPRING,\n ROW_PRESS_SCALE,\n SELECT_FILL_MS,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n title: z.string().describe(\"Question or prompt for the user\"),\n options: optionsField(\"List of choices\"),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Continue\"),\n multiSelect: z.boolean().optional().describe(\"Allow multiple selections\"),\n});\n\ntype Props = Omit<z.infer<typeof schema>, \"options\"> &\n InjectedProps & {\n /** Bare strings stay valid (normalized on the way in) — see optionSchema.ts. */\n options: ReadonlyArray<string | CardOption>;\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype OptionRowProps = {\n opt: CardOption;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (value: string) => void;\n};\n\nconst _OptionRow: React.FC<OptionRowProps> = ({ opt, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(opt.value), [opt.value, onToggle]);\n\n // Press tick: scale 1→0.975, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(ROW_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: the selected border+bg live on an absolute overlay whose opacity\n // crossfades in 180ms ease-wire — same visual as a color interpolation, but it\n // stays on the native driver (see EXTRACTED-SPEC.md D7). Reduce motion: snap.\n const selectT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(selectT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, SELECT_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, selectT]);\n\n // Check pop: scale 0.6→1 + fade, springy. Reduce motion: shown at scale 1 instantly.\n const checkT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n if (!isSelected) {\n checkT.setValue(0);\n return;\n }\n if (reduced) {\n checkT.setValue(1);\n return;\n }\n checkT.setValue(0);\n const anim = Animated.spring(checkT, {\n toValue: 1,\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, checkT]);\n\n const checkScale = checkT.interpolate({ inputRange: [0, 1], outputRange: [CHECK_SCALE_FROM, 1] });\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={opt.label}\n >\n <Animated.View\n style={[\n styles.option,\n {\n padding: t.spacing.md,\n borderRadius: t.radius.md,\n gap: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.background,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.selectedOverlay,\n {\n borderRadius: t.radius.md,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primarySoft,\n opacity: selectT,\n },\n ]}\n />\n <View\n style={[\n styles.indicator,\n { borderRadius: t.radius.full },\n isSelected\n ? { borderColor: t.colors.primary, backgroundColor: t.colors.primary }\n : { borderColor: t.colors.borderStrong, backgroundColor: \"transparent\" },\n ]}\n >\n {isSelected ? (\n <Animated.Text\n style={[\n styles.check,\n { color: t.colors.onPrimary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n ) : null}\n </View>\n {/* Accent discipline: the label keeps the text color in both states; the\n accent lives on the border, fill, and dot only. The icon obeys the same rule —\n it holds `text` in BOTH states rather than flipping to the accent, because an\n icon is not an excuse to invent a second accent. Decorative + unresolvable-safe:\n an unknown name renders null, so the row lays out exactly as an icon-less one. */}\n <WireIcon name={opt.icon} size={20} color={t.colors.text} />\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{opt.label}</Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst OptionRow = React.memo(_OptionRow);\n\nconst _SelectionCard: React.FC<Props> = ({\n title,\n options,\n submitLabel = \"Continue\",\n multiSelect = false,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const opts = React.useMemo(() => normalizeOptions(options), [options]);\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (value: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) => (prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value]));\n } else {\n setSelected([value]);\n }\n },\n [submitted, multiSelect],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={{ gap: t.spacing.sm + t.spacing.xs }}>\n {opts.map((opt) => (\n <OptionRow\n key={opt.value}\n opt={opt}\n isSelected={selected.includes(opt.value)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const SelectionCard: WireAIComponent = {\n name: \"SelectionCard\",\n description:\n \"Use for mutually exclusive (radio) or multi-select (checkbox) choices from 2–8 options, as a vertical list of rows. Best when options are wordy or need reading. Options may carry an optional `icon` from the vocabulary to make the list scannable. Use ChipSelectCard instead when options are short single words; use CardGridSelectCard when the options are visual and each has an obvious icon (occasions, channels, categories).\",\n component: React.memo(_SelectionCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Continue\", multiSelect: false },\n};\n\nconst styles = StyleSheet.create({\n option: { borderWidth: 1.5, flexDirection: \"row\", alignItems: \"center\", overflow: \"hidden\" },\n selectedOverlay: { borderWidth: 1.5 },\n indicator: { width: 24, height: 24, borderWidth: 2, alignItems: \"center\", justifyContent: \"center\" },\n check: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n});\n","/**\n * CardGridSelectCard — icon-led choices as a two-column grid of small cards.\n *\n * The shape Malik asked for (2026-07-16): \"the multi select needs to be a small card like this\n * one, with an icon on top, it is much better.\" Icon top-left, short label beneath, the whole\n * card is the tap target, selection lives on the card itself.\n *\n * ┌──────────────┐ ┌──────────────┐\n * │ ◇ │ │ ▣ │ ← icon on top\n * │ Wedding day │ │ Birthday │ ← label beneath\n * └──────────────┘ └──────────────┘\n *\n * WHY A NEW CARD RATHER THAN A `display` MODE ON SelectionCard: the card's `description` IS the\n * router — it is the only thing the model reads when choosing (frequent_rules #4). SelectionCard\n * already carries two modes behind one description; a third (\"a list, but sometimes a grid, and\n * then the icons matter\") cannot be stated honestly in one string, and a muddy description makes\n * the model pick the wrong card. The kit already has the precedent: ChipSelectCard exists ONLY\n * because \"compact vs. descriptive\" is a presentation difference worth its own name, over the\n * very same pick-from-options job. Back-compat costs nothing here — `supportedComponents`\n * (WireOnboarding.tsx) means an already-shipped client never advertises this name, so the server\n * intersects it away and can never emit it to the apps already in the stores. See the CHANGELOG.\n *\n * Layout is percentage flex, never a measured width: `flexBasis` ~47% + `flexGrow` makes exactly\n * two per row that fill the width, with no Dimensions read, no onLayout, and no re-render on\n * rotation. An odd last card stretches the row — deliberate, and the same thing every native\n * grid does.\n *\n * Motion mirrors SelectionCard's OptionRow exactly (press tick spring + a native-driver opacity\n * crossfade of the selected overlay), so the two cards feel like one system.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { labelStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport { WireIcon } from \"../icons/WireIcon\";\nimport { normalizeOptions, optionsField, type CardOption } from \"./optionSchema\";\nimport {\n PRESS_SPRING,\n ROW_PRESS_SCALE,\n SELECT_FILL_MS,\n WIRE_BEZIER,\n scaledMs,\n stateChangeDuration,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n title: z.string().describe(\"Question or prompt for the user, e.g. 'What brings you here?'\"),\n options: optionsField(\n \"The choices, 2-6 of them. Give EVERY option an `icon` from the vocabulary — the icon is \" +\n \"the point of this card, and an option without one renders as a bare label next to \" +\n \"icon-bearing neighbours. Keep labels short (1-3 words) so they fit a half-width card.\",\n ),\n submitLabel: z.string().optional().describe(\"Submit button label, default: Continue\"),\n multiSelect: z\n .boolean()\n .optional()\n .describe(\"Allow multiple cards selected at once, default true\"),\n});\n\ntype Props = Omit<z.infer<typeof schema>, \"options\"> &\n InjectedProps & {\n /** Bare strings stay valid (normalized on the way in) — see optionSchema.ts. */\n options: ReadonlyArray<string | CardOption>;\n onSelect?: (selected: string | string[]) => void;\n /** Fires as the live selection changes (before Continue), so the flow can prefetch the\n * next turn. Same value shape as onSelect. Optional — injected by OnboardingFlow. */\n onSelectionChange?: (selected: string | string[]) => void;\n };\n\ntype OptionCardProps = {\n opt: CardOption;\n isSelected: boolean;\n multiSelect: boolean;\n onToggle: (value: string) => void;\n};\n\nconst _OptionCard: React.FC<OptionCardProps> = ({ opt, isSelected, multiSelect, onToggle }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const handlePress = useCallback(() => onToggle(opt.value), [opt.value, onToggle]);\n\n // Press tick: scale 1→0.975, spring, native driver. Skipped under reduce motion.\n const pressScale = useRef(new Animated.Value(1)).current;\n const pressTo = useCallback(\n (to: number) => {\n if (reduced) return;\n Animated.spring(pressScale, {\n toValue: to,\n friction: PRESS_SPRING.friction,\n tension: PRESS_SPRING.tension,\n useNativeDriver: true,\n }).start();\n },\n [pressScale, reduced],\n );\n const handlePressIn = useCallback(() => pressTo(ROW_PRESS_SCALE), [pressTo]);\n const handlePressOut = useCallback(() => pressTo(1), [pressTo]);\n\n // Selected fill: accent border + tinted wash on an absolute overlay whose opacity crossfades\n // (native driver — see EXTRACTED-SPEC.md D7). Reduce motion: snap.\n const selectT = useRef(new Animated.Value(isSelected ? 1 : 0)).current;\n useEffect(() => {\n const anim = Animated.timing(selectT, {\n toValue: isSelected ? 1 : 0,\n duration: scaledMs(stateChangeDuration(reduced, SELECT_FILL_MS)),\n easing: easeWire,\n useNativeDriver: true,\n });\n anim.start();\n return () => anim.stop();\n }, [isSelected, reduced, selectT]);\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n accessibilityRole={multiSelect ? \"checkbox\" : \"radio\"}\n accessibilityState={multiSelect ? { checked: isSelected } : { selected: isSelected }}\n accessibilityLabel={opt.label}\n style={styles.cell}\n >\n <Animated.View\n style={[\n styles.card,\n {\n padding: t.spacing.md,\n borderRadius: t.radius.lg,\n gap: t.spacing.sm,\n borderColor: t.colors.border,\n backgroundColor: t.colors.surface,\n transform: [{ scale: pressScale }],\n },\n ]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n StyleSheet.absoluteFill,\n styles.selectedOverlay,\n {\n borderRadius: t.radius.lg,\n borderColor: t.colors.primary,\n backgroundColor: t.colors.primarySoft,\n opacity: selectT,\n },\n ]}\n />\n {/* Accent discipline (same rule as SelectionCard's rows): label AND icon keep the text\n color in both states; the accent lives on the border and fill only. An unresolvable\n icon renders null, so a card with a bad name lays out like one with no icon. */}\n <WireIcon name={opt.icon} size={24} color={t.colors.text} />\n <Text style={[labelStyle(t.fonts), { color: t.colors.text }]}>{opt.label}</Text>\n </Animated.View>\n </Pressable>\n );\n};\nconst OptionCard = React.memo(_OptionCard);\n\nconst _CardGridSelectCard: React.FC<Props> = ({\n title,\n options,\n submitLabel = \"Continue\",\n multiSelect = true,\n onSelect,\n onSelectionChange,\n}) => {\n const t = useOnboardingTheme();\n const opts = React.useMemo(() => normalizeOptions(options), [options]);\n const [selected, setSelected] = useState<string[]>([]);\n const [submitted, setSubmitted] = useState(false);\n\n // Report the settled selection upward (before Continue) so the flow can prefetch the next\n // turn. Debouncing lives in the flow; here we just emit on every change once something's picked.\n useEffect(() => {\n if (!submitted && selected.length) onSelectionChange?.(multiSelect ? selected : selected[0]!);\n }, [selected, submitted, multiSelect, onSelectionChange]);\n\n const toggle = useCallback(\n (value: string) => {\n if (submitted) return;\n if (multiSelect) {\n setSelected((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n } else {\n setSelected([value]);\n }\n },\n [submitted, multiSelect],\n );\n\n const handleSubmit = useCallback(() => {\n if (!selected.length || !onSelect || submitted) return;\n setSubmitted(true);\n onSelect(multiSelect ? selected : selected[0]!);\n }, [selected, onSelect, submitted, multiSelect]);\n\n return (\n <CardLayout\n title={title}\n footer={\n <Button\n title={submitLabel}\n onPress={handleSubmit}\n variant=\"primary\"\n disabled={selected.length === 0 || submitted}\n />\n }\n >\n <View style={[styles.grid, { gap: t.spacing.sm }]}>\n {opts.map((opt) => (\n <OptionCard\n key={opt.value}\n opt={opt}\n isSelected={selected.includes(opt.value)}\n multiSelect={multiSelect}\n onToggle={toggle}\n />\n ))}\n </View>\n </CardLayout>\n );\n};\n\nexport const CardGridSelectCard: WireAIComponent = {\n name: \"CardGridSelectCard\",\n description:\n \"Use for VISUAL, icon-led choices shown as a 2-column grid of tappable cards (icon on top, \" +\n \"short label beneath). Ideal for 2–6 concrete options that each have an obvious icon — \" +\n \"occasions, channels, goals, categories — e.g. 'What brings you here?' or 'Where did you \" +\n \"hear about us?'. Multi-select by default. Every option should carry an `icon`. Use \" +\n \"SelectionCard instead when options need descriptions or have no natural icon; use \" +\n \"ChipSelectCard for many short word-like tags.\",\n component: React.memo(_CardGridSelectCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { submitLabel: \"Continue\", multiSelect: true },\n};\n\nconst styles = StyleSheet.create({\n grid: { flexDirection: \"row\", flexWrap: \"wrap\" },\n // Two per row: ~47% basis leaves room for the gap, flexGrow fills the remainder exactly.\n cell: { flexBasis: \"47%\", flexGrow: 1 },\n card: { borderWidth: 1.5, alignItems: \"flex-start\", overflow: \"hidden\" },\n selectedOverlay: { borderWidth: 1.5 },\n});\n","/**\n * Themed StatusCard — drop-in for the OSS SDK's StatusCard. Same `name`,\n * `propsSchema`, and the onContinue/onPress/onSubmit callback fallback chain.\n * The terminal StatusCard is what OnboardingFlow treats as \"flow complete\".\n * Status colors read from the theme's semantic palette.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 14, 16): the status glyph pops in\n * with a spring (scale 0.4→1, overshoot) and the copy fades up 80ms behind it.\n * Reduce motion: final frame instantly. (The terminal payoff with the burst is\n * CompletionView; this card is the inline status treatment.)\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Easing, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n STATUS_COPY_MS,\n STATUS_COPY_STAGGER_MS,\n STATUS_POP_SCALE_FROM,\n STATUS_POP_SPRING,\n WIRE_BEZIER,\n scaledMs,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\n\nconst schema = z.object({\n status: z.enum([\"success\", \"warning\", \"error\", \"info\"]).describe(\"Status type\"),\n title: z.string().describe(\"Status title\"),\n message: z.string().optional().describe(\"Supporting message\"),\n ctaLabel: z\n .string()\n .optional()\n .describe(\n \"Optional call-to-action button label. Always include this on success status to keep the conversation going.\",\n ),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onContinue?: () => void;\n onPress?: (label: string) => void;\n onSubmit?: (value: string) => void;\n };\n\nconst STATUS_ICONS: Record<string, string> = {\n success: \"✓\",\n warning: \"⚠\",\n error: \"✗\",\n info: \"ℹ\",\n};\n\nconst _StatusCard: React.FC<Props> = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const [submitted, setSubmitted] = useState(false);\n\n const color = useMemo(() => {\n switch (status) {\n case \"success\":\n return t.colors.success;\n case \"warning\":\n return t.colors.warning;\n case \"error\":\n return t.colors.error;\n default:\n return t.colors.info;\n }\n }, [status, t.colors]);\n\n // Glyph pop + copy fade-up (final frame under reduce motion).\n const popT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const copyT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n useEffect(() => {\n if (reduced) {\n popT.setValue(1);\n copyT.setValue(1);\n return;\n }\n const anims = [\n Animated.spring(popT, {\n toValue: 1,\n friction: STATUS_POP_SPRING.friction,\n tension: STATUS_POP_SPRING.tension,\n useNativeDriver: true,\n }),\n Animated.timing(copyT, {\n toValue: 1,\n duration: scaledMs(STATUS_COPY_MS),\n delay: scaledMs(STATUS_COPY_STAGGER_MS),\n easing: easeWire,\n useNativeDriver: true,\n }),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, popT, copyT]);\n\n const popScale = popT.interpolate({ inputRange: [0, 1], outputRange: [STATUS_POP_SCALE_FROM, 1] });\n const copyRise = copyT.interpolate({ inputRange: [0, 1], outputRange: [10, 0] });\n\n const handleContinue = useCallback(() => {\n if (!submitted) {\n setSubmitted(true);\n if (onContinue) onContinue();\n else if (onPress && ctaLabel) onPress(ctaLabel);\n else if (onSubmit) onSubmit(\"continue\");\n }\n }, [submitted, onContinue, onPress, onSubmit, ctaLabel]);\n\n return (\n <CardLayout\n align=\"center\"\n footer={\n ctaLabel ? (\n <Button title={ctaLabel} onPress={handleContinue} variant=\"primary\" disabled={submitted} />\n ) : undefined\n }\n >\n <View style={[styles.center, { gap: t.spacing.sm }]}>\n <View style={[styles.titleRow, { gap: t.spacing.sm }]}>\n <Animated.Text\n style={[\n headingStyle(t.fonts),\n { color, opacity: popT, transform: [{ scale: popScale }] },\n ]}\n >\n {STATUS_ICONS[status] ?? \"·\"}\n </Animated.Text>\n <Animated.Text\n style={[\n headingStyle(t.fonts),\n { color, textAlign: \"center\", opacity: copyT, transform: [{ translateY: copyRise }] },\n ]}\n >\n {title}\n </Animated.Text>\n </View>\n {message ? (\n <Animated.Text\n style={[\n bodyStyle(t.fonts),\n {\n color: t.colors.textMuted,\n textAlign: \"center\",\n opacity: copyT,\n transform: [{ translateY: copyRise }],\n },\n ]}\n >\n {message}\n </Animated.Text>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const StatusCard: WireAIComponent = {\n name: \"StatusCard\",\n description:\n \"Use ONLY for real outcomes: booking confirmed, data saved, action completed. NEVER for 'you just viewed X' acknowledgments. Always include ctaLabel so the user can continue after seeing the status.\",\n component: React.memo(_StatusCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n};\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n titleRow: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * Themed NumberStepperCard — drop-in for the OSS SDK's NumberStepperCard. Same\n * `name`, `propsSchema`, `defaultProps`, and `onSubmit(value: number)` contract.\n * Keeps the SDK's defensive numeric coercion so a malformed LLM payload can never\n * feed NaN/Infinity into layout math.\n */\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { Pressable, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { captionStyle, headingStyle } from \"../theme/typography\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\n\nconst schema = z.object({\n label: z.string().describe(\"What is being counted, e.g. 'Number of days' or 'Travellers'\"),\n min: z.number().optional().describe(\"Minimum value, default 1\"),\n max: z.number().optional().describe(\"Maximum value, default 30\"),\n defaultValue: z.number().optional().describe(\"Starting value\"),\n step: z.number().optional().describe(\"Increment per tap, default 1\"),\n unit: z.string().optional().describe(\"Unit label shown next to value, e.g. 'days' or 'people'\"),\n submitLabel: z.string().optional().describe(\"Confirm button label, default: Confirm\"),\n});\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: number) => void;\n };\n\nconst safeNum = (n: unknown, fallback: number): number =>\n typeof n === \"number\" && Number.isFinite(n) ? n : fallback;\n\nconst _NumberStepperCard: React.FC<Props> = ({\n label,\n min,\n max,\n defaultValue,\n step,\n unit,\n submitLabel = \"Confirm\",\n onSubmit,\n}) => {\n const t = useOnboardingTheme();\n const styles = useMemo(() => makeStyles(t), [t]);\n\n const safeMin = safeNum(min, 1);\n const safeMaxRaw = safeNum(max, 30);\n const safeMax = safeMaxRaw < safeMin ? safeMin : safeMaxRaw;\n const safeStepRaw = safeNum(step, 1);\n const safeStep = safeStepRaw > 0 ? safeStepRaw : 1;\n const safeDefault = safeNum(defaultValue, safeMin);\n\n const [value, setValue] = useState(Math.min(Math.max(safeDefault, safeMin), safeMax));\n const [submitted, setSubmitted] = useState(false);\n\n const handleDecrement = useCallback(() => {\n if (!submitted) setValue((v) => Math.max(v - safeStep, safeMin));\n }, [submitted, safeStep, safeMin]);\n\n const handleIncrement = useCallback(() => {\n if (!submitted) setValue((v) => Math.min(v + safeStep, safeMax));\n }, [submitted, safeStep, safeMax]);\n\n const handleSubmit = useCallback(() => {\n if (!submitted) {\n setSubmitted(true);\n onSubmit?.(value);\n }\n }, [submitted, onSubmit, value]);\n\n const atMin = value <= safeMin;\n const atMax = value >= safeMax;\n\n const stepBtnStyle = (disabled: boolean) => [\n styles.stepBtn,\n { borderRadius: t.radius.full, backgroundColor: t.colors.background, borderColor: disabled ? t.colors.border : t.colors.primary },\n ];\n\n return (\n <CardLayout\n title={label}\n align=\"center\"\n footer={\n <Button title={submitLabel} onPress={handleSubmit} variant=\"primary\" disabled={submitted} />\n }\n >\n <View style={styles.wrap}>\n <View style={[styles.stepper, { gap: t.spacing.lg }]}>\n <Pressable onPress={atMin || submitted ? undefined : handleDecrement} disabled={atMin || submitted} style={stepBtnStyle(atMin)}>\n <Text style={[headingStyle(t.fonts), { color: atMin ? t.colors.textMuted : t.colors.primary }]}>{\"−\"}</Text>\n </Pressable>\n <View style={styles.valueBox}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.primary }]}>{String(value)}</Text>\n {unit ? <Text style={[captionStyle(t.fonts), { color: t.colors.textMuted }]}>{unit}</Text> : null}\n </View>\n <Pressable onPress={atMax || submitted ? undefined : handleIncrement} disabled={atMax || submitted} style={stepBtnStyle(atMax)}>\n <Text style={[headingStyle(t.fonts), { color: atMax ? t.colors.textMuted : t.colors.primary }]}>{\"+\"}</Text>\n </Pressable>\n </View>\n <Text style={[captionStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {`${safeMin} – ${safeMax}${unit ? ` ${unit}` : \"\"}`}\n </Text>\n </View>\n </CardLayout>\n );\n};\n\nexport const NumberStepperCard: WireAIComponent = {\n name: \"NumberStepperCard\",\n description:\n \"Use for any bounded numeric input: days, people, portions, budget tiers, ratings. Best for ranges 1–99. Set unit (e.g. 'days', 'people') for clarity.\",\n component: React.memo(_NumberStepperCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { min: 1, max: 30, defaultValue: 1, step: 1, submitLabel: \"Confirm\" },\n};\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n wrap: { gap: t.spacing.md, alignItems: \"center\" },\n stepper: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"center\" },\n stepBtn: { width: 44, height: 44, borderWidth: 2, alignItems: \"center\", justifyContent: \"center\" },\n valueBox: { alignItems: \"center\", minWidth: 80 },\n });\n}\n","/**\n * InterstitialCard — a mid-flow \"value\" screen (the Duolingo / Cal-AI beat): an\n * illustration + a short motivational line + a single Continue button. It is NOT a\n * question — it builds momentum and reinforces what the user is committing to,\n * which is one of the biggest retention levers in great onboarding.\n *\n * Artwork resolves in order so the screen is NEVER a blank box: the host's named\n * `illustration` (brand SVG/Lottie, keeping the kit dependency-free) → a\n * backend-supplied `imageUrl` via RN <Image> (which self-heals to art on load\n * error) → a named `illustrationFallback` (defaults to \"momentum\", always present\n * in the kit's default registry).\n *\n * A minimum display window keeps the momentum beat from flashing past when the next\n * card is already cached: Continue is disabled for MIN_DISPLAY_MS after mount.\n *\n * Motion (design-refs/EXTRACTED-SPEC.md rows 11-13): art and title fade-up in\n * sequence (500ms ease-wire, 100ms stagger); the optional `items` (short lines\n * referencing what the user already said) tick on one by one (90ms stagger),\n * each check popping 200ms after its row — \"work being done\", not a slideshow.\n * Reduce motion: everything rendered at its final frame at once.\n *\n * On Continue it sends \"continue\" back to the backend so the flow advances; the\n * submitted-state guard makes the tap idempotent.\n */\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Image, StyleSheet, Text, View } from \"react-native\";\nimport { z } from \"zod\";\nimport type { InjectedProps, WireAIComponent } from \"wireai-rn\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\nimport { useIllustration } from \"../components/Illustration\";\nimport { Button } from \"../components/Button\";\nimport { CardLayout } from \"../components/CardLayout\";\nimport {\n CHECK_SPRING,\n INTERSTITIAL_CHECK_SCALE_FROM,\n INTERSTITIAL_HEAD_MS,\n INTERSTITIAL_HEAD_STAGGER_MS,\n INTERSTITIAL_ITEM_MS,\n WIRE_BEZIER,\n interstitialCheckDelay,\n scaledMs,\n interstitialItemDelay,\n} from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\n\nconst easeWire = Easing.bezier(...WIRE_BEZIER);\nconst RISE_PX = 10;\n\nconst schema = z.object({\n title: z.string().describe(\"Short, warm headline for the value/momentum moment\"),\n body: z\n .string()\n .optional()\n .describe(\"One or two supporting lines that reflect the user's answers back and build momentum\"),\n items: z\n .array(z.string())\n .max(4)\n .optional()\n .describe(\n \"2-3 very short 'work being done' lines that each reference something the user already answered (e.g. 'Sized for a small team'). Shown as ticked items appearing in sequence. Prefer these over `body` when you have concrete answers to reflect back.\",\n ),\n illustration: z\n .string()\n .optional()\n .describe(\n \"Name of an app-provided illustration to show (the app's registry decides the artwork). Prefer this over imageUrl.\",\n ),\n imageUrl: z\n .string()\n .url()\n .refine((v) => v.startsWith(\"https://\"), \"imageUrl must be an https URL\")\n .optional()\n .describe(\n \"Fallback remote HTTPS image URL, used only when no named illustration is registered. A non-https or malformed value is rejected and degrades to the named-illustration fallback.\",\n ),\n illustrationFallback: z\n .string()\n .optional()\n .describe(\n \"Named illustration to show when neither `illustration` nor `imageUrl` resolves (or the image fails to load). Defaults to the kit's always-present 'momentum' art so the screen is never blank.\",\n ),\n ctaLabel: z.string().optional().describe(\"Continue button label, default: Continue\"),\n});\n\n// Minimum time the momentum screen stays interactive-locked, so it never flashes past\n// when the next card is already prefetched/cached.\nconst MIN_DISPLAY_MS = 500;\n\ntype Props = z.infer<typeof schema> &\n InjectedProps & {\n onSubmit?: (value: string) => void;\n onPress?: (label: string) => void;\n };\n\n/** One ticked \"work\" row: fades up on its stagger slot, then the check pops. */\nconst _WorkItem: React.FC<{ text: string; index: number; reduced: boolean }> = ({\n text,\n index,\n reduced,\n}) => {\n const t = useOnboardingTheme();\n const rowT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const checkT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n\n useEffect(() => {\n if (reduced) {\n rowT.setValue(1);\n checkT.setValue(1);\n return;\n }\n const anims = [\n Animated.timing(rowT, {\n toValue: 1,\n duration: scaledMs(INTERSTITIAL_ITEM_MS),\n delay: scaledMs(interstitialItemDelay(index)),\n easing: easeWire,\n useNativeDriver: true,\n }),\n Animated.spring(checkT, {\n toValue: 1,\n delay: scaledMs(interstitialCheckDelay(index)),\n friction: CHECK_SPRING.friction,\n tension: CHECK_SPRING.tension,\n useNativeDriver: true,\n }),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, index, rowT, checkT]);\n\n const rise = rowT.interpolate({ inputRange: [0, 1], outputRange: [RISE_PX, 0] });\n const checkScale = checkT.interpolate({\n inputRange: [0, 1],\n outputRange: [INTERSTITIAL_CHECK_SCALE_FROM, 1],\n });\n\n return (\n <Animated.View\n style={[styles.itemRow, { gap: t.spacing.sm + t.spacing.xs, opacity: rowT, transform: [{ translateY: rise }] }]}\n >\n <View\n style={[\n styles.itemBadge,\n { backgroundColor: t.colors.primarySoft, borderRadius: t.radius.full },\n ]}\n >\n <Animated.Text\n style={[\n styles.itemCheck,\n { color: t.colors.primary, opacity: checkT, transform: [{ scale: checkScale }] },\n ]}\n >\n ✓\n </Animated.Text>\n </View>\n <Text style={[bodyStyle(t.fonts), styles.itemText, { color: t.colors.text }]}>{text}</Text>\n </Animated.View>\n );\n};\nconst WorkItem = React.memo(_WorkItem);\n\nconst _InterstitialCard: React.FC<Props> = ({\n title,\n body,\n items,\n illustration,\n imageUrl,\n illustrationFallback,\n ctaLabel = \"Continue\",\n onSubmit,\n onPress,\n}) => {\n const t = useOnboardingTheme();\n const reduced = useReducedMotion();\n const node = useIllustration(illustration);\n const fallbackNode = useIllustration(illustrationFallback);\n const [submitted, setSubmitted] = useState(false);\n const [imgFailed, setImgFailed] = useState(false);\n // Keep the momentum beat on screen for at least MIN_DISPLAY_MS before Continue is tappable.\n const [canAdvance, setCanAdvance] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => setCanAdvance(true), MIN_DISPLAY_MS);\n return () => clearTimeout(timer);\n }, []);\n\n // Head reveal: art then title (then body) fade-up, 500ms ease-wire, 100ms stagger.\n // Reduce motion: final frame immediately (the shell handoff supplies the short fade).\n const artT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const titleT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n const bodyT = useRef(new Animated.Value(reduced ? 1 : 0)).current;\n useEffect(() => {\n if (reduced) {\n artT.setValue(1);\n titleT.setValue(1);\n bodyT.setValue(1);\n return;\n }\n const rise = (value: Animated.Value, delay: number) =>\n Animated.timing(value, {\n toValue: 1,\n duration: scaledMs(INTERSTITIAL_HEAD_MS),\n delay,\n easing: easeWire,\n useNativeDriver: true,\n });\n const anims = [\n rise(artT, 0),\n rise(titleT, scaledMs(INTERSTITIAL_HEAD_STAGGER_MS)),\n rise(bodyT, scaledMs(INTERSTITIAL_HEAD_STAGGER_MS * 2)),\n ];\n anims.forEach((a) => a.start());\n return () => anims.forEach((a) => a.stop());\n }, [reduced, artT, titleT, bodyT]);\n\n const riseStyle = (value: Animated.Value) => ({\n opacity: value,\n transform: [{ translateY: value.interpolate({ inputRange: [0, 1], outputRange: [RISE_PX, 0] }) }],\n });\n\n const handleContinue = useCallback(() => {\n if (submitted || !canAdvance) return;\n setSubmitted(true);\n if (onSubmit) onSubmit(\"continue\");\n else if (onPress) onPress(ctaLabel);\n }, [submitted, canAdvance, onSubmit, onPress, ctaLabel]);\n\n // Resolution order — a broken/missing image must never leave a blank box:\n // named illustration → remote image (until it errors) → named fallback art.\n const showImage = !node && !!imageUrl && !imgFailed;\n const art = node ?? (showImage ? undefined : fallbackNode);\n\n return (\n <CardLayout\n align=\"center\"\n footer={\n <Button\n title={ctaLabel}\n onPress={handleContinue}\n variant=\"primary\"\n disabled={submitted || !canAdvance}\n />\n }\n >\n <View style={[styles.center, { gap: t.spacing.md }]}>\n <Animated.View style={[styles.fullWidth, riseStyle(artT)]}>\n {showImage ? (\n <Image\n source={{ uri: imageUrl }}\n style={styles.image}\n resizeMode=\"contain\"\n onError={() => setImgFailed(true)}\n />\n ) : art ? (\n <View style={styles.art}>{art}</View>\n ) : null}\n </Animated.View>\n\n <Animated.View style={riseStyle(titleT)}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.text, textAlign: \"center\" }]}>{title}</Text>\n </Animated.View>\n\n {items?.length ? (\n <View style={[styles.items, { gap: t.spacing.md, marginTop: t.spacing.sm }]}>\n {items.map((item, i) => (\n <WorkItem key={`${item}-${i}`} text={item} index={i} reduced={reduced} />\n ))}\n </View>\n ) : body ? (\n <Animated.View style={riseStyle(bodyT)}>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>{body}</Text>\n </Animated.View>\n ) : null}\n </View>\n </CardLayout>\n );\n};\n\nexport const InterstitialCard: WireAIComponent = {\n name: \"InterstitialCard\",\n description:\n \"Use ONCE mid-flow (never first, never last) as a momentum/value screen between questions — an illustration + a warm line that reflects answers back, like Duolingo/Cal-AI. NOT a question; the user just taps Continue. Set `illustration` to an app-registered artwork name. Prefer `items` (2-3 short ticked lines, each reflecting a real answer) when you have the signal. Skip it if you don't have enough signal to make the line specific.\",\n component: React.memo(_InterstitialCard) as WireAIComponent[\"component\"],\n propsSchema: schema,\n defaultProps: { ctaLabel: \"Continue\", illustrationFallback: \"momentum\" },\n};\n\nconst styles = StyleSheet.create({\n center: { width: \"100%\", alignItems: \"center\", justifyContent: \"center\" },\n fullWidth: { width: \"100%\", alignItems: \"center\" },\n art: { alignItems: \"center\", justifyContent: \"center\" },\n image: { width: \"100%\", height: 200 },\n items: { width: \"100%\", alignSelf: \"stretch\" },\n itemRow: { flexDirection: \"row\", alignItems: \"center\" },\n itemBadge: { width: 24, height: 24, alignItems: \"center\", justifyContent: \"center\" },\n itemCheck: { fontSize: 13, fontWeight: \"800\", lineHeight: 15 },\n itemText: { flex: 1 },\n});\n","/**\n * onboardingComponents — the constrained set of themed cards the kit registers\n * with the SDK. The backend's `allowed_components` must be a subset of these\n * names so every card the agent asks for has a themed renderer.\n */\nimport type { WireAIComponent } from \"wireai-rn\";\nimport { ChipSelectCard } from \"./ChipSelectCard\";\nimport { TextInputCard } from \"./TextInputCard\";\nimport { SelectionCard } from \"./SelectionCard\";\nimport { CardGridSelectCard } from \"./CardGridSelectCard\";\nimport { StatusCard } from \"./StatusCard\";\nimport { NumberStepperCard } from \"./NumberStepperCard\";\nimport { InterstitialCard } from \"./InterstitialCard\";\n\nexport {\n ChipSelectCard,\n TextInputCard,\n SelectionCard,\n CardGridSelectCard,\n StatusCard,\n NumberStepperCard,\n InterstitialCard,\n};\nexport { normalizeOptions, optionsField, optionObjectSchema } from \"./optionSchema\";\nexport type { CardOption } from \"./optionSchema\";\n\nexport const onboardingComponents: WireAIComponent[] = [\n ChipSelectCard,\n TextInputCard,\n SelectionCard,\n CardGridSelectCard,\n StatusCard,\n NumberStepperCard,\n InterstitialCard,\n];\n","/**\n * appVersion — best-effort, DEPENDENCY-FREE auto-detection of the host app's version string.\n *\n * WHY this exists: analytics segments the funnel `by_app_version`, but that breakdown is only\n * populated when a `device.appVersion` rides the event. `config.appVersion` (see types.ts) has\n * always been the way to supply it — but it is easy for a host to forget, and then the release\n * breakdown is silently empty. This module fills that gap: when the host does NOT pass a version,\n * the kit makes a best-effort read of the app version the host already ships in its Expo config,\n * so the breakdown works out of the box. An explicit `config.appVersion` always WINS over this.\n *\n * WHY it adds NO dependency (the kit's hard rule): `expo-constants` / `expo-application` are read\n * through a GUARDED require with a STRING-LITERAL specifier, inside a try/catch. Both halves are\n * required: the literal is what lets Metro COLLECT the dep, and the try/catch is what marks it\n * OPTIONAL, so an absent module becomes a `null` dependencyMap entry whose require throws \"Cannot\n * find module\" straight into the catch. (`withWireOnboarding` in metro/index.js adds a stub-to-\n * empty-module safety net for hosts that disable Metro's `allowOptionalDependencies`.) Nothing is\n * added to `package.json`; nothing is forced on the host.\n *\n * The specifier MUST stay a literal. A variable specifier (`const req = require; req(name)`) is not\n * \"lazier\" — it is broken: Metro collects dependencies statically, so a variable collects NOTHING,\n * the module never enters the bundle, and the aliased `require` is Metro's own numeric-id-keyed\n * `metroRequire`, which can never resolve a package-name string. That shape is why this function\n * returned `undefined` on every host despite `expo-constants` being installed, which silently\n * emptied the `by_app_version` breakdown this module exists to fill. See icons/expoIcons.ts for\n * the full autopsy, and reviews/storeReview.ts for the literal-specifier counter-example.\n *\n * PRIVACY: an app version string is not PII and identifies no user or device, so surfacing it\n * changes no App Privacy / Data Safety declaration (same guarantee as the rest of deviceContext).\n *\n * NEVER THROWS: every read is guarded; a missing/odd value yields `undefined`, never an exception.\n * Analytics must never be able to break onboarding.\n */\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime. Declared locally so\n// this type-checks without ambient Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded runtime require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/** Trim + reject non-strings/empties so we only ever emit a real version string. */\nexport const coerceVersion = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Guarded runtime require.\n *\n * Every specifier below is a STRING LITERAL, because that is the only shape Metro's dependency\n * collector matches (callee literally `require`, argument literally a string). The `moduleName`\n * parameter exists only to keep the `OptionalRequire` seam shape for tests; an unrecognised name\n * resolves to undefined. See the header for why the old variable-specifier shape could not work.\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (typeof require !== \"function\") return undefined;\n try {\n switch (moduleName) {\n case \"expo-constants\":\n return require(\"expo-constants\");\n case \"expo-application\":\n return require(\"expo-application\");\n default:\n return undefined;\n }\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return mod as Record<string, unknown>;\n};\n\n/** Resolve a module namespace, swallowing a throwing require (an uninstalled module throws). */\nconst safeInterop = (\n requireModule: OptionalRequire,\n moduleName: string,\n): Record<string, unknown> | undefined => {\n try {\n return interop(requireModule(moduleName));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Detect the host app version, preferring `expo-constants` (`expoConfig.version`, then\n * `nativeAppVersion`) and finally `expo-application` (`nativeApplicationVersion`). Returns the\n * first real string, or `undefined` when none of those are available. Pure and never throws.\n *\n * `requireModule` is injectable so tests can exercise the \"found\" path without the native modules;\n * production defaults to the guarded runtime require above.\n */\nexport const detectAppVersion = (\n requireModule: OptionalRequire = runtimeRequire,\n): string | undefined => {\n try {\n const constants = safeInterop(requireModule, \"expo-constants\");\n if (constants) {\n const expoConfig = constants.expoConfig;\n if (expoConfig && typeof expoConfig === \"object\") {\n const fromExpoConfig = coerceVersion((expoConfig as { version?: unknown }).version);\n if (fromExpoConfig) return fromExpoConfig;\n }\n const fromNative = coerceVersion(constants.nativeAppVersion);\n if (fromNative) return fromNative;\n }\n\n const application = safeInterop(requireModule, \"expo-application\");\n if (application) {\n const fromApplication = coerceVersion(application.nativeApplicationVersion);\n if (fromApplication) return fromApplication;\n }\n } catch {\n // Any unexpected read error → \"unknown\"; analytics must never crash onboarding.\n }\n return undefined;\n};\n","/**\n * deviceModel — best-effort, DEPENDENCY-FREE detection of the device MODEL on iOS.\n *\n * WHY this exists (the asymmetry it closes): `collectDeviceContext` already reports `device.model`\n * on Android straight from `Platform.constants.Model` (e.g. \"SM-G991B\"), but iOS `Platform.constants`\n * exposes NO model — only `osVersion` / `interfaceIdiom`. So the analytics `by_model` breakdown was\n * Android-only. This module fills the iOS gap with the SAME zero-dependency technique the kit already\n * uses for `appVersion` (see device/appVersion.ts): a GUARDED, STRING-LITERAL `require` of the common\n * Expo `expo-device` module, inside a try/catch — the literal is what lets Metro COLLECT the dep and\n * the try/catch is what marks it OPTIONAL, so an absent module degrades instead of failing the build.\n * (`withWireOnboarding` in metro/index.js adds a stub-to-empty-module safety net for hosts that\n * disable Metro's `allowOptionalDependencies`.) If the host has it, iOS gets a model out of the box;\n * if not, the read yields `undefined` and iOS `model` stays omitted — nothing is forced, and nothing\n * is added to `package.json`.\n *\n * The specifier MUST stay a literal. A variable specifier (`const req = require; req(name)`) collects\n * NOTHING under Metro's static dependency collector, so the module never enters the bundle and the\n * aliased `require` — really Metro's numeric-id-keyed `metroRequire` — can never resolve a package\n * name. See icons/expoIcons.ts for the full autopsy.\n *\n * WHY it is NOT PII: `expo-device`'s `modelName` (\"iPhone 14 Pro\") and `modelId` (\"iPhone15,2\") are a\n * device CLASS shared by millions of units — the same privacy category as the Android `Model` the kit\n * already sends. It is NOT a unique device id / IDFA / fingerprint, so surfacing it changes no App\n * Privacy / Data Safety declaration (identical guarantee to the rest of deviceContext). It deliberately\n * does NOT read `expo-device`'s `deviceName` (that is the user-set name, e.g. \"Malik's iPhone\", and IS\n * personal data).\n *\n * NEVER THROWS: every read is guarded; a missing/odd value yields `undefined`, never an exception.\n */\n\n// Metro injects a module-scoped `require`; it is ABSENT in a pure-ESM runtime. Declared locally so\n// this type-checks without ambient Node types; the `typeof` guard keeps the reference ESM-safe.\ndeclare const require: ((id: string) => unknown) | undefined;\n\n/** A `require`-like resolver. Injectable in tests; production uses the guarded runtime require. */\nexport type OptionalRequire = (moduleName: string) => unknown;\n\n/** Trim + reject non-strings/empties so we only ever emit a real model string. */\nconst coerceModel = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Guarded runtime require.\n *\n * The specifier is a STRING LITERAL, because that is the only shape Metro's dependency collector\n * matches (callee literally `require`, argument literally a string). The `moduleName` parameter\n * exists only to keep the `OptionalRequire` seam shape for tests; an unrecognised name resolves to\n * undefined. (See the twin guard in ./appVersion.ts.)\n */\nconst runtimeRequire: OptionalRequire = (moduleName) => {\n if (moduleName !== \"expo-device\") return undefined;\n if (typeof require !== \"function\") return undefined;\n try {\n return require(\"expo-device\");\n } catch {\n return undefined;\n }\n};\n\n/** Read a module's `default` (Expo modules are often consumed as default exports) or the namespace. */\nconst interop = (mod: unknown): Record<string, unknown> | undefined => {\n if (!mod || typeof mod !== \"object\") return undefined;\n const def = (mod as { default?: unknown }).default;\n if (def && typeof def === \"object\") return def as Record<string, unknown>;\n return mod as Record<string, unknown>;\n};\n\n/** Resolve a module namespace, swallowing a throwing require (an uninstalled module throws). */\nconst safeInterop = (\n requireModule: OptionalRequire,\n moduleName: string,\n): Record<string, unknown> | undefined => {\n try {\n return interop(requireModule(moduleName));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Detect the device model via `expo-device`, preferring the human-readable `modelName`\n * (\"iPhone 14 Pro\") and falling back to the identifier `modelId` (\"iPhone15,2\"). Returns the first\n * real string, or `undefined` when `expo-device` is absent. Pure and never throws.\n *\n * `requireModule` is injectable so tests can exercise the \"found\" path without the native module;\n * production defaults to the guarded runtime require above.\n */\nexport const detectNativeModel = (\n requireModule: OptionalRequire = runtimeRequire,\n): string | undefined => {\n try {\n const device = safeInterop(requireModule, \"expo-device\");\n if (device) {\n const modelName = coerceModel(device.modelName);\n if (modelName) return modelName;\n const modelId = coerceModel(device.modelId);\n if (modelId) return modelId;\n }\n } catch {\n // Any unexpected read error → undefined; analytics must never crash onboarding.\n }\n return undefined;\n};\n","/**\n * deviceContext — collect a small, privacy-label-neutral snapshot of the device so\n * onboarding analytics can segment the funnel (platform / form factor / locale) WITHOUT\n * adding a single dependency to the kit or changing a host app's App Privacy / Data Safety\n * declarations.\n *\n * HARD RULE (why this file adds no dependency):\n * The kit stays dependency-free. Everything here comes from `Platform`, `Dimensions`,\n * `I18nManager`, and the standard `Intl` global — plus a best-effort `appVersion` read via\n * `detectAppVersion()`, which itself adds NO dependency (it reaches for `expo-constants` /\n * `expo-application` through a guarded, variable-specifier require that a host without them\n * simply never resolves — see device/appVersion.ts). There are NO advertising IDs, NO\n * `getUniqueId`/IDFA/GAID/fingerprinting APIs, and nothing that would require a new\n * privacy-label entry. A host can adopt this without touching its store declarations.\n *\n * DEFENSIVE BY DESIGN: `collectDeviceContext()` never throws. Every read is guarded and\n * a missing/unavailable field is simply omitted (Hermes may ship without full `Intl`,\n * `Platform.constants` differs per OS and RN version, etc.). Analytics must never be able\n * to break onboarding.\n */\nimport { Dimensions, I18nManager, Platform } from \"react-native\";\n\nimport { detectAppVersion } from \"./appVersion\";\nimport { detectNativeModel } from \"./deviceModel\";\n\n/** Coarse device class. iOS uses the reported interface idiom; else a screen-size heuristic. */\nexport type DeviceFormFactor = \"phone\" | \"tablet\";\n\n/**\n * A privacy-label-neutral device snapshot. ALL fields except `platform` are optional and are\n * omitted when unavailable. Nothing here identifies a user or device uniquely.\n */\nexport type DeviceContext = {\n /** `Platform.OS` — \"ios\" | \"android\" | \"windows\" | \"macos\" | \"web\". Always present. */\n platform: typeof Platform.OS;\n /** OS version string (iOS `osVersion`/`Platform.Version`, Android `Release`). */\n osVersion?: string;\n /** Android device brand (e.g. \"samsung\"). Android only. */\n brand?: string;\n /**\n * Device model. On Android it is read directly from `Platform.constants.Model` (e.g. \"SM-G991B\").\n * iOS `Platform.constants` exposes NO model, so on iOS it is a BEST-EFFORT read of `expo-device`'s\n * `modelName` (\"iPhone 14 Pro\"), falling back to `modelId` (\"iPhone15,2\") — dependency-free via a\n * guarded require (see device/deviceModel.ts). ASYMMETRY: without `expo-device` installed, iOS\n * `model` is omitted (there is no dependency-free iOS model in the already-used RN surface, and the\n * kit will not add a native dep for it); Android needs no extra module. Not PII (a device class,\n * not a unique id), so it changes no privacy-label declaration.\n */\n model?: string;\n /** iOS interface idiom (\"phone\" | \"pad\" | …), when reported. iOS only. */\n interfaceIdiom?: string;\n /** Derived device class. */\n formFactor?: DeviceFormFactor;\n /** `Dimensions.get('screen')` width in dp. */\n screenWidth?: number;\n /** `Dimensions.get('screen')` height in dp. */\n screenHeight?: number;\n /** Screen pixel density (`scale`). */\n screenScale?: number;\n /** Right-to-left layout (`I18nManager.isRTL`). */\n isRTL?: boolean;\n /** Resolved locale (e.g. \"en-US\"), from `Intl` when available. */\n locale?: string;\n /** IANA time zone (e.g. \"Europe/Berlin\"), from `Intl` when available. */\n timeZone?: string;\n /**\n * Host app version (e.g. \"1.4.2\"). BEST-EFFORT auto-detected here via `detectAppVersion()`\n * (reads `expo-constants` / `expo-application` when present; adds no dependency — see\n * device/appVersion.ts). An explicit host-injected `config.appVersion` always WINS: the merge\n * sites (`WireOnboarding`, the session-analytics hooks, the context envelope) overwrite this\n * with the host value when one is supplied. Omitted when neither source yields a version.\n */\n appVersion?: string;\n};\n\n/** iOS idiom wins; otherwise the shortest side in dp (>= 600 → tablet) picks the class. */\nconst deriveFormFactor = (\n iosIdiom: string | undefined,\n width: number | undefined,\n height: number | undefined,\n): DeviceFormFactor | undefined => {\n if (iosIdiom === \"pad\") return \"tablet\";\n if (iosIdiom === \"phone\") return \"phone\";\n if (typeof width === \"number\" && typeof height === \"number\") {\n return Math.min(width, height) >= 600 ? \"tablet\" : \"phone\";\n }\n return undefined;\n};\n\n/**\n * Collect the device snapshot. Pure, synchronous, and never throws — call it once per\n * onboarding session. Missing fields are omitted rather than sent as null/undefined so the\n * payload (and the server's stored dict) stays compact.\n */\nexport const collectDeviceContext = (): DeviceContext => {\n const ctx: DeviceContext = { platform: Platform.OS };\n\n // OS version (fallback; per-OS constants below may refine it).\n try {\n const version = Platform.Version;\n if (version !== undefined && version !== null && String(version)) {\n ctx.osVersion = String(version);\n }\n } catch {\n // ignore\n }\n\n // `Platform.constants` shape differs by OS and RN version — read every field defensively.\n let constants: Record<string, unknown> = {};\n try {\n constants = (Platform.constants ?? {}) as Record<string, unknown>;\n } catch {\n constants = {};\n }\n\n let iosIdiom: string | undefined;\n try {\n if (Platform.OS === \"android\") {\n const brand = constants.Brand;\n const model = constants.Model;\n const release = constants.Release;\n if (typeof brand === \"string\" && brand) ctx.brand = brand;\n if (typeof model === \"string\" && model) ctx.model = model;\n if (release !== undefined && release !== null && String(release)) {\n ctx.osVersion = String(release);\n }\n } else if (Platform.OS === \"ios\") {\n const osVersion = constants.osVersion;\n const idiom = constants.interfaceIdiom;\n if (osVersion !== undefined && osVersion !== null && String(osVersion)) {\n ctx.osVersion = String(osVersion);\n }\n if (typeof idiom === \"string\" && idiom) {\n ctx.interfaceIdiom = idiom;\n iosIdiom = idiom;\n }\n // iOS has no model in `Platform.constants`; best-effort via `expo-device` (adds no dep,\n // omitted when the module is absent — see device/deviceModel.ts).\n const iosModel = detectNativeModel();\n if (iosModel) ctx.model = iosModel;\n }\n } catch {\n // ignore per-OS constant reads\n }\n\n // Screen dimensions + derived form factor.\n try {\n const screen = Dimensions.get(\"screen\");\n if (screen) {\n if (typeof screen.width === \"number\") ctx.screenWidth = screen.width;\n if (typeof screen.height === \"number\") ctx.screenHeight = screen.height;\n if (typeof screen.scale === \"number\") ctx.screenScale = screen.scale;\n const formFactor = deriveFormFactor(iosIdiom, screen.width, screen.height);\n if (formFactor) ctx.formFactor = formFactor;\n }\n } catch {\n // ignore\n }\n\n // Layout direction.\n try {\n ctx.isRTL = I18nManager.isRTL;\n } catch {\n // ignore\n }\n\n // Locale + time zone via the standard Intl global. Hermes may ship without full Intl,\n // so referencing it can throw ReferenceError — the try/catch covers that too.\n try {\n const resolved = Intl.DateTimeFormat().resolvedOptions();\n if (resolved.locale) ctx.locale = resolved.locale;\n if (resolved.timeZone) ctx.timeZone = resolved.timeZone;\n } catch {\n // Intl unavailable — omit locale/timeZone.\n }\n\n // Best-effort host app version (adds no dependency; omitted when unavailable). An explicit\n // `config.appVersion` overrides this downstream at the merge sites.\n const appVersion = detectAppVersion();\n if (appVersion) ctx.appVersion = appVersion;\n\n return ctx;\n};\n","/**\n * currentSession — a tiny registry of the CURRENT per-open `session_id`.\n *\n * WHY it exists (kills the phantom-session): the per-open emitters (`reportSessionStart` and the\n * `useSessionStart` / `useLifecycleEvents` hooks) mint a fresh `session_id` for each app-open and\n * post `app.session_started` with it — so the SERVER knows that id. But other client paths\n * (`identify`, host `app_event`s through the analytics façade) used to reference a DIFFERENT id\n * (a frozen per-instance id), which the server had never seen, so it back-filled a synthetic\n * `session_started` — inflating session counts (the \"phantom-session\" bug).\n *\n * This registry is the single seam that lets those paths reuse the LIVE per-open session id the\n * server already ingested. `reportSessionStart` writes the current id here on every open; the façade\n * reads it so `identify`/app-events correlate to the real session instead of minting a phantom.\n *\n * ── WHY A globalThis SLOT, NOT A PLAIN MODULE VARIABLE ────────────────────────────────────────\n * This module is exported from TWO package entry points — the main `.` bundle (`src/index.ts`) and\n * the `./analytics` subpath (`src/analytics/index.ts`). Under `dist` resolution (node `import`/\n * `require`, which is how tests, SSR and some tooling load the kit) tsup inlines a SEPARATE copy of\n * this module into each bundle, so a plain `let` would give the SETTER (reached via `.` →\n * `reportSessionStart`) and the READER (reached via `./analytics` → façade / `userIdentity`) TWO\n * different variables: the reader would see `undefined` even after an open set the id, and gating\n * would fire under a null session id. On-device this was masked only because Metro's `react-native`\n * export condition resolves both subpaths back to this one `src/` file (a single instance) — a\n * bundler accident, not a guarantee.\n *\n * The bundler-agnostic fix: keep the ONE live value in a well-known `globalThis` slot keyed by a\n * `Symbol.for(...)`. `Symbol.for` uses the runtime-global symbol registry, so every inlined copy of\n * this module resolves the SAME symbol and reads/writes the SAME slot — one identity no matter how\n * many times the module is duplicated across bundles. `globalThis` is present and identical in\n * Hermes/React Native, Node and SSR (we never touch `window`), so this is safe on every host.\n *\n * PROCESS-LOCAL, NOT PERSISTED: the slot lives on the runtime global, so it tracks the CURRENT\n * process's open and a fresh open overwrites it. There is no cross-launch state.\n * `resetCurrentSessionId` clears the slot so a unit test starts from a clean registry.\n */\n\n/**\n * Well-known key into the runtime-global symbol registry. `Symbol.for` (NOT a plain `Symbol()`) is\n * what makes this cross-bundle: it returns the SAME symbol for the same string across every copy of\n * this module, so duplicated inlined copies all address one slot.\n */\nconst CURRENT_SESSION_ID_SLOT: unique symbol = Symbol.for(\n \"@wireai/activation:currentSessionId\",\n);\n\ntype GlobalWithSlot = typeof globalThis & {\n [CURRENT_SESSION_ID_SLOT]?: string | undefined;\n};\n\nconst globalSlot = globalThis as GlobalWithSlot;\n\n/**\n * Record the current per-open `session_id`. Called by `reportSessionStart` when it emits an\n * app-open. A blank / non-string id is ignored (the previous id stays current). Idempotent.\n */\nexport const setCurrentSessionId = (id: string | undefined): void => {\n if (typeof id === \"string\" && id.length > 0) {\n globalSlot[CURRENT_SESSION_ID_SLOT] = id;\n }\n};\n\n/** The current per-open `session_id`, or `undefined` when no app-open has been registered yet. */\nexport const getCurrentSessionId = (): string | undefined =>\n globalSlot[CURRENT_SESSION_ID_SLOT];\n\n/** Test-only: forget the current session id so a unit test starts from a clean registry. */\nexport const resetCurrentSessionId = (): void => {\n globalSlot[CURRENT_SESSION_ID_SLOT] = undefined;\n};\n","/**\n * Session-id persistence — the kit caching its OWN correlation seed across app kills.\n *\n * WHY: the session id is minted per mount and forwarded to the backend as the A2A\n * `contextId` (see WireOnboarding). Without persistence, an app KILL mid-onboarding\n * mints a NEW id on relaunch — the server counts a second `session_started` and the\n * orphaned first session reads as a phantom \"drop\", inflating the funnel's `started`\n * denominator. Persisting `{ id, ts }` and reusing a still-fresh id keeps a\n * kill-and-relaunch a SINGLE session in analytics.\n *\n * SCOPE: this persists the correlation seed ONLY — never answers. Answer persistence\n * stays a host concern via `onComplete` (the kit/host boundary is unchanged).\n *\n * The host injects the storage via the `storage` prop (an AsyncStorage-compatible\n * subset), keeping the kit dependency-free: an MMKV wrapper and AsyncStorage itself\n * both fit. Every operation is best-effort — a broken or hung storage must NEVER\n * break (or indefinitely gate) onboarding: reads race a short timeout, writes and\n * removes swallow all errors.\n */\nimport { makeSessionId } from \"../analytics/reportClientEvent\";\n\n/**\n * The storage the host injects. Deliberately the AsyncStorage-compatible subset so\n * `@react-native-async-storage/async-storage` can be passed as-is, and an MMKV (or\n * any other) wrapper is three one-line methods.\n */\nexport type WireOnboardingStorage = {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n};\n\n/**\n * Matches the backend's session TTL (SESSION_TTL_SECONDS = 3600): an id older than\n * this can't be resumed server-side anyway, so the client mints fresh past it.\n */\nexport const DEFAULT_SESSION_TTL_MS = 3_600_000;\n\n/** Ceiling on the storage read — a hung adapter degrades to a fresh mint, never a stuck gate. */\nconst READ_TIMEOUT_MS = 1_500;\n\n/** Storage key for an app's cached session, e.g. `wireai:session:acme`. */\nexport const sessionStorageKey = (appId: string): string => `wireai:session:${appId}`;\n\ntype PersistedSession = { id: string; ts: number };\n\n/** Resolved session for a mount: the id to use + whether it was restored from storage. */\nexport type LoadedSession = {\n id: string;\n /** True when a stored, still-fresh id was reused — the flow resumes instead of starting. */\n resumed: boolean;\n};\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n // Clear the timer once the race settles, so a won read doesn't leave a ≤ms no-op\n // timer holding the closure alive.\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\nconst parsePersisted = (raw: string | null | undefined): PersistedSession | undefined => {\n if (!raw) return undefined;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n typeof (parsed as PersistedSession).id === \"string\" &&\n typeof (parsed as PersistedSession).ts === \"number\"\n ) {\n return parsed as PersistedSession;\n }\n } catch {\n // Corrupt entry → treat as absent; the caller mints fresh and overwrites it.\n }\n return undefined;\n};\n\n/**\n * Resolve the session id for this mount: reuse the stored one while it's fresh\n * (→ `resumed: true`), else mint via `makeSessionId`, persist it, and start clean.\n * Never throws; never hangs past the read timeout.\n */\nexport const loadPersistedSession = async (\n storage: WireOnboardingStorage,\n key: string,\n ttlMs: number = DEFAULT_SESSION_TTL_MS,\n): Promise<LoadedSession> => {\n let stored: PersistedSession | undefined;\n try {\n stored = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n } catch {\n stored = undefined;\n }\n if (stored && Date.now() - stored.ts < ttlMs) {\n return { id: stored.id, resumed: true };\n }\n const id = makeSessionId();\n savePersistedSession(storage, key, id);\n return { id, resumed: false };\n};\n\n/**\n * Read the persisted session WITHOUT minting a fresh one (unlike `loadPersistedSession`).\n * Returns the stored `{ id, ts }` or `undefined` when absent/corrupt/timed-out. Used by the\n * post-onboarding `identifyOnboarding` helper to recover the contextId to bind a user to.\n * Never throws; never hangs past the read timeout.\n */\nexport const peekPersistedSession = async (\n storage: WireOnboardingStorage,\n key: string,\n): Promise<{ id: string; ts: number } | undefined> => {\n try {\n return parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n } catch {\n return undefined;\n }\n};\n\n/** Persist `{ id, ts }` under `key` — fire-and-forget, all errors swallowed. */\nexport const savePersistedSession = (\n storage: WireOnboardingStorage,\n key: string,\n id: string,\n): void => {\n try {\n void storage.setItem(key, JSON.stringify({ id, ts: Date.now() })).catch(() => {});\n } catch {\n // Best-effort: a failed write just means the next launch starts a fresh session.\n }\n};\n\n/** Remove the cached id (fired on completion) — fire-and-forget, all errors swallowed. */\nexport const clearPersistedSession = (storage: WireOnboardingStorage, key: string): void => {\n try {\n void storage.removeItem(key).catch(() => {});\n } catch {\n // Best-effort.\n }\n};\n\n/**\n * The opt-in decision for `WireOnboarding.handleComplete`: given the host's\n * `retainSessionOnComplete` opt-in, whether a completion should CLEAR the persisted seed.\n * (The caller still gates on `storage` being present — this only encodes the opt-in axis, so the\n * legacy `if (storage) clearPersistedSession(...)` guard stays byte-for-byte for a host that does\n * not opt in.)\n *\n * - undefined / false (the default) → `true`: clear on completion, so the NEXT onboarding on this\n * device mints a fresh session. This is the legacy single-stage behavior (e.g. Myelino).\n * - true → `false`: LEAVE the seed in place so a same-signup re-entry/remount within the TTL\n * resumes the SAME session (one funnel start) instead of minting a phantom second `started`.\n * Freshness for a genuinely new run is then governed by the TTL (past `sessionTtlMs` → fresh\n * mint) and an explicit new-run signal (a changed `persistKey`).\n */\nexport const shouldClearOnComplete = (retainSessionOnComplete: boolean | undefined): boolean =>\n !retainSessionOnComplete;\n","/**\n * User identity — bind an onboarding session to the HOST's own user id so the funnel can\n * be reconciled to real users later (console sessions ↔ your user table / GA4 users).\n *\n * The id is an OPAQUE PSEUDONYMOUS STRING the host owns — its internal user id, NOT an\n * email/name/phone. Same host-injection philosophy as `storage` and `userContext`: the kit\n * mints nothing and reads nothing; the host passes what it wants. Dependency-free.\n *\n * Three binding moments (see WireOnboarding + the README \"User identity\" section):\n * 1. MOUNT — pass `userId` and it rides the A2A session-start metadata; the server\n * binds it when it creates the session.\n * 2. MID-SESSION— the user registers DURING onboarding: change the `userId` prop and the\n * kit emits an `identify` client event that attaches the id to the live\n * session (late binding — the key scenario).\n * 3. POST-FLOW — the user registers AFTER onboarding: call `identifyOnboarding(...)` with\n * the same host storage (it recovers the persisted contextId, before completion\n * clears it) or, more reliably, the `contextId` you captured from the\n * `started`/`resumed` `onEvent` (both events carry a `contextId` field).\n *\n * ⚠️ NO PII. Pass an opaque id (or a hash), never a raw email/name/phone. The id is capped at\n * {@link USER_ID_MAX_LENGTH} chars (longer ids are truncated, not rejected).\n */\nimport { getCurrentSessionId } from \"../analytics/currentSession\";\nimport { reportClientEvent } from \"../analytics/reportClientEvent\";\nimport {\n peekPersistedSession,\n sessionStorageKey,\n type WireOnboardingStorage,\n} from \"../session/persistedSession\";\n\n/** Max accepted user-id length. Longer strings are truncated (never rejected). Keep in sync\n * with the server's `USER_ID_MAX_LENGTH` (analytics/events.py). */\nexport const USER_ID_MAX_LENGTH = 128;\n\n/**\n * Normalize a host-supplied user id: trim, drop empty, and cap at {@link USER_ID_MAX_LENGTH}.\n * Returns `undefined` for a missing/blank/non-string value so callers can `if (id)`-gate.\n * PII is a host concern — this only bounds length, it does not (and cannot) detect an email.\n */\nexport const sanitizeUserId = (raw: unknown): string | undefined => {\n if (typeof raw !== \"string\") return undefined;\n const trimmed = raw.trim();\n if (!trimmed) return undefined;\n return trimmed.length > USER_ID_MAX_LENGTH ? trimmed.slice(0, USER_ID_MAX_LENGTH) : trimmed;\n};\n\n/**\n * A permissive email-SHAPE test (`local@domain.tld`) — NOT an RFC validator. Its ONE job is to\n * catch the common integration mistake of binding a RAW EMAIL as the opaque `user_id`: that leaks\n * PII into the top-level id (which the server treats as an opaque key and may surface), when the\n * email belongs in the opt-in `user_context.user_email` field instead. `identify()` uses this to\n * refuse an email-shaped id (with a dev warning) unless the host opts in explicitly. Trims first.\n */\nexport const looksLikeEmail = (value: unknown): boolean =>\n typeof value === \"string\" && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value.trim());\n\n/** Options for {@link identifyOnboarding}. */\nexport type IdentifyOnboardingOptions = {\n /** Tenant transport, same shape as `WireOnboardingConfig` (only these two fields are used). */\n config: { serverUrl: string; apiKey: string };\n /** The host's opaque user id to bind. Trimmed + capped; NO PII. */\n userId: string;\n /**\n * The onboarding session id to bind to (the A2A contextId) — the `contextId` field carried on\n * the `started`/`resumed` `onEvent`. Pass this when you captured it there. Required after the\n * flow COMPLETED, since completion clears the persisted session. Wins over the storage lookup.\n */\n contextId?: string;\n /**\n * The SAME host storage you passed to `<WireOnboarding storage={…} />`. When `contextId` is\n * omitted, the helper reads the persisted contextId from it (works while the session is still\n * persisted — i.e. dropped or mid-flow, before completion clears it).\n */\n storage?: WireOnboardingStorage;\n /** App id, to derive the default storage key `wireai:session:<appId>` when reading from storage. */\n appId?: string;\n /** Storage key override — pass the same `persistKey` you gave `<WireOnboarding>`, if any. */\n persistKey?: string;\n};\n\n/**\n * Attach a host user id to an onboarding session AFTER the fact (post-registration), by sending\n * an `identify` client event to `/v1/events`. Resolves the contextId from an explicit\n * `contextId` or, failing that, from the persisted session in the host `storage`.\n *\n * Fire-and-forget under the hood (never throws, never blocks onboarding). Resolves to `true`\n * when an identify event was dispatched, `false` when it couldn't (no user id, no server url,\n * or no resolvable contextId).\n */\nexport const identifyOnboarding = async (\n opts: IdentifyOnboardingOptions,\n): Promise<boolean> => {\n const userId = sanitizeUserId(opts.userId);\n if (!userId || !opts.config?.serverUrl) return false;\n\n let contextId = opts.contextId?.trim() || undefined;\n if (!contextId && opts.storage) {\n const key = opts.persistKey ?? (opts.appId ? sessionStorageKey(opts.appId) : undefined);\n if (key) {\n const stored = await peekPersistedSession(opts.storage, key);\n contextId = stored?.id;\n }\n }\n // Last resort: bind to the LIVE per-open session (registered by `reportSessionStart`) so a\n // post-flow identify with no captured contextId still attaches to a session the server saw,\n // instead of no-oping. The onboarding contextId (above) is still preferred when available.\n if (!contextId) contextId = getCurrentSessionId();\n if (!contextId) return false;\n\n reportClientEvent(\n { serverUrl: opts.config.serverUrl, apiKey: opts.config.apiKey },\n { event_type: \"identify\", session_id: contextId, user_id: userId },\n );\n return true;\n};\n","/**\n * WireOnboarding — the public host component. Drop it into a screen and it runs\n * the whole AI onboarding: builds the A2A transport from `config`, wires the SDK\n * provider with the themed cards, applies the theme, and renders the flow.\n *\n * <WireOnboarding\n * config={{ apiKey, serverUrl, appId }}\n * theme={myBrandTheme}\n * validators={{ username: checkUsernameAvailable }}\n * onComplete={persist}\n * onSkip={skip}\n * />\n */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { WireAIProvider, type LocalLLMConfig } from \"wireai-rn\";\nimport { OnboardingThemeProvider } from \"./theme/ThemeContext\";\nimport { IllustrationProvider } from \"./components/Illustration\";\nimport { defaultIllustrations } from \"./illustrations/defaultIllustrations\";\nimport { IconRegistryProvider } from \"./icons/IconRegistry\";\nimport { LoadingScreen } from \"./components/LoadingScreen\";\nimport { OnboardingFlow, DEFAULT_COPY } from \"./OnboardingFlow\";\nimport { onboardingComponents } from \"./cards\";\nimport { makeSessionId, reportClientEvent, type ClientEventTarget } from \"./analytics/reportClientEvent\";\nimport { collectDeviceContext, type DeviceContext } from \"./device/deviceContext\";\nimport { sanitizeUserId } from \"./identity/userIdentity\";\nimport {\n clearPersistedSession,\n loadPersistedSession,\n sessionStorageKey,\n shouldClearOnComplete,\n DEFAULT_SESSION_TTL_MS,\n type LoadedSession,\n} from \"./session/persistedSession\";\nimport type { OnboardingResult, WireOnboardingProps } from \"./types\";\n\nexport const WireOnboarding: React.FC<WireOnboardingProps> = ({\n config,\n theme,\n components,\n illustrations,\n icons,\n validators,\n onComplete,\n onSkip,\n onError,\n onEvent,\n copy,\n approxScreens,\n startMessage = \"start\",\n startTimeoutMs = 15_000,\n fallbackFlow,\n maxRetries = 1,\n storage,\n sessionTtlMs = DEFAULT_SESSION_TTL_MS,\n persistKey,\n retainSessionOnComplete,\n userContext,\n userId,\n}) => {\n // The host's own opaque user id (trimmed + capped, NO PII) so onboarding sessions can be\n // reconciled to real users later. `sanitizeUserId` is a pure string transform → the memoized\n // result is a stable primitive, safe to feed the `llm` / `clientContext` memos directly (unlike\n // the raw object props). Bound at three moments: session-start metadata (mount), an `identify`\n // event on a mid-session change (late binding), and the `identifyOnboarding` helper post-flow.\n const boundUserId = useMemo(() => sanitizeUserId(userId), [userId]);\n\n // Privacy-label-neutral device snapshot, collected once per mount (no advertising IDs, no\n // fingerprinting — see device/deviceContext.ts). `collectDeviceContext` already carries a\n // best-effort auto-detected `appVersion`; an explicit host `config.appVersion` overrides it.\n // Attached to BOTH the A2A session metadata and every client event so the backend can segment\n // the funnel by device (and by app version).\n const device = useMemo<DeviceContext>(() => {\n const collected = collectDeviceContext();\n return config.appVersion ? { ...collected, appVersion: config.appVersion } : collected;\n }, [config.appVersion]);\n\n // Stable serialization of `userContext`. Hosts pass it INLINE (`userContext={{ … }}`, the\n // documented usage), so the raw object identity changes every render. Feeding that raw object\n // into the `llm` / `clientContext` memos below would make them unstable, and wireai-rn recreates\n // its A2A adapter whenever the llmConfig identity changes — the adapter ctor resets `contextId`\n // (node_modules/wireai-rn: `this.contextId = void 0`), so the server-learned session id is\n // dropped and correlation breaks. We key both memos on the JSON string (compared by value) and\n // reuse ONE normalized reference in the metadata + client-event paths.\n const userContextKey = userContext ? JSON.stringify(userContext) : \"\";\n const userContextStable = useMemo<Record<string, string | number | boolean> | undefined>(\n () => (userContextKey ? (JSON.parse(userContextKey) as Record<string, string | number | boolean>) : undefined),\n [userContextKey],\n );\n\n // The context payload shared by the A2A metadata + client-event paths. `userContext` +\n // `userId` are host-injected and forwarded verbatim (the server sanitizes them). Omitted keys\n // stay absent, so `dropped`/`client_fallback` events carry the user id when it's known.\n const clientContext = useMemo(\n () => ({ device, userContext: userContextStable, userId: boundUserId }),\n [device, userContextStable, boundUserId],\n );\n // One stable session id per onboarding SESSION (not per mount). It's used as the\n // client event `session_id` AND forwarded to the backend as `metadata.sessionId` so\n // the server can adopt it as the A2A `contextId` — making client-reported events\n // (`dropped`) correlate to the same session the server keys its own events by. See\n // the SDK-correlation note in analytics/reportClientEvent.ts.\n //\n // Without `storage`: minted synchronously per mount (the original behavior).\n // With `storage`: hydrated from the host-injected storage BEFORE the provider mounts\n // (loader-gate below), so an app KILL mid-onboarding resumes the SAME backend session\n // instead of minting a new one — which would count a phantom second `started` + a\n // false \"drop\" in the analytics funnel. See session/persistedSession.ts.\n const [session, setSession] = useState<LoadedSession | null>(() =>\n storage ? null : { id: makeSessionId(), resumed: false },\n );\n const storageKey = persistKey ?? sessionStorageKey(config.appId);\n\n useEffect(() => {\n if (!storage || session) return;\n // StrictMode/dev double-effect safe: the cancel flag drops the stale resolution.\n // Dev-only caveat: on a brand-new first mint, StrictMode's double-invoke can persist\n // then read the id back, surfacing a spurious `resumed: true`. Production is unaffected\n // (double-invoke is dev-only) and it self-heals on the next mount.\n let cancelled = false;\n void loadPersistedSession(storage, storageKey, sessionTtlMs).then((loaded) => {\n if (!cancelled) setSession(loaded);\n });\n return () => {\n cancelled = true;\n };\n }, [storage, storageKey, sessionTtlMs, session]);\n\n // By DEFAULT, clear the cached id the moment the flow completes, so the next onboarding on\n // this device starts a fresh session. Dropped/degraded paths deliberately do NOT clear —\n // a dropped session must stay resumable within the TTL.\n //\n // OPT-IN (`retainSessionOnComplete`): a multi-stage / replay-after-complete signup re-enters\n // (often via a `key=` remount) WITHIN one signup. If we cleared, that re-entry would find no\n // seed and mint a fresh `metadata.sessionId` → a phantom second `session_started` on the same\n // funnel. When the host opts in, we LEAVE the seed in place so the re-entry resumes the SAME\n // session (one funnel start); freshness for a genuinely new run then rides the TTL (past\n // `sessionTtlMs` → fresh mint) and an explicit new-run signal (a changed `persistKey`).\n // `shouldClearOnComplete` is the pure, unit-tested seam; the `storage` guard is unchanged, so a\n // host that does not opt in lands on the byte-for-byte legacy clear-on-complete path.\n const handleComplete = useCallback(\n (result: OnboardingResult) => {\n if (storage && shouldClearOnComplete(retainSessionOnComplete)) clearPersistedSession(storage, storageKey);\n onComplete(result);\n },\n [storage, storageKey, retainSessionOnComplete, onComplete],\n );\n\n const sessionId = session?.id ?? \"\";\n\n // Session-start snapshot of the bound user id. It seeds the A2A `metadata.userId` so the\n // adapter is built ONCE with whatever id was known at session start. A mid-session userId\n // change must NOT flow through this memo — recreating `llm` recreates the A2A adapter,\n // whose ctor resets `contextId` (see the userContext note above) and drops the server-\n // learned session id. Later changes ride EXCLUSIVELY on the `identify` effect below, which\n // mutates the live session in place. `useRef` captures the first-render value once.\n const startupUserIdRef = useRef<string | undefined>(boundUserId);\n\n // Build the A2A LocalLLMConfig from the friendlier kit config. The backend\n // resolves the app from the API key, so `model` (appId) is informational.\n const metadataKey = config.metadata ? JSON.stringify(config.metadata) : \"\";\n const metadataStable = useMemo(() => (metadataKey ? JSON.parse(metadataKey) : undefined), [metadataKey]);\n const componentNamesKey = (components ?? onboardingComponents).map((c) => c.name).join(\",\");\n const componentsStable = useMemo(() => components ?? onboardingComponents, [componentNamesKey]);\n\n const llm = useMemo<LocalLLMConfig>(() => {\n const baseUrl = config.serverUrl.replace(/\\/$/, \"\");\n return {\n provider: \"a2a\",\n baseUrl: `${baseUrl}/a2a`,\n model: config.appId,\n apiKey: config.apiKey,\n // Carry the kit session id alongside any host attribution so it reaches the A2A\n // request's `params.metadata` (the correlation seed; see note above), plus the\n // names of the components this device can actually render — so the backend only\n // emits cards the kit knows how to draw.\n metadata: {\n ...metadataStable,\n sessionId,\n supportedComponents: componentsStable.map((c) => c.name),\n // Device snapshot + host-injected user context ride the session-start metadata so the\n // backend can segment the funnel. Old servers ignore these unknown keys (backward compat).\n device,\n ...(userContextStable ? { userContext: userContextStable } : {}),\n // The session-start user id (from the ref) rides the session-start metadata so the\n // server binds the session to a real user at creation. Reading the ref — not\n // `boundUserId` — keeps this memo off the userId dependency, so a mid-session change\n // does NOT recreate the adapter; it's bound by the `identify` effect below instead.\n ...(startupUserIdRef.current ? { userId: startupUserIdRef.current } : {}),\n },\n timeoutMs: 60_000,\n };\n }, [config.serverUrl, config.appId, config.apiKey, metadataStable, sessionId, componentsStable, device, userContextStable]);\n\n // Where client-reported events are POSTed (`/v1/events`). Same tenant creds as the flow.\n const reportTarget = useMemo<ClientEventTarget>(\n () => ({ serverUrl: config.serverUrl, apiKey: config.apiKey }),\n [config.serverUrl, config.apiKey],\n );\n\n // LATE BINDING (mid-session): the user often registers DURING onboarding. When `userId`\n // becomes known (or changes) after the session already started, emit an `identify` client\n // event that attaches the id to the LIVE session, so the backend can map this in-flight\n // session to the real user. On a FRESH mount the initial id already rode the session-start\n // metadata, so we seed the \"already bound\" ref with it and only react to later CHANGES. On a\n // RESUMED session the server-side record predates this mount and won't re-read start metadata,\n // so we leave the seed empty to force an identify when a userId is present. Fire-and-forget.\n const identifiedRef = useRef<string | undefined>(undefined);\n const identifySeededRef = useRef(false);\n useEffect(() => {\n if (!session || !sessionId) return;\n if (!identifySeededRef.current) {\n identifySeededRef.current = true;\n identifiedRef.current = session.resumed ? undefined : boundUserId;\n }\n if (!boundUserId || boundUserId === identifiedRef.current) return;\n identifiedRef.current = boundUserId;\n reportClientEvent(reportTarget, {\n event_type: \"identify\",\n session_id: sessionId,\n user_id: boundUserId,\n });\n }, [session, sessionId, boundUserId, reportTarget]);\n\n const cards = components ?? onboardingComponents;\n\n // Loader-gate (hydration approach A): hold the entire provider subtree until the\n // stored id resolves. `sessionId` is a dependency of the `llm` memo above, so mounting\n // the provider with a throwaway id and swapping later would re-init it mid-flight.\n // The read is timeout-capped in loadPersistedSession, so this gate is one storage\n // read (~a frame), never an indefinite hold.\n if (!session) {\n return (\n <OnboardingThemeProvider theme={theme}>\n <LoadingScreen\n title={copy?.restoringTitle ?? DEFAULT_COPY.restoringTitle}\n hint={copy?.restoringHint ?? DEFAULT_COPY.restoringHint}\n />\n </OnboardingThemeProvider>\n );\n }\n\n return (\n <OnboardingThemeProvider theme={theme}>\n <IllustrationProvider registry={{ ...defaultIllustrations, ...illustrations }}>\n <IconRegistryProvider registry={icons}>\n <WireAIProvider llm={llm} components={cards}>\n <OnboardingFlow\n validators={validators}\n onComplete={handleComplete}\n onSkip={onSkip}\n onError={onError}\n onEvent={onEvent}\n copy={copy}\n approxScreens={approxScreens}\n startMessage={startMessage}\n startTimeoutMs={startTimeoutMs}\n fallbackFlow={fallbackFlow}\n maxRetries={maxRetries}\n reportTarget={reportTarget}\n sessionId={sessionId}\n resumed={session.resumed}\n clientContext={clientContext}\n />\n </WireAIProvider>\n </IconRegistryProvider>\n </IllustrationProvider>\n </OnboardingThemeProvider>\n );\n};\n","/**\n * DemoOnboarding — a drop-in dev/QA trigger that runs the onboarding flow ON\n * DEMAND in a modal, then closes. No loop, no account, no navigation side-effects:\n * re-runnable infinitely with the same logged-in user. Place it anywhere a host\n * wants (e.g. a __DEV__ row in Settings). If `config` is null (the app hasn't\n * integrated Wire AI yet), it shows a hint instead of the flow.\n *\n * {__DEV__ && (\n * <DemoOnboarding config={wireConfigFromEnv({ appId: \"my-app\" })} theme={myTheme} />\n * )}\n *\n * It does NOT persist by default (a demo, not a real run) — pass `onComplete` if\n * you want to observe the captured answers.\n */\nimport { useCallback, useMemo, useState, type ReactNode } from \"react\";\nimport { Modal, Pressable, StyleSheet, Text, View } from \"react-native\";\n\nimport { WireOnboarding } from \"./WireOnboarding\";\nimport { mergeTheme } from \"./theme/defaultTheme\";\nimport type { OnboardingTheme } from \"./theme/types\";\nimport type { OnboardingResult, WireOnboardingConfig, WireOnboardingProps } from \"./types\";\n\nexport type DemoOnboardingProps = {\n /** The Wire AI config, or `null` when the app hasn't integrated Wire AI yet. */\n config: WireOnboardingConfig | null;\n theme?: WireOnboardingProps[\"theme\"];\n illustrations?: WireOnboardingProps[\"illustrations\"];\n validators?: WireOnboardingProps[\"validators\"];\n copy?: WireOnboardingProps[\"copy\"];\n /** Trigger button label. Default \"Demo onboarding\". */\n label?: string;\n /** Observe the demo result. By default the demo just closes (no persistence). */\n onComplete?: (result: OnboardingResult) => void;\n /** Render your own trigger instead of the default button: `(open) => <YourButton onPress={open} />`. */\n renderTrigger?: (open: () => void) => ReactNode;\n};\n\nexport function DemoOnboarding({\n config,\n theme,\n illustrations,\n validators,\n copy,\n label = \"Demo onboarding\",\n onComplete,\n renderTrigger,\n}: DemoOnboardingProps) {\n const [open, setOpen] = useState(false);\n const [runId, setRunId] = useState(0);\n const t = useMemo(() => mergeTheme(theme ?? {}), [theme]);\n const styles = useMemo(() => makeStyles(t), [t]);\n\n const openDemo = useCallback(() => {\n setRunId((n) => n + 1); // remount WireOnboarding → a fresh A2A session each open\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n const finish = useCallback(\n (result: OnboardingResult) => {\n onComplete?.(result);\n setOpen(false);\n },\n [onComplete],\n );\n\n return (\n <>\n {renderTrigger ? (\n renderTrigger(openDemo)\n ) : (\n <Pressable onPress={openDemo} style={styles.trigger} accessibilityRole=\"button\">\n <Text style={styles.triggerText}>{label}</Text>\n </Pressable>\n )}\n\n <Modal\n visible={open}\n animationType=\"slide\"\n presentationStyle=\"fullScreen\"\n onRequestClose={close}\n >\n <View style={styles.modal}>\n {config ? (\n <WireOnboarding\n key={runId}\n config={config}\n theme={theme}\n illustrations={illustrations}\n validators={validators}\n copy={copy}\n onComplete={finish}\n onSkip={close}\n onError={close}\n />\n ) : (\n <View style={styles.notice}>\n <Text style={styles.noticeTitle}>Wire AI not configured</Text>\n <Text style={styles.noticeBody}>\n Set the Wire AI key + server URL (e.g. via wireConfigFromEnv) to demo the AI\n onboarding here.\n </Text>\n <Pressable onPress={close} style={styles.trigger} accessibilityRole=\"button\">\n <Text style={styles.triggerText}>Close</Text>\n </Pressable>\n </View>\n )}\n </View>\n </Modal>\n </>\n );\n}\n\nfunction makeStyles(t: OnboardingTheme) {\n return StyleSheet.create({\n trigger: {\n backgroundColor: t.colors.primary,\n borderRadius: t.button.radius,\n paddingVertical: 14,\n paddingHorizontal: 20,\n alignItems: \"center\",\n },\n triggerText: { color: t.colors.onPrimary, fontFamily: t.fonts.medium, fontSize: 16 },\n modal: { flex: 1, backgroundColor: t.colors.background },\n notice: { flex: 1, alignItems: \"center\", justifyContent: \"center\", padding: 24, gap: 12 },\n noticeTitle: { color: t.colors.text, fontFamily: t.fonts.bold, fontSize: 20 },\n noticeBody: {\n color: t.colors.textMuted,\n fontFamily: t.fonts.regular,\n fontSize: 15,\n textAlign: \"center\",\n },\n });\n}\n","/**\n * themeFromBrand — the fastest path to a branded flow. Give it a primary brand\n * color (and optionally a background + a font), and it derives a sensible full\n * `Partial<OnboardingTheme>` over the neutral `defaultOnboardingTheme` (via\n * `mergeTheme`): a tinted soft wash for selected states, a readable on-primary\n * label, and matching success/info accents left at the neutral default.\n *\n * theme={themeFromBrand({ primary: \"#15B0B0\" })}\n *\n * It stays intentionally small: it only touches the values that flow from a brand\n * color. Anything else (radius, spacing, button shape) keeps the default; pass\n * `extra` to override those without re-authoring the palette.\n */\nimport { defaultOnboardingTheme, mergeTheme } from \"./defaultTheme\";\nimport type { OnboardingTheme } from \"./types\";\n\nexport type ThemeFromBrandInput = {\n /** Brand / accent color — drives selected states, primary buttons, progress fill. */\n primary: string;\n /** App background behind the whole flow. Default: the neutral light background. */\n background?: string;\n /** Card / elevated surface background. Default: the neutral surface. */\n surface?: string;\n /** Primary body text color. Default: the neutral near-black. */\n text?: string;\n /** Text/icon color on top of `primary`. Default: white. */\n onPrimary?: string;\n /**\n * A single font family applied to regular/medium/bold (the kit derives weight\n * from size when a family isn't weight-split). Pass `fonts` in `extra` for\n * per-weight families.\n */\n font?: string;\n /** Any further theme overrides, deep-merged last (radius/spacing/button/fonts/colors). */\n extra?: Partial<OnboardingTheme>;\n};\n\n/** Parse a #RGB or #RRGGBB hex into [r,g,b]; returns null for anything else (e.g. rgba()). */\nconst hexToRgb = (hex: string): [number, number, number] | null => {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());\n if (!m) return null;\n let h = m[1] as string;\n if (h.length === 3) h = h[0]! + h[0]! + h[1]! + h[1]! + h[2]! + h[2]!;\n const int = parseInt(h, 16);\n return [(int >> 16) & 255, (int >> 8) & 255, int & 255];\n};\n\n/** A low-alpha wash of the primary for selected backgrounds, falling back gracefully. */\nconst softFromPrimary = (primary: string): string => {\n const rgb = hexToRgb(primary);\n if (!rgb) return defaultOnboardingTheme.colors.primarySoft;\n const [r, g, b] = rgb;\n return `rgba(${r},${g},${b},0.10)`;\n};\n\nexport const themeFromBrand = (input: ThemeFromBrandInput): Partial<OnboardingTheme> => {\n const { primary, background, surface, text, onPrimary, font, extra } = input;\n\n const derived: Partial<OnboardingTheme> = {\n colors: {\n ...defaultOnboardingTheme.colors,\n primary,\n primarySoft: softFromPrimary(primary),\n onPrimary: onPrimary ?? defaultOnboardingTheme.colors.onPrimary,\n ...(background ? { background } : {}),\n ...(surface ? { surface } : {}),\n ...(text ? { text } : {}),\n },\n ...(font\n ? {\n fonts: {\n ...defaultOnboardingTheme.fonts,\n regular: font,\n medium: font,\n bold: font,\n },\n }\n : {}),\n };\n\n // mergeTheme resolves the derived palette over the neutral default into a full\n // theme. Then deep-merge `extra` per sub-object so callers can override\n // radius/spacing/button/fonts/colors without re-authoring the palette.\n const base = mergeTheme(derived);\n if (!extra) return base;\n return {\n colors: { ...base.colors, ...extra.colors },\n fonts: { ...base.fonts, ...extra.fonts },\n radius: { ...base.radius, ...extra.radius },\n spacing: { ...base.spacing, ...extra.spacing },\n button: { ...base.button, ...extra.button },\n };\n};\n","/**\n * DoneBlock — a brief themed \"all set\" state shown when the flow completes, while\n * the host persists results and navigates away. Purely cosmetic; the real\n * terminal signal is the SDK's StatusCard (handled in OnboardingFlow).\n */\nimport React from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\nimport { useOnboardingTheme } from \"../theme/ThemeContext\";\nimport { bodyStyle, headingStyle } from \"../theme/typography\";\n\nexport type DoneBlockProps = {\n title?: string;\n message?: string;\n};\n\nconst _DoneBlock: React.FC<DoneBlockProps> = ({\n title = \"You're all set\",\n message = \"Personalizing your experience…\",\n}) => {\n const t = useOnboardingTheme();\n return (\n <View style={[styles.center, { gap: t.spacing.sm, padding: t.spacing.lg }]}>\n <Text style={[headingStyle(t.fonts), { color: t.colors.success, textAlign: \"center\" }]}>\n {title}\n </Text>\n <Text style={[bodyStyle(t.fonts), { color: t.colors.textMuted, textAlign: \"center\" }]}>\n {message}\n </Text>\n </View>\n );\n};\n\nexport const DoneBlock = React.memo(_DoneBlock);\n\nconst styles = StyleSheet.create({\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\" },\n});\n","/**\n * centeredModalMotion - the pure entrance spec for the content-agnostic CenteredModal shell.\n *\n * WHY split out: the shell UI (CenteredModal) is RN and cannot run under the kit's node:test\n * runner, but the entrance math is pure and worth pinning. Keep the animation spec here so both\n * the component and the tests read one source, and so any module (reviews, questionnaire) can\n * reuse the shell without depending on another feature module.\n *\n * The centered popup uses RN's built-in `Animated` (native driver), the same idiom as\n * CompletionView/CardHandoff, so the shell stays dependency-free (no reanimated).\n *\n * NOTE: `reviews/presentation.ts` re-exports these under their original names\n * (`REVIEW_MODAL_ANIM`, `entranceFrame`) for back-compat with the reviews public API.\n */\n\n/**\n * The entrance spec for the centered popup. Values chosen to match the boilerplate's\n * `animated-modal` feel (a springy zoom-in) with the kit's own native-driver idiom:\n * • backdrop fades 0 -> `backdropOpacity`\n * • card springs from `scaleFrom` -> 1 and fades 0 -> 1\n */\nexport const CENTERED_MODAL_ANIM = {\n /** Spring config for the card scale/opacity entrance (mirrors CompletionView's pop). */\n enterSpring: { friction: 7, tension: 80 },\n /** Exit timing in ms (fade + shrink back out before unmount). */\n exitMs: 160,\n /** Card scale at rest (progress 0); grows to 1 at progress 1. */\n scaleFrom: 0.9,\n /** Peak dim of the backdrop at progress 1. */\n backdropOpacity: 0.55,\n} as const;\n\n/** A single frame of the entrance, for a progress value in [0..1] (clamped). Pure, testable. */\nexport const centeredModalFrame = (\n progress: number,\n backdropMax: number = CENTERED_MODAL_ANIM.backdropOpacity,\n): { cardOpacity: number; cardScale: number; backdropOpacity: number } => {\n const p = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const { scaleFrom } = CENTERED_MODAL_ANIM;\n return {\n cardOpacity: p,\n cardScale: scaleFrom + (1 - scaleFrom) * p,\n backdropOpacity: backdropMax * p,\n };\n};\n","/**\n * CenteredModal - the content-agnostic centered-popup shell.\n *\n * Renders its children as an alert-style card in the MIDDLE of the screen, over a dimmed\n * backdrop, with a spring/fade entrance. It knows nothing about what it presents: the reviews\n * gate uses it (via the `ReviewModal` back-compat re-export) and the questionnaire module reuses\n * the same shell, neither depends on the other.\n *\n * Adapted from the mobile-launcher boilerplate's `animated-modal` (transparent RN Modal +\n * centered container + backdrop-tap dismiss + content stop-propagation + springy zoom-in), but\n * reimplemented on RN's built-in `Animated` (native driver) so the shell stays dependency-free:\n * the boilerplate uses react-native-reanimated, which the kit does not.\n *\n * Dismissal (backdrop tap / Android back / the imperative `close()` handle) animates the card\n * out, then fires `onDismiss`. It never auto-closes on resolve: the host keeps the card showing\n * whatever payoff it wants (a thank-you, a summary) until the user taps the backdrop to close,\n * exactly like CompletionView.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { Animated, BackHandler, Easing, Modal, Pressable, StyleSheet } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\n\nimport type { OnboardingTheme } from \"../theme/types\";\nimport { REDUCED_FADE_MS } from \"../motion/motionSpec\";\nimport { useReducedMotion } from \"../motion/useReducedMotion\";\nimport { CENTERED_MODAL_ANIM } from \"../motion/centeredModalMotion\";\n\n/** Imperative handle so an in-card \"Not now\"/\"Skip\" link can trigger the exit animation. */\nexport type CenteredModalHandle = { close: () => void };\n\nexport type CenteredModalProps = {\n /** The (already merged) active theme - card surface/radius/spacing come from here. */\n theme: OnboardingTheme;\n /** Whether a backdrop tap / back press dismisses. Default true (never a dead end). */\n dismissible?: boolean;\n /** Fired once, AFTER the exit animation, on any dismiss. Wire to the host's resolve. */\n onDismiss: () => void;\n children: React.ReactNode;\n};\n\nconst _CenteredModal = forwardRef<CenteredModalHandle, CenteredModalProps>(\n ({ theme, dismissible = true, onDismiss, children }, ref) => {\n const progress = useRef(new Animated.Value(0)).current;\n const [open, setOpen] = useState(true);\n const closingRef = useRef(false);\n const reduced = useReducedMotion();\n\n // Entrance: spring the card in (scale + fade); the backdrop fades up in lock-step.\n // Reduce motion: a short fade to the settled card, no spring/scale.\n useEffect(() => {\n const anim = reduced\n ? Animated.timing(progress, {\n toValue: 1,\n duration: REDUCED_FADE_MS,\n useNativeDriver: true,\n })\n : Animated.spring(progress, {\n toValue: 1,\n useNativeDriver: true,\n friction: CENTERED_MODAL_ANIM.enterSpring.friction,\n tension: CENTERED_MODAL_ANIM.enterSpring.tension,\n });\n anim.start();\n return () => anim.stop();\n }, [progress, reduced]);\n\n const close = useCallback(() => {\n if (closingRef.current) return;\n closingRef.current = true;\n Animated.timing(progress, {\n toValue: 0,\n duration: reduced ? REDUCED_FADE_MS : CENTERED_MODAL_ANIM.exitMs,\n easing: Easing.in(Easing.cubic),\n useNativeDriver: true,\n }).start(() => {\n setOpen(false);\n onDismiss();\n });\n }, [progress, onDismiss, reduced]);\n\n useImperativeHandle(ref, () => ({ close }), [close]);\n\n // Android hardware back -> dismiss (when allowed). Always consume so it never pops a route.\n useEffect(() => {\n const sub = BackHandler.addEventListener(\"hardwareBackPress\", () => {\n if (dismissible) close();\n return true;\n });\n return () => sub.remove();\n }, [dismissible, close]);\n\n const onBackdrop = useCallback(() => {\n if (dismissible) close();\n }, [dismissible, close]);\n\n const backdropOpacity = progress.interpolate({\n inputRange: [0, 1],\n outputRange: [0, CENTERED_MODAL_ANIM.backdropOpacity],\n });\n // Reduce motion: the card fades in already settled (no zoom).\n const cardScale = reduced\n ? 1\n : progress.interpolate({\n inputRange: [0, 1],\n outputRange: [CENTERED_MODAL_ANIM.scaleFrom, 1],\n });\n\n return (\n <Modal\n visible={open}\n transparent\n animationType=\"none\"\n statusBarTranslucent\n onRequestClose={dismissible ? close : undefined}\n >\n {/* Dimmed backdrop (fades with the entrance). */}\n <Animated.View\n style={[styles.backdrop, { opacity: backdropOpacity }]}\n pointerEvents=\"none\"\n />\n\n {/* Full-screen tap target: a tap outside the card dismisses. */}\n <Pressable\n style={styles.fill}\n onPress={onBackdrop}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Dismiss\"\n >\n <SafeAreaView style={styles.center} pointerEvents=\"box-none\">\n {/* Inner Pressable swallows taps so the card itself never dismisses. */}\n <Pressable onPress={() => {}} style={styles.cardWrap}>\n <Animated.View\n accessibilityViewIsModal\n accessibilityRole=\"alert\"\n style={[\n styles.card,\n {\n backgroundColor: theme.colors.surface,\n borderRadius: theme.radius.lg,\n padding: theme.spacing.lg,\n gap: theme.spacing.md,\n opacity: progress,\n transform: [{ scale: cardScale }],\n },\n ]}\n >\n {children}\n </Animated.View>\n </Pressable>\n </SafeAreaView>\n </Pressable>\n </Modal>\n );\n },\n);\n\n_CenteredModal.displayName = \"CenteredModal\";\n\nexport const CenteredModal = React.memo(_CenteredModal);\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n backdrop: { position: \"absolute\", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: \"#000\" },\n center: { flex: 1, alignItems: \"center\", justifyContent: \"center\", padding: 24 },\n cardWrap: { width: \"100%\", maxWidth: 420 },\n card: {\n width: \"100%\",\n // Soft elevation so the popup reads as lifted above the app in both themes.\n shadowColor: \"#000\",\n shadowOffset: { width: 0, height: 8 },\n shadowOpacity: 0.28,\n shadowRadius: 24,\n elevation: 12,\n },\n});\n\nexport default CenteredModal;\n","/**\n * The fail-open defaults + a tolerant parser for the server's flags payload.\n *\n * THE CONTRACT: fail-open, never fail-dark. An absent server object, a missing module key, a\n * malformed value, or an unreachable endpoint must resolve to the MOST PERMISSIVE state — every\n * module ON, onboarding `ai` — so a control-plane outage can only ever be more permissive than\n * the dashboard intends. It can never dark a tenant's activation. Matches the server's own\n * documented fail-open default (FEATURES.md: \"local defaults — every module on, onboarding ai\").\n */\nimport type { OnboardingMode, WireFeatures } from \"./types\";\n\n/**\n * ALL ON, onboarding `ai`. Frozen + module-level so its reference is stable across every call\n * (consumers that list resolved flags in an effect dep array never loop on a fresh identity).\n */\nexport const defaultWireFeatures: WireFeatures = Object.freeze({\n coachmarks: Object.freeze({ enabled: true }),\n showcase: Object.freeze({ enabled: true }),\n onboarding: Object.freeze({ mode: \"ai\" as OnboardingMode }),\n review: Object.freeze({ enabled: true }),\n questionnaire: Object.freeze({ enabled: true }),\n announcements: Object.freeze({ enabled: true }),\n}) as WireFeatures;\n\nconst VALID_MODES: readonly OnboardingMode[] = [\"ai\", \"static\", \"off\"];\n\n/** Read a `{ enabled: boolean }` module, defaulting to ON when absent/malformed (fail-open). */\nconst readEnabled = (raw: unknown): { enabled: boolean } => {\n if (raw && typeof raw === \"object\" && typeof (raw as { enabled?: unknown }).enabled === \"boolean\") {\n return { enabled: (raw as { enabled: boolean }).enabled };\n }\n return { enabled: true };\n};\n\n/**\n * Narrow the server's (untrusted) JSON to a complete `WireFeatures`. Every field is filled with\n * its fail-open default when the server omits it or sends the wrong type, so a partial or\n * malformed payload degrades PERMISSIVELY rather than throwing. A non-object input (null, array,\n * string) → the full defaults. Never throws.\n */\nexport const parseWireFeatures = (raw: unknown): WireFeatures => {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return defaultWireFeatures;\n const src = raw as Record<string, unknown>;\n const modeRaw = (src.onboarding as { mode?: unknown } | undefined)?.mode;\n const mode: OnboardingMode =\n typeof modeRaw === \"string\" && VALID_MODES.includes(modeRaw as OnboardingMode)\n ? (modeRaw as OnboardingMode)\n : \"ai\";\n return {\n coachmarks: readEnabled(src.coachmarks),\n showcase: readEnabled(src.showcase),\n onboarding: { mode },\n review: readEnabled(src.review),\n questionnaire: readEnabled(src.questionnaire),\n announcements: readEnabled(src.announcements),\n };\n};\n\n/** Value-equality of two resolved flags — lets the hook hold a stable reference across churn. */\nexport const featuresEqual = (a: WireFeatures, b: WireFeatures): boolean =>\n a === b ||\n (a.coachmarks.enabled === b.coachmarks.enabled &&\n a.showcase.enabled === b.showcase.enabled &&\n a.onboarding.mode === b.onboarding.mode &&\n a.review.enabled === b.review.enabled &&\n a.questionnaire.enabled === b.questionnaire.enabled &&\n a.announcements.enabled === b.announcements.enabled);\n","/**\n * The last-known-flags cache — persisted through the host's optional `storage`.\n *\n * WHY: the fetch is best-effort and fail-open. When the control plane is unreachable we serve the\n * LAST value we saw rather than snapping to defaults, so a tenant that intentionally disabled a\n * module during an incident keeps it disabled across an outage instead of flapping back on. That\n * is \"stale-while-error\": a fresh cache (< TTL) is trusted, and on a fetch error even a STALE\n * cache is served (any age beats a guess). Every operation is best-effort — a broken/hung storage\n * degrades to defaults, never a throw and never a stuck gate (mirrors persistedSession).\n */\nimport { parseWireFeatures } from \"./defaults\";\nimport type { WireFeatures } from \"./types\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\n/**\n * TTL for a cached flags entry, aligned to the server's `Cache-Control: private, max-age=300`.\n * A cache younger than this is \"fresh\"; older is \"stale\" (still served on a fetch error).\n */\nexport const DEFAULT_FEATURES_TTL_MS = 300_000;\n\n/** Ceiling on the storage read so a hung adapter degrades to defaults, never a stuck resolve. */\nconst READ_TIMEOUT_MS = 1_500;\n\n/** Storage key for a tenant's cached flags, e.g. `wireai:features:acme`. */\nexport const featuresCacheKey = (appId?: string): string =>\n `wireai:features:${appId && appId.length > 0 ? appId : \"default\"}`;\n\n/** A cached flags entry: the resolved flags + the epoch-ms they were fetched. */\nexport interface CachedFeatures {\n features: WireFeatures;\n /** Age of the entry in ms at read time. */\n ageMs: number;\n}\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n/** Whether a cache entry is still within the TTL (server max-age aligned). */\nexport const isFeaturesFresh = (ageMs: number, ttlMs: number = DEFAULT_FEATURES_TTL_MS): boolean =>\n ageMs >= 0 && ageMs < ttlMs;\n\n/**\n * Read the cached flags for `key`, or `undefined` when absent/corrupt/timed-out. Returns the\n * value AND its age so a caller can apply a TTL (fresh) or ignore it (stale-while-error). Never\n * throws; never hangs past the read timeout. The stored value is re-parsed through\n * `parseWireFeatures`, so a partially-corrupt entry still degrades fail-open.\n */\nexport const readCachedFeatures = async (\n storage: WireOnboardingStorage,\n key: string,\n): Promise<CachedFeatures | undefined> => {\n let raw: string | null | undefined;\n try {\n raw = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);\n } catch {\n return undefined;\n }\n if (!raw) return undefined;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && typeof (parsed as { ts?: unknown }).ts === \"number\") {\n const ts = (parsed as { ts: number }).ts;\n return {\n features: parseWireFeatures((parsed as { features?: unknown }).features),\n ageMs: Date.now() - ts,\n };\n }\n } catch {\n // Corrupt entry → treat as absent; the caller falls back to defaults / a fresh fetch.\n }\n return undefined;\n};\n\n/** Persist `{ features, ts }` under `key` — fire-and-forget, all errors swallowed. */\nexport const writeCachedFeatures = (\n storage: WireOnboardingStorage,\n key: string,\n features: WireFeatures,\n): void => {\n try {\n void storage\n .setItem(key, JSON.stringify({ features, ts: Date.now() }))\n .catch(() => {});\n } catch {\n // Best-effort: a failed write just means the next launch has no cache to fall back to.\n }\n};\n","/**\n * fetchWireFeatures — read the per-module kill switches from `GET {serverUrl}/v1/features`.\n *\n * Contract (server: chohra-med/wireai-onboarding-server, routers/onboarding.py):\n * GET {serverUrl}/v1/features\n * Authorization: Bearer {apiKey}\n * 200 → { coachmarks:{enabled}, showcase:{enabled}, onboarding:{mode}, review:{enabled},\n * announcements:{enabled} } (Cache-Control: private, max-age=300)\n *\n * THE CONTRACT — fail-open, never fail-dark. Unreachable, timed-out, unauthorized (401),\n * server-error (5xx), or malformed JSON all resolve to the LAST CACHED value, else the\n * all-on defaults. No throw ever reaches the host: this is timeout-capped and swallows every\n * error, exactly like the session's best-effort reads. A control-plane outage can only ever be\n * MORE permissive than the dashboard intends — it can never dark a tenant's activation.\n */\nimport { readCachedFeatures, featuresCacheKey, writeCachedFeatures } from \"./cache\";\nimport { defaultWireFeatures, parseWireFeatures } from \"./defaults\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\nconst DEFAULT_TIMEOUT_MS = 4_000;\n\n/** The fail-open fallback: last cached value (any age — stale-while-error), else defaults. */\nconst failOpen = async (\n storage: WireOnboardingStorage | undefined,\n key: string,\n): Promise<WireFeatures> => {\n if (!storage) return defaultWireFeatures;\n const cached = await readCachedFeatures(storage, key);\n return cached?.features ?? defaultWireFeatures;\n};\n\n/** GET with a hard timeout via AbortController (falls back to no-abort where unsupported). */\nconst fetchWithTimeout = async (\n url: string,\n apiKey: string,\n timeoutMs: number,\n): Promise<Response> => {\n const controller =\n typeof AbortController !== \"undefined\" ? new AbortController() : undefined;\n const timer = setTimeout(() => controller?.abort(), timeoutMs);\n try {\n return await fetch(url, {\n method: \"GET\",\n headers: { Accept: \"application/json\", Authorization: `Bearer ${apiKey}` },\n signal: controller?.signal,\n });\n } finally {\n clearTimeout(timer);\n }\n};\n\n/**\n * Resolve the tenant's feature flags. Attempts the network once; on ANY failure returns the\n * cached value (any age), else the all-on defaults. On success, persists the fresh value to the\n * cache (fire-and-forget) and returns it. Never throws.\n *\n * const flags = await fetchWireFeatures({ serverUrl, apiKey, appId, storage });\n * if (!flags.coachmarks.enabled) { /* skip the tour * / }\n */\nexport const fetchWireFeatures = async (\n config?: WireFeaturesConfig,\n): Promise<WireFeatures> => {\n const key = featuresCacheKey(config?.appId);\n const storage = config?.storage;\n\n // Nothing to fetch (no creds) → cache, else defaults. Lets a host mount the provider before\n // its config is ready without ever darking.\n if (!config?.serverUrl || !config?.apiKey) return failOpen(storage, key);\n\n const url = `${config.serverUrl.replace(/\\/$/, \"\")}/v1/features`;\n const timeoutMs = config.timeoutMs && config.timeoutMs > 0 ? config.timeoutMs : DEFAULT_TIMEOUT_MS;\n\n try {\n const res = await fetchWithTimeout(url, config.apiKey, timeoutMs);\n // 401 (bad/rotated key), 5xx, any non-2xx → last-known, never dark.\n if (!res || !res.ok) return failOpen(storage, key);\n const json: unknown = await res.json(); // throws on malformed body → caught below\n const features = parseWireFeatures(json);\n if (storage) writeCachedFeatures(storage, key, features);\n return features;\n } catch {\n // Timeout/abort, network error, missing fetch, or malformed JSON — all fail open.\n return failOpen(storage, key);\n }\n};\n","/**\n * useWireFeatures — resolve the tenant's feature flags for a component tree, once per mount.\n *\n * Returns the all-on defaults immediately (fail-open), then swaps to the fetched value when the\n * network resolves. When no `serverUrl`+`apiKey` is supplied it never fetches and just returns\n * defaults, so a host that never adopts flags sees ZERO behavior change and ZERO network calls.\n *\n * frequent_rules #11 (unstable inline props): the config is idiomatically passed inline\n * (`config={{ serverUrl, apiKey }}`), a fresh identity every render. We stabilize the fetch key\n * by VALUE so the effect fires once per real credential change, and we only swap the returned\n * flags object when its VALUES change — so a host that lists the returned flags in an effect dep\n * array settles in a bounded number of commits instead of looping (enforced by the canary suite).\n */\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { defaultWireFeatures, featuresEqual } from \"./defaults\";\nimport { fetchWireFeatures } from \"./fetchWireFeatures\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\n\n/** Hold a stable reference for a value while its CONTENT is unchanged (see reviews/equality.ts). */\nconst useStableValue = <T,>(value: T, isEqual: (a: T, b: T) => boolean): T => {\n const ref = useRef(value);\n if (!isEqual(ref.current, value)) ref.current = value;\n return ref.current;\n};\n\n/** The credential slice that actually drives a refetch — stabilized by value. */\nconst sameFetchKey = (a: WireFeaturesConfig | undefined, b: WireFeaturesConfig | undefined): boolean =>\n a?.serverUrl === b?.serverUrl && a?.apiKey === b?.apiKey && a?.appId === b?.appId;\n\nexport const useWireFeatures = (config?: WireFeaturesConfig): WireFeatures => {\n const stableConfig = useStableValue(config, sameFetchKey);\n const [flags, setFlags] = useState<WireFeatures>(defaultWireFeatures);\n\n const canFetch = !!stableConfig?.serverUrl && !!stableConfig?.apiKey;\n\n useEffect(() => {\n if (!canFetch) {\n // No creds → stay on the all-on defaults (and reset if creds were removed).\n setFlags((prev) => (featuresEqual(prev, defaultWireFeatures) ? prev : defaultWireFeatures));\n return;\n }\n let alive = true;\n // fetchWireFeatures never throws — the .then always runs with a fail-open value.\n void fetchWireFeatures(stableConfig).then((next) => {\n if (!alive) return;\n // Only adopt a NEW reference on a real value change, so a host effect keyed on the\n // returned flags doesn't loop (frequent_rules #11).\n setFlags((prev) => (featuresEqual(prev, next) ? prev : next));\n });\n return () => {\n alive = false;\n };\n }, [canFetch, stableConfig]);\n\n return flags;\n};\n","/**\n * WireFeaturesProvider + useResolvedFeatures — the OPTIONAL one-fetch-serves-all-modules layer.\n *\n * Mount `WireFeaturesProvider` once near your app root with the tenant `config` and it fetches the\n * flags ONCE; every gated surface below it (coachmarks / showcase / reviews) reads the same\n * resolved value from context instead of each fetching its own. It is entirely optional: with no\n * provider, every surface falls back to its own lazy fetch (when given a config) or to the all-on\n * defaults, so modules work with zero setup and a host that never adopts flags is unchanged.\n *\n * NOTE on the built npm subpaths: React context is shared across the kit's subpath entries in the\n * SOURCE-consumption path (the monorepo apps) and in this test suite — one module instance, one\n * context. If you consume the built `@wireai/activation/*` subpaths as separate bundles, pass the\n * resolved flags (or a `featuresConfig`) to each surface explicitly instead of relying on context.\n */\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nimport { defaultWireFeatures } from \"./defaults\";\nimport { useWireFeatures } from \"./useWireFeatures\";\nimport type { WireFeatures, WireFeaturesConfig } from \"./types\";\n\nconst CONTEXT_SYMBOL = Symbol.for(\"wireai.features.context\");\nconst globalObj = global as any;\n\nif (!globalObj[CONTEXT_SYMBOL]) {\n globalObj[CONTEXT_SYMBOL] = createContext<WireFeatures | null>(null);\n}\nconst WireFeaturesContext = globalObj[CONTEXT_SYMBOL];\n\nexport interface WireFeaturesProviderProps {\n /** Tenant creds (+ optional storage) to fetch the flags once for the whole tree. */\n config?: WireFeaturesConfig;\n /**\n * Pre-resolved flags to provide directly instead of fetching (e.g. you already have them, or\n * you drive them from your own remote-config). Takes precedence over `config`.\n */\n flags?: WireFeatures;\n children: React.ReactNode;\n}\n\n/**\n * Fetch (or accept) the flags once and broadcast them to descendants. The provider VALUE is\n * memoized (performance rule #6) so a fresh object each render doesn't re-render every consumer.\n */\nexport const WireFeaturesProvider: React.FC<WireFeaturesProviderProps> = ({\n config,\n flags,\n children,\n}) => {\n // Always call the hook (rules of hooks); when `flags` is supplied we pass no config so it\n // never fetches and the explicit flags win below.\n const fetched = useWireFeatures(flags ? undefined : config);\n const value = flags ?? fetched;\n const stable = useMemo(() => value, [value]);\n return <WireFeaturesContext.Provider value={stable}>{children}</WireFeaturesContext.Provider>;\n};\n\nWireFeaturesProvider.displayName = \"WireFeaturesProvider\";\n\n/** Raw context read — `null` when no `WireFeaturesProvider` is mounted above. */\nexport const useWireFeaturesContext = (): WireFeatures | null =>\n useContext(WireFeaturesContext);\n\n/** Options for `useResolvedFeatures`: an explicit override and/or a lazy-fetch config. */\nexport interface ResolveFeaturesOptions {\n /** Explicit flags — win over everything (a surface's own `features` prop). */\n flags?: WireFeatures;\n /** Lazy-fetch config, used ONLY when there is no explicit `flags` and no provider above. */\n config?: WireFeaturesConfig;\n}\n\n/**\n * The resolution every gated surface uses. Precedence:\n * 1. explicit `options.flags` (a surface's own prop) →\n * 2. the nearest `WireFeaturesProvider` (context) →\n * 3. a lazy fetch from `options.config` (serverUrl + apiKey) →\n * 4. the all-on defaults.\n * Always fail-open, always a stable reference for a given value (so it's safe in effect deps).\n */\nexport const useResolvedFeatures = (options?: ResolveFeaturesOptions): WireFeatures => {\n const ctx = useWireFeaturesContext();\n // Only lazily fetch when nothing else provides the flags — otherwise pass no config so the\n // hook stays inert (defaults, no network). The hook is always called (rules of hooks).\n const shouldFetch = !options?.flags && ctx == null;\n const fetched = useWireFeatures(shouldFetch ? options?.config : undefined);\n return options?.flags ?? ctx ?? fetched ?? defaultWireFeatures;\n};\n","/**\n * wireConfigFromEnv — stop re-authoring env gating in every app. Reads the Wire AI\n * tenant key + server URL from the standard Expo public env vars and returns a\n * ready `WireOnboardingConfig`, or `null` when the key/URL are missing (so a host\n * can fall through to a static onboarding without writing the `if (!key)` itself).\n *\n * EXPO_PUBLIC_WIREAI_API_KEY=... (required)\n * EXPO_PUBLIC_WIREAI_SERVER_URL=... (required)\n *\n * const config = wireConfigFromEnv({ appId: \"morrow\" });\n * if (!config) return <StaticOnboarding />;\n * return <WireOnboarding config={config} ... />;\n *\n * `appId` defaults to `EXPO_PUBLIC_WIREAI_APP_ID` (or \"default\"); pass overrides to\n * set `appId`/`metadata` or to substitute the key/URL programmatically.\n */\nimport type { WireOnboardingConfig } from \"../types\";\n\nexport type WireConfigOverrides = Partial<WireOnboardingConfig>;\n\n/**\n * Minimal `process.env` declaration so the kit stays RN-pure (no `@types/node`).\n * In RN/Expo, `process.env.EXPO_PUBLIC_*` is provided/inlined by Metro at build\n * time; we only read string env vars here.\n *\n * IMPORTANT: read each var via STATIC member access (`process.env.EXPO_PUBLIC_FOO`).\n * Expo's `babel-preset-expo` `inline-env-vars` plugin ONLY inlines static\n * `process.env.EXPO_PUBLIC_*` member expressions. Aliasing (`const env = process.env`)\n * or computed access (`process.env[name]`) is left `undefined` in the Metro bundle, so\n * the value reads fine in Jest (Node) but is null on a real device. Do not refactor\n * these to an alias.\n */\ndeclare const process: { env: Record<string, string | undefined> };\n\nexport const wireConfigFromEnv = (\n overrides?: WireConfigOverrides,\n): WireOnboardingConfig | null => {\n const apiKey = overrides?.apiKey ?? process.env.EXPO_PUBLIC_WIREAI_API_KEY;\n const serverUrl = overrides?.serverUrl ?? process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;\n const appId =\n overrides?.appId ?? process.env.EXPO_PUBLIC_WIREAI_APP_ID ?? \"default\";\n\n // Missing transport → null, so the host gates on one falsy check.\n if (!apiKey || !serverUrl) return null;\n\n return {\n apiKey,\n serverUrl,\n appId,\n ...(overrides?.metadata ? { metadata: overrides.metadata } : {}),\n };\n};\n","/**\n * isOnboardingEnabled — the ONE standard gate for AI onboarding, so every app stops\n * re-authoring `flag && hasConfig` (one app had `isAiOnboardingEnabled`, another had\n * `isWireBackendConfigured` — same idea, two shapes).\n *\n * The gate is **transport presence**: `wireConfigFromEnv()` is non-null (the key + URL are\n * set), and that is it. There is no separate on/off env flag — a missing key already means\n * \"off\", so a second `EXPO_PUBLIC_AI_ONBOARDING_ENABLED` flag was redundant (and, read via\n * computed access, it didn't even inline on device). An optional `remote` kill-switch lets an\n * app turn it off without a release; the kit stays dependency-free (the app owns the remote\n * read and hands us the boolean).\n *\n * Enabled ⇔ transport present AND `(remote ?? true)`.\n *\n * if (!isOnboardingEnabled()) return goToStaticOnboarding();\n * // or, with a remote kill-switch the app already read:\n * if (!isOnboardingEnabled({ remote: remoteKillSwitchOn })) return goToStaticOnboarding();\n */\nimport { wireConfigFromEnv } from \"./wireConfigFromEnv\";\nimport type { WireConfigOverrides } from \"./wireConfigFromEnv\";\n\nexport type OnboardingFlagOptions = {\n /**\n * Optional remote kill-switch the app already read (Firebase/LD/etc.). When `false`, it\n * disables onboarding even though transport is present. Omit (or `true`) to leave it on.\n */\n remote?: boolean;\n /**\n * Config overrides forwarded to `wireConfigFromEnv` for the transport-present check\n * (e.g. a programmatic `apiKey`/`serverUrl`). Usually omitted.\n */\n config?: WireConfigOverrides;\n};\n\nexport const isOnboardingEnabled = (opts?: OnboardingFlagOptions): boolean => {\n const transportPresent = wireConfigFromEnv(opts?.config) !== null;\n if (!transportPresent) return false;\n return opts?.remote ?? true;\n};\n","/**\n * Canonical analytics names for the onboarding funnel. The kit already emits a typed\n * `OnboardingEvent` (`started | turn | error | retry | fallback`) — but one app logged them as\n * `onboarding_*` and another as `AI_ONBOARDING_*`, so the same funnel reads differently per app.\n * This maps the kit event to ONE canonical `wire_onboarding_*` name + params, and the app logs\n * it through whatever transport it already has (Firebase, Amplitude, console). The app still\n * owns the logger; only the NAMES are standardized.\n *\n * <WireOnboarding\n * onEvent={(e) => { const a = toAnalyticsEvent(e); logEvent(a.name, a.params); }}\n * onComplete={(r) => { logEvent(WIRE_ONBOARDING_EVENTS.completed, { answers: Object.keys(r.answers).length }); persist(r); }}\n * />\n *\n * `completed` has no kit `OnboardingEvent` (the kit signals completion via `onComplete`, not\n * `onEvent`) — the app logs it explicitly on `onComplete` using the constant below, so the\n * funnel name stays canonical.\n */\nimport type { OnboardingEvent } from \"../types\";\n\nexport const WIRE_ONBOARDING_EVENTS = {\n started: \"wire_onboarding_started\",\n /** A persisted session was restored after an app kill (fires instead of `started`). */\n resumed: \"wire_onboarding_resumed\",\n turn: \"wire_onboarding_turn\",\n error: \"wire_onboarding_error\",\n retry: \"wire_onboarding_retry\",\n fallback: \"wire_onboarding_fallback\",\n /** Logged by the host on `onComplete` (no matching kit `OnboardingEvent`). */\n completed: \"wire_onboarding_completed\",\n} as const;\n\nexport type WireOnboardingEventName =\n (typeof WIRE_ONBOARDING_EVENTS)[keyof typeof WIRE_ONBOARDING_EVENTS];\n\nexport type AnalyticsEvent = {\n name: WireOnboardingEventName;\n params?: Record<string, unknown>;\n};\n\n/**\n * Map a kit `OnboardingEvent` to its canonical `{ name, params }`. Exhaustive over the union\n * (the `never` default makes a new event type a compile error here — intentional).\n */\nexport const toAnalyticsEvent = (event: OnboardingEvent): AnalyticsEvent => {\n switch (event.type) {\n case \"started\":\n return { name: WIRE_ONBOARDING_EVENTS.started };\n case \"resumed\":\n return { name: WIRE_ONBOARDING_EVENTS.resumed };\n case \"turn\":\n return {\n name: WIRE_ONBOARDING_EVENTS.turn,\n params: { step: event.step, component: event.component },\n };\n case \"error\":\n return { name: WIRE_ONBOARDING_EVENTS.error, params: { reason: event.reason } };\n case \"retry\":\n return {\n name: WIRE_ONBOARDING_EVENTS.retry,\n params: { reason: event.reason, attempt: event.attempt },\n };\n case \"fallback\":\n return { name: WIRE_ONBOARDING_EVENTS.fallback, params: { reason: event.reason } };\n default: {\n const _exhaustive: never = event;\n return _exhaustive;\n }\n }\n};\n","/**\n * attribution — forward install/ad attribution to the onboarding agent so it can tailor the\n * first question by acquisition source (e.g. a paid-campaign install vs an organic one). The\n * channel already exists: `WireOnboardingConfig.metadata` is merged into every A2A request by\n * `WireOnboarding`. No production app populated it before; this gives every app a standard shape.\n *\n * The app reads its raw attribution (AppsFlyer / Branch / deferred deep link — an app concern,\n * not the kit's) and passes the normalized result as `metadata`:\n *\n * const config = wireConfigFromEnv({\n * appId: \"morrow-self\",\n * metadata: attributionMetadata({ source: conv.mediaSource, campaign: conv.campaign, isOrganic: conv.isOrganic }),\n * });\n *\n * The backend sees `metadata.attribution = { source, campaign, ... }`.\n */\n\n/** Normalized acquisition attribution. All fields optional — pass what the SDK gives you. */\nexport type OnboardingAttribution = {\n /** Media source / network, e.g. \"appsflyer\", \"branch\", \"organic\". */\n source?: string;\n campaign?: string;\n adset?: string;\n ad?: string;\n /** Deferred deep-link slug / path that routed the install. */\n deepLink?: string;\n isFirstLaunch?: boolean;\n isOrganic?: boolean;\n /** Escape hatch for SDK-specific fields not covered above. */\n raw?: Record<string, unknown>;\n};\n\n/**\n * Wrap attribution into the `{ attribution: {...} }` metadata the agent reads. Drops `undefined`\n * fields so the request payload stays compact. Returns `{ attribution: {} }` for empty input\n * (still a valid, harmless metadata object).\n */\nexport const attributionMetadata = (\n a: OnboardingAttribution,\n): { attribution: Record<string, unknown> } => {\n const attribution: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(a)) {\n if (value !== undefined) attribution[key] = value;\n }\n return { attribution };\n};\n","/**\n * userContext — the ONE extensible object a host passes once and the kit flows into every\n * analytics event's `user_context` (plus the top-level opaque `user_id`).\n *\n * WHY it exists: hosts already hand the kit fragments of \"who this user is\" — `config.appVersion`,\n * `useSessionStart({ deviceKey, userId })`, `<WireOnboarding userContext={…} />` — but there was no\n * single object that carries app version + device key + user id + (opt-in) email + arbitrary extras\n * together, with one precedence rule, into every event. `WireUserContext` is that object;\n * `resolveUserContext` is the pure merge that turns it into the wire shape.\n *\n * PRECEDENCE (the one rule): an explicit `WireUserContext` field WINS over the #42 auto-detected\n * `device`/`appVersion`. A missing field is OMITTED, never sent empty.\n *\n * WHERE EACH FIELD LANDS (deliberate separation so nothing leaks across buckets):\n * • `userId` → the event's TOP-LEVEL opaque `user_id` (via `sanitizeUserId`). NEVER the bucket.\n * • `userEmail` → its OWN key `user_context.user_email`. NEVER merged into `userId`. OPT-IN PII.\n * • `deviceKey` → `user_context.device_key` (the server's `_event_device_key` reads it there).\n * • `appVersion`→ `user_context.app_version` (and returned as `appVersion` for `device.appVersion`).\n * • `extra` → NAMESPACED under a `custom.` key prefix, coerced to scalars, so a host extra can\n * never collide with a reserved `user_context` key.\n *\n * DEPENDENCY-FREE: the only import is the kit's own `sanitizeUserId`. The optional email hash is a\n * dependency-free FNV-1a fold (see {@link hashEmailFnv1a}) — no crypto library, no async.\n */\nimport { sanitizeUserId } from \"../identity/userIdentity\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\n/**\n * The single, extensible user-context object. A host passes it ONCE (at analytics init) and may\n * update it post-mount (e.g. attach `userId`/`userEmail` at login) via `setUserContext(partial)`.\n * Every field is optional; missing fields are omitted from the wire payload.\n */\nexport interface WireUserContext {\n /**\n * Host app version, e.g. \"1.4.2\". EXPLICIT — wins over the #42 auto-detected `device.appVersion`.\n * Lands in `user_context.app_version`. Omitted when neither this nor auto-detect yields a version.\n */\n appVersion?: string;\n /**\n * A stable, non-PII device id the host owns. Lands in `user_context.device_key` (NOT `session_id`),\n * where the server groups a device's sessions. Host-supplied; the kit never mints or reads one.\n */\n deviceKey?: string;\n /**\n * The host's OPAQUE PSEUDONYMOUS user id (their internal id — NOT an email/name/phone). Sanitized +\n * capped (see `sanitizeUserId`) and placed on the event's top-level `user_id`. NEVER the bucket.\n */\n userId?: string;\n /**\n * OPT-IN PII. The user's email, its OWN field (`user_context.user_email`) — NEVER merged into\n * `userId`. The kit NEVER auto-collects this; a host passes it only WITH the user's consent (EU\n * users: treat as personal data). For a non-reversible form, set {@link hashEmail} `true` (the kit\n * folds it with a dependency-free hash and stamps `user_context.user_email_hashed: true`), OR\n * pre-hash host-side with a cryptographic digest and pass that here with `hashEmail` falsy.\n */\n userEmail?: string;\n /**\n * When `true`, {@link userEmail} is folded with the kit's dependency-free {@link hashEmailFnv1a}\n * before it leaves the device, and `user_context.user_email_hashed` is set `true`. NOTE: FNV-1a is\n * a lightweight NON-cryptographic fold (obfuscation, not a secure digest). For a cryptographic\n * hash, compute it host-side (e.g. SHA-256 via `expo-crypto`) and pass the digest as `userEmail`\n * with `hashEmail` falsy. Default: raw email is sent as-is (opt-in already gated it upstream).\n */\n hashEmail?: boolean;\n /**\n * Arbitrary host context (signup method, referral, plan tier…). Each value is coerced to a scalar\n * (`string | number | boolean`; non-scalars and non-finite numbers are DROPPED) and NAMESPACED\n * under a `custom.` key prefix in `user_context` (e.g. `user_context[\"custom.referral\"]`) so it can\n * never collide with a reserved key. No raw PII — use {@link userEmail} for email.\n */\n extra?: Record<string, string | number | boolean>;\n}\n\n/**\n * The wire-shaped result of {@link resolveUserContext}. `userContext` is the non-PII/opt-in-PII\n * bucket stamped onto the event; `userId` is the top-level opaque id; `appVersion`/`deviceKey` are\n * echoed for callers that also place them elsewhere (e.g. `device.appVersion`). Absent fields are\n * omitted so a caller can spread this without sending empties.\n */\nexport interface ResolvedUserContext {\n /** The opaque, sanitized user id → the event's top-level `user_id`. Omitted when unset/blank. */\n userId?: string;\n /** The stable device id → `user_context.device_key`. Omitted when unset. */\n deviceKey?: string;\n /** The effective app version (explicit > auto-detected) → `user_context.app_version`. */\n appVersion?: string;\n /** The `user_context` bucket (device_key, app_version, user_email[+ _hashed], custom.*). */\n userContext?: Record<string, string | number | boolean>;\n}\n\n/** Reserved `user_context` keys the kit itself writes; host `extra` is namespaced away from these. */\nexport const RESERVED_USER_CONTEXT_KEYS = [\n \"device_key\",\n \"app_version\",\n \"app_build\",\n \"network_type\",\n \"session_count\",\n \"returning\",\n \"platform\",\n \"user_email\",\n \"user_email_hashed\",\n] as const;\n\n/** The prefix applied to every host `extra` key so it can never collide with a reserved key. */\nexport const EXTRA_KEY_PREFIX = \"custom.\" as const;\n\n/** A finite scalar the wire accepts. Non-finite numbers (NaN/Infinity) are NOT scalars here. */\nexport const isWireScalar = (value: unknown): value is string | number | boolean => {\n const t = typeof value;\n if (t === \"string\" || t === \"boolean\") return true;\n if (t === \"number\") return Number.isFinite(value as number);\n return false;\n};\n\n/**\n * Fold an email to a stable, dependency-free 32-bit FNV-1a hex token (lowercased + trimmed first so\n * the same address always folds identically). This is OBFUSCATION, not a cryptographic digest — it\n * is not collision-resistant. For a real hash, pre-hash host-side and pass the digest as `userEmail`.\n */\nexport const hashEmailFnv1a = (email: string): string => {\n const normalized = email.trim().toLowerCase();\n let hash = 0x811c9dc5; // FNV offset basis (32-bit)\n for (let i = 0; i < normalized.length; i++) {\n hash ^= normalized.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193); // FNV prime (32-bit), kept in 32-bit via imul\n }\n return (hash >>> 0).toString(16).padStart(8, \"0\");\n};\n\n/** Trim a candidate string; return `undefined` for a non-string / blank so callers can `if`-gate. */\nconst cleanString = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Coerce a host `extra` map into the namespaced, scalar-only bucket shape. Every kept value is\n * placed under `custom.<key>`; non-scalar values (objects, arrays, null, functions, NaN/Infinity)\n * are DROPPED. Returns an object (possibly empty).\n */\nexport const namespaceExtra = (\n extra: Record<string, unknown> | undefined,\n): Record<string, string | number | boolean> => {\n const out: Record<string, string | number | boolean> = {};\n if (!extra || typeof extra !== \"object\") return out;\n for (const [key, value] of Object.entries(extra)) {\n const cleanKey = cleanString(key);\n if (!cleanKey) continue;\n if (!isWireScalar(value)) continue; // drop anything that isn't a finite scalar\n out[`${EXTRA_KEY_PREFIX}${cleanKey}`] = value;\n }\n return out;\n};\n\n/**\n * The storage key the analytics façade persists the bound opaque `user_id` under (namespaced per\n * `appId`, mirroring {@link deviceIdStorageKey}). Exported so a logout path can target it directly.\n */\nexport const analyticsUserIdStorageKey = (appId?: string): string =>\n `wireai:analytics:userId:${appId ?? \"default\"}`;\n\n/**\n * Return a COPY of a {@link WireUserContext} with every USER-scoped (PII / pseudonymous) field\n * removed — `userId`, `userEmail`, `hashEmail`, and `extra` — while KEEPING the non-PII device-scope\n * fields (`appVersion`, `deviceKey`). This is the in-memory half of logout: after it, the same\n * analytics instance keeps its stable `device_key` (which groups a DEVICE, not a user) but no longer\n * stamps the previous user's id/email onto events. Pure; never mutates the input.\n */\nexport const clearPiiFromContext = (ctx: WireUserContext = {}): WireUserContext => {\n const rest: WireUserContext = {};\n if (typeof ctx.appVersion === \"string\") rest.appVersion = ctx.appVersion;\n if (typeof ctx.deviceKey === \"string\") rest.deviceKey = ctx.deviceKey;\n return rest;\n};\n\n/** Options for {@link clearUserContext}. */\nexport interface ClearUserContextOptions {\n /** Host persistence (AsyncStorage subset) — the persisted bound `user_id` is removed from here. */\n storage?: WireOnboardingStorage;\n /** Tenant/app id — namespaces the persisted key (`wireai:analytics:userId:<appId>`). */\n appId?: string;\n}\n\n/**\n * LOGOUT primitive: purge the persisted, bound opaque `user_id` for an app so the NEXT user on a\n * shared device is not silently attributed to the previous one. Removes the\n * `wireai:analytics:userId:<appId>` key that the analytics façade persists and reuses across\n * launches. Fire-and-forget: a missing storage or a failing adapter resolves quietly.\n *\n * COVERAGE. The stateful `createAnalytics(...)` instance also exposes {@link Analytics.reset}, which\n * does this AND clears the in-memory binding + PII in one call — prefer it when you hold the\n * instance. This standalone helper covers the `createWireActivation` / `wire` path (whose config is\n * captured immutably, so it has no `reset`): call `clearUserContext({ storage, appId })` on logout,\n * and RECREATE the `wire` / analytics instance without the user's `userContext` (userId/userEmail)\n * so no further events carry the previous user's identity. The non-PII per-install `device_key`\n * (`wireai:analytics:deviceKey:<appId>`) is intentionally left in place — it groups a device, not a\n * person, and stays stable across users of the same install.\n */\nexport const clearUserContext = async (opts: ClearUserContextOptions = {}): Promise<void> => {\n const storage = opts.storage;\n if (!storage) return;\n try {\n await storage.removeItem(analyticsUserIdStorageKey(opts.appId));\n } catch {\n /* best-effort, swallow — logout must never throw into the UI */\n }\n};\n\n/** Options for {@link resolveUserContext}. */\nexport interface ResolveUserContextOptions {\n /**\n * The kit's best-effort auto-detected app version (#42; from `detectAppVersion()`/the device\n * snapshot). Used ONLY when the explicit `WireUserContext.appVersion` is absent — explicit wins.\n */\n autoAppVersion?: string;\n}\n\n/**\n * Merge a {@link WireUserContext} into the wire shape with the precedence rule (explicit field >\n * auto-detected). Pure, never throws. Missing fields are omitted so the result can be spread onto an\n * event without sending empties.\n */\nexport const resolveUserContext = (\n ctx: WireUserContext = {},\n opts: ResolveUserContextOptions = {},\n): ResolvedUserContext => {\n const result: ResolvedUserContext = {};\n const bucket: Record<string, string | number | boolean> = {};\n\n // userId → top-level opaque id (NEVER the bucket). Sanitized + capped host-side.\n const userId = sanitizeUserId(ctx.userId);\n if (userId) result.userId = userId;\n\n // deviceKey → user_context.device_key (NOT session_id).\n const deviceKey = cleanString(ctx.deviceKey);\n if (deviceKey) {\n result.deviceKey = deviceKey;\n bucket.device_key = deviceKey;\n }\n\n // appVersion → explicit wins over auto-detected (#42); echoed for device.appVersion callers.\n const appVersion = cleanString(ctx.appVersion) ?? cleanString(opts.autoAppVersion);\n if (appVersion) {\n result.appVersion = appVersion;\n bucket.app_version = appVersion;\n }\n\n // userEmail → its OWN key. OPT-IN PII, optionally folded. NEVER touches userId.\n const email = cleanString(ctx.userEmail);\n if (email) {\n if (ctx.hashEmail) {\n bucket.user_email = hashEmailFnv1a(email);\n bucket.user_email_hashed = true;\n } else {\n bucket.user_email = email;\n }\n }\n\n // extra → namespaced + scalar-coerced.\n Object.assign(bucket, namespaceExtra(ctx.extra));\n\n if (Object.keys(bucket).length > 0) result.userContext = bucket;\n return result;\n};\n","/**\n * deviceId — mint a stable, NON-PII, per-install device id the kit owns when the host supplies\n * none. This is the headline of \"device fully automatic\": the analytics façade auto-mints ONE id,\n * persists it via the host's `storage` abstraction, and reuses it on every subsequent open — so\n * `user_context.device_key` is ALWAYS present and the server's review/questionnaire gating +\n * A/B stickiness (both key on `device_key`) work out of the box, with zero host wiring.\n *\n * WHY it is NOT PII and adds NO dependency (the kit's hard rules):\n * The id is a random token generated from `Date.now()` + `Math.random()` — it carries NO hardware\n * identifier, NO IDFA/GAID, NO fingerprint. It is a first-party per-install correlation key, the\n * same privacy category as a first-party cookie: it groups a single install's sessions and cannot\n * identify a person or be joined across apps. There is NO `uuid` (or any) dependency — a\n * time+random scheme is sufficient because the id is minted ONCE and then persisted, so global\n * uniqueness across the fleet is not required (a per-install collision is astronomically unlikely\n * and inconsequential — worst case two installs share a bucket).\n *\n * A host that wants its OWN device id still wins: pass `WireUserContext.deviceKey` and the kit uses\n * that verbatim and never mints/persists an auto id.\n */\n\n/** Prefix so an auto-minted id is visibly the kit's (distinguishable from a host-supplied `deviceKey`). */\nexport const AUTO_DEVICE_ID_PREFIX = \"wdev_\";\n\n/** The storage key the façade persists the auto-minted id under (namespaced per `appId`). */\nexport const deviceIdStorageKey = (appId?: string): string =>\n `wireai:analytics:deviceKey:${appId ?? \"default\"}`;\n\n/** One 32-bit base-36 chunk of randomness. Two chunks are concatenated for a wider token. */\nconst randomChunk = (): string =>\n Math.floor(Math.random() * 0x100000000)\n .toString(36)\n .padStart(6, \"0\");\n\n/**\n * Mint a fresh per-install device id. Dependency-free (`Date.now()` + `Math.random()`), never\n * throws, and returns a NEW value on every call — the façade mints ONCE and persists, so this is\n * called at most once per install (then the persisted value is reused). Two random chunks plus the\n * timestamp keep the token wide enough that a per-install collision is not a practical concern.\n */\nexport const mintDeviceId = (): string => {\n const time = Date.now().toString(36);\n return `${AUTO_DEVICE_ID_PREFIX}${time}_${randomChunk()}${randomChunk()}`;\n};\n","/**\n * activation revalidation — a tiny kit-owned pub/sub the review / questionnaire decision fetches\n * subscribe to, so they RE-FETCH their server decision AFTER a trigger action, not only on mount.\n *\n * WHY THIS EXISTS (subsumes Morrow's hand-rolled `activation-revalidation.ts`): a host mounts the\n * review / questionnaire gate on the home screen and fetches its `/decision` verdict once, in a\n * mount-scoped effect. But the screen stays mounted while the user goes elsewhere to perform the\n * triggering action (journal a win, complete a task); the server's firing rule is trigger-based AND\n * session-scoped, so the mount fetch ran BEFORE the trigger event existed and never re-runs. Bumping\n * this store after the action POSTs re-runs the gate's decision fetch (it lists the version in its\n * deps) → the server now sees the trigger → `{fire:true}`.\n *\n * `wire.track()` bumps this automatically on a successful POST, so a consumer no longer hand-rolls\n * an await-then-bump: it subscribes (via {@link useActivationRevalidation} in `useWireActivation`)\n * and re-fetches when the version changes.\n *\n * ── WHY A globalThis SLOT, NOT MODULE-LOCAL STATE (same reasoning as currentSession) ─────────────\n * This module can be reached from more than one package entry (the main `.` barrel exposes the\n * revalidation surface; the gates live under the `./reviews` / `./questionnaire` subpaths). Under\n * `dist` resolution tsup inlines a SEPARATE copy of a module into each bundle, so plain module-local\n * `version` + `listeners` would give the BUMPER (main entry, via `wire.track`) and a SUBSCRIBER a\n * different store — the bump would never reach the listener, exactly the defect-B failure mode. So\n * the ONE store lives in a `globalThis` slot keyed by `Symbol.for(...)`: every inlined copy resolves\n * the same symbol and shares one store, on Hermes/RN, Node and SSR alike.\n */\n\n/** Well-known key into the runtime-global symbol registry — one shared store across every bundle. */\nconst REVALIDATION_SLOT: unique symbol = Symbol.for(\n \"@wireai/activation:activationRevalidation\",\n);\n\n/** The shared store: a monotonic version + the set of subscriber callbacks. */\ntype RevalidationStore = { version: number; listeners: Set<() => void> };\n\ntype GlobalWithSlot = typeof globalThis & {\n [REVALIDATION_SLOT]?: RevalidationStore;\n};\n\nconst globalSlot = globalThis as GlobalWithSlot;\n\n/** The one shared store, lazily created on the runtime global (never a second copy per bundle). */\nconst store = (): RevalidationStore => {\n const existing = globalSlot[REVALIDATION_SLOT];\n if (existing) return existing;\n const created: RevalidationStore = { version: 0, listeners: new Set() };\n globalSlot[REVALIDATION_SLOT] = created;\n return created;\n};\n\n/**\n * Signal every activation subscriber to re-fetch its server decision. `wire.track()` calls this on a\n * successful POST (await the post first so the re-fetch sees the event). A throwing subscriber never\n * breaks the notify loop — each listener is isolated.\n */\nexport const bumpActivationRevalidation = (): void => {\n const s = store();\n s.version += 1;\n // Iterate a snapshot so a listener that (un)subscribes during notify never corrupts the walk.\n for (const listener of Array.from(s.listeners)) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others (fail-safe).\n }\n }\n};\n\n/**\n * Subscribe to revalidation. Returns an unsubscribe fn. Shaped for `useSyncExternalStore`\n * (see {@link useActivationRevalidation} in `useWireActivation`).\n */\nexport const subscribeActivationRevalidation = (listener: () => void): (() => void) => {\n const s = store();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n};\n\n/** The current revalidation version — include it in a decision-fetch effect's deps to re-fetch on bump. */\nexport const getActivationRevalidationVersion = (): number => store().version;\n\n/** Test-only: reset the shared store between cases (clears version + listeners). */\nexport const resetActivationRevalidation = (): void => {\n const s = store();\n s.version = 0;\n s.listeners.clear();\n};\n","/**\n * wireActivation — the kit-owned `wire.track()` + session accessor + revalidation surface.\n *\n * WHAT IT CONSOLIDATES (subsumes Morrow's workarounds): a consumer used to hand-roll three things\n * because the kit didn't own them — an awaitable action POST (`wireTrackActionAwait`), its OWN\n * per-open session id (`getWireSessionId`, minted because the kit's `getCurrentSessionId` desynced\n * cross-bundle — defect B), and an await-then-bump revalidation dance (`bumpActivationDecision`).\n * Defect B is fixed (PR #48: `getCurrentSessionId` is a `globalThis` singleton, reliable under\n * `dist`), so the kit can now own all three behind one thin surface:\n *\n * const wire = createWireActivation({ serverUrl, apiKey }); // or useWireActivation(...)\n * await wire.track(\"journal_done\"); // awaitable POST + auto-revalidate\n *\n * `track` POSTs `event_type='app_event'`, `question_key=<name>` (the EXACT string a review /\n * questionnaire firing TRIGGER matches on) under the CURRENT `getCurrentSessionId()` — the same id\n * the gates pass to their `/decision` fetch, so the server's session-scoped trigger rule agrees —\n * with `user_context.device_key` for the min-sessions / arm-assignment lookups. On a successful POST\n * it bumps decision revalidation so a subscribed gate re-fetches and can fire.\n *\n * ADDITIVE + built on existing primitives: it reuses the events transport\n * (`reportClientEventAwait`, the awaitable sibling of `reportClientEvents` — ONE `/v1/events` path)\n * and `getCurrentSessionId` — it introduces NO second session concept and duplicates no POST path.\n * React-free (the optional React glue is the thin `useWireActivation` hook).\n */\nimport { getCurrentSessionId } from \"../analytics/currentSession\";\nimport {\n reportClientEventAwait,\n type ClientEvent,\n type ClientEventTarget,\n} from \"../analytics/reportClientEvent\";\nimport { deviceIdStorageKey, mintDeviceId } from \"../context/deviceId\";\nimport { resolveUserContext, type WireUserContext } from \"../context/userContext\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport {\n bumpActivationRevalidation,\n getActivationRevalidationVersion,\n subscribeActivationRevalidation,\n} from \"./revalidation\";\n\n/** Trim a candidate string; return `undefined` for a non-string / blank so callers can `if`-gate. */\nconst clean = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n};\n\n/**\n * Tenant transport + context inputs for {@link createWireActivation}. `serverUrl`/`apiKey` are the\n * SAME creds as onboarding (never a second key); everything else is optional.\n */\nexport type WireActivationConfig = {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey: string;\n /**\n * A stable, non-PII device id → `user_context.device_key` (the server's review/questionnaire\n * gating + A/B stickiness key on it). When omitted, the kit auto-mints ONE per-install id, persists\n * it via `storage` when given, and reuses it — so `device_key` is ALWAYS present. Host-supplied wins.\n */\n deviceKey?: string;\n /**\n * Optional rich context stamped onto every tracked event's `user_context` (opaque `userId` →\n * top-level `user_id`, opt-in `userEmail`, namespaced `extra`). `deviceKey` here is equivalent to\n * the top-level one (top-level wins). Same shape the analytics façade accepts.\n */\n userContext?: WireUserContext;\n /** Tenant/app id — namespaces the auto-minted device-key storage slot. */\n appId?: string;\n /** Host app version → `user_context.app_version` when no explicit `userContext.appVersion` is set. */\n appVersion?: string;\n /** Host persistence (AsyncStorage-compatible subset) so the auto-minted device key survives launches. */\n storage?: WireOnboardingStorage;\n};\n\n/** The kit-owned activation surface. `sessionId` is a live getter (reads `getCurrentSessionId()`). */\nexport type WireActivation = {\n /**\n * Awaitable action report: POST `event_type='app_event'`, `question_key=<name>`, optional `meta`,\n * under the CURRENT session id + `user_context.device_key`. Resolves `true` once the server has\n * stored it (2xx) and THEN bumps decision revalidation; resolves `false` (no bump) when there is no\n * current session, a blank name, or the POST fails. Never throws.\n */\n track(name: string, meta?: Record<string, unknown>): Promise<boolean>;\n /** The CURRENT per-open session id (the kit's canonical `getCurrentSessionId()`), or `undefined`. */\n readonly sessionId: string | undefined;\n /** Subscribe to decision revalidation (bumped by a successful `track`). Returns an unsubscribe fn. */\n subscribeRevalidation(listener: () => void): () => void;\n /** The current revalidation version — include in a decision-fetch effect's deps to re-fetch on bump. */\n getRevalidationVersion(): number;\n};\n\n/**\n * Create a bound activation instance for a tenant transport. Resolves the device key once (explicit >\n * `userContext.deviceKey` > auto-minted + persisted). Pure + React-free.\n */\nexport const createWireActivation = (config: WireActivationConfig): WireActivation => {\n const target: ClientEventTarget = { serverUrl: config.serverUrl, apiKey: config.apiKey };\n\n // Device key: an explicit id (top-level or in userContext) wins and is never overwritten; otherwise\n // auto-mint ONE and persist via storage (reused every open) so `device_key` is always present.\n const explicitDeviceKey = clean(config.deviceKey) ?? clean(config.userContext?.deviceKey);\n let autoDeviceKey = explicitDeviceKey ?? mintDeviceId();\n if (config.storage && !explicitDeviceKey) {\n const storage = config.storage;\n const key = deviceIdStorageKey(config.appId);\n void storage\n .getItem(key)\n .then((saved) => {\n const persisted = clean(saved ?? undefined);\n if (persisted) autoDeviceKey = persisted;\n else void storage.setItem(key, autoDeviceKey).catch(() => {});\n })\n .catch(() => {});\n }\n\n // Stamp the resolved rich context onto the event: `user_context` bucket (device_key always, plus any\n // app_version / opt-in user_email / namespaced extra) and the top-level opaque `user_id`.\n const applyContext = (event: ClientEvent): void => {\n const resolved = resolveUserContext(\n { ...(config.userContext ?? {}), deviceKey: explicitDeviceKey ?? autoDeviceKey },\n { autoAppVersion: config.appVersion },\n );\n if (resolved.userContext) {\n event.user_context = { ...resolved.userContext, ...(event.user_context ?? {}) };\n }\n if (resolved.userId && !event.user_id) event.user_id = resolved.userId;\n };\n\n const track = async (name: string, meta?: Record<string, unknown>): Promise<boolean> => {\n const sessionId = getCurrentSessionId();\n // No current session (no app-open registered yet) or a blank name → nothing to correlate; bail\n // WITHOUT bumping (a bump with no posted event would only make the gate re-fetch for nothing).\n if (!clean(name) || !sessionId) return false;\n const event: ClientEvent = {\n event_type: \"app_event\",\n session_id: sessionId,\n question_key: name,\n };\n if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);\n applyContext(event);\n const ok = await reportClientEventAwait(target, event);\n // Only revalidate once the event is actually in the stream — a failed POST leaves the gate as-is.\n if (ok) bumpActivationRevalidation();\n return ok;\n };\n\n return {\n track,\n get sessionId() {\n return getCurrentSessionId();\n },\n subscribeRevalidation: subscribeActivationRevalidation,\n getRevalidationVersion: getActivationRevalidationVersion,\n };\n};\n","/**\n * useWireActivation — a THIN optional React hook over {@link createWireActivation}.\n *\n * One import gives a consumer everything the activation consolidation owns: `track` (awaitable POST\n * that auto-revalidates), the CURRENT `sessionId`, and a `revalidation` counter that ticks whenever\n * a `track()` (from anywhere) succeeds — subscribe to re-render, then re-fetch your gate decision.\n *\n * const { track, sessionId, revalidation } = useWireActivation({ serverUrl, apiKey });\n * // fetch the gate decision on mount AND whenever revalidation ticks:\n * useEffect(() => { fetchReviewDecision(target, { sessionId, deviceKey }).then(setDecision); },\n * [revalidation]);\n * // on the trigger action:\n * await track(\"journal_done\");\n *\n * Mirrors the existing `createAnalytics` / `useAnalytics` (and `createScreenTracker` /\n * `useScreenTracking`) split: the factory stays React-free; this is the glue. The instance is built\n * once per mount and held in a ref, so re-renders never rebuild it or re-resolve the device key.\n */\nimport { useRef, useSyncExternalStore } from \"react\";\n\nimport {\n getActivationRevalidationVersion,\n subscribeActivationRevalidation,\n} from \"./revalidation\";\nimport {\n createWireActivation,\n type WireActivation,\n type WireActivationConfig,\n} from \"./wireActivation\";\n\n/**\n * Subscribe a component to decision revalidation. Returns the current version; list it in a\n * decision-fetch effect's deps so a `bumpActivationRevalidation()` (which a successful `track` does)\n * re-runs the fetch. The kit-owned replacement for a host's hand-rolled `useActivationRevalidation`.\n */\nexport const useActivationRevalidation = (): number =>\n useSyncExternalStore(\n subscribeActivationRevalidation,\n getActivationRevalidationVersion,\n getActivationRevalidationVersion,\n );\n\n/** What {@link useWireActivation} returns: the awaitable `track`, the live `sessionId`, and the tick. */\nexport type UseWireActivation = {\n /** Awaitable action report that auto-revalidates on success (see {@link WireActivation.track}). */\n track: WireActivation[\"track\"];\n /** The CURRENT per-open session id (read fresh each render), or `undefined`. */\n sessionId: string | undefined;\n /** Monotonic counter that increments on every successful `track()` — a re-fetch trigger. */\n revalidation: number;\n};\n\n/**\n * Build a per-mount activation instance. `config` is read once at first render (the instance is\n * stable for the component's lifetime, keyed on the transport creds + device key); the returned\n * `revalidation` re-renders the component whenever any `track()` succeeds.\n */\nexport const useWireActivation = (config: WireActivationConfig): UseWireActivation => {\n const ref = useRef<WireActivation | undefined>(undefined);\n const prevKeys = useRef<string>(\"\");\n\n const currentKeys = `${config.serverUrl}|${config.apiKey}|${config.appId}|${config.deviceKey}`;\n if (!ref.current || prevKeys.current !== currentKeys) {\n prevKeys.current = currentKeys;\n ref.current = createWireActivation(config);\n }\n\n const revalidation = useActivationRevalidation();\n return { track: ref.current.track, sessionId: ref.current.sessionId, revalidation };\n};\n","/**\n * reportSessionStart — the ONE standard emitter for \"the user opened the app again\".\n *\n * Every app-open posts a single `app.session_started` event to the Wire analytics backend\n * (`POST {serverUrl}/v1/events`). That event does two jobs at once, with ZERO server changes:\n *\n * 1. SESSION MAPPING. It carries the host's opaque `userId` + a stable `deviceKey`, so the\n * backend can group a user's (or a pre-auth device's) opens over time — \"when did this\n * user last use the app, and how many times\". The device_key links the pre-auth opens to\n * the user once `userId` arrives (here or via `identifyOnboarding`).\n * 2. QUESTIONNAIRE / RETENTION FIRING. It flows into the SAME event stream the server's\n * decision engines read, so a questionnaire trigger `{event:\"app.session_started\", min_count:N}`\n * (matched within a session) or a questionnaire `min_sessions:N` (distinct device sessions)\n * fires on the user's Nth open with no new server endpoint.\n *\n * WIRE CONTRACT (server: analytics/events.py + routers/onboarding.py `POST /v1/events`):\n * The event is stored as `event_type='app_event'`, `question_key='app.session_started'` — the\n * generic app.* namespace the reviews wave shipped. The server's `_event_name(ev)` returns the\n * `question_key` for an `app_event`, which is what a trigger's `event` string matches. We do NOT\n * send `event_type:'app.session_started'` — that name is not in the server's EVENT_TYPES and\n * would be rejected. `device_key` rides in the non-PII `user_context` bucket, where the server's\n * `_event_device_key(ev)` reads it to group a device's sessions. `app_id` + `environment` are\n * filled server-side from the resolving key (never sent here).\n *\n * SESSION ID DISTINCTION (important): the `session_id` on this event is a PER-OPEN id (a fresh\n * `makeSessionId()` each app-open) — it is NOT the onboarding A2A `contextId`. Onboarding runs\n * ONCE (first launch) and owns its own context id; session-start fires on EVERY open, so it needs\n * its own per-open id. Grouping over time is done by `device_key`/`user_id`, not by session_id.\n *\n * Fire-and-forget: like every analytics path in the kit, this never throws into the UI, never\n * awaits, and swallows a missing target / bad URL / missing fetch / network error. Analytics must\n * never be able to break the app.\n */\nimport { setCurrentSessionId } from \"../analytics/currentSession\";\nimport { makeSessionId, type ClientEvent, type ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport type { DeviceContext } from \"../device/deviceContext\";\nimport { sanitizeUserId } from \"../identity/userIdentity\";\n\n/** The canonical event name for an app-open. A trigger keys off this exact string. */\nexport const SESSION_STARTED_EVENT = \"app.session_started\" as const;\n\n/** Options for {@link reportSessionStart}. Everything except `target` is optional so a pre-auth\n * open (no user yet) is a valid, device-only session. */\nexport interface ReportSessionStartOptions {\n /** Where to POST — the tenant transport (`serverUrl` + `apiKey`), same as `WireOnboardingConfig`. */\n target: ClientEventTarget | undefined;\n /**\n * The per-open session id. Defaults to a fresh `makeSessionId()`. Pass your own ONLY to\n * dedupe re-renders of the same open (the {@link useSessionStart} hook does exactly that).\n * This is NOT the onboarding contextId — see the file header.\n */\n sessionId?: string;\n /** The host's OPAQUE pseudonymous user id (their internal id, NOT an email/PII). Sanitized +\n * capped here; omitted on a pre-auth open (device-only session). */\n userId?: string;\n /** A stable, non-PII device id the host owns. Rides in `user_context.device_key` so the server\n * groups this device's sessions (the min_sessions signal). Host-supplied, same as reviews. */\n deviceKey?: string;\n /** The host's own local open-counter value for this open (1 on the first ever open). Drives the\n * `returning` flag and lets analytics read \"Nth session\" without server-side counting. */\n sessionCount?: number;\n /** Host app version (e.g. \"1.4.2\"), if cheaply available. Segments retention by release. */\n appVersion?: string;\n /** Platform string (e.g. \"ios\"), if cheaply available. */\n platform?: string;\n /** An optional richer device snapshot (from `collectDeviceContext()`); the hook fills this. */\n device?: DeviceContext;\n /** Small non-PII extras, stored as a JSON string in the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to bypass the once-per-open guard (default on). See {@link resetSessionStartGuard}. */\n once?: boolean;\n /**\n * OPTIONAL transport sink. When provided, the built `app.session_started` event is routed HERE\n * (e.g. the offline-first event queue's `enqueue`) INSTEAD of this emitter's own direct `fetch`,\n * while KEEPING the once-per-open guard above. This is how the lifecycle wiring\n * (`useLifecycleEvents` / `wireLifecycleEvents`) offline-buffers session-start WITHOUT adding a\n * second session emitter: one emitter, one guard, now durable. Omit it for the direct-POST path.\n * A throwing sink is swallowed — analytics must never surface into the UI.\n */\n sink?: (event: ClientEvent) => void;\n}\n\n// ── Once-per-open guard ──────────────────────────────────────────────────────\n// A re-render (or a host that lists the emitter in an effect) must never double-fire the SAME\n// open. We remember the session ids already emitted; a repeat call with a seen id is a no-op.\n// Bounded so a long-lived app never grows this unboundedly — a fresh open always mints a fresh\n// id, so evicting old ids can never cause a real re-fire.\nconst _emitted = new Set<string>();\nconst _GUARD_MAX = 128;\n\n/** Test-only: forget every emitted session id so a unit test starts from a clean guard. */\nexport const resetSessionStartGuard = (): void => {\n _emitted.clear();\n};\n\n/**\n * Emit one `app.session_started` event for this app-open. Fire-and-forget; returns immediately.\n * Idempotent per `sessionId` (unless `once:false`) so a re-render can never double-fire.\n */\nexport const reportSessionStart = (opts: ReportSessionStartOptions): void => {\n const target = opts.target;\n // A wired sink is a valid transport on its own — it owns the target (the queue's serverUrl), so\n // this emitter needs its own `target` ONLY for the direct-fetch fallback.\n if (!opts.sink && !target?.serverUrl) return;\n\n const sessionId = opts.sessionId ?? makeSessionId();\n\n // Register this open as the CURRENT per-open session so the analytics façade's `identify` /\n // app-events reuse the id the server sees here (via `app.session_started`) instead of minting a\n // fresh one it would back-fill into a phantom session. Idempotent; set before the once-guard so\n // even a guard-deduped repeat keeps the current id pointing at this open.\n setCurrentSessionId(sessionId);\n\n // Once-per-open guard: skip a repeat emit for a session id we already sent.\n if (opts.once !== false) {\n if (_emitted.has(sessionId)) return;\n if (_emitted.size >= _GUARD_MAX) {\n // Evict the oldest insertion (Set preserves insertion order).\n const oldest = _emitted.values().next().value;\n if (oldest !== undefined) _emitted.delete(oldest);\n }\n _emitted.add(sessionId);\n }\n\n try {\n // Non-PII correlation bucket. device_key is read by the server to group a device's sessions;\n // session_count / returning / app_version / platform feed per-user retention analytics.\n const userContext: Record<string, string | number | boolean> = {};\n if (opts.deviceKey) userContext.device_key = opts.deviceKey;\n if (typeof opts.sessionCount === \"number\" && Number.isFinite(opts.sessionCount)) {\n userContext.session_count = opts.sessionCount;\n userContext.returning = opts.sessionCount > 1;\n }\n if (opts.appVersion) userContext.app_version = opts.appVersion;\n if (opts.platform) userContext.platform = opts.platform;\n\n const event: Record<string, unknown> = {\n event_type: \"app_event\",\n question_key: SESSION_STARTED_EVENT,\n session_id: sessionId,\n };\n const userId = sanitizeUserId(opts.userId);\n if (userId) event.user_id = userId;\n if (Object.keys(userContext).length > 0) event.user_context = userContext;\n if (opts.device) event.device = opts.device;\n if (opts.meta && Object.keys(opts.meta).length > 0) event.meta = JSON.stringify(opts.meta);\n\n // Preferred transport: an injected sink (the offline-first event queue's `enqueue`), which\n // buffers + persists + retries. The once-guard above already ran, so this stays the single\n // session emitter with a single guard — now durable.\n if (opts.sink) {\n opts.sink(event as ClientEvent);\n return;\n }\n\n // Fallback: this emitter's own direct POST when no sink is wired.\n if (!target?.serverUrl) return;\n const url = `${target.serverUrl.replace(/\\/$/, \"\")}/v1/events`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;\n void fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ events: [event] }),\n }).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // URL construction, JSON serialization, a throwing sink, or a missing fetch — swallow.\n }\n};\n","/**\n * useSessionStart — the optional convenience hook that fires {@link reportSessionStart} for you.\n *\n * Two firing moments, mirroring the reference apps' session-counter semantics:\n * • ON MOUNT — the app opened (cold start or the provider first rendered).\n * • ON FOREGROUND after a real background — when AppState returns to `active` having been\n * backgrounded for at least {@link BACKGROUND_SESSION_MS} (30 min), that's a NEW open, so a\n * fresh session fires. A quick app-switch (under the threshold) does NOT count as a new open.\n *\n * Each firing mints its OWN per-open `session_id` (held in a ref so a re-render never re-fires),\n * so grouping over time is by `deviceKey`/`userId`, never by session_id (see reportSessionStart).\n *\n * The hook is OPTIONAL. A host that already owns a session counter (most hosts do) can skip\n * the hook and call `reportSessionStart(...)` directly from its own \"app opened\" path — BOTH\n * paths are first-class. This hook is the batteries-included option for a host that has none.\n *\n * Dependency policy: `AppState` + `Platform` are React Native built-ins (no new dep); the device\n * snapshot comes from the kit's own dependency-free `collectDeviceContext()`.\n */\nimport { useEffect, useRef } from \"react\";\nimport { AppState, Platform, type AppStateStatus } from \"react-native\";\n\nimport type { ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport { collectDeviceContext } from \"../device/deviceContext\";\nimport { reportSessionStart } from \"./reportSessionStart\";\n\n/** A foreground after at least this long in the background counts as a NEW app-open (30 min). */\nexport const BACKGROUND_SESSION_MS = 30 * 60 * 1000;\n\n/** Tenant transport + optional host app version. Same creds as `WireOnboardingConfig`. */\nexport interface SessionStartConfig {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl?: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey?: string;\n /** Host app version (e.g. \"1.4.2\"), forwarded for release segmentation. Optional. */\n appVersion?: string;\n}\n\n/** Per-open identity the host supplies. All optional: a pre-auth open is device-only. */\nexport interface UseSessionStartOptions {\n /** The host's opaque pseudonymous user id (NOT PII). Omitted before the user authenticates. */\n userId?: string;\n /** The host's local open-counter value for this open. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** A stable, non-PII device id the host owns. Groups this device's sessions server-side. */\n deviceKey?: string;\n /** Small non-PII extras forwarded on the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to disable firing (e.g. behind a consent gate). Default enabled. */\n enabled?: boolean;\n}\n\n/**\n * Fire `app.session_started` on mount and on every real foreground-after-background. Returns\n * nothing — it is a side-effecting hook. Safe to call with inline options (values are read\n * through a ref, so changing `userId`/`sessionCount` never re-fires a session).\n */\nexport const useSessionStart = (\n config: SessionStartConfig | undefined,\n options: UseSessionStartOptions = {},\n): void => {\n // Latest options/config through a ref so the mount/resume fires read fresh values without\n // listing them as effect deps (which would re-fire a session on every prop change).\n const latest = useRef({ config, options });\n latest.current = { config, options };\n\n useEffect(() => {\n const fire = () => {\n const { config: cfg, options: opts } = latest.current;\n if (!cfg?.serverUrl) return;\n if (opts.enabled === false) return;\n const target: ClientEventTarget = { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" };\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg.appVersion) device.appVersion = cfg.appVersion;\n reportSessionStart({\n target,\n // A fresh per-open id each fire; the emitter's once-guard dedupes within the open.\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n };\n\n // 1) Mount = an app-open.\n fire();\n\n // 2) Foreground after a real background = a new app-open.\n let backgroundedAt: number | null = null;\n const onChange = (state: AppStateStatus) => {\n if (state === \"background\" || state === \"inactive\") {\n // Record the first moment we left the foreground (don't overwrite inactive→background).\n if (backgroundedAt == null) backgroundedAt = Date.now();\n return;\n }\n if (state === \"active\") {\n const since = backgroundedAt;\n backgroundedAt = null;\n if (since != null && Date.now() - since >= BACKGROUND_SESSION_MS) fire();\n }\n };\n const sub = AppState.addEventListener(\"change\", onChange);\n return () => {\n // RN >= 0.65 returns a subscription with remove(); guard for older shims.\n if (sub && typeof (sub as { remove?: () => void }).remove === \"function\") sub.remove();\n };\n // Mount-only effect: firing reads fresh values via `latest`, so no reactive deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n","/**\n * lifecycle — the TOP-OF-FUNNEL app lifecycle events that sit ABOVE onboarding: `app.first_open`\n * (once ever per install) and `app.session_started` (per app-open). They compose with, and never\n * duplicate, the events the funnel already records.\n *\n * WHERE THIS FITS (one funnel, no double counting):\n * • `app.first_open` → THIS module, once ever (persisted flag). The in-app \"install\" proxy.\n * • `app.session_started` → the EXISTING {@link reportSessionStart} emitter (per app-open). This\n * module REUSES it (routed through the offline queue), never re-emits.\n * • onboarding started / completed / activated → ALREADY recorded: the server writes\n * `session_started` + `completed` during the A2A flow, and the client reports `dropped` /\n * `client_fallback` / `identify` via `reportClientEvent`. This module does NOT touch them —\n * emitting them here would double-count. It only ADDS the two lifecycle events above them.\n *\n * WIRE CONTRACT (identical to `app.session_started`): both lifecycle events are stored as\n * `event_type='app_event'` with the name in `question_key` (the server's `_event_name` returns\n * `question_key` for an `app_event`, which a trigger matches). `app.first_open` uses the SAME\n * `app.*` namespace + the SAME event shape as `app.session_started` — no bespoke `event_type`,\n * no invented contract. `device_key` rides in the non-PII `user_context` bucket; `app_id` +\n * `environment` are filled server-side.\n *\n * TWO FIRST-CLASS ENTRY POINTS (mirrors reportSessionStart vs useSessionStart):\n * • `reportFirstOpen(...)` / `wireLifecycleEvents(...)` — pure, React-free, for a host that owns\n * its own app-open path.\n * • `useLifecycleEvents(...)` — the batteries-included React hook (in `useLifecycleEvents.ts`).\n *\n * OFFLINE-FIRST: pass the Brief-01 event queue's `enqueue` as the `sink` and every lifecycle event\n * is buffered + persisted + retried instead of a blind fetch. Without a sink they degrade to a\n * direct fire-and-forget POST.\n *\n * PRIVACY (hard rule, same as the rest of the kit): NO GPS/location, NO advertising id. Nothing\n * here carries a coordinate or an ad id — a host adopting it changes no store privacy declaration.\n *\n * FIRE-AND-FORGET: like every analytics path in the kit, nothing here throws into the UI, awaits\n * in the caller, or hangs the app — storage reads race a short timeout, writes swallow errors.\n */\nimport { buildEventsRequest, makeSessionId, type ClientEvent, type ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport type { DeviceContext } from \"../device/deviceContext\";\nimport { sanitizeUserId } from \"../identity/userIdentity\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport { reportSessionStart, SESSION_STARTED_EVENT } from \"./reportSessionStart\";\n\n/** The canonical event name for the first-ever app open. Same `app.*` namespace as\n * {@link SESSION_STARTED_EVENT}; a trigger keys off this exact string. */\nexport const FIRST_OPEN_EVENT = \"app.first_open\" as const;\n\n/** Storage key for the once-ever first-open flag, e.g. `wireai:first_open:acme`. Mirrors the\n * `wireai:<concern>:<appId>` namespacing of {@link sessionStorageKey}. */\nexport const firstOpenStorageKey = (appId: string): string => `wireai:first_open:${appId}`;\n\n/** Ceiling on the flag read — a hung adapter degrades to the in-memory latch, never a stuck gate. */\nconst READ_TIMEOUT_MS = 1_500;\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n// ── First-open in-memory latch ───────────────────────────────────────────────\n// Covers TWO cases the persisted flag can't: (1) two near-simultaneous calls in one process (the\n// flag read is async, so a synchronous latch is what guarantees at-most-one before any await), and\n// (2) the documented DEGRADED no-storage mode (fires once per process). Keyed by appId.\nconst _firstOpenLatched = new Set<string>();\n\n/** Test-only: forget the first-open latch so a unit test starts from a clean process state. */\nexport const resetFirstOpenLatch = (): void => {\n _firstOpenLatched.clear();\n};\n\n/** Shared inputs for a lifecycle event. Everything is optional except a transport (`target` for the\n * direct-POST fallback, or a `sink`). A pre-auth open (no user yet) is a valid device-only event. */\nexport interface LifecycleEventInput {\n /** Where to POST if no `sink` is wired (the tenant transport, same as `WireOnboardingConfig`). */\n target?: ClientEventTarget;\n /** Preferred transport: route the built event HERE (the offline queue's `enqueue`). */\n sink?: (event: ClientEvent) => void;\n /** The per-open session id. Defaults to a fresh `makeSessionId()`. */\n sessionId?: string;\n /** The host's OPAQUE pseudonymous user id (NOT PII). Sanitized + capped; omitted pre-auth. */\n userId?: string;\n /** A stable, non-PII device id the host owns. Rides in `user_context.device_key`. */\n deviceKey?: string;\n /** The host's local open-counter value. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** Host app version (e.g. \"1.4.2\"), if cheaply available. */\n appVersion?: string;\n /** Platform string (e.g. \"ios\"), if cheaply available. */\n platform?: string;\n /** An optional richer device snapshot (from `collectDeviceContext()`); the hook fills this. */\n device?: DeviceContext;\n /** Small non-PII extras, stored as a JSON string in the event `meta`. */\n meta?: Record<string, unknown>;\n}\n\n/** Options for {@link reportFirstOpen}. Adds the once-ever persistence inputs on top of the shared\n * lifecycle inputs. Without `storage` it degrades to the in-memory latch (once per process). */\nexport interface ReportFirstOpenOptions extends LifecycleEventInput {\n /** Host persistence (AsyncStorage subset). The once-ever flag lives here — it is what survives an\n * app kill. Omit it for the documented degraded (in-memory, once-per-process) mode. */\n storage?: WireOnboardingStorage;\n /** Tenant/app id — namespaces the persisted flag (`wireai:first_open:<appId>`). */\n appId?: string;\n}\n\n/**\n * Build the `app_event` payload shared by `app.first_open` and `app.session_started`. This is a\n * BYTE-FOR-BYTE mirror of the field logic in {@link reportSessionStart} — same `event_type`, same\n * `question_key`-as-name contract, same `user_context` bucket, same optional fields — so the two\n * lifecycle events are one contract with two names. Do NOT let these diverge (see lifecycle.test).\n */\nconst buildLifecycleEvent = (questionKey: string, opts: LifecycleEventInput): Record<string, unknown> => {\n const userContext: Record<string, string | number | boolean> = {};\n if (opts.deviceKey) userContext.device_key = opts.deviceKey;\n if (typeof opts.sessionCount === \"number\" && Number.isFinite(opts.sessionCount)) {\n userContext.session_count = opts.sessionCount;\n userContext.returning = opts.sessionCount > 1;\n }\n if (opts.appVersion) userContext.app_version = opts.appVersion;\n if (opts.platform) userContext.platform = opts.platform;\n\n const event: Record<string, unknown> = {\n event_type: \"app_event\",\n question_key: questionKey,\n session_id: opts.sessionId ?? makeSessionId(),\n };\n const userId = sanitizeUserId(opts.userId);\n if (userId) event.user_id = userId;\n if (Object.keys(userContext).length > 0) event.user_context = userContext;\n if (opts.device) event.device = opts.device;\n if (opts.meta && Object.keys(opts.meta).length > 0) event.meta = JSON.stringify(opts.meta);\n return event;\n};\n\n/** Route a built event to the wired sink, else a direct fire-and-forget POST. Never throws. */\nconst routeLifecycleEvent = (event: Record<string, unknown>, opts: LifecycleEventInput): void => {\n try {\n if (opts.sink) {\n opts.sink(event as ClientEvent);\n return;\n }\n // Route the direct-POST fallback through the ONE canonical /v1/events builder (url + headers +\n // body) instead of re-describing the endpoint here; still fire-and-forget.\n const req = buildEventsRequest(opts.target, [event as unknown as ClientEvent]);\n if (!req) return;\n void fetch(req.url, req.init).catch(() => {\n // Network/transport error — analytics is best-effort, swallow.\n });\n } catch {\n // A throwing sink, URL/JSON error, or a missing fetch — swallow.\n }\n};\n\nconst emitFirstOpen = (opts: ReportFirstOpenOptions): void => {\n routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);\n};\n\n/**\n * Emit `app.first_open` EXACTLY ONCE EVER per install. Fire-and-forget; returns immediately.\n *\n * • With `storage`: reads the persisted flag (`wireai:first_open:<appId>`). Absent → emit, then\n * write the flag (survives app kills, so a second launch is a no-op). Present → no-op.\n * • Race guard: an in-memory latch is set SYNCHRONOUSLY before the async read, so two\n * near-simultaneous calls fire at most once.\n * • Without `storage`: degraded mode — fires once per PROCESS via the latch only (documented).\n */\nexport const reportFirstOpen = (opts: ReportFirstOpenOptions): void => {\n const appId = opts.appId ?? \"default\";\n\n // Synchronous latch FIRST: guarantees at-most-one before any await (same-process race guard) and\n // is the sole guard in the no-storage degraded mode.\n if (_firstOpenLatched.has(appId)) return;\n _firstOpenLatched.add(appId);\n\n const storage = opts.storage;\n if (!storage) {\n // Degraded: no persistence to survive a kill → the latch fires it once per process.\n emitFirstOpen(opts);\n return;\n }\n\n const key = firstOpenStorageKey(appId);\n void (async () => {\n try {\n const seen = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);\n // A prior launch already fired + wrote the flag → once-ever satisfied, no-op.\n if (seen) return;\n emitFirstOpen(opts);\n try {\n // Best-effort persist: a failed write just means the next launch may re-fire once.\n void storage.setItem(key, JSON.stringify({ ts: Date.now() })).catch(() => {});\n } catch {\n // Missing/broken storage write — swallow.\n }\n } catch {\n // Unreadable flag → the in-memory latch still caps us at one fire this process.\n emitFirstOpen(opts);\n }\n })();\n};\n\n/** Options for {@link wireLifecycleEvents}: the shared lifecycle inputs + first-open persistence. */\nexport interface WireLifecycleOptions extends ReportFirstOpenOptions {}\n\n/**\n * Wire BOTH lifecycle events in one call for a host that owns its own app-open path (the non-hook\n * counterpart to {@link useLifecycleEvents}). Fires `app.first_open` (once ever) and one\n * `app.session_started` for THIS open through the EXISTING {@link reportSessionStart} emitter (so\n * the once-per-open guard still applies — pass the same `sessionId` and it never double-fires).\n * Route both through the same `sink` (the offline queue) to buffer them. Fire-and-forget.\n */\nexport const wireLifecycleEvents = (opts: WireLifecycleOptions): void => {\n reportFirstOpen(opts);\n reportSessionStart({\n target: opts.target,\n sink: opts.sink,\n sessionId: opts.sessionId,\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: opts.appVersion,\n platform: opts.platform,\n device: opts.device,\n meta: opts.meta,\n });\n};\n\n// Re-exported so callers wiring lifecycle events have the session name alongside the first-open one.\nexport { SESSION_STARTED_EVENT };\n","/**\n * eventQueue — the OFFLINE-FIRST, persistent transport buffer for client analytics events.\n *\n * The existing `reportClientEvents` is a blind fire-and-forget POST: it returns `void`, has no\n * success signal, and drops events when the network is down. The analytics data story depends on\n * NEVER losing an event offline, so this queue adds the missing durability layer on top of the\n * same `POST {serverUrl}/v1/events` contract:\n *\n * • Persists pending events to the host-injected `WireOnboardingStorage` (survives app kills).\n * • Batches them into one request body `{ events: [...] }`.\n * • Owns its OWN awaited `fetch` that reads `res.ok` — the only way to drive retry + dequeue,\n * since `reportClientEvents` cannot ack. A 2xx dequeues the batch; a non-ok / rejected / thrown\n * response keeps it and schedules an exponential backoff retry.\n * • Flushes on `enqueue`, on an explicit `flush()`, and on `notifyOnline()` (host reconnect).\n * • Caps the buffer (drop-OLDEST under pressure) and de-dups identical pending events.\n * • Stamps the current context envelope (device + host scalars) onto every event before send.\n *\n * FIRE-AND-FORGET (load-bearing): `enqueue` returns immediately and NEVER throws into the UI. A\n * missing `fetch`, a hung/broken storage, a rejecting network, or a JSON error is swallowed and\n * degrades gracefully — analytics must never be able to break the app. In-memory fallback covers\n * the no-storage case (survives re-renders, not app kills).\n *\n * DEPENDENCY-FREE: no network-detection or persistence library. Connectivity is host-driven via\n * `notifyOnline()`; persistence is the host-injected AsyncStorage-compatible subset.\n */\nimport type { ContextEnvelope } from \"./contextEnvelope\";\nimport { buildEventsRequest, type ClientEvent, type ClientEventTarget } from \"./reportClientEvent\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\n\n/** Envelope source: a fixed envelope or a provider evaluated at enqueue time (fresh network type). */\nexport type EnvelopeSource = ContextEnvelope | (() => ContextEnvelope | undefined);\n\n/** Options for {@link createEventQueue}. Only `target` is conceptually required to actually send. */\nexport type EventQueueOptions = {\n /** Where to POST — the tenant transport (`serverUrl` + `apiKey`), same as `WireOnboardingConfig`. */\n target: ClientEventTarget | undefined;\n /**\n * Host persistence (AsyncStorage-compatible subset). When omitted, the queue runs in the\n * documented DEGRADED in-memory mode — it survives re-renders but not an app kill.\n */\n storage?: WireOnboardingStorage;\n /** Tenant/app id used to namespace the default storage key (`wireai:evtq:<appId>`). */\n appId?: string;\n /** Explicit storage key override (wins over the `appId`-derived default). */\n storageKey?: string;\n /** The context envelope stamped onto every event before send (device + host scalars). */\n envelope?: EnvelopeSource;\n /** Max pending events; enqueuing past this DROPS THE OLDEST first (default 200). */\n maxSize?: number;\n /** Events per POST batch (default 20). */\n batchSize?: number;\n /** First retry delay in ms; doubles each failed attempt (default 1000). */\n baseBackoffMs?: number;\n /** Backoff ceiling in ms (default 30000). */\n maxBackoffMs?: number;\n /** Max AUTOMATIC backoff retries before pausing (default 6); `notifyOnline()`/`flush()` re-arm it. */\n maxRetries?: number;\n};\n\n/** The queue's public surface. `enqueue` is fire-and-forget (returns immediately, never throws). */\nexport type EventQueue = {\n /** Buffer one event (envelope-stamped), persist, and schedule a flush. Never throws. */\n enqueue(event: ClientEvent): void;\n /** Attempt an immediate drain of the pending buffer. Fire-and-forget. */\n flush(): void;\n /** Host reconnect signal: reset backoff and drain immediately. Fire-and-forget. */\n notifyOnline(): void;\n /** Current pending (in-memory) count. */\n size(): number;\n};\n\nconst DEFAULTS = {\n maxSize: 200,\n batchSize: 20,\n baseBackoffMs: 1000,\n maxBackoffMs: 30000,\n maxRetries: 6,\n} as const;\n\n/** Ceiling on the persisted-backlog read — a hung adapter degrades to an empty start, never a stall. */\nconst READ_TIMEOUT_MS = 1500;\n\n/** Internal buffered item. `id` is a local monotonic handle for deterministic dequeue-after-ack;\n * it is NEVER sent to the server. `sig` is the de-dup signature (serialized stamped event). */\ntype QueuedItem = { id: number; event: ClientEvent; sig: string };\n\n/** Persisted shape — the local id + the (already envelope-stamped) event. `sig` is recomputed on load. */\ntype PersistedItem = { id: number; event: ClientEvent };\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | undefined> => {\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), ms);\n });\n return Promise.race([p, timeout]).finally(() => clearTimeout(timer));\n};\n\n/** Detach a timer from the event loop where the runtime supports it (Node test process / some RNs). */\nconst unrefTimer = (timer: ReturnType<typeof setTimeout>): void => {\n const t = timer as unknown as { unref?: () => void };\n if (typeof t.unref === \"function\") t.unref();\n};\n\nconst parsePersisted = (raw: string | null | undefined): PersistedItem[] => {\n if (!raw) return [];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n const items: PersistedItem[] = [];\n for (const entry of parsed) {\n if (\n entry &&\n typeof entry === \"object\" &&\n typeof (entry as PersistedItem).id === \"number\" &&\n (entry as PersistedItem).event &&\n typeof (entry as PersistedItem).event === \"object\"\n ) {\n items.push(entry as PersistedItem);\n }\n }\n return items;\n } catch {\n // Corrupt backlog → start empty; the next persist overwrites it.\n return [];\n }\n};\n\n/**\n * Create an offline-first event queue. Loads any persisted backlog on creation so a\n * killed-and-relaunched app resumes where it left off. Returns the {@link EventQueue} surface.\n */\nexport const createEventQueue = (options: EventQueueOptions): EventQueue => {\n const target = options.target;\n const storage = options.storage;\n const key = options.storageKey ?? `wireai:evtq:${options.appId ?? \"default\"}`;\n const maxSize = options.maxSize ?? DEFAULTS.maxSize;\n const batchSize = options.batchSize ?? DEFAULTS.batchSize;\n const baseBackoffMs = options.baseBackoffMs ?? DEFAULTS.baseBackoffMs;\n const maxBackoffMs = options.maxBackoffMs ?? DEFAULTS.maxBackoffMs;\n const maxRetries = options.maxRetries ?? DEFAULTS.maxRetries;\n\n let pending: QueuedItem[] = [];\n let nextId = 0;\n let flushing = false;\n let attempt = 0;\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n\n const resolveEnvelope = (): ContextEnvelope | undefined => {\n try {\n return typeof options.envelope === \"function\" ? options.envelope() : options.envelope;\n } catch {\n return undefined;\n }\n };\n\n // Stamp the current envelope onto a COPY of the event (never mutate the caller's object):\n // device → event.device (when the event has none)\n // sessionId → event.session_id (when the event has none)\n // appVersion / appBuild / networkType → event.user_context (the non-PII bucket the server\n // sanitizes), never overwriting a key the caller already set.\n const stamp = (event: ClientEvent): ClientEvent => {\n const env = resolveEnvelope();\n const stamped: ClientEvent = { ...event };\n // Client enqueue timestamp: distinguishes a GENUINE repeat (same event fired seconds apart)\n // from a REDUNDANT re-enqueue of the same instant. The de-dup signature below includes it, so\n // two identical events enqueued in the same millisecond still collapse (a re-render), while the\n // same action repeated later carries a fresh `ts` and survives. A caller-set `ts` is preserved.\n if (stamped.ts === undefined) stamped.ts = Date.now();\n if (!env) return stamped;\n if (!stamped.device && env.device) stamped.device = env.device;\n if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;\n const uc: Record<string, string | number | boolean> = { ...(stamped.user_context ?? {}) };\n if (env.appVersion && uc.app_version === undefined) uc.app_version = env.appVersion;\n if (env.appBuild && uc.app_build === undefined) uc.app_build = env.appBuild;\n if (env.networkType && uc.network_type === undefined) uc.network_type = env.networkType;\n if (Object.keys(uc).length > 0) stamped.user_context = uc;\n return stamped;\n };\n\n const persist = (): void => {\n if (!storage) return;\n try {\n if (pending.length === 0) {\n void storage.removeItem(key).catch(() => {});\n return;\n }\n const payload: PersistedItem[] = pending.map((item) => ({ id: item.id, event: item.event }));\n void storage.setItem(key, JSON.stringify(payload)).catch(() => {});\n } catch {\n // Best-effort: a failed write just means the backlog is not durable this launch.\n }\n };\n\n const enforceSizeCap = (): void => {\n // Drop the OLDEST first so the newest events are never the ones lost under pressure.\n if (pending.length > maxSize) pending.splice(0, pending.length - maxSize);\n };\n\n const safeSig = (event: ClientEvent): string => {\n try {\n return JSON.stringify(event);\n } catch {\n // Non-serializable event → give it a unique signature so it is never wrongly de-duped.\n return `__nosig_${nextId}_${Math.random()}`;\n }\n };\n\n // Load any persisted backlog. Anything enqueued before this settles stays in memory; we merge\n // persisted (older) ahead of it and reassign monotonic ids so dequeue-after-ack is deterministic.\n const loadPromise: Promise<void> = (async () => {\n if (!storage) return;\n try {\n const persistedItems = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));\n if (persistedItems.length === 0) return;\n const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];\n pending = [];\n nextId = 0;\n const seen = new Set<string>();\n for (const event of events) {\n const sig = safeSig(event);\n if (seen.has(sig)) continue; // collapse duplicates carried across the merge\n seen.add(sig);\n pending.push({ id: nextId++, event, sig });\n }\n enforceSizeCap();\n persist();\n } catch {\n // Unreadable backlog → start empty; nothing enqueued in-memory is lost.\n }\n })();\n\n // The queue's OWN awaited POST. Reads `res.ok` to drive retry/dequeue. NEVER throws — a missing\n // fetch, a rejecting network, or a JSON error resolves to `false` (batch stays, retry schedules).\n const postBatch = async (events: ClientEvent[]): Promise<boolean> => {\n // Build the /v1/events request through the ONE canonical builder (url + headers + body) so this\n // queue never re-describes the endpoint. The abort-timeout stays: the queue owns retry/dequeue,\n // so a hung request must be cut loose to schedule a backoff rather than block the drain forever.\n const req = buildEventsRequest(target, events);\n if (!req) return false;\n const controller = typeof AbortController !== \"undefined\" ? new AbortController() : undefined;\n const timer = setTimeout(() => controller?.abort(), 15_000);\n try {\n const res = await fetch(req.url, { ...req.init, signal: controller?.signal });\n return !!(res && (res as { ok?: boolean }).ok);\n } catch {\n return false;\n } finally {\n clearTimeout(timer);\n }\n };\n\n const clearRetry = (): void => {\n if (retryTimer !== undefined) {\n clearTimeout(retryTimer);\n retryTimer = undefined;\n }\n };\n\n const scheduleRetry = (): void => {\n // Bounded automatic retry. Past the cap the backlog simply waits for the next\n // `notifyOnline()` / `flush()` (both re-arm attempt), so events are paused, never dropped.\n if (attempt >= maxRetries) return;\n const delay = Math.min(baseBackoffMs * 2 ** attempt, maxBackoffMs);\n attempt++;\n clearRetry();\n retryTimer = setTimeout(() => {\n retryTimer = undefined;\n void drain();\n }, delay);\n unrefTimer(retryTimer);\n };\n\n const drain = async (): Promise<void> => {\n try {\n await loadPromise;\n } catch {\n // load already swallows; guard the await defensively.\n }\n if (flushing) return;\n flushing = true;\n try {\n while (pending.length > 0) {\n const batch = pending.slice(0, batchSize);\n const ok = await postBatch(batch.map((item) => item.event));\n if (!ok) {\n scheduleRetry();\n return;\n }\n // Dequeue exactly the acked batch by id (pending may have grown while in flight).\n const acked = new Set(batch.map((item) => item.id));\n pending = pending.filter((item) => !acked.has(item.id));\n persist();\n attempt = 0;\n clearRetry();\n }\n } finally {\n flushing = false;\n }\n };\n\n const flush = (): void => {\n try {\n void drain();\n } catch {\n // drain never throws synchronously, but guard the kick anyway.\n }\n };\n\n const enqueue = (event: ClientEvent): void => {\n try {\n const stamped = stamp(event);\n const sig = safeSig(stamped);\n // Collapse a redundant re-enqueue of an identical pending event.\n for (const item of pending) {\n if (item.sig === sig) return;\n }\n pending.push({ id: nextId++, event: stamped, sig });\n enforceSizeCap();\n persist();\n // Only kick a drain when no retry is already pending — avoids hammering fetch while offline.\n if (retryTimer === undefined) flush();\n } catch {\n // Fire-and-forget: nothing in enqueue may surface to the UI.\n }\n };\n\n const notifyOnline = (): void => {\n // Host reconnected: reset the backoff and drain now.\n attempt = 0;\n clearRetry();\n flush();\n };\n\n const size = (): number => pending.length;\n\n return { enqueue, flush, notifyOnline, size };\n};\n","/**\n * useLifecycleEvents — the batteries-included React hook that wires the TOP-OF-FUNNEL lifecycle\n * events in ONE place: `app.first_open` (once ever) on mount, and `app.session_started` on every\n * real app-open, both offline-buffered through the Brief-01 event queue.\n *\n * ONE emitter, one guard, no double-emit: session-start goes through the EXISTING\n * {@link reportSessionStart} emitter (routed via a `sink`), NOT a second session emitter — so a\n * host must use EITHER this hook OR `useSessionStart`, never both (both would fire an app-open).\n * The once-per-open guard dedupes re-renders within this hook.\n *\n * Firing moments mirror {@link useSessionStart} exactly:\n * • ON MOUNT — the app opened (cold start / provider first render). `app.first_open` fires here\n * too (once ever, gated by the persisted flag in `reportFirstOpen`).\n * • ON FOREGROUND after a real background of at least {@link BACKGROUND_SESSION_MS} (30 min) — a\n * new app-open, so a fresh `app.session_started` fires. A quick app-switch does NOT count.\n *\n * OFFLINE-FIRST by default: pass your shared {@link EventQueue}'s `enqueue` as `options.sink` to\n * route both events through your one queue. If you pass no sink, the hook lazily creates its OWN\n * offline queue (dedicated storage key, so it never collides with your main queue) from the config\n * + storage. Either way lifecycle events are buffered + persisted + retried, never lost offline.\n *\n * Dependency policy: `AppState` + `Platform` are RN built-ins (no new dep); the device snapshot is\n * the kit's own dependency-free `collectDeviceContext()`; the queue is the dependency-free Brief-01\n * `createEventQueue`. The pure `reportFirstOpen` / `wireLifecycleEvents` (in lifecycle.ts) import no\n * React — this hook is the only React surface.\n */\nimport { useEffect, useRef } from \"react\";\nimport { AppState, Platform, type AppStateStatus } from \"react-native\";\n\nimport { createEventQueue, type EnvelopeSource, type EventQueue } from \"../analytics/eventQueue\";\nimport { makeSessionId, type ClientEvent, type ClientEventTarget } from \"../analytics/reportClientEvent\";\nimport { collectDeviceContext } from \"../device/deviceContext\";\nimport type { WireOnboardingStorage } from \"../session/persistedSession\";\nimport { reportFirstOpen } from \"./lifecycle\";\nimport { reportSessionStart } from \"./reportSessionStart\";\nimport { BACKGROUND_SESSION_MS } from \"./useSessionStart\";\n\n/** Tenant transport + host persistence for the lifecycle wiring. Same creds as `WireOnboardingConfig`. */\nexport interface LifecycleConfig {\n /** Base server URL (same as `WireOnboardingConfig.serverUrl`); `/v1/events` is appended. */\n serverUrl?: string;\n /** Tenant API key; sent as `Authorization: Bearer`. */\n apiKey?: string;\n /** Host app version (e.g. \"1.4.2\"), forwarded for release segmentation. Optional. */\n appVersion?: string;\n /** Tenant/app id — namespaces the first-open flag AND the hook's internal queue storage key. */\n appId?: string;\n /** Host storage (AsyncStorage subset). Enables the persisted once-ever first-open flag AND the\n * offline durability of the hook's internal queue. Omit it and both degrade to in-memory. */\n storage?: WireOnboardingStorage;\n}\n\n/** Per-open identity + wiring the host supplies. All optional: a pre-auth open is device-only. */\nexport interface UseLifecycleEventsOptions {\n /** The host's opaque pseudonymous user id (NOT PII). Omitted before the user authenticates. */\n userId?: string;\n /** The host's local open-counter value for this open. Drives `returning` + \"Nth session\". */\n sessionCount?: number;\n /** A stable, non-PII device id the host owns. Groups this device's sessions server-side. */\n deviceKey?: string;\n /** Small non-PII extras forwarded on the event `meta`. */\n meta?: Record<string, unknown>;\n /** Set `false` to disable firing (e.g. behind a consent gate). Default enabled. */\n enabled?: boolean;\n /**\n * Explicit transport sink (e.g. an existing shared `EventQueue.enqueue`). When provided, BOTH\n * lifecycle events route here and the hook does NOT create its own queue — pass this to share ONE\n * offline queue across the kit's analytics (screen tracking + lifecycle).\n */\n sink?: (event: ClientEvent) => void;\n /**\n * Context envelope (or provider) for the hook's internally-created queue. Ignored when `sink` is\n * supplied (the host's queue owns envelope stamping).\n */\n envelope?: EnvelopeSource;\n}\n\n/**\n * Fire `app.first_open` (once ever) + `app.session_started` (per open), offline-buffered. Returns\n * nothing — a side-effecting hook. Safe to call with inline options (read through a ref, so\n * changing `userId`/`sessionCount` never re-fires a session).\n */\nexport const useLifecycleEvents = (\n config: LifecycleConfig | undefined,\n options: UseLifecycleEventsOptions = {},\n): void => {\n // Latest options/config through a ref so the mount/resume fires read fresh values without listing\n // them as effect deps (which would re-fire a session on every prop change).\n const latest = useRef({ config, options });\n latest.current = { config, options };\n\n // The resolved sink is created at most once and reused for every fire this mount.\n const queueRef = useRef<EventQueue | undefined>(undefined);\n\n useEffect(() => {\n const resolveSink = (): ((event: ClientEvent) => void) | undefined => {\n const { config: cfg, options: opts } = latest.current;\n // Host-owned shared queue wins — one queue across the whole kit.\n if (opts.sink) return opts.sink;\n // No transport → no sink (events no-op rather than buffer forever against a dead target).\n if (!cfg?.serverUrl) return undefined;\n if (!queueRef.current) {\n queueRef.current = createEventQueue({\n target: { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" },\n storage: cfg.storage,\n // Dedicated key so the hook's internal queue never collides with a host's main queue.\n storageKey: `wireai:evtq:lifecycle:${cfg.appId ?? \"default\"}`,\n envelope: opts.envelope,\n });\n }\n return queueRef.current.enqueue;\n };\n\n const targetOf = (cfg: LifecycleConfig | undefined): ClientEventTarget | undefined =>\n cfg?.serverUrl ? { serverUrl: cfg.serverUrl, apiKey: cfg.apiKey ?? \"\" } : undefined;\n\n // ONE per-open session id for the MOUNT open, shared by first_open AND session_started below.\n // WHY: `first_open` used to default to its OWN fresh `makeSessionId()` (via `buildLifecycleEvent`)\n // while `session_started` minted a different one — so every install's `first_open` carried a\n // session id the server never got a `session_started` for (a PHANTOM session the server\n // back-filled). Minting one id here and handing it to both makes them agree, so the server sees\n // `first_open` under the same session it saw `session_started` for. A later foreground open\n // (below) mints its OWN fresh id — a new open is a new session.\n const mountOpenSessionId = makeSessionId();\n\n // session_start — the EXISTING emitter routed through the sink (offline-buffered, one guard).\n // Accepts the per-open id so the mount open reuses `mountOpenSessionId`; omit it and the emitter\n // mints a fresh id (a genuinely new open). Either way the once-guard dedupes within the open.\n const fireSession = (sessionId?: string) => {\n const { config: cfg, options: opts } = latest.current;\n if (opts.enabled === false) return;\n if (!cfg?.serverUrl && !opts.sink) return;\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg?.appVersion) device.appVersion = cfg.appVersion;\n reportSessionStart({\n target: targetOf(cfg),\n sink: resolveSink(),\n sessionId,\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg?.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n };\n\n // 1) session_start FIRST (mount = an app-open), so the server has ingested `session_started`\n // for `mountOpenSessionId` before first_open references the same id.\n fireSession(mountOpenSessionId);\n\n // 2) first_open — once ever (persisted flag + in-memory latch inside reportFirstOpen), pinned to\n // the SAME per-open id so it is never a phantom session.\n {\n const { config: cfg, options: opts } = latest.current;\n if (opts.enabled !== false) {\n const device = collectDeviceContext();\n // `device.appVersion` is auto-detected best-effort; an explicit host version always wins.\n if (cfg?.appVersion) device.appVersion = cfg.appVersion;\n reportFirstOpen({\n target: targetOf(cfg),\n sink: resolveSink(),\n sessionId: mountOpenSessionId,\n storage: cfg?.storage,\n appId: cfg?.appId,\n userId: opts.userId,\n deviceKey: opts.deviceKey,\n sessionCount: opts.sessionCount,\n appVersion: cfg?.appVersion ?? device.appVersion,\n platform: Platform.OS,\n device,\n meta: opts.meta,\n });\n }\n }\n\n // Foreground after a real background = a new app-open.\n let backgroundedAt: number | null = null;\n const onChange = (state: AppStateStatus) => {\n if (state === \"background\" || state === \"inactive\") {\n if (backgroundedAt == null) backgroundedAt = Date.now();\n return;\n }\n if (state === \"active\") {\n const since = backgroundedAt;\n backgroundedAt = null;\n if (since != null && Date.now() - since >= BACKGROUND_SESSION_MS) fireSession();\n }\n };\n const sub = AppState.addEventListener(\"change\", onChange);\n return () => {\n // RN >= 0.65 returns a subscription with remove(); guard for older shims.\n if (sub && typeof (sub as { remove?: () => void }).remove === \"function\") sub.remove();\n };\n // Mount-only effect: firing reads fresh values via `latest`, so no reactive deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n"]}
|