@wireai/activation 0.13.2 → 0.13.3

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.
Files changed (69) hide show
  1. package/AGENTS.md +4 -3
  2. package/CHANGELOG.md +228 -4
  3. package/README.md +16 -2
  4. package/dist/analytics/index.d.mts +4 -4
  5. package/dist/analytics/index.d.ts +4 -4
  6. package/dist/analytics/index.js +104 -470
  7. package/dist/analytics/index.js.map +1 -1
  8. package/dist/analytics/index.mjs +102 -468
  9. package/dist/analytics/index.mjs.map +1 -1
  10. package/dist/coachmarks/index.d.mts +14 -1
  11. package/dist/coachmarks/index.d.ts +14 -1
  12. package/dist/coachmarks/index.js +58 -14
  13. package/dist/coachmarks/index.js.map +1 -1
  14. package/dist/coachmarks/index.mjs +58 -14
  15. package/dist/coachmarks/index.mjs.map +1 -1
  16. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-BoWtr3Jp.d.mts} +2 -2
  17. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-CCOMlaQ2.d.ts} +2 -2
  18. package/dist/{decision-Bl_M2y3r.d.mts → decision-Cjw0jbEj.d.mts} +1 -1
  19. package/dist/{decision-Cau5KmP6.d.ts → decision-GfpXAsk_.d.ts} +1 -1
  20. package/dist/index.d.mts +25 -2
  21. package/dist/index.d.ts +25 -2
  22. package/dist/index.js +220 -573
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +217 -570
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/questionnaire/index.d.mts +42 -10
  27. package/dist/questionnaire/index.d.ts +42 -10
  28. package/dist/questionnaire/index.js +45 -13
  29. package/dist/questionnaire/index.js.map +1 -1
  30. package/dist/questionnaire/index.mjs +45 -13
  31. package/dist/questionnaire/index.mjs.map +1 -1
  32. package/dist/reviews/index.d.mts +4 -4
  33. package/dist/reviews/index.d.ts +4 -4
  34. package/dist/reviews/index.js +27 -7
  35. package/dist/reviews/index.js.map +1 -1
  36. package/dist/reviews/index.mjs +27 -7
  37. package/dist/reviews/index.mjs.map +1 -1
  38. package/dist/showcase/index.js +7 -2
  39. package/dist/showcase/index.js.map +1 -1
  40. package/dist/showcase/index.mjs +7 -2
  41. package/dist/showcase/index.mjs.map +1 -1
  42. package/dist/{transport-DsRe4epC.d.ts → transport-CefdERPs.d.mts} +44 -5
  43. package/dist/{transport-CF_eHwzC.d.mts → transport-DFuPyCoJ.d.ts} +44 -5
  44. package/dist/{types-Buj9Lw9t.d.ts → types-UVYt9BJe.d.ts} +41 -1
  45. package/dist/{types-CNUqMK0D.d.mts → types-l2tfg23P.d.mts} +41 -1
  46. package/package.json +4 -1
  47. package/src/OnboardingFlow.tsx +44 -15
  48. package/src/WireOnboarding.tsx +7 -6
  49. package/src/activation/wireActivation.ts +3 -3
  50. package/src/analytics/analyticsFacade.ts +2 -2
  51. package/src/analytics/eventQueue.ts +83 -20
  52. package/src/cards/CardGridSelectCard.tsx +1 -1
  53. package/src/cards/ChipSelectCard.tsx +2 -2
  54. package/src/cards/SelectionCard.tsx +1 -1
  55. package/src/coachmarks/runtime.ts +62 -2
  56. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  57. package/src/context/deviceId.ts +4 -4
  58. package/src/features/WireFeaturesProvider.tsx +4 -1
  59. package/src/identity/userIdentity.ts +1 -1
  60. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  61. package/src/questionnaire/index.ts +9 -1
  62. package/src/questionnaire/transport.ts +46 -11
  63. package/src/reviews/ReviewGate.tsx +61 -6
  64. package/src/reviews/index.ts +10 -1
  65. package/src/reviews/transport.ts +58 -12
  66. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  67. package/src/theme/ThemeContext.tsx +42 -1
  68. package/src/types.ts +1 -1
  69. package/src/utils/submitResult.ts +39 -0
package/dist/index.mjs CHANGED
@@ -1,406 +1,21 @@
1
- import { StyleSheet, Easing, Animated, BackHandler, Modal, Pressable, Text, View, TouchableOpacity, KeyboardAvoidingView, ScrollView, useWindowDimensions, TextInput, Image, AccessibilityInfo, Platform, Dimensions, I18nManager, AppState, NativeModules, TurboModuleRegistry } from 'react-native';
2
1
  import React19, { createContext, forwardRef, useRef, useState, useEffect, useCallback, useImperativeHandle, useMemo, useContext, useSyncExternalStore } from 'react';
3
2
  import { useWireAIThread, useWireAIAction, ComponentRenderer, WireAIProvider } from 'wireai-rn';
4
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
+ import { StyleSheet, Easing, Animated, BackHandler, Modal, Pressable, Text, View, TouchableOpacity, KeyboardAvoidingView, ScrollView, useWindowDimensions, TextInput, Image, AccessibilityInfo, Platform, Dimensions, I18nManager, AppState } from 'react-native';
5
5
  import { SafeAreaView } from 'react-native-safe-area-context';
6
6
  import { z } from 'zod';
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
9
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
13
10
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
14
11
  }) : x)(function(x) {
15
12
  if (typeof require !== "undefined") return require.apply(this, arguments);
16
13
  throw Error('Dynamic require of "' + x + '" is not supported');
17
14
  });
18
- var __esm = (fn, res) => function __init() {
19
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
20
- };
21
15
  var __export = (target, all) => {
22
- for (var name2 in all)
23
- __defProp(target, name2, { get: all[name2], enumerable: true });
24
- };
25
- var __copyProps = (to, from, except, desc) => {
26
- if (from && typeof from === "object" || typeof from === "function") {
27
- for (let key of __getOwnPropNames(from))
28
- if (!__hasOwnProp.call(to, key) && key !== except)
29
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
- }
31
- return to;
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
32
18
  };
33
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
-
35
- // node_modules/expo-modules-core/src/errors/CodedError.ts
36
- var CodedError;
37
- var init_CodedError = __esm({
38
- "node_modules/expo-modules-core/src/errors/CodedError.ts"() {
39
- CodedError = class extends Error {
40
- constructor(code, message) {
41
- super(message);
42
- this.code = code;
43
- }
44
- };
45
- }
46
- });
47
-
48
- // node_modules/expo-modules-core/src/NativeModulesProxy.ts
49
- var NativeModulesProxy_default;
50
- var init_NativeModulesProxy = __esm({
51
- "node_modules/expo-modules-core/src/NativeModulesProxy.ts"() {
52
- NativeModulesProxy_default = {};
53
- }
54
- });
55
-
56
- // node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts
57
- function createTurboModuleToExpoProxy(turboModule, name2) {
58
- return null;
59
- }
60
- var init_TurboModuleToExpoModuleProxy = __esm({
61
- "node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts"() {
62
- }
63
- });
64
- var init_ensureNativeModulesAreInstalled = __esm({
65
- "node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts"() {
66
- }
67
- });
68
- function requireOptionalNativeModule(moduleName) {
69
- var _a2, _b, _c, _d, _e;
70
- try {
71
- return (_e = (_d = (_c = (_b = (_a2 = globalThis.expo) == null ? void 0 : _a2.modules) == null ? void 0 : _b[moduleName]) != null ? _c : NativeModulesProxy_default[moduleName]) != null ? _d : createTurboModuleToExpoProxy(TurboModuleRegistry.get(moduleName), moduleName)) != null ? _e : null;
72
- } catch (e) {
73
- const error = e;
74
- console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);
75
- return null;
76
- }
77
- }
78
- var init_requireNativeModule = __esm({
79
- "node_modules/expo-modules-core/src/requireNativeModule.ts"() {
80
- init_NativeModulesProxy();
81
- init_TurboModuleToExpoModuleProxy();
82
- init_ensureNativeModulesAreInstalled();
83
- }
84
- });
85
-
86
- // node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts
87
- var init_setUpJsLogger_fx = __esm({
88
- "node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts"() {
89
- init_CodedError();
90
- init_requireNativeModule();
91
- if (__DEV__ && typeof window !== "undefined" && (process.env.EXPO_OS === "android" || process.env.EXPO_OS === "ios")) {
92
- const NativeJSLogger = requireOptionalNativeModule("ExpoModulesCoreJSLogger");
93
- if (NativeJSLogger) {
94
- const onNewException = {
95
- eventName: "ExpoModulesCoreJSLogger.onNewError",
96
- action: console.error
97
- };
98
- const onNewWarning = {
99
- eventName: "ExpoModulesCoreJSLogger.onNewWarning",
100
- action: console.warn
101
- };
102
- const onNewDebug = {
103
- eventName: "ExpoModulesCoreJSLogger.onNewDebug",
104
- action: console.debug
105
- };
106
- const onNewInfo = {
107
- eventName: "ExpoModulesCoreJSLogger.onNewInfo",
108
- action: console.info
109
- };
110
- const onNewTrace = {
111
- eventName: "ExpoModulesCoreJSLogger.onNewTrace",
112
- action: console.trace
113
- };
114
- const listeners = [
115
- onNewException,
116
- onNewWarning,
117
- onNewDebug,
118
- onNewInfo,
119
- onNewTrace
120
- ];
121
- for (const listener of listeners) {
122
- NativeJSLogger.addListener(listener.eventName, ({ message }) => {
123
- listener.action(message);
124
- });
125
- }
126
- }
127
- }
128
- globalThis.ExpoModulesCore_CodedError = CodedError;
129
- }
130
- });
131
-
132
- // node_modules/expo-modules-core/src/registerWebModule.ts
133
- var init_registerWebModule = __esm({
134
- "node_modules/expo-modules-core/src/registerWebModule.ts"() {
135
- }
136
- });
137
-
138
- // node_modules/expo-modules-core/src/TypedArrays.types.ts
139
- var init_TypedArrays_types = __esm({
140
- "node_modules/expo-modules-core/src/TypedArrays.types.ts"() {
141
- }
142
- });
143
-
144
- // node_modules/expo-modules-core/src/PermissionsInterface.ts
145
- var init_PermissionsInterface = __esm({
146
- "node_modules/expo-modules-core/src/PermissionsInterface.ts"() {
147
- }
148
- });
149
- var init_PermissionsHook = __esm({
150
- "node_modules/expo-modules-core/src/PermissionsHook.ts"() {
151
- "use client";
152
- }
153
- });
154
- var init_Refs = __esm({
155
- "node_modules/expo-modules-core/src/Refs.ts"() {
156
- }
157
- });
158
- var init_useReleasingSharedObject = __esm({
159
- "node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts"() {
160
- "use client";
161
- }
162
- });
163
-
164
- // node_modules/expo-modules-core/src/reload.ts
165
- var init_reload = __esm({
166
- "node_modules/expo-modules-core/src/reload.ts"() {
167
- }
168
- });
169
-
170
- // node_modules/expo-modules-core/src/index.ts
171
- var init_src = __esm({
172
- "node_modules/expo-modules-core/src/index.ts"() {
173
- init_setUpJsLogger_fx();
174
- init_requireNativeModule();
175
- init_registerWebModule();
176
- init_TypedArrays_types();
177
- init_PermissionsInterface();
178
- init_PermissionsHook();
179
- init_Refs();
180
- init_useReleasingSharedObject();
181
- init_reload();
182
- init_CodedError();
183
- }
184
- });
185
-
186
- // node_modules/expo-constants/build/Constants.types.js
187
- var AppOwnership, ExecutionEnvironment, UserInterfaceIdiom;
188
- var init_Constants_types = __esm({
189
- "node_modules/expo-constants/build/Constants.types.js"() {
190
- (function(AppOwnership2) {
191
- AppOwnership2["Expo"] = "expo";
192
- })(AppOwnership || (AppOwnership = {}));
193
- (function(ExecutionEnvironment2) {
194
- ExecutionEnvironment2["Bare"] = "bare";
195
- ExecutionEnvironment2["Standalone"] = "standalone";
196
- ExecutionEnvironment2["StoreClient"] = "storeClient";
197
- })(ExecutionEnvironment || (ExecutionEnvironment = {}));
198
- (function(UserInterfaceIdiom2) {
199
- UserInterfaceIdiom2["Handset"] = "handset";
200
- UserInterfaceIdiom2["Tablet"] = "tablet";
201
- UserInterfaceIdiom2["Desktop"] = "desktop";
202
- UserInterfaceIdiom2["TV"] = "tv";
203
- UserInterfaceIdiom2["Unsupported"] = "unsupported";
204
- })(UserInterfaceIdiom || (UserInterfaceIdiom = {}));
205
- }
206
- });
207
-
208
- // node_modules/expo-constants/build/ExponentConstants.js
209
- var ExponentConstants_default;
210
- var init_ExponentConstants = __esm({
211
- "node_modules/expo-constants/build/ExponentConstants.js"() {
212
- init_src();
213
- ExponentConstants_default = requireOptionalNativeModule("ExponentConstants");
214
- }
215
- });
216
-
217
- // node_modules/expo-constants/build/Constants.js
218
- var Constants_exports = {};
219
- __export(Constants_exports, {
220
- AppOwnership: () => AppOwnership,
221
- ExecutionEnvironment: () => ExecutionEnvironment,
222
- UserInterfaceIdiom: () => UserInterfaceIdiom,
223
- default: () => Constants_default
224
- });
225
- function isEmbeddedManifest(manifest) {
226
- return !isExpoUpdatesManifest(manifest);
227
- }
228
- function isExpoUpdatesManifest(manifest) {
229
- return "metadata" in manifest;
230
- }
231
- function getManifest(suppressWarning = false) {
232
- if (!rawManifest) {
233
- const invalidManifestType = rawManifest === null ? "null" : "undefined";
234
- if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && Platform.OS !== "web") {
235
- if (!suppressWarning) {
236
- console.warn(`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.`);
237
- }
238
- } else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {
239
- throw new CodedError("ERR_CONSTANTS_MANIFEST_UNAVAILABLE", `Constants.manifest is ${invalidManifestType}, must be an object.`);
240
- }
241
- }
242
- return rawManifest;
243
- }
244
- var ExpoUpdates, rawUpdatesManifest, rawDevLauncherManifest, rawAppConfig, _a, rawManifest, name, appOwnership, nativeConstants, constants, Constants_default;
245
- var init_Constants = __esm({
246
- "node_modules/expo-constants/build/Constants.js"() {
247
- init_src();
248
- init_Constants_types();
249
- init_ExponentConstants();
250
- init_Constants_types();
251
- if (!ExponentConstants_default) {
252
- console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");
253
- }
254
- ExpoUpdates = requireOptionalNativeModule("ExpoUpdates");
255
- rawUpdatesManifest = null;
256
- if (ExpoUpdates) {
257
- let updatesManifest;
258
- if (ExpoUpdates.manifest) {
259
- updatesManifest = ExpoUpdates.manifest;
260
- } else if (ExpoUpdates.manifestString) {
261
- updatesManifest = JSON.parse(ExpoUpdates.manifestString);
262
- }
263
- if (updatesManifest && Object.keys(updatesManifest).length > 0) {
264
- rawUpdatesManifest = updatesManifest;
265
- }
266
- }
267
- rawDevLauncherManifest = null;
268
- if (NativeModules.EXDevLauncher) {
269
- let devLauncherManifest;
270
- if (NativeModules.EXDevLauncher.manifestString) {
271
- devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);
272
- }
273
- if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {
274
- rawDevLauncherManifest = devLauncherManifest;
275
- }
276
- }
277
- rawAppConfig = null;
278
- if (ExponentConstants_default && ExponentConstants_default.manifest) {
279
- const appConfig = ExponentConstants_default.manifest;
280
- if (typeof appConfig === "string") {
281
- rawAppConfig = JSON.parse(appConfig);
282
- } else {
283
- rawAppConfig = appConfig;
284
- }
285
- }
286
- rawManifest = (_a = rawUpdatesManifest != null ? rawUpdatesManifest : rawDevLauncherManifest) != null ? _a : rawAppConfig;
287
- ({ name, appOwnership, ...nativeConstants } = ExponentConstants_default || {});
288
- constants = {
289
- ...nativeConstants,
290
- // Ensure this is null in bare workflow
291
- appOwnership: appOwnership != null ? appOwnership : null
292
- };
293
- Object.defineProperties(constants, {
294
- /**
295
- * Use `manifest` property by default.
296
- * This property is only used for internal purposes.
297
- * It behaves similarly to the original one, but suppresses warning upon no manifest available.
298
- * `expo-asset` uses it to prevent users from seeing mentioned warning.
299
- */
300
- __unsafeNoWarnManifest: {
301
- get() {
302
- const maybeManifest = getManifest(true);
303
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
304
- return null;
305
- }
306
- return maybeManifest;
307
- },
308
- enumerable: false
309
- },
310
- __unsafeNoWarnManifest2: {
311
- get() {
312
- const maybeManifest = getManifest(true);
313
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
314
- return null;
315
- }
316
- return maybeManifest;
317
- },
318
- enumerable: false
319
- },
320
- manifest: {
321
- get() {
322
- const maybeManifest = getManifest();
323
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
324
- return null;
325
- }
326
- return maybeManifest;
327
- },
328
- enumerable: true
329
- },
330
- manifest2: {
331
- get() {
332
- const maybeManifest = getManifest();
333
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
334
- return null;
335
- }
336
- return maybeManifest;
337
- },
338
- enumerable: true
339
- },
340
- expoConfig: {
341
- get() {
342
- var _a2, _b;
343
- const maybeManifest = getManifest(true);
344
- if (!maybeManifest) {
345
- return null;
346
- }
347
- if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {
348
- return rawAppConfig;
349
- }
350
- if (isExpoUpdatesManifest(maybeManifest)) {
351
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoClient) != null ? _b : null;
352
- } else if (isEmbeddedManifest(maybeManifest)) {
353
- return maybeManifest;
354
- }
355
- return null;
356
- },
357
- enumerable: true
358
- },
359
- expoGoConfig: {
360
- get() {
361
- var _a2, _b;
362
- const maybeManifest = getManifest(true);
363
- if (!maybeManifest) {
364
- return null;
365
- }
366
- if (isExpoUpdatesManifest(maybeManifest)) {
367
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoGo) != null ? _b : null;
368
- } else if (isEmbeddedManifest(maybeManifest)) {
369
- return maybeManifest;
370
- }
371
- return null;
372
- },
373
- enumerable: true
374
- },
375
- easConfig: {
376
- get() {
377
- var _a2, _b;
378
- const maybeManifest = getManifest(true);
379
- if (!maybeManifest) {
380
- return null;
381
- }
382
- if (isExpoUpdatesManifest(maybeManifest)) {
383
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.eas) != null ? _b : null;
384
- } else if (isEmbeddedManifest(maybeManifest)) {
385
- return maybeManifest;
386
- }
387
- return null;
388
- },
389
- enumerable: true
390
- },
391
- __rawManifest_TEST: {
392
- get() {
393
- return rawManifest;
394
- },
395
- set(value) {
396
- rawManifest = value;
397
- },
398
- enumerable: false
399
- }
400
- });
401
- Constants_default = constants;
402
- }
403
- });
404
19
 
405
20
  // src/theme/defaultTheme.ts
406
21
  var defaultOnboardingTheme = {
@@ -458,7 +73,12 @@ var mergeTheme = (override) => {
458
73
  button: { ...defaultOnboardingTheme.button, ...override.button }
459
74
  };
460
75
  };
461
- var OnboardingThemeContext = createContext(null);
76
+ var THEME_CONTEXT_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:themeContext");
77
+ var themeGlobal = globalThis;
78
+ if (!themeGlobal[THEME_CONTEXT_SLOT]) {
79
+ themeGlobal[THEME_CONTEXT_SLOT] = createContext(null);
80
+ }
81
+ var OnboardingThemeContext = themeGlobal[THEME_CONTEXT_SLOT];
462
82
  var OnboardingThemeProvider = ({
463
83
  theme,
464
84
  children
@@ -479,10 +99,10 @@ var IllustrationProvider = ({
479
99
  const value = useMemo(() => registry != null ? registry : EMPTY_REGISTRY, [registry]);
480
100
  return /* @__PURE__ */ jsx(IllustrationContext.Provider, { value, children });
481
101
  };
482
- var useIllustration = (name2) => {
102
+ var useIllustration = (name) => {
483
103
  const registry = useContext(IllustrationContext);
484
- if (!name2) return void 0;
485
- return registry[name2];
104
+ if (!name) return void 0;
105
+ return registry[name];
486
106
  };
487
107
  var Disc = ({ children }) => {
488
108
  const t = useOnboardingTheme();
@@ -581,11 +201,11 @@ var IconRegistryProvider = ({
581
201
  const value = useMemo(() => registry != null ? registry : EMPTY_REGISTRY2, [registry]);
582
202
  return /* @__PURE__ */ jsx(IconContext.Provider, { value, children });
583
203
  };
584
- var useHostIcon = (name2) => {
204
+ var useHostIcon = (name) => {
585
205
  const registry = useContext(IconContext);
586
- if (!name2) return void 0;
587
- if (!Object.prototype.hasOwnProperty.call(registry, name2)) return void 0;
588
- return registry[name2];
206
+ if (!name) return void 0;
207
+ if (!Object.prototype.hasOwnProperty.call(registry, name)) return void 0;
208
+ return registry[name];
589
209
  };
590
210
 
591
211
  // src/theme/typography.ts
@@ -601,9 +221,9 @@ var captionStyle = (f) => ({
601
221
  lineHeight: round(f.baseSize * 0.8125 * f.scale * 1.5)
602
222
  });
603
223
  var labelStyle = (f) => {
604
- var _a2;
224
+ var _a;
605
225
  return {
606
- fontFamily: (_a2 = f.medium) != null ? _a2 : f.bold,
226
+ fontFamily: (_a = f.medium) != null ? _a : f.bold,
607
227
  fontSize: round(f.baseSize * f.scale),
608
228
  lineHeight: round(f.baseSize * f.scale * 1.4),
609
229
  fontWeight: f.medium ? void 0 : "600"
@@ -616,9 +236,9 @@ var headingStyle = (f) => ({
616
236
  fontWeight: f.bold ? void 0 : "700"
617
237
  });
618
238
  var buttonLabelStyle = (f) => {
619
- var _a2;
239
+ var _a;
620
240
  return {
621
- fontFamily: (_a2 = f.bold) != null ? _a2 : f.medium,
241
+ fontFamily: (_a = f.bold) != null ? _a : f.medium,
622
242
  fontSize: round(f.baseSize * f.scale),
623
243
  fontWeight: f.bold ? void 0 : "600"
624
244
  };
@@ -1367,7 +987,7 @@ var _CardHandoff = ({
1367
987
  const running = useRef({});
1368
988
  const mounted = useRef(false);
1369
989
  useEffect(() => {
1370
- var _a2, _b;
990
+ var _a, _b;
1371
991
  const last = prev.current;
1372
992
  prev.current = { key: transitionKey, node: children, variant };
1373
993
  if (!mounted.current) {
@@ -1376,7 +996,7 @@ var _CardHandoff = ({
1376
996
  return;
1377
997
  }
1378
998
  if (last.key === transitionKey) return;
1379
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
999
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1380
1000
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1381
1001
  setLeaving(last);
1382
1002
  enterT.setValue(0);
@@ -1401,8 +1021,8 @@ var _CardHandoff = ({
1401
1021
  });
1402
1022
  useEffect(
1403
1023
  () => () => {
1404
- var _a2, _b;
1405
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
1024
+ var _a, _b;
1025
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1406
1026
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1407
1027
  },
1408
1028
  []
@@ -1483,13 +1103,13 @@ var tryParse = (s) => {
1483
1103
  }
1484
1104
  };
1485
1105
  var deriveAnswers = (messages) => {
1486
- var _a2, _b, _c;
1106
+ var _a, _b, _c;
1487
1107
  const out = {};
1488
1108
  for (let i = 0; i < messages.length; i++) {
1489
1109
  const m = messages[i];
1490
1110
  const r = m == null ? void 0 : m.response;
1491
1111
  if (!m || m.role !== "assistant" || !r || r.action !== "render") continue;
1492
- const props = (_a2 = r.props) != null ? _a2 : {};
1112
+ const props = (_a = r.props) != null ? _a : {};
1493
1113
  const progress = props.progress;
1494
1114
  const questionText = (_c = (_b = props.title) != null ? _b : props.label) != null ? _c : props.question;
1495
1115
  const key = (progress == null ? void 0 : progress.slot_id) || (progress == null ? void 0 : progress.key) || questionText;
@@ -1503,9 +1123,9 @@ var deriveAnswers = (messages) => {
1503
1123
 
1504
1124
  // src/utils/readProgress.ts
1505
1125
  var readProgress = (response) => {
1506
- var _a2;
1126
+ var _a;
1507
1127
  if (!response || response.action !== "render") return {};
1508
- const props = (_a2 = response.props) != null ? _a2 : {};
1128
+ const props = (_a = response.props) != null ? _a : {};
1509
1129
  const raw = props.progress;
1510
1130
  if (!raw || typeof raw !== "object") return {};
1511
1131
  const p = raw;
@@ -1746,10 +1366,10 @@ var _PermissionCard = ({
1746
1366
  getStatusRef.current = getStatus;
1747
1367
  const shownRef = useRef(false);
1748
1368
  useEffect(() => {
1749
- var _a2;
1369
+ var _a;
1750
1370
  if (shownRef.current) return;
1751
1371
  shownRef.current = true;
1752
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "shown");
1372
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "shown");
1753
1373
  }, []);
1754
1374
  useEffect(() => {
1755
1375
  const probe = getStatusRef.current;
@@ -1775,18 +1395,18 @@ var _PermissionCard = ({
1775
1395
  );
1776
1396
  }, [permission]);
1777
1397
  const settle = useCallback((outcome) => {
1778
- var _a2;
1398
+ var _a;
1779
1399
  if (settledRef.current) return;
1780
1400
  settledRef.current = true;
1781
1401
  clearWatchdog();
1782
- (_a2 = onSettledRef.current) == null ? void 0 : _a2.call(onSettledRef, outcome);
1402
+ (_a = onSettledRef.current) == null ? void 0 : _a.call(onSettledRef, outcome);
1783
1403
  }, [clearWatchdog]);
1784
1404
  const primaryAction = status === "blocked" ? "settings" : status === "granted" || !request ? "continue" : "ask";
1785
1405
  const handlePrimary = useCallback(() => {
1786
- var _a2, _b, _c, _d;
1406
+ var _a, _b, _c, _d;
1787
1407
  if (settledRef.current || busy) return;
1788
1408
  if (primaryAction === "settings") {
1789
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "settings", "blocked");
1409
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "settings", "blocked");
1790
1410
  try {
1791
1411
  void Promise.resolve(openSettings == null ? void 0 : openSettings()).catch(() => {
1792
1412
  });
@@ -1811,7 +1431,7 @@ var _PermissionCard = ({
1811
1431
  }
1812
1432
  setBusy(true);
1813
1433
  const finish = (value) => {
1814
- var _a3, _b2;
1434
+ var _a2, _b2;
1815
1435
  if (settledRef.current) return;
1816
1436
  clearWatchdog();
1817
1437
  const resolved = normalizePermissionStatus(value);
@@ -1819,7 +1439,7 @@ var _PermissionCard = ({
1819
1439
  setStatus(resolved);
1820
1440
  if (resolved === "granted") {
1821
1441
  playHaptic("success");
1822
- (_a3 = onStageRef.current) == null ? void 0 : _a3.call(onStageRef, "granted", "granted");
1442
+ (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "granted", "granted");
1823
1443
  } else {
1824
1444
  (_b2 = onStageRef.current) == null ? void 0 : _b2.call(onStageRef, "denied", resolved);
1825
1445
  }
@@ -1841,9 +1461,9 @@ var _PermissionCard = ({
1841
1461
  }
1842
1462
  }, [busy, primaryAction, status, request, openSettings, settle, clearWatchdog, permission]);
1843
1463
  const handleSecondary = useCallback(() => {
1844
- var _a2;
1464
+ var _a;
1845
1465
  if (settledRef.current || busy) return;
1846
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "skipped");
1466
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "skipped");
1847
1467
  settle("skipped");
1848
1468
  }, [busy, settle]);
1849
1469
  const popT = useRef(new Animated.Value(reduced ? 1 : 0)).current;
@@ -1949,18 +1569,18 @@ var isPermissionDue = (placement, position) => {
1949
1569
  return position.cardIndex >= target || position.isTerminal;
1950
1570
  };
1951
1571
  var permissionScreenId = (screen, index) => {
1952
- var _a2;
1953
- return (_a2 = screen.id) != null ? _a2 : `${screen.permission}:${index}`;
1572
+ var _a;
1573
+ return (_a = screen.id) != null ? _a : `${screen.permission}:${index}`;
1954
1574
  };
1955
1575
  var selectDuePermissionScreen = (screens, settled, position) => {
1956
- var _a2;
1576
+ var _a;
1957
1577
  if (!screens || screens.length === 0) return void 0;
1958
1578
  for (let index = 0; index < screens.length; index++) {
1959
1579
  const screen = screens[index];
1960
1580
  if (!screen) continue;
1961
1581
  const id = permissionScreenId(screen, index);
1962
1582
  if (settled.includes(id)) continue;
1963
- if (isPermissionDue((_a2 = screen.placement) != null ? _a2 : DEFAULT_PERMISSION_PLACEMENT, position)) {
1583
+ if (isPermissionDue((_a = screen.placement) != null ? _a : DEFAULT_PERMISSION_PLACEMENT, position)) {
1964
1584
  return { screen, id };
1965
1585
  }
1966
1586
  }
@@ -1992,8 +1612,8 @@ var DEFAULT_PERMISSION_COPY = {
1992
1612
  notifications: NOTIFICATIONS_PERMISSION_COPY
1993
1613
  };
1994
1614
  var resolvePermissionCopy = (permission, overrides) => {
1995
- var _a2;
1996
- const base = (_a2 = DEFAULT_PERMISSION_COPY[permission]) != null ? _a2 : GENERIC_PERMISSION_COPY;
1615
+ var _a;
1616
+ const base = (_a = DEFAULT_PERMISSION_COPY[permission]) != null ? _a : GENERIC_PERMISSION_COPY;
1997
1617
  if (!overrides) return base;
1998
1618
  const merged = { ...base };
1999
1619
  for (const key of Object.keys(overrides)) {
@@ -2036,7 +1656,7 @@ var OnboardingFlow = ({
2036
1656
  permissionsPending = false,
2037
1657
  onPermissionSettled
2038
1658
  }) => {
2039
- var _a2, _b, _c, _d, _e, _f;
1659
+ var _a, _b, _c, _d, _e, _f;
2040
1660
  const { messages, error, isLoading, sendMessage, reset } = useWireAIThread();
2041
1661
  const makeActions = useWireAIAction(sendMessage);
2042
1662
  const c = useMemo(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);
@@ -2056,7 +1676,8 @@ var OnboardingFlow = ({
2056
1676
  clientContextRef.current = clientContext;
2057
1677
  const lastScreenIndexRef = useRef(-1);
2058
1678
  const previewTimer = useRef(null);
2059
- const started = useRef(false);
1679
+ const [runId, setRunId] = useState(0);
1680
+ const startedRunRef = useRef(-1);
2060
1681
  const finished = useRef(false);
2061
1682
  const errored = useRef(false);
2062
1683
  const attempts = useRef(0);
@@ -2070,39 +1691,41 @@ var OnboardingFlow = ({
2070
1691
  onPermissionSettledRef.current = onPermissionSettled;
2071
1692
  const lastCard = useMemo(
2072
1693
  () => [...messages].reverse().find((m) => {
2073
- var _a3;
2074
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1694
+ var _a2;
1695
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2075
1696
  }),
2076
1697
  [messages]
2077
1698
  );
2078
1699
  const renderedCount = useMemo(
2079
1700
  () => messages.filter((m) => {
2080
- var _a3;
2081
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1701
+ var _a2;
1702
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2082
1703
  }).length,
2083
1704
  [messages]
2084
1705
  );
2085
1706
  const progress = useMemo(() => readProgress(lastCard == null ? void 0 : lastCard.response), [lastCard]);
2086
1707
  useEffect(() => {
2087
- var _a3;
2088
- if (started.current) return;
2089
- started.current = true;
2090
- sendMessage(resumed ? SKIP_ONE_SENTINEL : startMessage);
2091
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(
1708
+ var _a2;
1709
+ if (startedRunRef.current === runId) return;
1710
+ const isFirstRun = startedRunRef.current < 0;
1711
+ startedRunRef.current = runId;
1712
+ sendMessage(isFirstRun && !resumed ? startMessage : SKIP_ONE_SENTINEL);
1713
+ if (!isFirstRun) return;
1714
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(
2092
1715
  onEventRef,
2093
1716
  resumed ? { type: "resumed", contextId: sessionId } : { type: "started", contextId: sessionId }
2094
1717
  );
2095
- }, [sendMessage, startMessage, resumed, sessionId]);
1718
+ }, [sendMessage, startMessage, resumed, sessionId, runId]);
2096
1719
  useEffect(() => {
2097
1720
  if (lastCard) return;
2098
1721
  const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);
2099
1722
  return () => clearTimeout(timer);
2100
- }, [lastCard, startTimeoutMs]);
1723
+ }, [lastCard, startTimeoutMs, runId]);
2101
1724
  useEffect(() => {
2102
- var _a3, _b2, _c2, _d2;
1725
+ var _a2, _b2, _c2, _d2;
2103
1726
  setValidationError(void 0);
2104
1727
  if (!(lastCard == null ? void 0 : lastCard.id)) return;
2105
- const step2 = (_a3 = progress.step) != null ? _a3 : renderedCount;
1728
+ const step2 = (_a2 = progress.step) != null ? _a2 : renderedCount;
2106
1729
  lastScreenIndexRef.current = Math.max(0, step2 - 1);
2107
1730
  (_c2 = onEventRef.current) == null ? void 0 : _c2.call(onEventRef, {
2108
1731
  type: "turn",
@@ -2118,13 +1741,13 @@ var OnboardingFlow = ({
2118
1741
  }, [lastCard == null ? void 0 : lastCard.id]);
2119
1742
  useEffect(() => {
2120
1743
  return () => {
2121
- var _a3, _b2, _c2;
1744
+ var _a2, _b2, _c2;
2122
1745
  if (finished.current || degradedRef.current) return;
2123
1746
  reportClientEvent(reportTargetRef.current, {
2124
1747
  event_type: "dropped",
2125
1748
  session_id: sessionIdRef.current,
2126
1749
  screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : void 0,
2127
- device: (_a3 = clientContextRef.current) == null ? void 0 : _a3.device,
1750
+ device: (_a2 = clientContextRef.current) == null ? void 0 : _a2.device,
2128
1751
  user_context: (_b2 = clientContextRef.current) == null ? void 0 : _b2.userContext,
2129
1752
  user_id: (_c2 = clientContextRef.current) == null ? void 0 : _c2.userId
2130
1753
  });
@@ -2132,17 +1755,17 @@ var OnboardingFlow = ({
2132
1755
  }, []);
2133
1756
  const restartThread = useCallback(() => {
2134
1757
  setTimedOut(false);
2135
- started.current = false;
2136
1758
  errored.current = false;
1759
+ setRunId((n) => n + 1);
2137
1760
  reset();
2138
1761
  }, [reset]);
2139
1762
  useEffect(() => {
2140
- var _a3, _b2, _c2, _d2, _e2, _f2, _g;
1763
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
2141
1764
  if (errored.current) return;
2142
1765
  if (!error && !timedOut) return;
2143
1766
  errored.current = true;
2144
1767
  const reason = error ? "backend" : "timeout";
2145
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "error", reason });
1768
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "error", reason });
2146
1769
  attempts.current += 1;
2147
1770
  if (attempts.current <= maxRetries) {
2148
1771
  (_b2 = onEventRef.current) == null ? void 0 : _b2.call(onEventRef, { type: "retry", reason, attempt: attempts.current });
@@ -2180,8 +1803,8 @@ var OnboardingFlow = ({
2180
1803
  }, [isLoading, sendMessage]);
2181
1804
  const emitPermissionStage = useCallback(
2182
1805
  (permission, stage, status) => {
2183
- var _a3, _b2, _c2, _d2;
2184
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "permission", permission, stage, status });
1806
+ var _a2, _b2, _c2, _d2;
1807
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "permission", permission, stage, status });
2185
1808
  reportClientEvent(reportTargetRef.current, {
2186
1809
  event_type: "app_event",
2187
1810
  session_id: sessionIdRef.current,
@@ -2198,9 +1821,9 @@ var OnboardingFlow = ({
2198
1821
  );
2199
1822
  const settlePermission = useCallback(
2200
1823
  (id, screen, outcome) => {
2201
- var _a3, _b2;
1824
+ var _a2, _b2;
2202
1825
  setLocallySettledPermissions((prev) => prev.includes(id) ? prev : [...prev, id]);
2203
- (_a3 = onPermissionSettledRef.current) == null ? void 0 : _a3.call(onPermissionSettledRef, id, outcome);
1826
+ (_a2 = onPermissionSettledRef.current) == null ? void 0 : _a2.call(onPermissionSettledRef, id, outcome);
2204
1827
  try {
2205
1828
  (_b2 = screen.onResult) == null ? void 0 : _b2.call(screen, screen.permission, outcome);
2206
1829
  } catch {
@@ -2225,26 +1848,26 @@ var OnboardingFlow = ({
2225
1848
  }, []);
2226
1849
  const wrappedActions = useCallback(
2227
1850
  (messageId) => {
2228
- var _a3;
1851
+ var _a2;
2229
1852
  const base = makeActions(messageId);
2230
1853
  const validators2 = validatorsRef.current;
2231
- const validator = (_a3 = progress.slot_id ? validators2 == null ? void 0 : validators2[progress.slot_id] : void 0) != null ? _a3 : progress.key ? validators2 == null ? void 0 : validators2[progress.key] : void 0;
1854
+ const validator = (_a2 = progress.slot_id ? validators2 == null ? void 0 : validators2[progress.slot_id] : void 0) != null ? _a2 : progress.key ? validators2 == null ? void 0 : validators2[progress.key] : void 0;
2232
1855
  if (!validator) return base;
2233
1856
  const out = { ...base };
2234
- for (const name2 of ANSWER_CALLBACKS) {
2235
- const original = base[name2];
1857
+ for (const name of ANSWER_CALLBACKS) {
1858
+ const original = base[name];
2236
1859
  if (!original) continue;
2237
- out[name2] = (...args) => {
1860
+ out[name] = (...args) => {
2238
1861
  const value = args[0];
2239
1862
  if (typeof value !== "string") return original(...args);
2240
1863
  setValidating(true);
2241
1864
  validator(value).then((res) => {
2242
- var _a4;
1865
+ var _a3;
2243
1866
  if (res.ok) {
2244
1867
  setValidationError(void 0);
2245
1868
  original(...args);
2246
1869
  } else {
2247
- setValidationError((_a4 = res.error) != null ? _a4 : "That value isn't available.");
1870
+ setValidationError((_a3 = res.error) != null ? _a3 : "That value isn't available.");
2248
1871
  }
2249
1872
  }).catch(() => {
2250
1873
  original(...args);
@@ -2275,7 +1898,7 @@ var OnboardingFlow = ({
2275
1898
  if (!lastCard || !response) {
2276
1899
  return /* @__PURE__ */ jsx(LoadingScreen, { title: c.startingTitle, hint: c.startingHint });
2277
1900
  }
2278
- const step = (_a2 = progress.step) != null ? _a2 : renderedCount;
1901
+ const step = (_a = progress.step) != null ? _a : renderedCount;
2279
1902
  const total = (_b = progress.total) != null ? _b : approxScreens;
2280
1903
  const isTerminal = response.action === "render" && response.component === "StatusCard";
2281
1904
  const duePermission = permissionsPending ? void 0 : selectDuePermissionScreen(
@@ -2800,13 +2423,13 @@ var WIRE_ICON_GLYPHS = {
2800
2423
  other: { family: "MaterialCommunityIcons", name: "dots-horizontal-circle" }
2801
2424
  };
2802
2425
  var WIRE_ICON_NAMES = Object.keys(WIRE_ICON_GLYPHS).sort();
2803
- var lookupIconGlyph = (name2) => {
2804
- if (!name2) return void 0;
2805
- if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name2)) return void 0;
2806
- return WIRE_ICON_GLYPHS[name2];
2426
+ var lookupIconGlyph = (name) => {
2427
+ if (!name) return void 0;
2428
+ if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return void 0;
2429
+ return WIRE_ICON_GLYPHS[name];
2807
2430
  };
2808
- var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2809
- const hostIcon = useHostIcon(name2);
2431
+ var _WireIcon = ({ name, size = 20, color, requireModule }) => {
2432
+ const hostIcon = useHostIcon(name);
2810
2433
  if (hostIcon) {
2811
2434
  return /* @__PURE__ */ jsx(
2812
2435
  View,
@@ -2818,7 +2441,7 @@ var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2818
2441
  }
2819
2442
  );
2820
2443
  }
2821
- const glyph = lookupIconGlyph(name2);
2444
+ const glyph = lookupIconGlyph(name);
2822
2445
  if (!glyph) return null;
2823
2446
  const Family = resolveIconFamily(glyph.family, requireModule);
2824
2447
  if (!Family) return null;
@@ -3231,7 +2854,7 @@ var STATUS_ICONS = {
3231
2854
  info: "\u2139"
3232
2855
  };
3233
2856
  var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {
3234
- var _a2;
2857
+ var _a;
3235
2858
  const t = useOnboardingTheme();
3236
2859
  const reduced = useReducedMotion();
3237
2860
  const [submitted, setSubmitted] = useState(false);
@@ -3297,7 +2920,7 @@ var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSu
3297
2920
  headingStyle(t.fonts),
3298
2921
  { color, opacity: popT, transform: [{ scale: popScale }] }
3299
2922
  ],
3300
- children: (_a2 = STATUS_ICONS[status]) != null ? _a2 : "\xB7"
2923
+ children: (_a = STATUS_ICONS[status]) != null ? _a : "\xB7"
3301
2924
  }
3302
2925
  ),
3303
2926
  /* @__PURE__ */ jsx(
@@ -3640,7 +3263,7 @@ var runtimeRequire2 = (moduleName) => {
3640
3263
  try {
3641
3264
  switch (moduleName) {
3642
3265
  case "expo-constants":
3643
- return init_Constants(), __toCommonJS(Constants_exports);
3266
+ return __require("expo-constants");
3644
3267
  case "expo-application":
3645
3268
  return __require("expo-application");
3646
3269
  default:
@@ -3665,14 +3288,14 @@ var safeInterop = (requireModule, moduleName) => {
3665
3288
  };
3666
3289
  var detectAppVersion = (requireModule = runtimeRequire2) => {
3667
3290
  try {
3668
- const constants2 = safeInterop(requireModule, "expo-constants");
3669
- if (constants2) {
3670
- const expoConfig = constants2.expoConfig;
3291
+ const constants = safeInterop(requireModule, "expo-constants");
3292
+ if (constants) {
3293
+ const expoConfig = constants.expoConfig;
3671
3294
  if (expoConfig && typeof expoConfig === "object") {
3672
3295
  const fromExpoConfig = coerceVersion(expoConfig.version);
3673
3296
  if (fromExpoConfig) return fromExpoConfig;
3674
3297
  }
3675
- const fromNative = coerceVersion(constants2.nativeAppVersion);
3298
+ const fromNative = coerceVersion(constants.nativeAppVersion);
3676
3299
  if (fromNative) return fromNative;
3677
3300
  }
3678
3301
  const application = safeInterop(requireModule, "expo-application");
@@ -3737,7 +3360,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
3737
3360
  return void 0;
3738
3361
  };
3739
3362
  var collectDeviceContext = () => {
3740
- var _a2;
3363
+ var _a;
3741
3364
  const ctx = { platform: Platform.OS };
3742
3365
  try {
3743
3366
  const version = Platform.Version;
@@ -3746,26 +3369,26 @@ var collectDeviceContext = () => {
3746
3369
  }
3747
3370
  } catch {
3748
3371
  }
3749
- let constants2 = {};
3372
+ let constants = {};
3750
3373
  try {
3751
- constants2 = (_a2 = Platform.constants) != null ? _a2 : {};
3374
+ constants = (_a = Platform.constants) != null ? _a : {};
3752
3375
  } catch {
3753
- constants2 = {};
3376
+ constants = {};
3754
3377
  }
3755
3378
  let iosIdiom;
3756
3379
  try {
3757
3380
  if (Platform.OS === "android") {
3758
- const brand = constants2.Brand;
3759
- const model = constants2.Model;
3760
- const release = constants2.Release;
3381
+ const brand = constants.Brand;
3382
+ const model = constants.Model;
3383
+ const release = constants.Release;
3761
3384
  if (typeof brand === "string" && brand) ctx.brand = brand;
3762
3385
  if (typeof model === "string" && model) ctx.model = model;
3763
3386
  if (release !== void 0 && release !== null && String(release)) {
3764
3387
  ctx.osVersion = String(release);
3765
3388
  }
3766
3389
  } else if (Platform.OS === "ios") {
3767
- const osVersion = constants2.osVersion;
3768
- const idiom = constants2.interfaceIdiom;
3390
+ const osVersion = constants.osVersion;
3391
+ const idiom = constants.interfaceIdiom;
3769
3392
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
3770
3393
  ctx.osVersion = String(osVersion);
3771
3394
  }
@@ -3816,11 +3439,11 @@ var provenanceRegistry = () => {
3816
3439
  };
3817
3440
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
3818
3441
  var resolveIdentity = (input) => {
3819
- var _a2;
3442
+ var _a;
3820
3443
  if (typeof input.value !== "string") return void 0;
3821
3444
  const value = input.value.trim();
3822
3445
  if (!value) return void 0;
3823
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
3446
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
3824
3447
  if (input.source === "host") {
3825
3448
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
3826
3449
  }
@@ -3854,8 +3477,8 @@ var startHydration = (registry, appId, storage, minted) => {
3854
3477
  if (existing) return existing;
3855
3478
  const slot = deviceIdStorageKey(appId);
3856
3479
  const degraded = () => {
3857
- var _a2;
3858
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
3480
+ var _a;
3481
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
3859
3482
  };
3860
3483
  const adopted = (value) => ({ value, durable: true });
3861
3484
  let run;
@@ -3868,8 +3491,8 @@ var startHydration = (registry, appId, storage, minted) => {
3868
3491
  }
3869
3492
  return Promise.resolve(storage.setItem(slot, minted)).then(
3870
3493
  () => {
3871
- var _a2;
3872
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
3494
+ var _a;
3495
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
3873
3496
  },
3874
3497
  degraded
3875
3498
  );
@@ -3879,17 +3502,17 @@ var startHydration = (registry, appId, storage, minted) => {
3879
3502
  }
3880
3503
  registry.pending.set(appId, run);
3881
3504
  void run.then((outcome) => {
3882
- var _a2;
3505
+ var _a;
3883
3506
  if (outcome.durable) return;
3884
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
3507
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
3885
3508
  registry.hydrating.delete(appId);
3886
3509
  });
3887
3510
  return run;
3888
3511
  };
3889
3512
  var resolveAutoDeviceKey = (opts = {}) => {
3890
- var _a2, _b;
3513
+ var _a, _b;
3891
3514
  const registry = autoDeviceKeyRegistry();
3892
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3515
+ const appId = (_a = opts.appId) != null ? _a : "default";
3893
3516
  let id = registry.keys.get(appId);
3894
3517
  if (!id) {
3895
3518
  id = mintDeviceId();
@@ -3903,13 +3526,13 @@ var resolveAutoDeviceKey = (opts = {}) => {
3903
3526
  return (_b = registry.keys.get(appId)) != null ? _b : id;
3904
3527
  };
3905
3528
  var hydrateAutoDeviceKey = async (opts = {}) => {
3906
- var _a2, _b;
3907
- return (_b = (_a2 = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a2.value) != null ? _b : resolveAutoDeviceKey(opts);
3529
+ var _a, _b;
3530
+ return (_b = (_a = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a.value) != null ? _b : resolveAutoDeviceKey(opts);
3908
3531
  };
3909
3532
  var hydrateDeviceIdentity = async (opts = {}) => {
3910
- var _a2, _b, _c;
3533
+ var _a, _b, _c;
3911
3534
  const id = resolveAutoDeviceKey(opts);
3912
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3535
+ const appId = (_a = opts.appId) != null ? _a : "default";
3913
3536
  const record = (value, durable) => resolveIdentity({ value, space: "device", source: "auto", durable, scope: appId });
3914
3537
  if (!opts.storage) return record(id, false);
3915
3538
  const registry = autoDeviceKeyRegistry();
@@ -3919,11 +3542,11 @@ var hydrateDeviceIdentity = async (opts = {}) => {
3919
3542
  return record(outcome.value, outcome.durable);
3920
3543
  };
3921
3544
  var resetAutoDeviceKeys = () => {
3922
- var _a2;
3545
+ var _a;
3923
3546
  const registry = autoDeviceKeyRegistry();
3924
3547
  registry.keys.clear();
3925
3548
  registry.hydrating.clear();
3926
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
3549
+ (_a = registry.pending) == null ? void 0 : _a.clear();
3927
3550
  };
3928
3551
 
3929
3552
  // src/analytics/currentSession.ts
@@ -4025,9 +3648,9 @@ var sanitizeUserId = (raw) => {
4025
3648
  };
4026
3649
  var looksLikeEmail = (value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
4027
3650
  var identifyOnboarding = async (opts) => {
4028
- var _a2, _b, _c;
3651
+ var _a, _b, _c;
4029
3652
  const userId = sanitizeUserId(opts.userId);
4030
- if (!userId || !((_a2 = opts.config) == null ? void 0 : _a2.serverUrl)) return false;
3653
+ if (!userId || !((_a = opts.config) == null ? void 0 : _a.serverUrl)) return false;
4031
3654
  let contextId = ((_b = opts.contextId) == null ? void 0 : _b.trim()) || void 0;
4032
3655
  if (!contextId && opts.storage) {
4033
3656
  const key = (_c = opts.persistKey) != null ? _c : opts.appId ? sessionStorageKey(opts.appId) : void 0;
@@ -4098,11 +3721,11 @@ var clearUserContext = async (opts = {}) => {
4098
3721
  }
4099
3722
  };
4100
3723
  var activationJoinContext = (deviceKey) => {
4101
- var _a2;
4102
- return (_a2 = resolveUserContext({ deviceKey }).userContext) != null ? _a2 : {};
3724
+ var _a;
3725
+ return (_a = resolveUserContext({ deviceKey }).userContext) != null ? _a : {};
4103
3726
  };
4104
3727
  var resolveUserContext = (ctx = {}, opts = {}) => {
4105
- var _a2;
3728
+ var _a;
4106
3729
  const result = {};
4107
3730
  const bucket = {};
4108
3731
  const userId = sanitizeUserId(ctx.userId);
@@ -4112,7 +3735,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
4112
3735
  result.deviceKey = deviceKey;
4113
3736
  bucket.device_key = deviceKey;
4114
3737
  }
4115
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
3738
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
4116
3739
  if (appVersion) {
4117
3740
  result.appVersion = appVersion;
4118
3741
  bucket.app_version = appVersion;
@@ -4194,7 +3817,7 @@ var WireOnboarding = ({
4194
3817
  autoJoinKey = true,
4195
3818
  permissionScreens
4196
3819
  }) => {
4197
- var _a2, _b, _c, _d, _e, _f;
3820
+ var _a, _b, _c, _d, _e, _f;
4198
3821
  const boundUserId = useMemo(() => sanitizeUserId(userId), [userId]);
4199
3822
  const device = useMemo(() => {
4200
3823
  const collected = collectDeviceContext();
@@ -4236,7 +3859,7 @@ var WireOnboarding = ({
4236
3859
  clearTimeout(timer);
4237
3860
  };
4238
3861
  }, [wantsAutoJoin, autoJoinOutcome, config.appId, storage]);
4239
- const injectedJoinKey = wantsAutoJoin ? (_a2 = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a2 : void 0 : void 0;
3862
+ const injectedJoinKey = wantsAutoJoin ? (_a = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a : void 0 : void 0;
4240
3863
  const autoJoinPending = wantsAutoJoin && autoJoinOutcome === void 0;
4241
3864
  const effectiveUserContext = useMemo(
4242
3865
  () => injectedJoinKey ? { ...userContextStable, ...activationJoinContext(injectedJoinKey) } : userContextStable,
@@ -4320,8 +3943,8 @@ var WireOnboarding = ({
4320
3943
  settledPermissionsRef.current = settledPermissions;
4321
3944
  const handlePermissionSettled = useCallback(
4322
3945
  (id) => {
4323
- var _a3;
4324
- const current = (_a3 = settledPermissionsRef.current) != null ? _a3 : [];
3946
+ var _a2;
3947
+ const current = (_a2 = settledPermissionsRef.current) != null ? _a2 : [];
4325
3948
  if (current.includes(id)) return;
4326
3949
  const next = [...current, id];
4327
3950
  settledPermissionsRef.current = next;
@@ -4696,10 +4319,10 @@ var readEnabled = (raw) => {
4696
4319
  return { enabled: true };
4697
4320
  };
4698
4321
  var parseWireFeatures = (raw) => {
4699
- var _a2;
4322
+ var _a;
4700
4323
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return defaultWireFeatures;
4701
4324
  const src = raw;
4702
- const modeRaw = (_a2 = src.onboarding) == null ? void 0 : _a2.mode;
4325
+ const modeRaw = (_a = src.onboarding) == null ? void 0 : _a.mode;
4703
4326
  const mode = typeof modeRaw === "string" && VALID_MODES.includes(modeRaw) ? modeRaw : "ai";
4704
4327
  return {
4705
4328
  coachmarks: readEnabled(src.coachmarks),
@@ -4756,10 +4379,10 @@ var writeCachedFeatures = (storage, key, features) => {
4756
4379
  // src/features/fetchWireFeatures.ts
4757
4380
  var DEFAULT_TIMEOUT_MS = 4e3;
4758
4381
  var failOpen = async (storage, key) => {
4759
- var _a2;
4382
+ var _a;
4760
4383
  if (!storage) return defaultWireFeatures;
4761
4384
  const cached2 = await readCachedFeatures(storage, key);
4762
- return (_a2 = cached2 == null ? void 0 : cached2.features) != null ? _a2 : defaultWireFeatures;
4385
+ return (_a = cached2 == null ? void 0 : cached2.features) != null ? _a : defaultWireFeatures;
4763
4386
  };
4764
4387
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
4765
4388
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -4818,7 +4441,7 @@ var useWireFeatures = (config) => {
4818
4441
  return flags;
4819
4442
  };
4820
4443
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
4821
- var globalObj = global;
4444
+ var globalObj = globalThis;
4822
4445
  if (!globalObj[CONTEXT_SYMBOL]) {
4823
4446
  globalObj[CONTEXT_SYMBOL] = createContext(null);
4824
4447
  }
@@ -4836,11 +4459,11 @@ var WireFeaturesProvider = ({
4836
4459
  WireFeaturesProvider.displayName = "WireFeaturesProvider";
4837
4460
  var useWireFeaturesContext = () => useContext(WireFeaturesContext);
4838
4461
  var useResolvedFeatures = (options) => {
4839
- var _a2, _b, _c;
4462
+ var _a, _b, _c;
4840
4463
  const ctx = useWireFeaturesContext();
4841
4464
  const shouldFetch = !(options == null ? void 0 : options.flags) && ctx == null;
4842
4465
  const fetched = useWireFeatures(shouldFetch ? options == null ? void 0 : options.config : void 0);
4843
- return (_c = (_b = (_a2 = options == null ? void 0 : options.flags) != null ? _a2 : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4466
+ return (_c = (_b = (_a = options == null ? void 0 : options.flags) != null ? _a : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4844
4467
  };
4845
4468
 
4846
4469
  // src/config/wireConfigFromEnv.ts
@@ -4850,8 +4473,8 @@ var WIRE_ENV_VARS = [
4850
4473
  "EXPO_PUBLIC_WIREAI_APP_ID"
4851
4474
  ];
4852
4475
  var wireConfigFromEnv = (overrides) => {
4853
- var _a2, _b, _c, _d, _e;
4854
- const apiKey = (_a2 = overrides == null ? void 0 : overrides.apiKey) != null ? _a2 : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4476
+ var _a, _b, _c, _d, _e;
4477
+ const apiKey = (_a = overrides == null ? void 0 : overrides.apiKey) != null ? _a : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4855
4478
  const serverUrl = (_b = overrides == null ? void 0 : overrides.serverUrl) != null ? _b : process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;
4856
4479
  const appId = (_d = (_c = overrides == null ? void 0 : overrides.appId) != null ? _c : process.env.EXPO_PUBLIC_WIREAI_APP_ID) != null ? _d : "default";
4857
4480
  if (!apiKey || !serverUrl) {
@@ -4876,10 +4499,10 @@ var wireConfigFromEnv = (overrides) => {
4876
4499
 
4877
4500
  // src/config/onboardingFlag.ts
4878
4501
  var isOnboardingEnabled = (opts) => {
4879
- var _a2;
4502
+ var _a;
4880
4503
  const transportPresent = wireConfigFromEnv(opts == null ? void 0 : opts.config) !== null;
4881
4504
  if (!transportPresent) return false;
4882
- return (_a2 = opts == null ? void 0 : opts.remote) != null ? _a2 : true;
4505
+ return (_a = opts == null ? void 0 : opts.remote) != null ? _a : true;
4883
4506
  };
4884
4507
 
4885
4508
  // src/analytics/analyticsEvent.ts
@@ -4974,9 +4597,9 @@ var resetActivationRevalidation = () => {
4974
4597
  // src/activation/wireActivation.ts
4975
4598
  var clean = cleanString;
4976
4599
  var createWireActivation = (config) => {
4977
- var _a2, _b;
4600
+ var _a, _b;
4978
4601
  const target = { serverUrl: config.serverUrl, apiKey: config.apiKey };
4979
- const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey);
4602
+ const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a = config.userContext) == null ? void 0 : _a.deviceKey);
4980
4603
  resolveIdentity({
4981
4604
  value: explicitDeviceKey,
4982
4605
  space: "device",
@@ -4991,11 +4614,11 @@ var createWireActivation = (config) => {
4991
4614
  if (!explicitDeviceKey) resolveAutoDeviceKey(autoDeviceKeyOptions);
4992
4615
  const detectedAppVersion = detectAppVersion();
4993
4616
  const applyContext = (event) => {
4994
- var _a3, _b2, _c;
4617
+ var _a2, _b2, _c;
4995
4618
  const resolved = resolveUserContext(
4996
4619
  // `??` is lazy on purpose: an explicit key must never even touch the auto registry.
4997
4620
  {
4998
- ...(_a3 = config.userContext) != null ? _a3 : {},
4621
+ ...(_a2 = config.userContext) != null ? _a2 : {},
4999
4622
  deviceKey: explicitDeviceKey != null ? explicitDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions)
5000
4623
  },
5001
4624
  { autoAppVersion: (_b2 = config.appVersion) != null ? _b2 : detectedAppVersion }
@@ -5005,13 +4628,13 @@ var createWireActivation = (config) => {
5005
4628
  }
5006
4629
  if (resolved.userId && !event.user_id) event.user_id = resolved.userId;
5007
4630
  };
5008
- const track = async (name2, meta) => {
5009
- if (!clean(name2)) return false;
4631
+ const track = async (name, meta) => {
4632
+ if (!clean(name)) return false;
5010
4633
  const sessionId = ensureCurrentSessionId();
5011
4634
  const event = {
5012
4635
  event_type: "app_event",
5013
4636
  session_id: sessionId,
5014
- question_key: name2
4637
+ question_key: name
5015
4638
  };
5016
4639
  if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);
5017
4640
  applyContext(event);
@@ -5034,7 +4657,7 @@ var useActivationRevalidation = () => useSyncExternalStore(
5034
4657
  getActivationRevalidationVersion
5035
4658
  );
5036
4659
  var useWireActivation = (config) => {
5037
- var _a2;
4660
+ var _a;
5038
4661
  const ref = useRef(void 0);
5039
4662
  const prevKeys = useRef("");
5040
4663
  const currentKeys = [
@@ -5042,7 +4665,7 @@ var useWireActivation = (config) => {
5042
4665
  config.apiKey,
5043
4666
  config.appId,
5044
4667
  config.deviceKey,
5045
- (_a2 = config.userContext) == null ? void 0 : _a2.deviceKey
4668
+ (_a = config.userContext) == null ? void 0 : _a.deviceKey
5046
4669
  ].join("|");
5047
4670
  if (!ref.current || prevKeys.current !== currentKeys) {
5048
4671
  prevKeys.current = currentKeys;
@@ -5068,8 +4691,8 @@ var WIRE_PURCHASE_EVENTS = {
5068
4691
  var PLAN_TIER_CONTEXT_KEY = "plan_tier";
5069
4692
  var asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
5070
4693
  var activeEntitlement = (info, entitlementId) => {
5071
- var _a2, _b;
5072
- const active = asRecord((_b = asRecord((_a2 = asRecord(info)) == null ? void 0 : _a2.entitlements)) == null ? void 0 : _b.active);
4694
+ var _a, _b;
4695
+ const active = asRecord((_b = asRecord((_a = asRecord(info)) == null ? void 0 : _a.entitlements)) == null ? void 0 : _b.active);
5073
4696
  const found = active == null ? void 0 : active[entitlementId];
5074
4697
  const entitlement = asRecord(found);
5075
4698
  if (!entitlement) return void 0;
@@ -5142,19 +4765,19 @@ var createRevenueCatBridge = (config) => {
5142
4765
  }
5143
4766
  };
5144
4767
  const syncPlanTier = (customerInfo) => {
5145
- var _a2;
4768
+ var _a;
5146
4769
  const tier = resolvePlanTier(customerInfo, entitlementId);
5147
4770
  if (!writeTier) return tier;
5148
4771
  try {
5149
- (_a2 = analytics.setUserContext) == null ? void 0 : _a2.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
4772
+ (_a = analytics.setUserContext) == null ? void 0 : _a.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
5150
4773
  } catch {
5151
4774
  }
5152
4775
  return tier;
5153
4776
  };
5154
4777
  const paywallShown = (offering, props) => {
5155
- var _a2, _b;
4778
+ var _a, _b;
5156
4779
  const shown = {
5157
- packages_count: (_b = (_a2 = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a2.length) != null ? _b : 0
4780
+ packages_count: (_b = (_a = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a.length) != null ? _b : 0
5158
4781
  };
5159
4782
  if (typeof (offering == null ? void 0 : offering.identifier) === "string") shown.offering_id = offering.identifier;
5160
4783
  emit(WIRE_PURCHASE_EVENTS.paywallShown, { ...shown, ...props });
@@ -5208,10 +4831,10 @@ var resetSessionStartGuard = () => {
5208
4831
  _emitted.clear();
5209
4832
  };
5210
4833
  var reportSessionStart = (opts) => {
5211
- var _a2;
4834
+ var _a;
5212
4835
  const target = opts.target;
5213
4836
  if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
5214
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
4837
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5215
4838
  setCurrentSessionId(sessionId);
5216
4839
  if (opts.once !== false) {
5217
4840
  if (_emitted.has(sessionId)) return;
@@ -5271,11 +4894,11 @@ var useSessionStart = (config, options = {}) => {
5271
4894
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5272
4895
  };
5273
4896
  const fire = () => {
5274
- var _a2, _b;
4897
+ var _a, _b;
5275
4898
  const { config: cfg, options: opts } = latest.current;
5276
4899
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return;
5277
4900
  if (opts.enabled === false) return;
5278
- const target = { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" };
4901
+ const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
5279
4902
  const device = collectDeviceContext();
5280
4903
  if (cfg.appVersion) device.appVersion = cfg.appVersion;
5281
4904
  reportSessionStart({
@@ -5326,7 +4949,7 @@ var resetFirstOpenLatch = () => {
5326
4949
  _firstOpenLatched.clear();
5327
4950
  };
5328
4951
  var buildLifecycleEvent = (questionKey, opts) => {
5329
- var _a2;
4952
+ var _a;
5330
4953
  const userContext = {};
5331
4954
  if (opts.deviceKey) userContext.device_key = opts.deviceKey;
5332
4955
  if (typeof opts.sessionCount === "number" && Number.isFinite(opts.sessionCount)) {
@@ -5338,7 +4961,7 @@ var buildLifecycleEvent = (questionKey, opts) => {
5338
4961
  const event = {
5339
4962
  event_type: "app_event",
5340
4963
  question_key: questionKey,
5341
- session_id: (_a2 = opts.sessionId) != null ? _a2 : makeSessionId()
4964
+ session_id: (_a = opts.sessionId) != null ? _a : makeSessionId()
5342
4965
  };
5343
4966
  const userId = sanitizeUserId(opts.userId);
5344
4967
  if (userId) event.user_id = userId;
@@ -5364,8 +4987,8 @@ var emitFirstOpen = (opts) => {
5364
4987
  routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);
5365
4988
  };
5366
4989
  var reportFirstOpen = (opts) => {
5367
- var _a2;
5368
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
4990
+ var _a;
4991
+ const appId = (_a = opts.appId) != null ? _a : "default";
5369
4992
  if (_firstOpenLatched.has(appId)) return;
5370
4993
  _firstOpenLatched.add(appId);
5371
4994
  const storage = opts.storage;
@@ -5390,8 +5013,8 @@ var reportFirstOpen = (opts) => {
5390
5013
  })();
5391
5014
  };
5392
5015
  var wireLifecycleEvents = (opts) => {
5393
- var _a2;
5394
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
5016
+ var _a;
5017
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5395
5018
  reportFirstOpen({ ...opts, sessionId });
5396
5019
  reportSessionStart({
5397
5020
  target: opts.target,
@@ -5440,10 +5063,11 @@ var claimQueueKey = (preferred, explicit) => {
5440
5063
  );
5441
5064
  return key;
5442
5065
  };
5066
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
5443
5067
  var withTimeout4 = (p, ms) => {
5444
5068
  let timer;
5445
5069
  const timeout = new Promise((resolve) => {
5446
- timer = setTimeout(() => resolve(void 0), ms);
5070
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
5447
5071
  });
5448
5072
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
5449
5073
  };
@@ -5468,10 +5092,10 @@ var parsePersisted2 = (raw) => {
5468
5092
  }
5469
5093
  };
5470
5094
  var createEventQueue = (options) => {
5471
- var _a2, _b, _c, _d, _e, _f, _g;
5095
+ var _a, _b, _c, _d, _e, _f, _g;
5472
5096
  const target = options.target;
5473
5097
  const storage = options.storage;
5474
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
5098
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
5475
5099
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
5476
5100
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
5477
5101
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -5483,6 +5107,7 @@ var createEventQueue = (options) => {
5483
5107
  let flushing = false;
5484
5108
  let attempt = 0;
5485
5109
  let retryTimer;
5110
+ let backlogUnread = false;
5486
5111
  const resolveEnvelope = () => {
5487
5112
  try {
5488
5113
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -5491,14 +5116,14 @@ var createEventQueue = (options) => {
5491
5116
  }
5492
5117
  };
5493
5118
  const stamp = (event) => {
5494
- var _a3;
5119
+ var _a2;
5495
5120
  const env = resolveEnvelope();
5496
5121
  const stamped = { ...event };
5497
5122
  if (stamped.ts === void 0) stamped.ts = Date.now();
5498
5123
  if (!env) return stamped;
5499
5124
  if (!stamped.device && env.device) stamped.device = env.device;
5500
5125
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
5501
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
5126
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
5502
5127
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
5503
5128
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
5504
5129
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -5507,6 +5132,7 @@ var createEventQueue = (options) => {
5507
5132
  };
5508
5133
  const persist = () => {
5509
5134
  if (!storage) return;
5135
+ if (backlogUnread) return;
5510
5136
  try {
5511
5137
  if (pending.length === 0) {
5512
5138
  void storage.removeItem(key).catch(() => {
@@ -5529,23 +5155,44 @@ var createEventQueue = (options) => {
5529
5155
  return `__nosig_${nextId}_${Math.random()}`;
5530
5156
  }
5531
5157
  };
5158
+ const mergePersisted = (persistedItems) => {
5159
+ if (persistedItems.length === 0) return;
5160
+ const seen = new Set(pending.map((item) => item.sig));
5161
+ const restored = [];
5162
+ for (const persisted of persistedItems) {
5163
+ const sig = safeSig(persisted.event);
5164
+ if (seen.has(sig)) continue;
5165
+ seen.add(sig);
5166
+ restored.push({ id: nextId++, event: persisted.event, sig });
5167
+ }
5168
+ if (restored.length === 0) return;
5169
+ pending = [...restored, ...pending];
5170
+ enforceSizeCap();
5171
+ persist();
5172
+ };
5532
5173
  const loadPromise = (async () => {
5533
5174
  if (!storage) return;
5534
5175
  try {
5535
- const persistedItems = parsePersisted2(await withTimeout4(storage.getItem(key), READ_TIMEOUT_MS4));
5536
- if (persistedItems.length === 0) return;
5537
- const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];
5538
- pending = [];
5539
- nextId = 0;
5540
- const seen = /* @__PURE__ */ new Set();
5541
- for (const event of events) {
5542
- const sig = safeSig(event);
5543
- if (seen.has(sig)) continue;
5544
- seen.add(sig);
5545
- pending.push({ id: nextId++, event, sig });
5176
+ const read = Promise.resolve(storage.getItem(key));
5177
+ read.catch(() => {
5178
+ });
5179
+ const raced = await withTimeout4(read, READ_TIMEOUT_MS4);
5180
+ if (raced === READ_TIMED_OUT) {
5181
+ backlogUnread = true;
5182
+ warnInDev(
5183
+ `[wireai] the persisted analytics backlog at "${key}" took longer than ${READ_TIMEOUT_MS4}ms to read, so the queue started without it. The stored events are NOT discarded: writes are held back until the read lands, and the backlog is merged in then. If you see this on every cold start, your storage adapter is too slow to be on the launch path.`
5184
+ );
5185
+ void read.then((late) => {
5186
+ backlogUnread = false;
5187
+ mergePersisted(parsePersisted2(late));
5188
+ flush();
5189
+ }).catch(() => {
5190
+ backlogUnread = false;
5191
+ persist();
5192
+ });
5193
+ return;
5546
5194
  }
5547
- enforceSizeCap();
5548
- persist();
5195
+ mergePersisted(parsePersisted2(raced));
5549
5196
  } catch {
5550
5197
  }
5551
5198
  })();
@@ -5642,13 +5289,13 @@ var useLifecycleEvents = (config, options = {}) => {
5642
5289
  const queueRef = useRef(void 0);
5643
5290
  useEffect(() => {
5644
5291
  const resolveSink = () => {
5645
- var _a2, _b;
5292
+ var _a, _b;
5646
5293
  const { config: cfg, options: opts } = latest.current;
5647
5294
  if (opts.sink) return opts.sink;
5648
5295
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return void 0;
5649
5296
  if (!queueRef.current) {
5650
5297
  queueRef.current = createEventQueue({
5651
- target: { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" },
5298
+ target: { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" },
5652
5299
  storage: cfg.storage,
5653
5300
  // Dedicated key so the hook's internal queue never collides with a host's main queue.
5654
5301
  storageKey: `wireai:evtq:lifecycle:${(_b = cfg.appId) != null ? _b : "default"}`,
@@ -5658,24 +5305,24 @@ var useLifecycleEvents = (config, options = {}) => {
5658
5305
  return queueRef.current.enqueue;
5659
5306
  };
5660
5307
  const targetOf = (cfg) => {
5661
- var _a2;
5662
- return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" } : void 0;
5308
+ var _a;
5309
+ return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" } : void 0;
5663
5310
  };
5664
5311
  const resolveDeviceKey = (cfg, opts) => {
5665
- var _a2;
5666
- const host = (_a2 = resolveIdentity({
5312
+ var _a;
5313
+ const host = (_a = resolveIdentity({
5667
5314
  value: opts.deviceKey,
5668
5315
  space: "device",
5669
5316
  source: "host",
5670
5317
  scope: cfg == null ? void 0 : cfg.appId
5671
- })) == null ? void 0 : _a2.value;
5318
+ })) == null ? void 0 : _a.value;
5672
5319
  if (host) return host;
5673
5320
  if (!(cfg == null ? void 0 : cfg.storage)) return void 0;
5674
5321
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5675
5322
  };
5676
5323
  const mountOpenSessionId = makeSessionId();
5677
5324
  const fireSession = (sessionId) => {
5678
- var _a2;
5325
+ var _a;
5679
5326
  const { config: cfg, options: opts } = latest.current;
5680
5327
  if (opts.enabled === false) return;
5681
5328
  if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
@@ -5688,14 +5335,14 @@ var useLifecycleEvents = (config, options = {}) => {
5688
5335
  userId: opts.userId,
5689
5336
  deviceKey: resolveDeviceKey(cfg, opts),
5690
5337
  sessionCount: opts.sessionCount,
5691
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5338
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5692
5339
  platform: Platform.OS,
5693
5340
  device,
5694
5341
  meta: opts.meta
5695
5342
  });
5696
5343
  };
5697
5344
  const fireMountOpen = () => {
5698
- var _a2;
5345
+ var _a;
5699
5346
  fireSession(mountOpenSessionId);
5700
5347
  const { config: cfg, options: opts } = latest.current;
5701
5348
  if (opts.enabled === false) return;
@@ -5710,7 +5357,7 @@ var useLifecycleEvents = (config, options = {}) => {
5710
5357
  userId: opts.userId,
5711
5358
  deviceKey: resolveDeviceKey(cfg, opts),
5712
5359
  sessionCount: opts.sessionCount,
5713
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5360
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5714
5361
  platform: Platform.OS,
5715
5362
  device,
5716
5363
  meta: opts.meta