@wireai/activation 0.13.2 → 0.13.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +291 -4
  3. package/INTEGRATION_PROMPT.md +7 -1
  4. package/README.md +68 -2
  5. package/dist/analytics/index.d.mts +86 -6
  6. package/dist/analytics/index.d.ts +86 -6
  7. package/dist/analytics/index.js +271 -472
  8. package/dist/analytics/index.js.map +1 -1
  9. package/dist/analytics/index.mjs +269 -471
  10. package/dist/analytics/index.mjs.map +1 -1
  11. package/dist/coachmarks/index.d.mts +15 -2
  12. package/dist/coachmarks/index.d.ts +15 -2
  13. package/dist/coachmarks/index.js +58 -14
  14. package/dist/coachmarks/index.js.map +1 -1
  15. package/dist/coachmarks/index.mjs +58 -14
  16. package/dist/coachmarks/index.mjs.map +1 -1
  17. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-DgJf0fRz.d.mts} +4 -4
  18. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-EOHU64QD.d.ts} +4 -4
  19. package/dist/{decision-Bl_M2y3r.d.mts → decision-Bgo17oH7.d.mts} +1 -1
  20. package/dist/{decision-Cau5KmP6.d.ts → decision-Bkh_LigV.d.ts} +1 -1
  21. package/dist/index.d.mts +27 -4
  22. package/dist/index.d.ts +27 -4
  23. package/dist/index.js +224 -575
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +221 -572
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/questionnaire/index.d.mts +43 -11
  28. package/dist/questionnaire/index.d.ts +43 -11
  29. package/dist/questionnaire/index.js +45 -13
  30. package/dist/questionnaire/index.js.map +1 -1
  31. package/dist/questionnaire/index.mjs +45 -13
  32. package/dist/questionnaire/index.mjs.map +1 -1
  33. package/dist/reviews/index.d.mts +5 -5
  34. package/dist/reviews/index.d.ts +5 -5
  35. package/dist/reviews/index.js +31 -9
  36. package/dist/reviews/index.js.map +1 -1
  37. package/dist/reviews/index.mjs +31 -9
  38. package/dist/reviews/index.mjs.map +1 -1
  39. package/dist/showcase/index.d.mts +1 -1
  40. package/dist/showcase/index.d.ts +1 -1
  41. package/dist/showcase/index.js +7 -2
  42. package/dist/showcase/index.js.map +1 -1
  43. package/dist/showcase/index.mjs +7 -2
  44. package/dist/showcase/index.mjs.map +1 -1
  45. package/dist/{transport-CF_eHwzC.d.mts → transport-B_0SgCBe.d.ts} +44 -5
  46. package/dist/{transport-DsRe4epC.d.ts → transport-j5gFfJhK.d.mts} +44 -5
  47. package/dist/{types-CKFhyrMu.d.mts → types-BpwiRpA8.d.mts} +1 -1
  48. package/dist/{types-CKFhyrMu.d.ts → types-BpwiRpA8.d.ts} +1 -1
  49. package/dist/{types-CNUqMK0D.d.mts → types-Cju-1_jT.d.mts} +42 -2
  50. package/dist/{types-Buj9Lw9t.d.ts → types-h2BZvl1t.d.ts} +42 -2
  51. package/llms.txt +1 -1
  52. package/package.json +6 -1
  53. package/src/OnboardingFlow.tsx +44 -15
  54. package/src/WireOnboarding.tsx +7 -6
  55. package/src/activation/revalidation.ts +9 -1
  56. package/src/activation/wireActivation.ts +3 -3
  57. package/src/analytics/analyticsFacade.ts +2 -2
  58. package/src/analytics/currentSession.ts +10 -0
  59. package/src/analytics/eventQueue.ts +88 -20
  60. package/src/analytics/index.ts +6 -0
  61. package/src/analytics/reportClientEvent.ts +29 -7
  62. package/src/analytics/wireDoctor.ts +330 -0
  63. package/src/cards/CardGridSelectCard.tsx +1 -1
  64. package/src/cards/ChipSelectCard.tsx +2 -2
  65. package/src/cards/SelectionCard.tsx +1 -1
  66. package/src/coachmarks/runtime.ts +72 -3
  67. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  68. package/src/context/deviceId.ts +14 -5
  69. package/src/features/WireFeaturesProvider.tsx +12 -1
  70. package/src/identity/identityRecord.ts +9 -1
  71. package/src/identity/userIdentity.ts +1 -1
  72. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  73. package/src/questionnaire/index.ts +9 -1
  74. package/src/questionnaire/transport.ts +46 -11
  75. package/src/reviews/ReviewGate.tsx +61 -6
  76. package/src/reviews/index.ts +10 -1
  77. package/src/reviews/runtime.ts +11 -1
  78. package/src/reviews/transport.ts +58 -12
  79. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  80. package/src/theme/ThemeContext.tsx +49 -1
  81. package/src/types.ts +1 -1
  82. 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;
@@ -1531,13 +1151,15 @@ var toWireEvents = (events) => events.map((event) => {
1531
1151
  return rest;
1532
1152
  }
1533
1153
  });
1534
- var buildEventsRequest = (target, events) => {
1154
+ var buildEventsRequest = (target, events, options) => {
1535
1155
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
1536
1156
  try {
1537
1157
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
1538
1158
  const headers = { "Content-Type": "application/json" };
1539
1159
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
1540
- const body = JSON.stringify({ events: toWireEvents(events) });
1160
+ const envelope = { events: toWireEvents(events) };
1161
+ if ((options == null ? void 0 : options.dryRun) === true) ;
1162
+ const body = JSON.stringify(envelope);
1541
1163
  return { url, init: { method: "POST", headers, body } };
1542
1164
  } catch {
1543
1165
  return null;
@@ -1746,10 +1368,10 @@ var _PermissionCard = ({
1746
1368
  getStatusRef.current = getStatus;
1747
1369
  const shownRef = useRef(false);
1748
1370
  useEffect(() => {
1749
- var _a2;
1371
+ var _a;
1750
1372
  if (shownRef.current) return;
1751
1373
  shownRef.current = true;
1752
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "shown");
1374
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "shown");
1753
1375
  }, []);
1754
1376
  useEffect(() => {
1755
1377
  const probe = getStatusRef.current;
@@ -1775,18 +1397,18 @@ var _PermissionCard = ({
1775
1397
  );
1776
1398
  }, [permission]);
1777
1399
  const settle = useCallback((outcome) => {
1778
- var _a2;
1400
+ var _a;
1779
1401
  if (settledRef.current) return;
1780
1402
  settledRef.current = true;
1781
1403
  clearWatchdog();
1782
- (_a2 = onSettledRef.current) == null ? void 0 : _a2.call(onSettledRef, outcome);
1404
+ (_a = onSettledRef.current) == null ? void 0 : _a.call(onSettledRef, outcome);
1783
1405
  }, [clearWatchdog]);
1784
1406
  const primaryAction = status === "blocked" ? "settings" : status === "granted" || !request ? "continue" : "ask";
1785
1407
  const handlePrimary = useCallback(() => {
1786
- var _a2, _b, _c, _d;
1408
+ var _a, _b, _c, _d;
1787
1409
  if (settledRef.current || busy) return;
1788
1410
  if (primaryAction === "settings") {
1789
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "settings", "blocked");
1411
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "settings", "blocked");
1790
1412
  try {
1791
1413
  void Promise.resolve(openSettings == null ? void 0 : openSettings()).catch(() => {
1792
1414
  });
@@ -1811,7 +1433,7 @@ var _PermissionCard = ({
1811
1433
  }
1812
1434
  setBusy(true);
1813
1435
  const finish = (value) => {
1814
- var _a3, _b2;
1436
+ var _a2, _b2;
1815
1437
  if (settledRef.current) return;
1816
1438
  clearWatchdog();
1817
1439
  const resolved = normalizePermissionStatus(value);
@@ -1819,7 +1441,7 @@ var _PermissionCard = ({
1819
1441
  setStatus(resolved);
1820
1442
  if (resolved === "granted") {
1821
1443
  playHaptic("success");
1822
- (_a3 = onStageRef.current) == null ? void 0 : _a3.call(onStageRef, "granted", "granted");
1444
+ (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "granted", "granted");
1823
1445
  } else {
1824
1446
  (_b2 = onStageRef.current) == null ? void 0 : _b2.call(onStageRef, "denied", resolved);
1825
1447
  }
@@ -1841,9 +1463,9 @@ var _PermissionCard = ({
1841
1463
  }
1842
1464
  }, [busy, primaryAction, status, request, openSettings, settle, clearWatchdog, permission]);
1843
1465
  const handleSecondary = useCallback(() => {
1844
- var _a2;
1466
+ var _a;
1845
1467
  if (settledRef.current || busy) return;
1846
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "skipped");
1468
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "skipped");
1847
1469
  settle("skipped");
1848
1470
  }, [busy, settle]);
1849
1471
  const popT = useRef(new Animated.Value(reduced ? 1 : 0)).current;
@@ -1949,18 +1571,18 @@ var isPermissionDue = (placement, position) => {
1949
1571
  return position.cardIndex >= target || position.isTerminal;
1950
1572
  };
1951
1573
  var permissionScreenId = (screen, index) => {
1952
- var _a2;
1953
- return (_a2 = screen.id) != null ? _a2 : `${screen.permission}:${index}`;
1574
+ var _a;
1575
+ return (_a = screen.id) != null ? _a : `${screen.permission}:${index}`;
1954
1576
  };
1955
1577
  var selectDuePermissionScreen = (screens, settled, position) => {
1956
- var _a2;
1578
+ var _a;
1957
1579
  if (!screens || screens.length === 0) return void 0;
1958
1580
  for (let index = 0; index < screens.length; index++) {
1959
1581
  const screen = screens[index];
1960
1582
  if (!screen) continue;
1961
1583
  const id = permissionScreenId(screen, index);
1962
1584
  if (settled.includes(id)) continue;
1963
- if (isPermissionDue((_a2 = screen.placement) != null ? _a2 : DEFAULT_PERMISSION_PLACEMENT, position)) {
1585
+ if (isPermissionDue((_a = screen.placement) != null ? _a : DEFAULT_PERMISSION_PLACEMENT, position)) {
1964
1586
  return { screen, id };
1965
1587
  }
1966
1588
  }
@@ -1992,8 +1614,8 @@ var DEFAULT_PERMISSION_COPY = {
1992
1614
  notifications: NOTIFICATIONS_PERMISSION_COPY
1993
1615
  };
1994
1616
  var resolvePermissionCopy = (permission, overrides) => {
1995
- var _a2;
1996
- const base = (_a2 = DEFAULT_PERMISSION_COPY[permission]) != null ? _a2 : GENERIC_PERMISSION_COPY;
1617
+ var _a;
1618
+ const base = (_a = DEFAULT_PERMISSION_COPY[permission]) != null ? _a : GENERIC_PERMISSION_COPY;
1997
1619
  if (!overrides) return base;
1998
1620
  const merged = { ...base };
1999
1621
  for (const key of Object.keys(overrides)) {
@@ -2036,7 +1658,7 @@ var OnboardingFlow = ({
2036
1658
  permissionsPending = false,
2037
1659
  onPermissionSettled
2038
1660
  }) => {
2039
- var _a2, _b, _c, _d, _e, _f;
1661
+ var _a, _b, _c, _d, _e, _f;
2040
1662
  const { messages, error, isLoading, sendMessage, reset } = useWireAIThread();
2041
1663
  const makeActions = useWireAIAction(sendMessage);
2042
1664
  const c = useMemo(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);
@@ -2056,7 +1678,8 @@ var OnboardingFlow = ({
2056
1678
  clientContextRef.current = clientContext;
2057
1679
  const lastScreenIndexRef = useRef(-1);
2058
1680
  const previewTimer = useRef(null);
2059
- const started = useRef(false);
1681
+ const [runId, setRunId] = useState(0);
1682
+ const startedRunRef = useRef(-1);
2060
1683
  const finished = useRef(false);
2061
1684
  const errored = useRef(false);
2062
1685
  const attempts = useRef(0);
@@ -2070,39 +1693,41 @@ var OnboardingFlow = ({
2070
1693
  onPermissionSettledRef.current = onPermissionSettled;
2071
1694
  const lastCard = useMemo(
2072
1695
  () => [...messages].reverse().find((m) => {
2073
- var _a3;
2074
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1696
+ var _a2;
1697
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2075
1698
  }),
2076
1699
  [messages]
2077
1700
  );
2078
1701
  const renderedCount = useMemo(
2079
1702
  () => messages.filter((m) => {
2080
- var _a3;
2081
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1703
+ var _a2;
1704
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2082
1705
  }).length,
2083
1706
  [messages]
2084
1707
  );
2085
1708
  const progress = useMemo(() => readProgress(lastCard == null ? void 0 : lastCard.response), [lastCard]);
2086
1709
  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(
1710
+ var _a2;
1711
+ if (startedRunRef.current === runId) return;
1712
+ const isFirstRun = startedRunRef.current < 0;
1713
+ startedRunRef.current = runId;
1714
+ sendMessage(isFirstRun && !resumed ? startMessage : SKIP_ONE_SENTINEL);
1715
+ if (!isFirstRun) return;
1716
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(
2092
1717
  onEventRef,
2093
1718
  resumed ? { type: "resumed", contextId: sessionId } : { type: "started", contextId: sessionId }
2094
1719
  );
2095
- }, [sendMessage, startMessage, resumed, sessionId]);
1720
+ }, [sendMessage, startMessage, resumed, sessionId, runId]);
2096
1721
  useEffect(() => {
2097
1722
  if (lastCard) return;
2098
1723
  const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);
2099
1724
  return () => clearTimeout(timer);
2100
- }, [lastCard, startTimeoutMs]);
1725
+ }, [lastCard, startTimeoutMs, runId]);
2101
1726
  useEffect(() => {
2102
- var _a3, _b2, _c2, _d2;
1727
+ var _a2, _b2, _c2, _d2;
2103
1728
  setValidationError(void 0);
2104
1729
  if (!(lastCard == null ? void 0 : lastCard.id)) return;
2105
- const step2 = (_a3 = progress.step) != null ? _a3 : renderedCount;
1730
+ const step2 = (_a2 = progress.step) != null ? _a2 : renderedCount;
2106
1731
  lastScreenIndexRef.current = Math.max(0, step2 - 1);
2107
1732
  (_c2 = onEventRef.current) == null ? void 0 : _c2.call(onEventRef, {
2108
1733
  type: "turn",
@@ -2118,13 +1743,13 @@ var OnboardingFlow = ({
2118
1743
  }, [lastCard == null ? void 0 : lastCard.id]);
2119
1744
  useEffect(() => {
2120
1745
  return () => {
2121
- var _a3, _b2, _c2;
1746
+ var _a2, _b2, _c2;
2122
1747
  if (finished.current || degradedRef.current) return;
2123
1748
  reportClientEvent(reportTargetRef.current, {
2124
1749
  event_type: "dropped",
2125
1750
  session_id: sessionIdRef.current,
2126
1751
  screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : void 0,
2127
- device: (_a3 = clientContextRef.current) == null ? void 0 : _a3.device,
1752
+ device: (_a2 = clientContextRef.current) == null ? void 0 : _a2.device,
2128
1753
  user_context: (_b2 = clientContextRef.current) == null ? void 0 : _b2.userContext,
2129
1754
  user_id: (_c2 = clientContextRef.current) == null ? void 0 : _c2.userId
2130
1755
  });
@@ -2132,17 +1757,17 @@ var OnboardingFlow = ({
2132
1757
  }, []);
2133
1758
  const restartThread = useCallback(() => {
2134
1759
  setTimedOut(false);
2135
- started.current = false;
2136
1760
  errored.current = false;
1761
+ setRunId((n) => n + 1);
2137
1762
  reset();
2138
1763
  }, [reset]);
2139
1764
  useEffect(() => {
2140
- var _a3, _b2, _c2, _d2, _e2, _f2, _g;
1765
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
2141
1766
  if (errored.current) return;
2142
1767
  if (!error && !timedOut) return;
2143
1768
  errored.current = true;
2144
1769
  const reason = error ? "backend" : "timeout";
2145
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "error", reason });
1770
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "error", reason });
2146
1771
  attempts.current += 1;
2147
1772
  if (attempts.current <= maxRetries) {
2148
1773
  (_b2 = onEventRef.current) == null ? void 0 : _b2.call(onEventRef, { type: "retry", reason, attempt: attempts.current });
@@ -2180,8 +1805,8 @@ var OnboardingFlow = ({
2180
1805
  }, [isLoading, sendMessage]);
2181
1806
  const emitPermissionStage = useCallback(
2182
1807
  (permission, stage, status) => {
2183
- var _a3, _b2, _c2, _d2;
2184
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "permission", permission, stage, status });
1808
+ var _a2, _b2, _c2, _d2;
1809
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "permission", permission, stage, status });
2185
1810
  reportClientEvent(reportTargetRef.current, {
2186
1811
  event_type: "app_event",
2187
1812
  session_id: sessionIdRef.current,
@@ -2198,9 +1823,9 @@ var OnboardingFlow = ({
2198
1823
  );
2199
1824
  const settlePermission = useCallback(
2200
1825
  (id, screen, outcome) => {
2201
- var _a3, _b2;
1826
+ var _a2, _b2;
2202
1827
  setLocallySettledPermissions((prev) => prev.includes(id) ? prev : [...prev, id]);
2203
- (_a3 = onPermissionSettledRef.current) == null ? void 0 : _a3.call(onPermissionSettledRef, id, outcome);
1828
+ (_a2 = onPermissionSettledRef.current) == null ? void 0 : _a2.call(onPermissionSettledRef, id, outcome);
2204
1829
  try {
2205
1830
  (_b2 = screen.onResult) == null ? void 0 : _b2.call(screen, screen.permission, outcome);
2206
1831
  } catch {
@@ -2225,26 +1850,26 @@ var OnboardingFlow = ({
2225
1850
  }, []);
2226
1851
  const wrappedActions = useCallback(
2227
1852
  (messageId) => {
2228
- var _a3;
1853
+ var _a2;
2229
1854
  const base = makeActions(messageId);
2230
1855
  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;
1856
+ 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
1857
  if (!validator) return base;
2233
1858
  const out = { ...base };
2234
- for (const name2 of ANSWER_CALLBACKS) {
2235
- const original = base[name2];
1859
+ for (const name of ANSWER_CALLBACKS) {
1860
+ const original = base[name];
2236
1861
  if (!original) continue;
2237
- out[name2] = (...args) => {
1862
+ out[name] = (...args) => {
2238
1863
  const value = args[0];
2239
1864
  if (typeof value !== "string") return original(...args);
2240
1865
  setValidating(true);
2241
1866
  validator(value).then((res) => {
2242
- var _a4;
1867
+ var _a3;
2243
1868
  if (res.ok) {
2244
1869
  setValidationError(void 0);
2245
1870
  original(...args);
2246
1871
  } else {
2247
- setValidationError((_a4 = res.error) != null ? _a4 : "That value isn't available.");
1872
+ setValidationError((_a3 = res.error) != null ? _a3 : "That value isn't available.");
2248
1873
  }
2249
1874
  }).catch(() => {
2250
1875
  original(...args);
@@ -2275,7 +1900,7 @@ var OnboardingFlow = ({
2275
1900
  if (!lastCard || !response) {
2276
1901
  return /* @__PURE__ */ jsx(LoadingScreen, { title: c.startingTitle, hint: c.startingHint });
2277
1902
  }
2278
- const step = (_a2 = progress.step) != null ? _a2 : renderedCount;
1903
+ const step = (_a = progress.step) != null ? _a : renderedCount;
2279
1904
  const total = (_b = progress.total) != null ? _b : approxScreens;
2280
1905
  const isTerminal = response.action === "render" && response.component === "StatusCard";
2281
1906
  const duePermission = permissionsPending ? void 0 : selectDuePermissionScreen(
@@ -2800,13 +2425,13 @@ var WIRE_ICON_GLYPHS = {
2800
2425
  other: { family: "MaterialCommunityIcons", name: "dots-horizontal-circle" }
2801
2426
  };
2802
2427
  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];
2428
+ var lookupIconGlyph = (name) => {
2429
+ if (!name) return void 0;
2430
+ if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return void 0;
2431
+ return WIRE_ICON_GLYPHS[name];
2807
2432
  };
2808
- var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2809
- const hostIcon = useHostIcon(name2);
2433
+ var _WireIcon = ({ name, size = 20, color, requireModule }) => {
2434
+ const hostIcon = useHostIcon(name);
2810
2435
  if (hostIcon) {
2811
2436
  return /* @__PURE__ */ jsx(
2812
2437
  View,
@@ -2818,7 +2443,7 @@ var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2818
2443
  }
2819
2444
  );
2820
2445
  }
2821
- const glyph = lookupIconGlyph(name2);
2446
+ const glyph = lookupIconGlyph(name);
2822
2447
  if (!glyph) return null;
2823
2448
  const Family = resolveIconFamily(glyph.family, requireModule);
2824
2449
  if (!Family) return null;
@@ -3231,7 +2856,7 @@ var STATUS_ICONS = {
3231
2856
  info: "\u2139"
3232
2857
  };
3233
2858
  var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {
3234
- var _a2;
2859
+ var _a;
3235
2860
  const t = useOnboardingTheme();
3236
2861
  const reduced = useReducedMotion();
3237
2862
  const [submitted, setSubmitted] = useState(false);
@@ -3297,7 +2922,7 @@ var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSu
3297
2922
  headingStyle(t.fonts),
3298
2923
  { color, opacity: popT, transform: [{ scale: popScale }] }
3299
2924
  ],
3300
- children: (_a2 = STATUS_ICONS[status]) != null ? _a2 : "\xB7"
2925
+ children: (_a = STATUS_ICONS[status]) != null ? _a : "\xB7"
3301
2926
  }
3302
2927
  ),
3303
2928
  /* @__PURE__ */ jsx(
@@ -3640,7 +3265,7 @@ var runtimeRequire2 = (moduleName) => {
3640
3265
  try {
3641
3266
  switch (moduleName) {
3642
3267
  case "expo-constants":
3643
- return init_Constants(), __toCommonJS(Constants_exports);
3268
+ return __require("expo-constants");
3644
3269
  case "expo-application":
3645
3270
  return __require("expo-application");
3646
3271
  default:
@@ -3665,14 +3290,14 @@ var safeInterop = (requireModule, moduleName) => {
3665
3290
  };
3666
3291
  var detectAppVersion = (requireModule = runtimeRequire2) => {
3667
3292
  try {
3668
- const constants2 = safeInterop(requireModule, "expo-constants");
3669
- if (constants2) {
3670
- const expoConfig = constants2.expoConfig;
3293
+ const constants = safeInterop(requireModule, "expo-constants");
3294
+ if (constants) {
3295
+ const expoConfig = constants.expoConfig;
3671
3296
  if (expoConfig && typeof expoConfig === "object") {
3672
3297
  const fromExpoConfig = coerceVersion(expoConfig.version);
3673
3298
  if (fromExpoConfig) return fromExpoConfig;
3674
3299
  }
3675
- const fromNative = coerceVersion(constants2.nativeAppVersion);
3300
+ const fromNative = coerceVersion(constants.nativeAppVersion);
3676
3301
  if (fromNative) return fromNative;
3677
3302
  }
3678
3303
  const application = safeInterop(requireModule, "expo-application");
@@ -3737,7 +3362,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
3737
3362
  return void 0;
3738
3363
  };
3739
3364
  var collectDeviceContext = () => {
3740
- var _a2;
3365
+ var _a;
3741
3366
  const ctx = { platform: Platform.OS };
3742
3367
  try {
3743
3368
  const version = Platform.Version;
@@ -3746,26 +3371,26 @@ var collectDeviceContext = () => {
3746
3371
  }
3747
3372
  } catch {
3748
3373
  }
3749
- let constants2 = {};
3374
+ let constants = {};
3750
3375
  try {
3751
- constants2 = (_a2 = Platform.constants) != null ? _a2 : {};
3376
+ constants = (_a = Platform.constants) != null ? _a : {};
3752
3377
  } catch {
3753
- constants2 = {};
3378
+ constants = {};
3754
3379
  }
3755
3380
  let iosIdiom;
3756
3381
  try {
3757
3382
  if (Platform.OS === "android") {
3758
- const brand = constants2.Brand;
3759
- const model = constants2.Model;
3760
- const release = constants2.Release;
3383
+ const brand = constants.Brand;
3384
+ const model = constants.Model;
3385
+ const release = constants.Release;
3761
3386
  if (typeof brand === "string" && brand) ctx.brand = brand;
3762
3387
  if (typeof model === "string" && model) ctx.model = model;
3763
3388
  if (release !== void 0 && release !== null && String(release)) {
3764
3389
  ctx.osVersion = String(release);
3765
3390
  }
3766
3391
  } else if (Platform.OS === "ios") {
3767
- const osVersion = constants2.osVersion;
3768
- const idiom = constants2.interfaceIdiom;
3392
+ const osVersion = constants.osVersion;
3393
+ const idiom = constants.interfaceIdiom;
3769
3394
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
3770
3395
  ctx.osVersion = String(osVersion);
3771
3396
  }
@@ -3816,11 +3441,11 @@ var provenanceRegistry = () => {
3816
3441
  };
3817
3442
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
3818
3443
  var resolveIdentity = (input) => {
3819
- var _a2;
3444
+ var _a;
3820
3445
  if (typeof input.value !== "string") return void 0;
3821
3446
  const value = input.value.trim();
3822
3447
  if (!value) return void 0;
3823
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
3448
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
3824
3449
  if (input.source === "host") {
3825
3450
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
3826
3451
  }
@@ -3854,8 +3479,8 @@ var startHydration = (registry, appId, storage, minted) => {
3854
3479
  if (existing) return existing;
3855
3480
  const slot = deviceIdStorageKey(appId);
3856
3481
  const degraded = () => {
3857
- var _a2;
3858
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
3482
+ var _a;
3483
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
3859
3484
  };
3860
3485
  const adopted = (value) => ({ value, durable: true });
3861
3486
  let run;
@@ -3868,8 +3493,8 @@ var startHydration = (registry, appId, storage, minted) => {
3868
3493
  }
3869
3494
  return Promise.resolve(storage.setItem(slot, minted)).then(
3870
3495
  () => {
3871
- var _a2;
3872
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
3496
+ var _a;
3497
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
3873
3498
  },
3874
3499
  degraded
3875
3500
  );
@@ -3879,17 +3504,17 @@ var startHydration = (registry, appId, storage, minted) => {
3879
3504
  }
3880
3505
  registry.pending.set(appId, run);
3881
3506
  void run.then((outcome) => {
3882
- var _a2;
3507
+ var _a;
3883
3508
  if (outcome.durable) return;
3884
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
3509
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
3885
3510
  registry.hydrating.delete(appId);
3886
3511
  });
3887
3512
  return run;
3888
3513
  };
3889
3514
  var resolveAutoDeviceKey = (opts = {}) => {
3890
- var _a2, _b;
3515
+ var _a, _b;
3891
3516
  const registry = autoDeviceKeyRegistry();
3892
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3517
+ const appId = (_a = opts.appId) != null ? _a : "default";
3893
3518
  let id = registry.keys.get(appId);
3894
3519
  if (!id) {
3895
3520
  id = mintDeviceId();
@@ -3903,13 +3528,13 @@ var resolveAutoDeviceKey = (opts = {}) => {
3903
3528
  return (_b = registry.keys.get(appId)) != null ? _b : id;
3904
3529
  };
3905
3530
  var hydrateAutoDeviceKey = async (opts = {}) => {
3906
- var _a2, _b;
3907
- return (_b = (_a2 = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a2.value) != null ? _b : resolveAutoDeviceKey(opts);
3531
+ var _a, _b;
3532
+ return (_b = (_a = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a.value) != null ? _b : resolveAutoDeviceKey(opts);
3908
3533
  };
3909
3534
  var hydrateDeviceIdentity = async (opts = {}) => {
3910
- var _a2, _b, _c;
3535
+ var _a, _b, _c;
3911
3536
  const id = resolveAutoDeviceKey(opts);
3912
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3537
+ const appId = (_a = opts.appId) != null ? _a : "default";
3913
3538
  const record = (value, durable) => resolveIdentity({ value, space: "device", source: "auto", durable, scope: appId });
3914
3539
  if (!opts.storage) return record(id, false);
3915
3540
  const registry = autoDeviceKeyRegistry();
@@ -3919,11 +3544,11 @@ var hydrateDeviceIdentity = async (opts = {}) => {
3919
3544
  return record(outcome.value, outcome.durable);
3920
3545
  };
3921
3546
  var resetAutoDeviceKeys = () => {
3922
- var _a2;
3547
+ var _a;
3923
3548
  const registry = autoDeviceKeyRegistry();
3924
3549
  registry.keys.clear();
3925
3550
  registry.hydrating.clear();
3926
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
3551
+ (_a = registry.pending) == null ? void 0 : _a.clear();
3927
3552
  };
3928
3553
 
3929
3554
  // src/analytics/currentSession.ts
@@ -4025,9 +3650,9 @@ var sanitizeUserId = (raw) => {
4025
3650
  };
4026
3651
  var looksLikeEmail = (value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
4027
3652
  var identifyOnboarding = async (opts) => {
4028
- var _a2, _b, _c;
3653
+ var _a, _b, _c;
4029
3654
  const userId = sanitizeUserId(opts.userId);
4030
- if (!userId || !((_a2 = opts.config) == null ? void 0 : _a2.serverUrl)) return false;
3655
+ if (!userId || !((_a = opts.config) == null ? void 0 : _a.serverUrl)) return false;
4031
3656
  let contextId = ((_b = opts.contextId) == null ? void 0 : _b.trim()) || void 0;
4032
3657
  if (!contextId && opts.storage) {
4033
3658
  const key = (_c = opts.persistKey) != null ? _c : opts.appId ? sessionStorageKey(opts.appId) : void 0;
@@ -4098,11 +3723,11 @@ var clearUserContext = async (opts = {}) => {
4098
3723
  }
4099
3724
  };
4100
3725
  var activationJoinContext = (deviceKey) => {
4101
- var _a2;
4102
- return (_a2 = resolveUserContext({ deviceKey }).userContext) != null ? _a2 : {};
3726
+ var _a;
3727
+ return (_a = resolveUserContext({ deviceKey }).userContext) != null ? _a : {};
4103
3728
  };
4104
3729
  var resolveUserContext = (ctx = {}, opts = {}) => {
4105
- var _a2;
3730
+ var _a;
4106
3731
  const result = {};
4107
3732
  const bucket = {};
4108
3733
  const userId = sanitizeUserId(ctx.userId);
@@ -4112,7 +3737,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
4112
3737
  result.deviceKey = deviceKey;
4113
3738
  bucket.device_key = deviceKey;
4114
3739
  }
4115
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
3740
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
4116
3741
  if (appVersion) {
4117
3742
  result.appVersion = appVersion;
4118
3743
  bucket.app_version = appVersion;
@@ -4194,7 +3819,7 @@ var WireOnboarding = ({
4194
3819
  autoJoinKey = true,
4195
3820
  permissionScreens
4196
3821
  }) => {
4197
- var _a2, _b, _c, _d, _e, _f;
3822
+ var _a, _b, _c, _d, _e, _f;
4198
3823
  const boundUserId = useMemo(() => sanitizeUserId(userId), [userId]);
4199
3824
  const device = useMemo(() => {
4200
3825
  const collected = collectDeviceContext();
@@ -4236,7 +3861,7 @@ var WireOnboarding = ({
4236
3861
  clearTimeout(timer);
4237
3862
  };
4238
3863
  }, [wantsAutoJoin, autoJoinOutcome, config.appId, storage]);
4239
- const injectedJoinKey = wantsAutoJoin ? (_a2 = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a2 : void 0 : void 0;
3864
+ const injectedJoinKey = wantsAutoJoin ? (_a = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a : void 0 : void 0;
4240
3865
  const autoJoinPending = wantsAutoJoin && autoJoinOutcome === void 0;
4241
3866
  const effectiveUserContext = useMemo(
4242
3867
  () => injectedJoinKey ? { ...userContextStable, ...activationJoinContext(injectedJoinKey) } : userContextStable,
@@ -4320,8 +3945,8 @@ var WireOnboarding = ({
4320
3945
  settledPermissionsRef.current = settledPermissions;
4321
3946
  const handlePermissionSettled = useCallback(
4322
3947
  (id) => {
4323
- var _a3;
4324
- const current = (_a3 = settledPermissionsRef.current) != null ? _a3 : [];
3948
+ var _a2;
3949
+ const current = (_a2 = settledPermissionsRef.current) != null ? _a2 : [];
4325
3950
  if (current.includes(id)) return;
4326
3951
  const next = [...current, id];
4327
3952
  settledPermissionsRef.current = next;
@@ -4696,10 +4321,10 @@ var readEnabled = (raw) => {
4696
4321
  return { enabled: true };
4697
4322
  };
4698
4323
  var parseWireFeatures = (raw) => {
4699
- var _a2;
4324
+ var _a;
4700
4325
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return defaultWireFeatures;
4701
4326
  const src = raw;
4702
- const modeRaw = (_a2 = src.onboarding) == null ? void 0 : _a2.mode;
4327
+ const modeRaw = (_a = src.onboarding) == null ? void 0 : _a.mode;
4703
4328
  const mode = typeof modeRaw === "string" && VALID_MODES.includes(modeRaw) ? modeRaw : "ai";
4704
4329
  return {
4705
4330
  coachmarks: readEnabled(src.coachmarks),
@@ -4756,10 +4381,10 @@ var writeCachedFeatures = (storage, key, features) => {
4756
4381
  // src/features/fetchWireFeatures.ts
4757
4382
  var DEFAULT_TIMEOUT_MS = 4e3;
4758
4383
  var failOpen = async (storage, key) => {
4759
- var _a2;
4384
+ var _a;
4760
4385
  if (!storage) return defaultWireFeatures;
4761
4386
  const cached2 = await readCachedFeatures(storage, key);
4762
- return (_a2 = cached2 == null ? void 0 : cached2.features) != null ? _a2 : defaultWireFeatures;
4387
+ return (_a = cached2 == null ? void 0 : cached2.features) != null ? _a : defaultWireFeatures;
4763
4388
  };
4764
4389
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
4765
4390
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -4818,7 +4443,7 @@ var useWireFeatures = (config) => {
4818
4443
  return flags;
4819
4444
  };
4820
4445
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
4821
- var globalObj = global;
4446
+ var globalObj = globalThis;
4822
4447
  if (!globalObj[CONTEXT_SYMBOL]) {
4823
4448
  globalObj[CONTEXT_SYMBOL] = createContext(null);
4824
4449
  }
@@ -4836,11 +4461,11 @@ var WireFeaturesProvider = ({
4836
4461
  WireFeaturesProvider.displayName = "WireFeaturesProvider";
4837
4462
  var useWireFeaturesContext = () => useContext(WireFeaturesContext);
4838
4463
  var useResolvedFeatures = (options) => {
4839
- var _a2, _b, _c;
4464
+ var _a, _b, _c;
4840
4465
  const ctx = useWireFeaturesContext();
4841
4466
  const shouldFetch = !(options == null ? void 0 : options.flags) && ctx == null;
4842
4467
  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;
4468
+ return (_c = (_b = (_a = options == null ? void 0 : options.flags) != null ? _a : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4844
4469
  };
4845
4470
 
4846
4471
  // src/config/wireConfigFromEnv.ts
@@ -4850,8 +4475,8 @@ var WIRE_ENV_VARS = [
4850
4475
  "EXPO_PUBLIC_WIREAI_APP_ID"
4851
4476
  ];
4852
4477
  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;
4478
+ var _a, _b, _c, _d, _e;
4479
+ const apiKey = (_a = overrides == null ? void 0 : overrides.apiKey) != null ? _a : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4855
4480
  const serverUrl = (_b = overrides == null ? void 0 : overrides.serverUrl) != null ? _b : process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;
4856
4481
  const appId = (_d = (_c = overrides == null ? void 0 : overrides.appId) != null ? _c : process.env.EXPO_PUBLIC_WIREAI_APP_ID) != null ? _d : "default";
4857
4482
  if (!apiKey || !serverUrl) {
@@ -4876,10 +4501,10 @@ var wireConfigFromEnv = (overrides) => {
4876
4501
 
4877
4502
  // src/config/onboardingFlag.ts
4878
4503
  var isOnboardingEnabled = (opts) => {
4879
- var _a2;
4504
+ var _a;
4880
4505
  const transportPresent = wireConfigFromEnv(opts == null ? void 0 : opts.config) !== null;
4881
4506
  if (!transportPresent) return false;
4882
- return (_a2 = opts == null ? void 0 : opts.remote) != null ? _a2 : true;
4507
+ return (_a = opts == null ? void 0 : opts.remote) != null ? _a : true;
4883
4508
  };
4884
4509
 
4885
4510
  // src/analytics/analyticsEvent.ts
@@ -4974,9 +4599,9 @@ var resetActivationRevalidation = () => {
4974
4599
  // src/activation/wireActivation.ts
4975
4600
  var clean = cleanString;
4976
4601
  var createWireActivation = (config) => {
4977
- var _a2, _b;
4602
+ var _a, _b;
4978
4603
  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);
4604
+ const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a = config.userContext) == null ? void 0 : _a.deviceKey);
4980
4605
  resolveIdentity({
4981
4606
  value: explicitDeviceKey,
4982
4607
  space: "device",
@@ -4991,11 +4616,11 @@ var createWireActivation = (config) => {
4991
4616
  if (!explicitDeviceKey) resolveAutoDeviceKey(autoDeviceKeyOptions);
4992
4617
  const detectedAppVersion = detectAppVersion();
4993
4618
  const applyContext = (event) => {
4994
- var _a3, _b2, _c;
4619
+ var _a2, _b2, _c;
4995
4620
  const resolved = resolveUserContext(
4996
4621
  // `??` is lazy on purpose: an explicit key must never even touch the auto registry.
4997
4622
  {
4998
- ...(_a3 = config.userContext) != null ? _a3 : {},
4623
+ ...(_a2 = config.userContext) != null ? _a2 : {},
4999
4624
  deviceKey: explicitDeviceKey != null ? explicitDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions)
5000
4625
  },
5001
4626
  { autoAppVersion: (_b2 = config.appVersion) != null ? _b2 : detectedAppVersion }
@@ -5005,13 +4630,13 @@ var createWireActivation = (config) => {
5005
4630
  }
5006
4631
  if (resolved.userId && !event.user_id) event.user_id = resolved.userId;
5007
4632
  };
5008
- const track = async (name2, meta) => {
5009
- if (!clean(name2)) return false;
4633
+ const track = async (name, meta) => {
4634
+ if (!clean(name)) return false;
5010
4635
  const sessionId = ensureCurrentSessionId();
5011
4636
  const event = {
5012
4637
  event_type: "app_event",
5013
4638
  session_id: sessionId,
5014
- question_key: name2
4639
+ question_key: name
5015
4640
  };
5016
4641
  if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);
5017
4642
  applyContext(event);
@@ -5034,7 +4659,7 @@ var useActivationRevalidation = () => useSyncExternalStore(
5034
4659
  getActivationRevalidationVersion
5035
4660
  );
5036
4661
  var useWireActivation = (config) => {
5037
- var _a2;
4662
+ var _a;
5038
4663
  const ref = useRef(void 0);
5039
4664
  const prevKeys = useRef("");
5040
4665
  const currentKeys = [
@@ -5042,7 +4667,7 @@ var useWireActivation = (config) => {
5042
4667
  config.apiKey,
5043
4668
  config.appId,
5044
4669
  config.deviceKey,
5045
- (_a2 = config.userContext) == null ? void 0 : _a2.deviceKey
4670
+ (_a = config.userContext) == null ? void 0 : _a.deviceKey
5046
4671
  ].join("|");
5047
4672
  if (!ref.current || prevKeys.current !== currentKeys) {
5048
4673
  prevKeys.current = currentKeys;
@@ -5068,8 +4693,8 @@ var WIRE_PURCHASE_EVENTS = {
5068
4693
  var PLAN_TIER_CONTEXT_KEY = "plan_tier";
5069
4694
  var asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
5070
4695
  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);
4696
+ var _a, _b;
4697
+ const active = asRecord((_b = asRecord((_a = asRecord(info)) == null ? void 0 : _a.entitlements)) == null ? void 0 : _b.active);
5073
4698
  const found = active == null ? void 0 : active[entitlementId];
5074
4699
  const entitlement = asRecord(found);
5075
4700
  if (!entitlement) return void 0;
@@ -5142,19 +4767,19 @@ var createRevenueCatBridge = (config) => {
5142
4767
  }
5143
4768
  };
5144
4769
  const syncPlanTier = (customerInfo) => {
5145
- var _a2;
4770
+ var _a;
5146
4771
  const tier = resolvePlanTier(customerInfo, entitlementId);
5147
4772
  if (!writeTier) return tier;
5148
4773
  try {
5149
- (_a2 = analytics.setUserContext) == null ? void 0 : _a2.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
4774
+ (_a = analytics.setUserContext) == null ? void 0 : _a.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
5150
4775
  } catch {
5151
4776
  }
5152
4777
  return tier;
5153
4778
  };
5154
4779
  const paywallShown = (offering, props) => {
5155
- var _a2, _b;
4780
+ var _a, _b;
5156
4781
  const shown = {
5157
- packages_count: (_b = (_a2 = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a2.length) != null ? _b : 0
4782
+ packages_count: (_b = (_a = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a.length) != null ? _b : 0
5158
4783
  };
5159
4784
  if (typeof (offering == null ? void 0 : offering.identifier) === "string") shown.offering_id = offering.identifier;
5160
4785
  emit(WIRE_PURCHASE_EVENTS.paywallShown, { ...shown, ...props });
@@ -5208,10 +4833,10 @@ var resetSessionStartGuard = () => {
5208
4833
  _emitted.clear();
5209
4834
  };
5210
4835
  var reportSessionStart = (opts) => {
5211
- var _a2;
4836
+ var _a;
5212
4837
  const target = opts.target;
5213
4838
  if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
5214
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
4839
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5215
4840
  setCurrentSessionId(sessionId);
5216
4841
  if (opts.once !== false) {
5217
4842
  if (_emitted.has(sessionId)) return;
@@ -5271,11 +4896,11 @@ var useSessionStart = (config, options = {}) => {
5271
4896
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5272
4897
  };
5273
4898
  const fire = () => {
5274
- var _a2, _b;
4899
+ var _a, _b;
5275
4900
  const { config: cfg, options: opts } = latest.current;
5276
4901
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return;
5277
4902
  if (opts.enabled === false) return;
5278
- const target = { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" };
4903
+ const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
5279
4904
  const device = collectDeviceContext();
5280
4905
  if (cfg.appVersion) device.appVersion = cfg.appVersion;
5281
4906
  reportSessionStart({
@@ -5326,7 +4951,7 @@ var resetFirstOpenLatch = () => {
5326
4951
  _firstOpenLatched.clear();
5327
4952
  };
5328
4953
  var buildLifecycleEvent = (questionKey, opts) => {
5329
- var _a2;
4954
+ var _a;
5330
4955
  const userContext = {};
5331
4956
  if (opts.deviceKey) userContext.device_key = opts.deviceKey;
5332
4957
  if (typeof opts.sessionCount === "number" && Number.isFinite(opts.sessionCount)) {
@@ -5338,7 +4963,7 @@ var buildLifecycleEvent = (questionKey, opts) => {
5338
4963
  const event = {
5339
4964
  event_type: "app_event",
5340
4965
  question_key: questionKey,
5341
- session_id: (_a2 = opts.sessionId) != null ? _a2 : makeSessionId()
4966
+ session_id: (_a = opts.sessionId) != null ? _a : makeSessionId()
5342
4967
  };
5343
4968
  const userId = sanitizeUserId(opts.userId);
5344
4969
  if (userId) event.user_id = userId;
@@ -5364,8 +4989,8 @@ var emitFirstOpen = (opts) => {
5364
4989
  routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);
5365
4990
  };
5366
4991
  var reportFirstOpen = (opts) => {
5367
- var _a2;
5368
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
4992
+ var _a;
4993
+ const appId = (_a = opts.appId) != null ? _a : "default";
5369
4994
  if (_firstOpenLatched.has(appId)) return;
5370
4995
  _firstOpenLatched.add(appId);
5371
4996
  const storage = opts.storage;
@@ -5390,8 +5015,8 @@ var reportFirstOpen = (opts) => {
5390
5015
  })();
5391
5016
  };
5392
5017
  var wireLifecycleEvents = (opts) => {
5393
- var _a2;
5394
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
5018
+ var _a;
5019
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5395
5020
  reportFirstOpen({ ...opts, sessionId });
5396
5021
  reportSessionStart({
5397
5022
  target: opts.target,
@@ -5440,10 +5065,11 @@ var claimQueueKey = (preferred, explicit) => {
5440
5065
  );
5441
5066
  return key;
5442
5067
  };
5068
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
5443
5069
  var withTimeout4 = (p, ms) => {
5444
5070
  let timer;
5445
5071
  const timeout = new Promise((resolve) => {
5446
- timer = setTimeout(() => resolve(void 0), ms);
5072
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
5447
5073
  });
5448
5074
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
5449
5075
  };
@@ -5468,10 +5094,10 @@ var parsePersisted2 = (raw) => {
5468
5094
  }
5469
5095
  };
5470
5096
  var createEventQueue = (options) => {
5471
- var _a2, _b, _c, _d, _e, _f, _g;
5097
+ var _a, _b, _c, _d, _e, _f, _g;
5472
5098
  const target = options.target;
5473
5099
  const storage = options.storage;
5474
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
5100
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
5475
5101
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
5476
5102
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
5477
5103
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -5483,6 +5109,7 @@ var createEventQueue = (options) => {
5483
5109
  let flushing = false;
5484
5110
  let attempt = 0;
5485
5111
  let retryTimer;
5112
+ let backlogUnread = false;
5486
5113
  const resolveEnvelope = () => {
5487
5114
  try {
5488
5115
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -5491,14 +5118,14 @@ var createEventQueue = (options) => {
5491
5118
  }
5492
5119
  };
5493
5120
  const stamp = (event) => {
5494
- var _a3;
5121
+ var _a2;
5495
5122
  const env = resolveEnvelope();
5496
5123
  const stamped = { ...event };
5497
5124
  if (stamped.ts === void 0) stamped.ts = Date.now();
5498
5125
  if (!env) return stamped;
5499
5126
  if (!stamped.device && env.device) stamped.device = env.device;
5500
5127
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
5501
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
5128
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
5502
5129
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
5503
5130
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
5504
5131
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -5507,6 +5134,7 @@ var createEventQueue = (options) => {
5507
5134
  };
5508
5135
  const persist = () => {
5509
5136
  if (!storage) return;
5137
+ if (backlogUnread) return;
5510
5138
  try {
5511
5139
  if (pending.length === 0) {
5512
5140
  void storage.removeItem(key).catch(() => {
@@ -5529,23 +5157,44 @@ var createEventQueue = (options) => {
5529
5157
  return `__nosig_${nextId}_${Math.random()}`;
5530
5158
  }
5531
5159
  };
5160
+ const mergePersisted = (persistedItems) => {
5161
+ if (persistedItems.length === 0) return;
5162
+ const seen = new Set(pending.map((item) => item.sig));
5163
+ const restored = [];
5164
+ for (const persisted of persistedItems) {
5165
+ const sig = safeSig(persisted.event);
5166
+ if (seen.has(sig)) continue;
5167
+ seen.add(sig);
5168
+ restored.push({ id: nextId++, event: persisted.event, sig });
5169
+ }
5170
+ if (restored.length === 0) return;
5171
+ pending = [...restored, ...pending];
5172
+ enforceSizeCap();
5173
+ persist();
5174
+ };
5532
5175
  const loadPromise = (async () => {
5533
5176
  if (!storage) return;
5534
5177
  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 });
5178
+ const read = Promise.resolve(storage.getItem(key));
5179
+ read.catch(() => {
5180
+ });
5181
+ const raced = await withTimeout4(read, READ_TIMEOUT_MS4);
5182
+ if (raced === READ_TIMED_OUT) {
5183
+ backlogUnread = true;
5184
+ warnInDev(
5185
+ `[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.`
5186
+ );
5187
+ void read.then((late) => {
5188
+ backlogUnread = false;
5189
+ mergePersisted(parsePersisted2(late));
5190
+ flush();
5191
+ }).catch(() => {
5192
+ backlogUnread = false;
5193
+ persist();
5194
+ });
5195
+ return;
5546
5196
  }
5547
- enforceSizeCap();
5548
- persist();
5197
+ mergePersisted(parsePersisted2(raced));
5549
5198
  } catch {
5550
5199
  }
5551
5200
  })();
@@ -5642,13 +5291,13 @@ var useLifecycleEvents = (config, options = {}) => {
5642
5291
  const queueRef = useRef(void 0);
5643
5292
  useEffect(() => {
5644
5293
  const resolveSink = () => {
5645
- var _a2, _b;
5294
+ var _a, _b;
5646
5295
  const { config: cfg, options: opts } = latest.current;
5647
5296
  if (opts.sink) return opts.sink;
5648
5297
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return void 0;
5649
5298
  if (!queueRef.current) {
5650
5299
  queueRef.current = createEventQueue({
5651
- target: { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" },
5300
+ target: { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" },
5652
5301
  storage: cfg.storage,
5653
5302
  // Dedicated key so the hook's internal queue never collides with a host's main queue.
5654
5303
  storageKey: `wireai:evtq:lifecycle:${(_b = cfg.appId) != null ? _b : "default"}`,
@@ -5658,24 +5307,24 @@ var useLifecycleEvents = (config, options = {}) => {
5658
5307
  return queueRef.current.enqueue;
5659
5308
  };
5660
5309
  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;
5310
+ var _a;
5311
+ return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" } : void 0;
5663
5312
  };
5664
5313
  const resolveDeviceKey = (cfg, opts) => {
5665
- var _a2;
5666
- const host = (_a2 = resolveIdentity({
5314
+ var _a;
5315
+ const host = (_a = resolveIdentity({
5667
5316
  value: opts.deviceKey,
5668
5317
  space: "device",
5669
5318
  source: "host",
5670
5319
  scope: cfg == null ? void 0 : cfg.appId
5671
- })) == null ? void 0 : _a2.value;
5320
+ })) == null ? void 0 : _a.value;
5672
5321
  if (host) return host;
5673
5322
  if (!(cfg == null ? void 0 : cfg.storage)) return void 0;
5674
5323
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5675
5324
  };
5676
5325
  const mountOpenSessionId = makeSessionId();
5677
5326
  const fireSession = (sessionId) => {
5678
- var _a2;
5327
+ var _a;
5679
5328
  const { config: cfg, options: opts } = latest.current;
5680
5329
  if (opts.enabled === false) return;
5681
5330
  if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
@@ -5688,14 +5337,14 @@ var useLifecycleEvents = (config, options = {}) => {
5688
5337
  userId: opts.userId,
5689
5338
  deviceKey: resolveDeviceKey(cfg, opts),
5690
5339
  sessionCount: opts.sessionCount,
5691
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5340
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5692
5341
  platform: Platform.OS,
5693
5342
  device,
5694
5343
  meta: opts.meta
5695
5344
  });
5696
5345
  };
5697
5346
  const fireMountOpen = () => {
5698
- var _a2;
5347
+ var _a;
5699
5348
  fireSession(mountOpenSessionId);
5700
5349
  const { config: cfg, options: opts } = latest.current;
5701
5350
  if (opts.enabled === false) return;
@@ -5710,7 +5359,7 @@ var useLifecycleEvents = (config, options = {}) => {
5710
5359
  userId: opts.userId,
5711
5360
  deviceKey: resolveDeviceKey(cfg, opts),
5712
5361
  sessionCount: opts.sessionCount,
5713
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5362
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5714
5363
  platform: Platform.OS,
5715
5364
  device,
5716
5365
  meta: opts.meta