@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.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var reactNative = require('react-native');
4
3
  var React19 = require('react');
5
4
  var wireaiRn = require('wireai-rn');
6
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactNative = require('react-native');
7
7
  var reactNativeSafeAreaContext = require('react-native-safe-area-context');
8
8
  var zod = require('zod');
9
9
 
@@ -12,401 +12,16 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
  var React19__default = /*#__PURE__*/_interopDefault(React19);
13
13
 
14
14
  var __defProp = Object.defineProperty;
15
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
- var __getOwnPropNames = Object.getOwnPropertyNames;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
19
16
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
20
17
  }) : x)(function(x) {
21
18
  if (typeof require !== "undefined") return require.apply(this, arguments);
22
19
  throw Error('Dynamic require of "' + x + '" is not supported');
23
20
  });
24
- var __esm = (fn, res) => function __init() {
25
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
26
- };
27
21
  var __export = (target, all) => {
28
- for (var name2 in all)
29
- __defProp(target, name2, { get: all[name2], enumerable: true });
30
- };
31
- var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (let key of __getOwnPropNames(from))
34
- if (!__hasOwnProp.call(to, key) && key !== except)
35
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
- }
37
- return to;
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
38
24
  };
39
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
-
41
- // node_modules/expo-modules-core/src/errors/CodedError.ts
42
- var CodedError;
43
- var init_CodedError = __esm({
44
- "node_modules/expo-modules-core/src/errors/CodedError.ts"() {
45
- CodedError = class extends Error {
46
- constructor(code, message) {
47
- super(message);
48
- this.code = code;
49
- }
50
- };
51
- }
52
- });
53
-
54
- // node_modules/expo-modules-core/src/NativeModulesProxy.ts
55
- var NativeModulesProxy_default;
56
- var init_NativeModulesProxy = __esm({
57
- "node_modules/expo-modules-core/src/NativeModulesProxy.ts"() {
58
- NativeModulesProxy_default = {};
59
- }
60
- });
61
-
62
- // node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts
63
- function createTurboModuleToExpoProxy(turboModule, name2) {
64
- return null;
65
- }
66
- var init_TurboModuleToExpoModuleProxy = __esm({
67
- "node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts"() {
68
- }
69
- });
70
- var init_ensureNativeModulesAreInstalled = __esm({
71
- "node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts"() {
72
- }
73
- });
74
- function requireOptionalNativeModule(moduleName) {
75
- var _a2, _b, _c, _d, _e;
76
- try {
77
- 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(reactNative.TurboModuleRegistry.get(moduleName), moduleName)) != null ? _e : null;
78
- } catch (e) {
79
- const error = e;
80
- console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);
81
- return null;
82
- }
83
- }
84
- var init_requireNativeModule = __esm({
85
- "node_modules/expo-modules-core/src/requireNativeModule.ts"() {
86
- init_NativeModulesProxy();
87
- init_TurboModuleToExpoModuleProxy();
88
- init_ensureNativeModulesAreInstalled();
89
- }
90
- });
91
-
92
- // node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts
93
- var init_setUpJsLogger_fx = __esm({
94
- "node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts"() {
95
- init_CodedError();
96
- init_requireNativeModule();
97
- if (__DEV__ && typeof window !== "undefined" && (process.env.EXPO_OS === "android" || process.env.EXPO_OS === "ios")) {
98
- const NativeJSLogger = requireOptionalNativeModule("ExpoModulesCoreJSLogger");
99
- if (NativeJSLogger) {
100
- const onNewException = {
101
- eventName: "ExpoModulesCoreJSLogger.onNewError",
102
- action: console.error
103
- };
104
- const onNewWarning = {
105
- eventName: "ExpoModulesCoreJSLogger.onNewWarning",
106
- action: console.warn
107
- };
108
- const onNewDebug = {
109
- eventName: "ExpoModulesCoreJSLogger.onNewDebug",
110
- action: console.debug
111
- };
112
- const onNewInfo = {
113
- eventName: "ExpoModulesCoreJSLogger.onNewInfo",
114
- action: console.info
115
- };
116
- const onNewTrace = {
117
- eventName: "ExpoModulesCoreJSLogger.onNewTrace",
118
- action: console.trace
119
- };
120
- const listeners = [
121
- onNewException,
122
- onNewWarning,
123
- onNewDebug,
124
- onNewInfo,
125
- onNewTrace
126
- ];
127
- for (const listener of listeners) {
128
- NativeJSLogger.addListener(listener.eventName, ({ message }) => {
129
- listener.action(message);
130
- });
131
- }
132
- }
133
- }
134
- globalThis.ExpoModulesCore_CodedError = CodedError;
135
- }
136
- });
137
-
138
- // node_modules/expo-modules-core/src/registerWebModule.ts
139
- var init_registerWebModule = __esm({
140
- "node_modules/expo-modules-core/src/registerWebModule.ts"() {
141
- }
142
- });
143
-
144
- // node_modules/expo-modules-core/src/TypedArrays.types.ts
145
- var init_TypedArrays_types = __esm({
146
- "node_modules/expo-modules-core/src/TypedArrays.types.ts"() {
147
- }
148
- });
149
-
150
- // node_modules/expo-modules-core/src/PermissionsInterface.ts
151
- var init_PermissionsInterface = __esm({
152
- "node_modules/expo-modules-core/src/PermissionsInterface.ts"() {
153
- }
154
- });
155
- var init_PermissionsHook = __esm({
156
- "node_modules/expo-modules-core/src/PermissionsHook.ts"() {
157
- "use client";
158
- }
159
- });
160
- var init_Refs = __esm({
161
- "node_modules/expo-modules-core/src/Refs.ts"() {
162
- }
163
- });
164
- var init_useReleasingSharedObject = __esm({
165
- "node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts"() {
166
- "use client";
167
- }
168
- });
169
-
170
- // node_modules/expo-modules-core/src/reload.ts
171
- var init_reload = __esm({
172
- "node_modules/expo-modules-core/src/reload.ts"() {
173
- }
174
- });
175
-
176
- // node_modules/expo-modules-core/src/index.ts
177
- var init_src = __esm({
178
- "node_modules/expo-modules-core/src/index.ts"() {
179
- init_setUpJsLogger_fx();
180
- init_requireNativeModule();
181
- init_registerWebModule();
182
- init_TypedArrays_types();
183
- init_PermissionsInterface();
184
- init_PermissionsHook();
185
- init_Refs();
186
- init_useReleasingSharedObject();
187
- init_reload();
188
- init_CodedError();
189
- }
190
- });
191
-
192
- // node_modules/expo-constants/build/Constants.types.js
193
- var AppOwnership, ExecutionEnvironment, UserInterfaceIdiom;
194
- var init_Constants_types = __esm({
195
- "node_modules/expo-constants/build/Constants.types.js"() {
196
- (function(AppOwnership2) {
197
- AppOwnership2["Expo"] = "expo";
198
- })(AppOwnership || (AppOwnership = {}));
199
- (function(ExecutionEnvironment2) {
200
- ExecutionEnvironment2["Bare"] = "bare";
201
- ExecutionEnvironment2["Standalone"] = "standalone";
202
- ExecutionEnvironment2["StoreClient"] = "storeClient";
203
- })(ExecutionEnvironment || (ExecutionEnvironment = {}));
204
- (function(UserInterfaceIdiom2) {
205
- UserInterfaceIdiom2["Handset"] = "handset";
206
- UserInterfaceIdiom2["Tablet"] = "tablet";
207
- UserInterfaceIdiom2["Desktop"] = "desktop";
208
- UserInterfaceIdiom2["TV"] = "tv";
209
- UserInterfaceIdiom2["Unsupported"] = "unsupported";
210
- })(UserInterfaceIdiom || (UserInterfaceIdiom = {}));
211
- }
212
- });
213
-
214
- // node_modules/expo-constants/build/ExponentConstants.js
215
- var ExponentConstants_default;
216
- var init_ExponentConstants = __esm({
217
- "node_modules/expo-constants/build/ExponentConstants.js"() {
218
- init_src();
219
- ExponentConstants_default = requireOptionalNativeModule("ExponentConstants");
220
- }
221
- });
222
-
223
- // node_modules/expo-constants/build/Constants.js
224
- var Constants_exports = {};
225
- __export(Constants_exports, {
226
- AppOwnership: () => AppOwnership,
227
- ExecutionEnvironment: () => ExecutionEnvironment,
228
- UserInterfaceIdiom: () => UserInterfaceIdiom,
229
- default: () => Constants_default
230
- });
231
- function isEmbeddedManifest(manifest) {
232
- return !isExpoUpdatesManifest(manifest);
233
- }
234
- function isExpoUpdatesManifest(manifest) {
235
- return "metadata" in manifest;
236
- }
237
- function getManifest(suppressWarning = false) {
238
- if (!rawManifest) {
239
- const invalidManifestType = rawManifest === null ? "null" : "undefined";
240
- if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && reactNative.Platform.OS !== "web") {
241
- if (!suppressWarning) {
242
- 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.`);
243
- }
244
- } else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {
245
- throw new CodedError("ERR_CONSTANTS_MANIFEST_UNAVAILABLE", `Constants.manifest is ${invalidManifestType}, must be an object.`);
246
- }
247
- }
248
- return rawManifest;
249
- }
250
- var ExpoUpdates, rawUpdatesManifest, rawDevLauncherManifest, rawAppConfig, _a, rawManifest, name, appOwnership, nativeConstants, constants, Constants_default;
251
- var init_Constants = __esm({
252
- "node_modules/expo-constants/build/Constants.js"() {
253
- init_src();
254
- init_Constants_types();
255
- init_ExponentConstants();
256
- init_Constants_types();
257
- if (!ExponentConstants_default) {
258
- console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");
259
- }
260
- ExpoUpdates = requireOptionalNativeModule("ExpoUpdates");
261
- rawUpdatesManifest = null;
262
- if (ExpoUpdates) {
263
- let updatesManifest;
264
- if (ExpoUpdates.manifest) {
265
- updatesManifest = ExpoUpdates.manifest;
266
- } else if (ExpoUpdates.manifestString) {
267
- updatesManifest = JSON.parse(ExpoUpdates.manifestString);
268
- }
269
- if (updatesManifest && Object.keys(updatesManifest).length > 0) {
270
- rawUpdatesManifest = updatesManifest;
271
- }
272
- }
273
- rawDevLauncherManifest = null;
274
- if (reactNative.NativeModules.EXDevLauncher) {
275
- let devLauncherManifest;
276
- if (reactNative.NativeModules.EXDevLauncher.manifestString) {
277
- devLauncherManifest = JSON.parse(reactNative.NativeModules.EXDevLauncher.manifestString);
278
- }
279
- if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {
280
- rawDevLauncherManifest = devLauncherManifest;
281
- }
282
- }
283
- rawAppConfig = null;
284
- if (ExponentConstants_default && ExponentConstants_default.manifest) {
285
- const appConfig = ExponentConstants_default.manifest;
286
- if (typeof appConfig === "string") {
287
- rawAppConfig = JSON.parse(appConfig);
288
- } else {
289
- rawAppConfig = appConfig;
290
- }
291
- }
292
- rawManifest = (_a = rawUpdatesManifest != null ? rawUpdatesManifest : rawDevLauncherManifest) != null ? _a : rawAppConfig;
293
- ({ name, appOwnership, ...nativeConstants } = ExponentConstants_default || {});
294
- constants = {
295
- ...nativeConstants,
296
- // Ensure this is null in bare workflow
297
- appOwnership: appOwnership != null ? appOwnership : null
298
- };
299
- Object.defineProperties(constants, {
300
- /**
301
- * Use `manifest` property by default.
302
- * This property is only used for internal purposes.
303
- * It behaves similarly to the original one, but suppresses warning upon no manifest available.
304
- * `expo-asset` uses it to prevent users from seeing mentioned warning.
305
- */
306
- __unsafeNoWarnManifest: {
307
- get() {
308
- const maybeManifest = getManifest(true);
309
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
310
- return null;
311
- }
312
- return maybeManifest;
313
- },
314
- enumerable: false
315
- },
316
- __unsafeNoWarnManifest2: {
317
- get() {
318
- const maybeManifest = getManifest(true);
319
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
320
- return null;
321
- }
322
- return maybeManifest;
323
- },
324
- enumerable: false
325
- },
326
- manifest: {
327
- get() {
328
- const maybeManifest = getManifest();
329
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
330
- return null;
331
- }
332
- return maybeManifest;
333
- },
334
- enumerable: true
335
- },
336
- manifest2: {
337
- get() {
338
- const maybeManifest = getManifest();
339
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
340
- return null;
341
- }
342
- return maybeManifest;
343
- },
344
- enumerable: true
345
- },
346
- expoConfig: {
347
- get() {
348
- var _a2, _b;
349
- const maybeManifest = getManifest(true);
350
- if (!maybeManifest) {
351
- return null;
352
- }
353
- if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {
354
- return rawAppConfig;
355
- }
356
- if (isExpoUpdatesManifest(maybeManifest)) {
357
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoClient) != null ? _b : null;
358
- } else if (isEmbeddedManifest(maybeManifest)) {
359
- return maybeManifest;
360
- }
361
- return null;
362
- },
363
- enumerable: true
364
- },
365
- expoGoConfig: {
366
- get() {
367
- var _a2, _b;
368
- const maybeManifest = getManifest(true);
369
- if (!maybeManifest) {
370
- return null;
371
- }
372
- if (isExpoUpdatesManifest(maybeManifest)) {
373
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoGo) != null ? _b : null;
374
- } else if (isEmbeddedManifest(maybeManifest)) {
375
- return maybeManifest;
376
- }
377
- return null;
378
- },
379
- enumerable: true
380
- },
381
- easConfig: {
382
- get() {
383
- var _a2, _b;
384
- const maybeManifest = getManifest(true);
385
- if (!maybeManifest) {
386
- return null;
387
- }
388
- if (isExpoUpdatesManifest(maybeManifest)) {
389
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.eas) != null ? _b : null;
390
- } else if (isEmbeddedManifest(maybeManifest)) {
391
- return maybeManifest;
392
- }
393
- return null;
394
- },
395
- enumerable: true
396
- },
397
- __rawManifest_TEST: {
398
- get() {
399
- return rawManifest;
400
- },
401
- set(value) {
402
- rawManifest = value;
403
- },
404
- enumerable: false
405
- }
406
- });
407
- Constants_default = constants;
408
- }
409
- });
410
25
 
411
26
  // src/theme/defaultTheme.ts
412
27
  var defaultOnboardingTheme = {
@@ -464,7 +79,12 @@ var mergeTheme = (override) => {
464
79
  button: { ...defaultOnboardingTheme.button, ...override.button }
465
80
  };
466
81
  };
467
- var OnboardingThemeContext = React19.createContext(null);
82
+ var THEME_CONTEXT_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:themeContext");
83
+ var themeGlobal = globalThis;
84
+ if (!themeGlobal[THEME_CONTEXT_SLOT]) {
85
+ themeGlobal[THEME_CONTEXT_SLOT] = React19.createContext(null);
86
+ }
87
+ var OnboardingThemeContext = themeGlobal[THEME_CONTEXT_SLOT];
468
88
  var OnboardingThemeProvider = ({
469
89
  theme,
470
90
  children
@@ -485,10 +105,10 @@ var IllustrationProvider = ({
485
105
  const value = React19.useMemo(() => registry != null ? registry : EMPTY_REGISTRY, [registry]);
486
106
  return /* @__PURE__ */ jsxRuntime.jsx(IllustrationContext.Provider, { value, children });
487
107
  };
488
- var useIllustration = (name2) => {
108
+ var useIllustration = (name) => {
489
109
  const registry = React19.useContext(IllustrationContext);
490
- if (!name2) return void 0;
491
- return registry[name2];
110
+ if (!name) return void 0;
111
+ return registry[name];
492
112
  };
493
113
  var Disc = ({ children }) => {
494
114
  const t = useOnboardingTheme();
@@ -587,11 +207,11 @@ var IconRegistryProvider = ({
587
207
  const value = React19.useMemo(() => registry != null ? registry : EMPTY_REGISTRY2, [registry]);
588
208
  return /* @__PURE__ */ jsxRuntime.jsx(IconContext.Provider, { value, children });
589
209
  };
590
- var useHostIcon = (name2) => {
210
+ var useHostIcon = (name) => {
591
211
  const registry = React19.useContext(IconContext);
592
- if (!name2) return void 0;
593
- if (!Object.prototype.hasOwnProperty.call(registry, name2)) return void 0;
594
- return registry[name2];
212
+ if (!name) return void 0;
213
+ if (!Object.prototype.hasOwnProperty.call(registry, name)) return void 0;
214
+ return registry[name];
595
215
  };
596
216
 
597
217
  // src/theme/typography.ts
@@ -607,9 +227,9 @@ var captionStyle = (f) => ({
607
227
  lineHeight: round(f.baseSize * 0.8125 * f.scale * 1.5)
608
228
  });
609
229
  var labelStyle = (f) => {
610
- var _a2;
230
+ var _a;
611
231
  return {
612
- fontFamily: (_a2 = f.medium) != null ? _a2 : f.bold,
232
+ fontFamily: (_a = f.medium) != null ? _a : f.bold,
613
233
  fontSize: round(f.baseSize * f.scale),
614
234
  lineHeight: round(f.baseSize * f.scale * 1.4),
615
235
  fontWeight: f.medium ? void 0 : "600"
@@ -622,9 +242,9 @@ var headingStyle = (f) => ({
622
242
  fontWeight: f.bold ? void 0 : "700"
623
243
  });
624
244
  var buttonLabelStyle = (f) => {
625
- var _a2;
245
+ var _a;
626
246
  return {
627
- fontFamily: (_a2 = f.bold) != null ? _a2 : f.medium,
247
+ fontFamily: (_a = f.bold) != null ? _a : f.medium,
628
248
  fontSize: round(f.baseSize * f.scale),
629
249
  fontWeight: f.bold ? void 0 : "600"
630
250
  };
@@ -1373,7 +993,7 @@ var _CardHandoff = ({
1373
993
  const running = React19.useRef({});
1374
994
  const mounted = React19.useRef(false);
1375
995
  React19.useEffect(() => {
1376
- var _a2, _b;
996
+ var _a, _b;
1377
997
  const last = prev.current;
1378
998
  prev.current = { key: transitionKey, node: children, variant };
1379
999
  if (!mounted.current) {
@@ -1382,7 +1002,7 @@ var _CardHandoff = ({
1382
1002
  return;
1383
1003
  }
1384
1004
  if (last.key === transitionKey) return;
1385
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
1005
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1386
1006
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1387
1007
  setLeaving(last);
1388
1008
  enterT.setValue(0);
@@ -1407,8 +1027,8 @@ var _CardHandoff = ({
1407
1027
  });
1408
1028
  React19.useEffect(
1409
1029
  () => () => {
1410
- var _a2, _b;
1411
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
1030
+ var _a, _b;
1031
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1412
1032
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1413
1033
  },
1414
1034
  []
@@ -1489,13 +1109,13 @@ var tryParse = (s) => {
1489
1109
  }
1490
1110
  };
1491
1111
  var deriveAnswers = (messages) => {
1492
- var _a2, _b, _c;
1112
+ var _a, _b, _c;
1493
1113
  const out = {};
1494
1114
  for (let i = 0; i < messages.length; i++) {
1495
1115
  const m = messages[i];
1496
1116
  const r = m == null ? void 0 : m.response;
1497
1117
  if (!m || m.role !== "assistant" || !r || r.action !== "render") continue;
1498
- const props = (_a2 = r.props) != null ? _a2 : {};
1118
+ const props = (_a = r.props) != null ? _a : {};
1499
1119
  const progress = props.progress;
1500
1120
  const questionText = (_c = (_b = props.title) != null ? _b : props.label) != null ? _c : props.question;
1501
1121
  const key = (progress == null ? void 0 : progress.slot_id) || (progress == null ? void 0 : progress.key) || questionText;
@@ -1509,9 +1129,9 @@ var deriveAnswers = (messages) => {
1509
1129
 
1510
1130
  // src/utils/readProgress.ts
1511
1131
  var readProgress = (response) => {
1512
- var _a2;
1132
+ var _a;
1513
1133
  if (!response || response.action !== "render") return {};
1514
- const props = (_a2 = response.props) != null ? _a2 : {};
1134
+ const props = (_a = response.props) != null ? _a : {};
1515
1135
  const raw = props.progress;
1516
1136
  if (!raw || typeof raw !== "object") return {};
1517
1137
  const p = raw;
@@ -1537,13 +1157,15 @@ var toWireEvents = (events) => events.map((event) => {
1537
1157
  return rest;
1538
1158
  }
1539
1159
  });
1540
- var buildEventsRequest = (target, events) => {
1160
+ var buildEventsRequest = (target, events, options) => {
1541
1161
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
1542
1162
  try {
1543
1163
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
1544
1164
  const headers = { "Content-Type": "application/json" };
1545
1165
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
1546
- const body = JSON.stringify({ events: toWireEvents(events) });
1166
+ const envelope = { events: toWireEvents(events) };
1167
+ if ((options == null ? void 0 : options.dryRun) === true) ;
1168
+ const body = JSON.stringify(envelope);
1547
1169
  return { url, init: { method: "POST", headers, body } };
1548
1170
  } catch {
1549
1171
  return null;
@@ -1752,10 +1374,10 @@ var _PermissionCard = ({
1752
1374
  getStatusRef.current = getStatus;
1753
1375
  const shownRef = React19.useRef(false);
1754
1376
  React19.useEffect(() => {
1755
- var _a2;
1377
+ var _a;
1756
1378
  if (shownRef.current) return;
1757
1379
  shownRef.current = true;
1758
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "shown");
1380
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "shown");
1759
1381
  }, []);
1760
1382
  React19.useEffect(() => {
1761
1383
  const probe = getStatusRef.current;
@@ -1781,18 +1403,18 @@ var _PermissionCard = ({
1781
1403
  );
1782
1404
  }, [permission]);
1783
1405
  const settle = React19.useCallback((outcome) => {
1784
- var _a2;
1406
+ var _a;
1785
1407
  if (settledRef.current) return;
1786
1408
  settledRef.current = true;
1787
1409
  clearWatchdog();
1788
- (_a2 = onSettledRef.current) == null ? void 0 : _a2.call(onSettledRef, outcome);
1410
+ (_a = onSettledRef.current) == null ? void 0 : _a.call(onSettledRef, outcome);
1789
1411
  }, [clearWatchdog]);
1790
1412
  const primaryAction = status === "blocked" ? "settings" : status === "granted" || !request ? "continue" : "ask";
1791
1413
  const handlePrimary = React19.useCallback(() => {
1792
- var _a2, _b, _c, _d;
1414
+ var _a, _b, _c, _d;
1793
1415
  if (settledRef.current || busy) return;
1794
1416
  if (primaryAction === "settings") {
1795
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "settings", "blocked");
1417
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "settings", "blocked");
1796
1418
  try {
1797
1419
  void Promise.resolve(openSettings == null ? void 0 : openSettings()).catch(() => {
1798
1420
  });
@@ -1817,7 +1439,7 @@ var _PermissionCard = ({
1817
1439
  }
1818
1440
  setBusy(true);
1819
1441
  const finish = (value) => {
1820
- var _a3, _b2;
1442
+ var _a2, _b2;
1821
1443
  if (settledRef.current) return;
1822
1444
  clearWatchdog();
1823
1445
  const resolved = normalizePermissionStatus(value);
@@ -1825,7 +1447,7 @@ var _PermissionCard = ({
1825
1447
  setStatus(resolved);
1826
1448
  if (resolved === "granted") {
1827
1449
  playHaptic("success");
1828
- (_a3 = onStageRef.current) == null ? void 0 : _a3.call(onStageRef, "granted", "granted");
1450
+ (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "granted", "granted");
1829
1451
  } else {
1830
1452
  (_b2 = onStageRef.current) == null ? void 0 : _b2.call(onStageRef, "denied", resolved);
1831
1453
  }
@@ -1847,9 +1469,9 @@ var _PermissionCard = ({
1847
1469
  }
1848
1470
  }, [busy, primaryAction, status, request, openSettings, settle, clearWatchdog, permission]);
1849
1471
  const handleSecondary = React19.useCallback(() => {
1850
- var _a2;
1472
+ var _a;
1851
1473
  if (settledRef.current || busy) return;
1852
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "skipped");
1474
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "skipped");
1853
1475
  settle("skipped");
1854
1476
  }, [busy, settle]);
1855
1477
  const popT = React19.useRef(new reactNative.Animated.Value(reduced ? 1 : 0)).current;
@@ -1955,18 +1577,18 @@ var isPermissionDue = (placement, position) => {
1955
1577
  return position.cardIndex >= target || position.isTerminal;
1956
1578
  };
1957
1579
  var permissionScreenId = (screen, index) => {
1958
- var _a2;
1959
- return (_a2 = screen.id) != null ? _a2 : `${screen.permission}:${index}`;
1580
+ var _a;
1581
+ return (_a = screen.id) != null ? _a : `${screen.permission}:${index}`;
1960
1582
  };
1961
1583
  var selectDuePermissionScreen = (screens, settled, position) => {
1962
- var _a2;
1584
+ var _a;
1963
1585
  if (!screens || screens.length === 0) return void 0;
1964
1586
  for (let index = 0; index < screens.length; index++) {
1965
1587
  const screen = screens[index];
1966
1588
  if (!screen) continue;
1967
1589
  const id = permissionScreenId(screen, index);
1968
1590
  if (settled.includes(id)) continue;
1969
- if (isPermissionDue((_a2 = screen.placement) != null ? _a2 : DEFAULT_PERMISSION_PLACEMENT, position)) {
1591
+ if (isPermissionDue((_a = screen.placement) != null ? _a : DEFAULT_PERMISSION_PLACEMENT, position)) {
1970
1592
  return { screen, id };
1971
1593
  }
1972
1594
  }
@@ -1998,8 +1620,8 @@ var DEFAULT_PERMISSION_COPY = {
1998
1620
  notifications: NOTIFICATIONS_PERMISSION_COPY
1999
1621
  };
2000
1622
  var resolvePermissionCopy = (permission, overrides) => {
2001
- var _a2;
2002
- const base = (_a2 = DEFAULT_PERMISSION_COPY[permission]) != null ? _a2 : GENERIC_PERMISSION_COPY;
1623
+ var _a;
1624
+ const base = (_a = DEFAULT_PERMISSION_COPY[permission]) != null ? _a : GENERIC_PERMISSION_COPY;
2003
1625
  if (!overrides) return base;
2004
1626
  const merged = { ...base };
2005
1627
  for (const key of Object.keys(overrides)) {
@@ -2042,7 +1664,7 @@ var OnboardingFlow = ({
2042
1664
  permissionsPending = false,
2043
1665
  onPermissionSettled
2044
1666
  }) => {
2045
- var _a2, _b, _c, _d, _e, _f;
1667
+ var _a, _b, _c, _d, _e, _f;
2046
1668
  const { messages, error, isLoading, sendMessage, reset } = wireaiRn.useWireAIThread();
2047
1669
  const makeActions = wireaiRn.useWireAIAction(sendMessage);
2048
1670
  const c = React19.useMemo(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);
@@ -2062,7 +1684,8 @@ var OnboardingFlow = ({
2062
1684
  clientContextRef.current = clientContext;
2063
1685
  const lastScreenIndexRef = React19.useRef(-1);
2064
1686
  const previewTimer = React19.useRef(null);
2065
- const started = React19.useRef(false);
1687
+ const [runId, setRunId] = React19.useState(0);
1688
+ const startedRunRef = React19.useRef(-1);
2066
1689
  const finished = React19.useRef(false);
2067
1690
  const errored = React19.useRef(false);
2068
1691
  const attempts = React19.useRef(0);
@@ -2076,39 +1699,41 @@ var OnboardingFlow = ({
2076
1699
  onPermissionSettledRef.current = onPermissionSettled;
2077
1700
  const lastCard = React19.useMemo(
2078
1701
  () => [...messages].reverse().find((m) => {
2079
- var _a3;
2080
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1702
+ var _a2;
1703
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2081
1704
  }),
2082
1705
  [messages]
2083
1706
  );
2084
1707
  const renderedCount = React19.useMemo(
2085
1708
  () => messages.filter((m) => {
2086
- var _a3;
2087
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1709
+ var _a2;
1710
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2088
1711
  }).length,
2089
1712
  [messages]
2090
1713
  );
2091
1714
  const progress = React19.useMemo(() => readProgress(lastCard == null ? void 0 : lastCard.response), [lastCard]);
2092
1715
  React19.useEffect(() => {
2093
- var _a3;
2094
- if (started.current) return;
2095
- started.current = true;
2096
- sendMessage(resumed ? SKIP_ONE_SENTINEL : startMessage);
2097
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(
1716
+ var _a2;
1717
+ if (startedRunRef.current === runId) return;
1718
+ const isFirstRun = startedRunRef.current < 0;
1719
+ startedRunRef.current = runId;
1720
+ sendMessage(isFirstRun && !resumed ? startMessage : SKIP_ONE_SENTINEL);
1721
+ if (!isFirstRun) return;
1722
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(
2098
1723
  onEventRef,
2099
1724
  resumed ? { type: "resumed", contextId: sessionId } : { type: "started", contextId: sessionId }
2100
1725
  );
2101
- }, [sendMessage, startMessage, resumed, sessionId]);
1726
+ }, [sendMessage, startMessage, resumed, sessionId, runId]);
2102
1727
  React19.useEffect(() => {
2103
1728
  if (lastCard) return;
2104
1729
  const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);
2105
1730
  return () => clearTimeout(timer);
2106
- }, [lastCard, startTimeoutMs]);
1731
+ }, [lastCard, startTimeoutMs, runId]);
2107
1732
  React19.useEffect(() => {
2108
- var _a3, _b2, _c2, _d2;
1733
+ var _a2, _b2, _c2, _d2;
2109
1734
  setValidationError(void 0);
2110
1735
  if (!(lastCard == null ? void 0 : lastCard.id)) return;
2111
- const step2 = (_a3 = progress.step) != null ? _a3 : renderedCount;
1736
+ const step2 = (_a2 = progress.step) != null ? _a2 : renderedCount;
2112
1737
  lastScreenIndexRef.current = Math.max(0, step2 - 1);
2113
1738
  (_c2 = onEventRef.current) == null ? void 0 : _c2.call(onEventRef, {
2114
1739
  type: "turn",
@@ -2124,13 +1749,13 @@ var OnboardingFlow = ({
2124
1749
  }, [lastCard == null ? void 0 : lastCard.id]);
2125
1750
  React19.useEffect(() => {
2126
1751
  return () => {
2127
- var _a3, _b2, _c2;
1752
+ var _a2, _b2, _c2;
2128
1753
  if (finished.current || degradedRef.current) return;
2129
1754
  reportClientEvent(reportTargetRef.current, {
2130
1755
  event_type: "dropped",
2131
1756
  session_id: sessionIdRef.current,
2132
1757
  screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : void 0,
2133
- device: (_a3 = clientContextRef.current) == null ? void 0 : _a3.device,
1758
+ device: (_a2 = clientContextRef.current) == null ? void 0 : _a2.device,
2134
1759
  user_context: (_b2 = clientContextRef.current) == null ? void 0 : _b2.userContext,
2135
1760
  user_id: (_c2 = clientContextRef.current) == null ? void 0 : _c2.userId
2136
1761
  });
@@ -2138,17 +1763,17 @@ var OnboardingFlow = ({
2138
1763
  }, []);
2139
1764
  const restartThread = React19.useCallback(() => {
2140
1765
  setTimedOut(false);
2141
- started.current = false;
2142
1766
  errored.current = false;
1767
+ setRunId((n) => n + 1);
2143
1768
  reset();
2144
1769
  }, [reset]);
2145
1770
  React19.useEffect(() => {
2146
- var _a3, _b2, _c2, _d2, _e2, _f2, _g;
1771
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
2147
1772
  if (errored.current) return;
2148
1773
  if (!error && !timedOut) return;
2149
1774
  errored.current = true;
2150
1775
  const reason = error ? "backend" : "timeout";
2151
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "error", reason });
1776
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "error", reason });
2152
1777
  attempts.current += 1;
2153
1778
  if (attempts.current <= maxRetries) {
2154
1779
  (_b2 = onEventRef.current) == null ? void 0 : _b2.call(onEventRef, { type: "retry", reason, attempt: attempts.current });
@@ -2186,8 +1811,8 @@ var OnboardingFlow = ({
2186
1811
  }, [isLoading, sendMessage]);
2187
1812
  const emitPermissionStage = React19.useCallback(
2188
1813
  (permission, stage, status) => {
2189
- var _a3, _b2, _c2, _d2;
2190
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "permission", permission, stage, status });
1814
+ var _a2, _b2, _c2, _d2;
1815
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "permission", permission, stage, status });
2191
1816
  reportClientEvent(reportTargetRef.current, {
2192
1817
  event_type: "app_event",
2193
1818
  session_id: sessionIdRef.current,
@@ -2204,9 +1829,9 @@ var OnboardingFlow = ({
2204
1829
  );
2205
1830
  const settlePermission = React19.useCallback(
2206
1831
  (id, screen, outcome) => {
2207
- var _a3, _b2;
1832
+ var _a2, _b2;
2208
1833
  setLocallySettledPermissions((prev) => prev.includes(id) ? prev : [...prev, id]);
2209
- (_a3 = onPermissionSettledRef.current) == null ? void 0 : _a3.call(onPermissionSettledRef, id, outcome);
1834
+ (_a2 = onPermissionSettledRef.current) == null ? void 0 : _a2.call(onPermissionSettledRef, id, outcome);
2210
1835
  try {
2211
1836
  (_b2 = screen.onResult) == null ? void 0 : _b2.call(screen, screen.permission, outcome);
2212
1837
  } catch {
@@ -2231,26 +1856,26 @@ var OnboardingFlow = ({
2231
1856
  }, []);
2232
1857
  const wrappedActions = React19.useCallback(
2233
1858
  (messageId) => {
2234
- var _a3;
1859
+ var _a2;
2235
1860
  const base = makeActions(messageId);
2236
1861
  const validators2 = validatorsRef.current;
2237
- 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;
1862
+ 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;
2238
1863
  if (!validator) return base;
2239
1864
  const out = { ...base };
2240
- for (const name2 of ANSWER_CALLBACKS) {
2241
- const original = base[name2];
1865
+ for (const name of ANSWER_CALLBACKS) {
1866
+ const original = base[name];
2242
1867
  if (!original) continue;
2243
- out[name2] = (...args) => {
1868
+ out[name] = (...args) => {
2244
1869
  const value = args[0];
2245
1870
  if (typeof value !== "string") return original(...args);
2246
1871
  setValidating(true);
2247
1872
  validator(value).then((res) => {
2248
- var _a4;
1873
+ var _a3;
2249
1874
  if (res.ok) {
2250
1875
  setValidationError(void 0);
2251
1876
  original(...args);
2252
1877
  } else {
2253
- setValidationError((_a4 = res.error) != null ? _a4 : "That value isn't available.");
1878
+ setValidationError((_a3 = res.error) != null ? _a3 : "That value isn't available.");
2254
1879
  }
2255
1880
  }).catch(() => {
2256
1881
  original(...args);
@@ -2281,7 +1906,7 @@ var OnboardingFlow = ({
2281
1906
  if (!lastCard || !response) {
2282
1907
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingScreen, { title: c.startingTitle, hint: c.startingHint });
2283
1908
  }
2284
- const step = (_a2 = progress.step) != null ? _a2 : renderedCount;
1909
+ const step = (_a = progress.step) != null ? _a : renderedCount;
2285
1910
  const total = (_b = progress.total) != null ? _b : approxScreens;
2286
1911
  const isTerminal = response.action === "render" && response.component === "StatusCard";
2287
1912
  const duePermission = permissionsPending ? void 0 : selectDuePermissionScreen(
@@ -2677,7 +2302,7 @@ var runtimeRequire = (moduleName) => {
2677
2302
  if (moduleName !== "@expo/vector-icons") return void 0;
2678
2303
  if (typeof __require !== "function") return void 0;
2679
2304
  try {
2680
- return __require("@expo/vector-icons");
2305
+ return require("@expo/vector-icons");
2681
2306
  } catch {
2682
2307
  return void 0;
2683
2308
  }
@@ -2806,13 +2431,13 @@ var WIRE_ICON_GLYPHS = {
2806
2431
  other: { family: "MaterialCommunityIcons", name: "dots-horizontal-circle" }
2807
2432
  };
2808
2433
  var WIRE_ICON_NAMES = Object.keys(WIRE_ICON_GLYPHS).sort();
2809
- var lookupIconGlyph = (name2) => {
2810
- if (!name2) return void 0;
2811
- if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name2)) return void 0;
2812
- return WIRE_ICON_GLYPHS[name2];
2434
+ var lookupIconGlyph = (name) => {
2435
+ if (!name) return void 0;
2436
+ if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return void 0;
2437
+ return WIRE_ICON_GLYPHS[name];
2813
2438
  };
2814
- var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2815
- const hostIcon = useHostIcon(name2);
2439
+ var _WireIcon = ({ name, size = 20, color, requireModule }) => {
2440
+ const hostIcon = useHostIcon(name);
2816
2441
  if (hostIcon) {
2817
2442
  return /* @__PURE__ */ jsxRuntime.jsx(
2818
2443
  reactNative.View,
@@ -2824,7 +2449,7 @@ var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2824
2449
  }
2825
2450
  );
2826
2451
  }
2827
- const glyph = lookupIconGlyph(name2);
2452
+ const glyph = lookupIconGlyph(name);
2828
2453
  if (!glyph) return null;
2829
2454
  const Family = resolveIconFamily(glyph.family, requireModule);
2830
2455
  if (!Family) return null;
@@ -3237,7 +2862,7 @@ var STATUS_ICONS = {
3237
2862
  info: "\u2139"
3238
2863
  };
3239
2864
  var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {
3240
- var _a2;
2865
+ var _a;
3241
2866
  const t = useOnboardingTheme();
3242
2867
  const reduced = useReducedMotion();
3243
2868
  const [submitted, setSubmitted] = React19.useState(false);
@@ -3303,7 +2928,7 @@ var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSu
3303
2928
  headingStyle(t.fonts),
3304
2929
  { color, opacity: popT, transform: [{ scale: popScale }] }
3305
2930
  ],
3306
- children: (_a2 = STATUS_ICONS[status]) != null ? _a2 : "\xB7"
2931
+ children: (_a = STATUS_ICONS[status]) != null ? _a : "\xB7"
3307
2932
  }
3308
2933
  ),
3309
2934
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3646,9 +3271,9 @@ var runtimeRequire2 = (moduleName) => {
3646
3271
  try {
3647
3272
  switch (moduleName) {
3648
3273
  case "expo-constants":
3649
- return init_Constants(), __toCommonJS(Constants_exports);
3274
+ return require("expo-constants");
3650
3275
  case "expo-application":
3651
- return __require("expo-application");
3276
+ return require("expo-application");
3652
3277
  default:
3653
3278
  return void 0;
3654
3279
  }
@@ -3671,14 +3296,14 @@ var safeInterop = (requireModule, moduleName) => {
3671
3296
  };
3672
3297
  var detectAppVersion = (requireModule = runtimeRequire2) => {
3673
3298
  try {
3674
- const constants2 = safeInterop(requireModule, "expo-constants");
3675
- if (constants2) {
3676
- const expoConfig = constants2.expoConfig;
3299
+ const constants = safeInterop(requireModule, "expo-constants");
3300
+ if (constants) {
3301
+ const expoConfig = constants.expoConfig;
3677
3302
  if (expoConfig && typeof expoConfig === "object") {
3678
3303
  const fromExpoConfig = coerceVersion(expoConfig.version);
3679
3304
  if (fromExpoConfig) return fromExpoConfig;
3680
3305
  }
3681
- const fromNative = coerceVersion(constants2.nativeAppVersion);
3306
+ const fromNative = coerceVersion(constants.nativeAppVersion);
3682
3307
  if (fromNative) return fromNative;
3683
3308
  }
3684
3309
  const application = safeInterop(requireModule, "expo-application");
@@ -3701,7 +3326,7 @@ var runtimeRequire3 = (moduleName) => {
3701
3326
  if (moduleName !== "expo-device") return void 0;
3702
3327
  if (typeof __require !== "function") return void 0;
3703
3328
  try {
3704
- return __require("expo-device");
3329
+ return require("expo-device");
3705
3330
  } catch {
3706
3331
  return void 0;
3707
3332
  }
@@ -3743,7 +3368,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
3743
3368
  return void 0;
3744
3369
  };
3745
3370
  var collectDeviceContext = () => {
3746
- var _a2;
3371
+ var _a;
3747
3372
  const ctx = { platform: reactNative.Platform.OS };
3748
3373
  try {
3749
3374
  const version = reactNative.Platform.Version;
@@ -3752,26 +3377,26 @@ var collectDeviceContext = () => {
3752
3377
  }
3753
3378
  } catch {
3754
3379
  }
3755
- let constants2 = {};
3380
+ let constants = {};
3756
3381
  try {
3757
- constants2 = (_a2 = reactNative.Platform.constants) != null ? _a2 : {};
3382
+ constants = (_a = reactNative.Platform.constants) != null ? _a : {};
3758
3383
  } catch {
3759
- constants2 = {};
3384
+ constants = {};
3760
3385
  }
3761
3386
  let iosIdiom;
3762
3387
  try {
3763
3388
  if (reactNative.Platform.OS === "android") {
3764
- const brand = constants2.Brand;
3765
- const model = constants2.Model;
3766
- const release = constants2.Release;
3389
+ const brand = constants.Brand;
3390
+ const model = constants.Model;
3391
+ const release = constants.Release;
3767
3392
  if (typeof brand === "string" && brand) ctx.brand = brand;
3768
3393
  if (typeof model === "string" && model) ctx.model = model;
3769
3394
  if (release !== void 0 && release !== null && String(release)) {
3770
3395
  ctx.osVersion = String(release);
3771
3396
  }
3772
3397
  } else if (reactNative.Platform.OS === "ios") {
3773
- const osVersion = constants2.osVersion;
3774
- const idiom = constants2.interfaceIdiom;
3398
+ const osVersion = constants.osVersion;
3399
+ const idiom = constants.interfaceIdiom;
3775
3400
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
3776
3401
  ctx.osVersion = String(osVersion);
3777
3402
  }
@@ -3822,11 +3447,11 @@ var provenanceRegistry = () => {
3822
3447
  };
3823
3448
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
3824
3449
  var resolveIdentity = (input) => {
3825
- var _a2;
3450
+ var _a;
3826
3451
  if (typeof input.value !== "string") return void 0;
3827
3452
  const value = input.value.trim();
3828
3453
  if (!value) return void 0;
3829
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
3454
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
3830
3455
  if (input.source === "host") {
3831
3456
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
3832
3457
  }
@@ -3860,8 +3485,8 @@ var startHydration = (registry, appId, storage, minted) => {
3860
3485
  if (existing) return existing;
3861
3486
  const slot = deviceIdStorageKey(appId);
3862
3487
  const degraded = () => {
3863
- var _a2;
3864
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
3488
+ var _a;
3489
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
3865
3490
  };
3866
3491
  const adopted = (value) => ({ value, durable: true });
3867
3492
  let run;
@@ -3874,8 +3499,8 @@ var startHydration = (registry, appId, storage, minted) => {
3874
3499
  }
3875
3500
  return Promise.resolve(storage.setItem(slot, minted)).then(
3876
3501
  () => {
3877
- var _a2;
3878
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
3502
+ var _a;
3503
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
3879
3504
  },
3880
3505
  degraded
3881
3506
  );
@@ -3885,17 +3510,17 @@ var startHydration = (registry, appId, storage, minted) => {
3885
3510
  }
3886
3511
  registry.pending.set(appId, run);
3887
3512
  void run.then((outcome) => {
3888
- var _a2;
3513
+ var _a;
3889
3514
  if (outcome.durable) return;
3890
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
3515
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
3891
3516
  registry.hydrating.delete(appId);
3892
3517
  });
3893
3518
  return run;
3894
3519
  };
3895
3520
  var resolveAutoDeviceKey = (opts = {}) => {
3896
- var _a2, _b;
3521
+ var _a, _b;
3897
3522
  const registry = autoDeviceKeyRegistry();
3898
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3523
+ const appId = (_a = opts.appId) != null ? _a : "default";
3899
3524
  let id = registry.keys.get(appId);
3900
3525
  if (!id) {
3901
3526
  id = mintDeviceId();
@@ -3909,13 +3534,13 @@ var resolveAutoDeviceKey = (opts = {}) => {
3909
3534
  return (_b = registry.keys.get(appId)) != null ? _b : id;
3910
3535
  };
3911
3536
  var hydrateAutoDeviceKey = async (opts = {}) => {
3912
- var _a2, _b;
3913
- return (_b = (_a2 = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a2.value) != null ? _b : resolveAutoDeviceKey(opts);
3537
+ var _a, _b;
3538
+ return (_b = (_a = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a.value) != null ? _b : resolveAutoDeviceKey(opts);
3914
3539
  };
3915
3540
  var hydrateDeviceIdentity = async (opts = {}) => {
3916
- var _a2, _b, _c;
3541
+ var _a, _b, _c;
3917
3542
  const id = resolveAutoDeviceKey(opts);
3918
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3543
+ const appId = (_a = opts.appId) != null ? _a : "default";
3919
3544
  const record = (value, durable) => resolveIdentity({ value, space: "device", source: "auto", durable, scope: appId });
3920
3545
  if (!opts.storage) return record(id, false);
3921
3546
  const registry = autoDeviceKeyRegistry();
@@ -3925,11 +3550,11 @@ var hydrateDeviceIdentity = async (opts = {}) => {
3925
3550
  return record(outcome.value, outcome.durable);
3926
3551
  };
3927
3552
  var resetAutoDeviceKeys = () => {
3928
- var _a2;
3553
+ var _a;
3929
3554
  const registry = autoDeviceKeyRegistry();
3930
3555
  registry.keys.clear();
3931
3556
  registry.hydrating.clear();
3932
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
3557
+ (_a = registry.pending) == null ? void 0 : _a.clear();
3933
3558
  };
3934
3559
 
3935
3560
  // src/analytics/currentSession.ts
@@ -4031,9 +3656,9 @@ var sanitizeUserId = (raw) => {
4031
3656
  };
4032
3657
  var looksLikeEmail = (value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
4033
3658
  var identifyOnboarding = async (opts) => {
4034
- var _a2, _b, _c;
3659
+ var _a, _b, _c;
4035
3660
  const userId = sanitizeUserId(opts.userId);
4036
- if (!userId || !((_a2 = opts.config) == null ? void 0 : _a2.serverUrl)) return false;
3661
+ if (!userId || !((_a = opts.config) == null ? void 0 : _a.serverUrl)) return false;
4037
3662
  let contextId = ((_b = opts.contextId) == null ? void 0 : _b.trim()) || void 0;
4038
3663
  if (!contextId && opts.storage) {
4039
3664
  const key = (_c = opts.persistKey) != null ? _c : opts.appId ? sessionStorageKey(opts.appId) : void 0;
@@ -4104,11 +3729,11 @@ var clearUserContext = async (opts = {}) => {
4104
3729
  }
4105
3730
  };
4106
3731
  var activationJoinContext = (deviceKey) => {
4107
- var _a2;
4108
- return (_a2 = resolveUserContext({ deviceKey }).userContext) != null ? _a2 : {};
3732
+ var _a;
3733
+ return (_a = resolveUserContext({ deviceKey }).userContext) != null ? _a : {};
4109
3734
  };
4110
3735
  var resolveUserContext = (ctx = {}, opts = {}) => {
4111
- var _a2;
3736
+ var _a;
4112
3737
  const result = {};
4113
3738
  const bucket = {};
4114
3739
  const userId = sanitizeUserId(ctx.userId);
@@ -4118,7 +3743,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
4118
3743
  result.deviceKey = deviceKey;
4119
3744
  bucket.device_key = deviceKey;
4120
3745
  }
4121
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
3746
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
4122
3747
  if (appVersion) {
4123
3748
  result.appVersion = appVersion;
4124
3749
  bucket.app_version = appVersion;
@@ -4200,7 +3825,7 @@ var WireOnboarding = ({
4200
3825
  autoJoinKey = true,
4201
3826
  permissionScreens
4202
3827
  }) => {
4203
- var _a2, _b, _c, _d, _e, _f;
3828
+ var _a, _b, _c, _d, _e, _f;
4204
3829
  const boundUserId = React19.useMemo(() => sanitizeUserId(userId), [userId]);
4205
3830
  const device = React19.useMemo(() => {
4206
3831
  const collected = collectDeviceContext();
@@ -4242,7 +3867,7 @@ var WireOnboarding = ({
4242
3867
  clearTimeout(timer);
4243
3868
  };
4244
3869
  }, [wantsAutoJoin, autoJoinOutcome, config.appId, storage]);
4245
- const injectedJoinKey = wantsAutoJoin ? (_a2 = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a2 : void 0 : void 0;
3870
+ const injectedJoinKey = wantsAutoJoin ? (_a = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a : void 0 : void 0;
4246
3871
  const autoJoinPending = wantsAutoJoin && autoJoinOutcome === void 0;
4247
3872
  const effectiveUserContext = React19.useMemo(
4248
3873
  () => injectedJoinKey ? { ...userContextStable, ...activationJoinContext(injectedJoinKey) } : userContextStable,
@@ -4326,8 +3951,8 @@ var WireOnboarding = ({
4326
3951
  settledPermissionsRef.current = settledPermissions;
4327
3952
  const handlePermissionSettled = React19.useCallback(
4328
3953
  (id) => {
4329
- var _a3;
4330
- const current = (_a3 = settledPermissionsRef.current) != null ? _a3 : [];
3954
+ var _a2;
3955
+ const current = (_a2 = settledPermissionsRef.current) != null ? _a2 : [];
4331
3956
  if (current.includes(id)) return;
4332
3957
  const next = [...current, id];
4333
3958
  settledPermissionsRef.current = next;
@@ -4702,10 +4327,10 @@ var readEnabled = (raw) => {
4702
4327
  return { enabled: true };
4703
4328
  };
4704
4329
  var parseWireFeatures = (raw) => {
4705
- var _a2;
4330
+ var _a;
4706
4331
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return defaultWireFeatures;
4707
4332
  const src = raw;
4708
- const modeRaw = (_a2 = src.onboarding) == null ? void 0 : _a2.mode;
4333
+ const modeRaw = (_a = src.onboarding) == null ? void 0 : _a.mode;
4709
4334
  const mode = typeof modeRaw === "string" && VALID_MODES.includes(modeRaw) ? modeRaw : "ai";
4710
4335
  return {
4711
4336
  coachmarks: readEnabled(src.coachmarks),
@@ -4762,10 +4387,10 @@ var writeCachedFeatures = (storage, key, features) => {
4762
4387
  // src/features/fetchWireFeatures.ts
4763
4388
  var DEFAULT_TIMEOUT_MS = 4e3;
4764
4389
  var failOpen = async (storage, key) => {
4765
- var _a2;
4390
+ var _a;
4766
4391
  if (!storage) return defaultWireFeatures;
4767
4392
  const cached2 = await readCachedFeatures(storage, key);
4768
- return (_a2 = cached2 == null ? void 0 : cached2.features) != null ? _a2 : defaultWireFeatures;
4393
+ return (_a = cached2 == null ? void 0 : cached2.features) != null ? _a : defaultWireFeatures;
4769
4394
  };
4770
4395
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
4771
4396
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -4824,7 +4449,7 @@ var useWireFeatures = (config) => {
4824
4449
  return flags;
4825
4450
  };
4826
4451
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
4827
- var globalObj = global;
4452
+ var globalObj = globalThis;
4828
4453
  if (!globalObj[CONTEXT_SYMBOL]) {
4829
4454
  globalObj[CONTEXT_SYMBOL] = React19.createContext(null);
4830
4455
  }
@@ -4842,11 +4467,11 @@ var WireFeaturesProvider = ({
4842
4467
  WireFeaturesProvider.displayName = "WireFeaturesProvider";
4843
4468
  var useWireFeaturesContext = () => React19.useContext(WireFeaturesContext);
4844
4469
  var useResolvedFeatures = (options) => {
4845
- var _a2, _b, _c;
4470
+ var _a, _b, _c;
4846
4471
  const ctx = useWireFeaturesContext();
4847
4472
  const shouldFetch = !(options == null ? void 0 : options.flags) && ctx == null;
4848
4473
  const fetched = useWireFeatures(shouldFetch ? options == null ? void 0 : options.config : void 0);
4849
- return (_c = (_b = (_a2 = options == null ? void 0 : options.flags) != null ? _a2 : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4474
+ return (_c = (_b = (_a = options == null ? void 0 : options.flags) != null ? _a : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4850
4475
  };
4851
4476
 
4852
4477
  // src/config/wireConfigFromEnv.ts
@@ -4856,8 +4481,8 @@ var WIRE_ENV_VARS = [
4856
4481
  "EXPO_PUBLIC_WIREAI_APP_ID"
4857
4482
  ];
4858
4483
  var wireConfigFromEnv = (overrides) => {
4859
- var _a2, _b, _c, _d, _e;
4860
- const apiKey = (_a2 = overrides == null ? void 0 : overrides.apiKey) != null ? _a2 : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4484
+ var _a, _b, _c, _d, _e;
4485
+ const apiKey = (_a = overrides == null ? void 0 : overrides.apiKey) != null ? _a : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4861
4486
  const serverUrl = (_b = overrides == null ? void 0 : overrides.serverUrl) != null ? _b : process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;
4862
4487
  const appId = (_d = (_c = overrides == null ? void 0 : overrides.appId) != null ? _c : process.env.EXPO_PUBLIC_WIREAI_APP_ID) != null ? _d : "default";
4863
4488
  if (!apiKey || !serverUrl) {
@@ -4882,10 +4507,10 @@ var wireConfigFromEnv = (overrides) => {
4882
4507
 
4883
4508
  // src/config/onboardingFlag.ts
4884
4509
  var isOnboardingEnabled = (opts) => {
4885
- var _a2;
4510
+ var _a;
4886
4511
  const transportPresent = wireConfigFromEnv(opts == null ? void 0 : opts.config) !== null;
4887
4512
  if (!transportPresent) return false;
4888
- return (_a2 = opts == null ? void 0 : opts.remote) != null ? _a2 : true;
4513
+ return (_a = opts == null ? void 0 : opts.remote) != null ? _a : true;
4889
4514
  };
4890
4515
 
4891
4516
  // src/analytics/analyticsEvent.ts
@@ -4980,9 +4605,9 @@ var resetActivationRevalidation = () => {
4980
4605
  // src/activation/wireActivation.ts
4981
4606
  var clean = cleanString;
4982
4607
  var createWireActivation = (config) => {
4983
- var _a2, _b;
4608
+ var _a, _b;
4984
4609
  const target = { serverUrl: config.serverUrl, apiKey: config.apiKey };
4985
- const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey);
4610
+ const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a = config.userContext) == null ? void 0 : _a.deviceKey);
4986
4611
  resolveIdentity({
4987
4612
  value: explicitDeviceKey,
4988
4613
  space: "device",
@@ -4997,11 +4622,11 @@ var createWireActivation = (config) => {
4997
4622
  if (!explicitDeviceKey) resolveAutoDeviceKey(autoDeviceKeyOptions);
4998
4623
  const detectedAppVersion = detectAppVersion();
4999
4624
  const applyContext = (event) => {
5000
- var _a3, _b2, _c;
4625
+ var _a2, _b2, _c;
5001
4626
  const resolved = resolveUserContext(
5002
4627
  // `??` is lazy on purpose: an explicit key must never even touch the auto registry.
5003
4628
  {
5004
- ...(_a3 = config.userContext) != null ? _a3 : {},
4629
+ ...(_a2 = config.userContext) != null ? _a2 : {},
5005
4630
  deviceKey: explicitDeviceKey != null ? explicitDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions)
5006
4631
  },
5007
4632
  { autoAppVersion: (_b2 = config.appVersion) != null ? _b2 : detectedAppVersion }
@@ -5011,13 +4636,13 @@ var createWireActivation = (config) => {
5011
4636
  }
5012
4637
  if (resolved.userId && !event.user_id) event.user_id = resolved.userId;
5013
4638
  };
5014
- const track = async (name2, meta) => {
5015
- if (!clean(name2)) return false;
4639
+ const track = async (name, meta) => {
4640
+ if (!clean(name)) return false;
5016
4641
  const sessionId = ensureCurrentSessionId();
5017
4642
  const event = {
5018
4643
  event_type: "app_event",
5019
4644
  session_id: sessionId,
5020
- question_key: name2
4645
+ question_key: name
5021
4646
  };
5022
4647
  if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);
5023
4648
  applyContext(event);
@@ -5040,7 +4665,7 @@ var useActivationRevalidation = () => React19.useSyncExternalStore(
5040
4665
  getActivationRevalidationVersion
5041
4666
  );
5042
4667
  var useWireActivation = (config) => {
5043
- var _a2;
4668
+ var _a;
5044
4669
  const ref = React19.useRef(void 0);
5045
4670
  const prevKeys = React19.useRef("");
5046
4671
  const currentKeys = [
@@ -5048,7 +4673,7 @@ var useWireActivation = (config) => {
5048
4673
  config.apiKey,
5049
4674
  config.appId,
5050
4675
  config.deviceKey,
5051
- (_a2 = config.userContext) == null ? void 0 : _a2.deviceKey
4676
+ (_a = config.userContext) == null ? void 0 : _a.deviceKey
5052
4677
  ].join("|");
5053
4678
  if (!ref.current || prevKeys.current !== currentKeys) {
5054
4679
  prevKeys.current = currentKeys;
@@ -5074,8 +4699,8 @@ var WIRE_PURCHASE_EVENTS = {
5074
4699
  var PLAN_TIER_CONTEXT_KEY = "plan_tier";
5075
4700
  var asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
5076
4701
  var activeEntitlement = (info, entitlementId) => {
5077
- var _a2, _b;
5078
- const active = asRecord((_b = asRecord((_a2 = asRecord(info)) == null ? void 0 : _a2.entitlements)) == null ? void 0 : _b.active);
4702
+ var _a, _b;
4703
+ const active = asRecord((_b = asRecord((_a = asRecord(info)) == null ? void 0 : _a.entitlements)) == null ? void 0 : _b.active);
5079
4704
  const found = active == null ? void 0 : active[entitlementId];
5080
4705
  const entitlement = asRecord(found);
5081
4706
  if (!entitlement) return void 0;
@@ -5148,19 +4773,19 @@ var createRevenueCatBridge = (config) => {
5148
4773
  }
5149
4774
  };
5150
4775
  const syncPlanTier = (customerInfo) => {
5151
- var _a2;
4776
+ var _a;
5152
4777
  const tier = resolvePlanTier(customerInfo, entitlementId);
5153
4778
  if (!writeTier) return tier;
5154
4779
  try {
5155
- (_a2 = analytics.setUserContext) == null ? void 0 : _a2.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
4780
+ (_a = analytics.setUserContext) == null ? void 0 : _a.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
5156
4781
  } catch {
5157
4782
  }
5158
4783
  return tier;
5159
4784
  };
5160
4785
  const paywallShown = (offering, props) => {
5161
- var _a2, _b;
4786
+ var _a, _b;
5162
4787
  const shown = {
5163
- packages_count: (_b = (_a2 = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a2.length) != null ? _b : 0
4788
+ packages_count: (_b = (_a = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a.length) != null ? _b : 0
5164
4789
  };
5165
4790
  if (typeof (offering == null ? void 0 : offering.identifier) === "string") shown.offering_id = offering.identifier;
5166
4791
  emit(WIRE_PURCHASE_EVENTS.paywallShown, { ...shown, ...props });
@@ -5214,10 +4839,10 @@ var resetSessionStartGuard = () => {
5214
4839
  _emitted.clear();
5215
4840
  };
5216
4841
  var reportSessionStart = (opts) => {
5217
- var _a2;
4842
+ var _a;
5218
4843
  const target = opts.target;
5219
4844
  if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
5220
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
4845
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5221
4846
  setCurrentSessionId(sessionId);
5222
4847
  if (opts.once !== false) {
5223
4848
  if (_emitted.has(sessionId)) return;
@@ -5277,11 +4902,11 @@ var useSessionStart = (config, options = {}) => {
5277
4902
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5278
4903
  };
5279
4904
  const fire = () => {
5280
- var _a2, _b;
4905
+ var _a, _b;
5281
4906
  const { config: cfg, options: opts } = latest.current;
5282
4907
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return;
5283
4908
  if (opts.enabled === false) return;
5284
- const target = { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" };
4909
+ const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
5285
4910
  const device = collectDeviceContext();
5286
4911
  if (cfg.appVersion) device.appVersion = cfg.appVersion;
5287
4912
  reportSessionStart({
@@ -5332,7 +4957,7 @@ var resetFirstOpenLatch = () => {
5332
4957
  _firstOpenLatched.clear();
5333
4958
  };
5334
4959
  var buildLifecycleEvent = (questionKey, opts) => {
5335
- var _a2;
4960
+ var _a;
5336
4961
  const userContext = {};
5337
4962
  if (opts.deviceKey) userContext.device_key = opts.deviceKey;
5338
4963
  if (typeof opts.sessionCount === "number" && Number.isFinite(opts.sessionCount)) {
@@ -5344,7 +4969,7 @@ var buildLifecycleEvent = (questionKey, opts) => {
5344
4969
  const event = {
5345
4970
  event_type: "app_event",
5346
4971
  question_key: questionKey,
5347
- session_id: (_a2 = opts.sessionId) != null ? _a2 : makeSessionId()
4972
+ session_id: (_a = opts.sessionId) != null ? _a : makeSessionId()
5348
4973
  };
5349
4974
  const userId = sanitizeUserId(opts.userId);
5350
4975
  if (userId) event.user_id = userId;
@@ -5370,8 +4995,8 @@ var emitFirstOpen = (opts) => {
5370
4995
  routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);
5371
4996
  };
5372
4997
  var reportFirstOpen = (opts) => {
5373
- var _a2;
5374
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
4998
+ var _a;
4999
+ const appId = (_a = opts.appId) != null ? _a : "default";
5375
5000
  if (_firstOpenLatched.has(appId)) return;
5376
5001
  _firstOpenLatched.add(appId);
5377
5002
  const storage = opts.storage;
@@ -5396,8 +5021,8 @@ var reportFirstOpen = (opts) => {
5396
5021
  })();
5397
5022
  };
5398
5023
  var wireLifecycleEvents = (opts) => {
5399
- var _a2;
5400
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
5024
+ var _a;
5025
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5401
5026
  reportFirstOpen({ ...opts, sessionId });
5402
5027
  reportSessionStart({
5403
5028
  target: opts.target,
@@ -5446,10 +5071,11 @@ var claimQueueKey = (preferred, explicit) => {
5446
5071
  );
5447
5072
  return key;
5448
5073
  };
5074
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
5449
5075
  var withTimeout4 = (p, ms) => {
5450
5076
  let timer;
5451
5077
  const timeout = new Promise((resolve) => {
5452
- timer = setTimeout(() => resolve(void 0), ms);
5078
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
5453
5079
  });
5454
5080
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
5455
5081
  };
@@ -5474,10 +5100,10 @@ var parsePersisted2 = (raw) => {
5474
5100
  }
5475
5101
  };
5476
5102
  var createEventQueue = (options) => {
5477
- var _a2, _b, _c, _d, _e, _f, _g;
5103
+ var _a, _b, _c, _d, _e, _f, _g;
5478
5104
  const target = options.target;
5479
5105
  const storage = options.storage;
5480
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
5106
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
5481
5107
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
5482
5108
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
5483
5109
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -5489,6 +5115,7 @@ var createEventQueue = (options) => {
5489
5115
  let flushing = false;
5490
5116
  let attempt = 0;
5491
5117
  let retryTimer;
5118
+ let backlogUnread = false;
5492
5119
  const resolveEnvelope = () => {
5493
5120
  try {
5494
5121
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -5497,14 +5124,14 @@ var createEventQueue = (options) => {
5497
5124
  }
5498
5125
  };
5499
5126
  const stamp = (event) => {
5500
- var _a3;
5127
+ var _a2;
5501
5128
  const env = resolveEnvelope();
5502
5129
  const stamped = { ...event };
5503
5130
  if (stamped.ts === void 0) stamped.ts = Date.now();
5504
5131
  if (!env) return stamped;
5505
5132
  if (!stamped.device && env.device) stamped.device = env.device;
5506
5133
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
5507
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
5134
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
5508
5135
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
5509
5136
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
5510
5137
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -5513,6 +5140,7 @@ var createEventQueue = (options) => {
5513
5140
  };
5514
5141
  const persist = () => {
5515
5142
  if (!storage) return;
5143
+ if (backlogUnread) return;
5516
5144
  try {
5517
5145
  if (pending.length === 0) {
5518
5146
  void storage.removeItem(key).catch(() => {
@@ -5535,23 +5163,44 @@ var createEventQueue = (options) => {
5535
5163
  return `__nosig_${nextId}_${Math.random()}`;
5536
5164
  }
5537
5165
  };
5166
+ const mergePersisted = (persistedItems) => {
5167
+ if (persistedItems.length === 0) return;
5168
+ const seen = new Set(pending.map((item) => item.sig));
5169
+ const restored = [];
5170
+ for (const persisted of persistedItems) {
5171
+ const sig = safeSig(persisted.event);
5172
+ if (seen.has(sig)) continue;
5173
+ seen.add(sig);
5174
+ restored.push({ id: nextId++, event: persisted.event, sig });
5175
+ }
5176
+ if (restored.length === 0) return;
5177
+ pending = [...restored, ...pending];
5178
+ enforceSizeCap();
5179
+ persist();
5180
+ };
5538
5181
  const loadPromise = (async () => {
5539
5182
  if (!storage) return;
5540
5183
  try {
5541
- const persistedItems = parsePersisted2(await withTimeout4(storage.getItem(key), READ_TIMEOUT_MS4));
5542
- if (persistedItems.length === 0) return;
5543
- const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];
5544
- pending = [];
5545
- nextId = 0;
5546
- const seen = /* @__PURE__ */ new Set();
5547
- for (const event of events) {
5548
- const sig = safeSig(event);
5549
- if (seen.has(sig)) continue;
5550
- seen.add(sig);
5551
- pending.push({ id: nextId++, event, sig });
5184
+ const read = Promise.resolve(storage.getItem(key));
5185
+ read.catch(() => {
5186
+ });
5187
+ const raced = await withTimeout4(read, READ_TIMEOUT_MS4);
5188
+ if (raced === READ_TIMED_OUT) {
5189
+ backlogUnread = true;
5190
+ warnInDev(
5191
+ `[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.`
5192
+ );
5193
+ void read.then((late) => {
5194
+ backlogUnread = false;
5195
+ mergePersisted(parsePersisted2(late));
5196
+ flush();
5197
+ }).catch(() => {
5198
+ backlogUnread = false;
5199
+ persist();
5200
+ });
5201
+ return;
5552
5202
  }
5553
- enforceSizeCap();
5554
- persist();
5203
+ mergePersisted(parsePersisted2(raced));
5555
5204
  } catch {
5556
5205
  }
5557
5206
  })();
@@ -5648,13 +5297,13 @@ var useLifecycleEvents = (config, options = {}) => {
5648
5297
  const queueRef = React19.useRef(void 0);
5649
5298
  React19.useEffect(() => {
5650
5299
  const resolveSink = () => {
5651
- var _a2, _b;
5300
+ var _a, _b;
5652
5301
  const { config: cfg, options: opts } = latest.current;
5653
5302
  if (opts.sink) return opts.sink;
5654
5303
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return void 0;
5655
5304
  if (!queueRef.current) {
5656
5305
  queueRef.current = createEventQueue({
5657
- target: { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" },
5306
+ target: { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" },
5658
5307
  storage: cfg.storage,
5659
5308
  // Dedicated key so the hook's internal queue never collides with a host's main queue.
5660
5309
  storageKey: `wireai:evtq:lifecycle:${(_b = cfg.appId) != null ? _b : "default"}`,
@@ -5664,24 +5313,24 @@ var useLifecycleEvents = (config, options = {}) => {
5664
5313
  return queueRef.current.enqueue;
5665
5314
  };
5666
5315
  const targetOf = (cfg) => {
5667
- var _a2;
5668
- return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" } : void 0;
5316
+ var _a;
5317
+ return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" } : void 0;
5669
5318
  };
5670
5319
  const resolveDeviceKey = (cfg, opts) => {
5671
- var _a2;
5672
- const host = (_a2 = resolveIdentity({
5320
+ var _a;
5321
+ const host = (_a = resolveIdentity({
5673
5322
  value: opts.deviceKey,
5674
5323
  space: "device",
5675
5324
  source: "host",
5676
5325
  scope: cfg == null ? void 0 : cfg.appId
5677
- })) == null ? void 0 : _a2.value;
5326
+ })) == null ? void 0 : _a.value;
5678
5327
  if (host) return host;
5679
5328
  if (!(cfg == null ? void 0 : cfg.storage)) return void 0;
5680
5329
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5681
5330
  };
5682
5331
  const mountOpenSessionId = makeSessionId();
5683
5332
  const fireSession = (sessionId) => {
5684
- var _a2;
5333
+ var _a;
5685
5334
  const { config: cfg, options: opts } = latest.current;
5686
5335
  if (opts.enabled === false) return;
5687
5336
  if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
@@ -5694,14 +5343,14 @@ var useLifecycleEvents = (config, options = {}) => {
5694
5343
  userId: opts.userId,
5695
5344
  deviceKey: resolveDeviceKey(cfg, opts),
5696
5345
  sessionCount: opts.sessionCount,
5697
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5346
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5698
5347
  platform: reactNative.Platform.OS,
5699
5348
  device,
5700
5349
  meta: opts.meta
5701
5350
  });
5702
5351
  };
5703
5352
  const fireMountOpen = () => {
5704
- var _a2;
5353
+ var _a;
5705
5354
  fireSession(mountOpenSessionId);
5706
5355
  const { config: cfg, options: opts } = latest.current;
5707
5356
  if (opts.enabled === false) return;
@@ -5716,7 +5365,7 @@ var useLifecycleEvents = (config, options = {}) => {
5716
5365
  userId: opts.userId,
5717
5366
  deviceKey: resolveDeviceKey(cfg, opts),
5718
5367
  sessionCount: opts.sessionCount,
5719
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5368
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5720
5369
  platform: reactNative.Platform.OS,
5721
5370
  device,
5722
5371
  meta: opts.meta