@zean-chat/react-native 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
21
 
20
22
  // src/index.ts
21
23
  var index_exports = {};
@@ -28,7 +30,7 @@ __export(index_exports, {
28
30
  module.exports = __toCommonJS(index_exports);
29
31
 
30
32
  // src/components/ZeanChat.tsx
31
- var import_react18 = require("react");
33
+ var import_react19 = require("react");
32
34
 
33
35
  // ../shared/src/constants/app.ts
34
36
  var APP_NAME = "Zean";
@@ -79,6 +81,7 @@ var QUOTE_HIGHLIGHT_MS = 1600;
79
81
  var APP_PLATFORMS = ["web", "react_native"];
80
82
  var DEVICE_TYPES = ["phone", "tablet", "computer"];
81
83
  var DEVICE_DETAIL_MAX_LENGTH = 80;
84
+ var SDK_ERROR_MAX_LENGTH = { label: 64, message: 500, stack: 8e3 };
82
85
  var EXPO_GO_BUNDLE_ID = "host.exp.exponent";
83
86
  var DEFAULT_WIDGET_TEXTS = {
84
87
  fr: {
@@ -219,6 +222,22 @@ function minutesOf(clock) {
219
222
  const [hours, minutes] = clock.split(":").map(Number);
220
223
  return hours * 60 + minutes;
221
224
  }
225
+ function deviceStorageKey(appKey) {
226
+ return `zean:${appKey}:device`;
227
+ }
228
+ function sdkErrorReportOf(body) {
229
+ if (typeof body !== "object" || body === null) return null;
230
+ const { appKey, sdk, version: version2, os, method, name, message, stack } = body;
231
+ const labels = { appKey, sdk, version: version2, os, method, name };
232
+ if (Object.values(labels).some((value) => typeof value !== "string" || value === "")) return null;
233
+ if (typeof message !== "string" || stack !== void 0 && typeof stack !== "string") return null;
234
+ const cut = (value, max) => value.slice(0, max);
235
+ return {
236
+ ...Object.fromEntries(Object.entries(labels).map(([key, value]) => [key, cut(value, SDK_ERROR_MAX_LENGTH.label)])),
237
+ message: cut(message, SDK_ERROR_MAX_LENGTH.message),
238
+ ...stack ? { stack: cut(stack, SDK_ERROR_MAX_LENGTH.stack) } : {}
239
+ };
240
+ }
222
241
 
223
242
  // ../sdk-core/src/chat.ts
224
243
  var CLOCK_MS = 3e4;
@@ -251,7 +270,7 @@ function joinedSession(place, own) {
251
270
  };
252
271
  }
253
272
  function createChatStore(backend, options) {
254
- const secretKey = `zean:${options.appKey}:device`;
273
+ const secretKey = deviceStorageKey(options.appKey);
255
274
  const outboxKey = `zean:${options.appKey}:outbox`;
256
275
  const attributesKey = `zean:${options.appKey}:attributes`;
257
276
  const keptKey = `zean:${options.appKey}:conversation`;
@@ -326,6 +345,8 @@ function createChatStore(backend, options) {
326
345
  ...options.deviceDetails ? { details: options.deviceDetails() } : {},
327
346
  timeZone
328
347
  });
348
+ let fingerprinted;
349
+ const fingerprint = (read) => fingerprinted ?? (fingerprinted = Promise.resolve().then(read).catch(() => null));
329
350
  const deviceWaiters = [];
330
351
  const useSecret = (secret) => {
331
352
  deviceSecret = secret;
@@ -399,7 +420,7 @@ function createChatStore(backend, options) {
399
420
  watches.push(placeStop);
400
421
  const deviceStop = backend.watch(
401
422
  "device",
402
- { appKey: options.appKey, deviceSecret: secret },
423
+ { ...where, deviceSecret: secret },
403
424
  (result) => {
404
425
  own = result;
405
426
  handle();
@@ -589,13 +610,16 @@ function createChatStore(backend, options) {
589
610
  );
590
611
  }
591
612
  function deliver(entry) {
592
- call("send", {
613
+ const input = {
593
614
  ...args(),
594
615
  body: entry.body,
595
616
  ...entry.attachments ? { attachments: entry.attachments } : {},
596
617
  clientId: entry.clientId,
597
618
  device: device()
598
- }).then(
619
+ };
620
+ const read = session && "app" in session && session.app.sendsFingerprint ? options.fingerprint : void 0;
621
+ const sent = read ? fingerprint(read).then((print) => call("send", print ? { ...input, fingerprint: print } : input)) : call("send", input);
622
+ sent.then(
599
623
  () => {
600
624
  outbox = outbox.filter((other) => other.clientId !== entry.clientId);
601
625
  saveOutbox();
@@ -1606,8 +1630,8 @@ function convexToJson(value) {
1606
1630
 
1607
1631
  // ../../node_modules/convex/dist/esm/values/validators.js
1608
1632
  var __defProp2 = Object.defineProperty;
1609
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1610
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1633
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1634
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
1611
1635
  var UNDEFINED_VALIDATOR_ERROR_URL = "https://docs.convex.dev/error#undefined-validator";
1612
1636
  function throwUndefinedValidatorError(context, fieldName) {
1613
1637
  const fieldInfo = fieldName !== void 0 ? ` for field "${fieldName}"` : "";
@@ -1617,10 +1641,10 @@ function throwUndefinedValidatorError(context, fieldName) {
1617
1641
  }
1618
1642
  var BaseValidator = class {
1619
1643
  constructor({ isOptional }) {
1620
- __publicField(this, "type");
1621
- __publicField(this, "fieldPaths");
1622
- __publicField(this, "isOptional");
1623
- __publicField(this, "isConvexValidator");
1644
+ __publicField2(this, "type");
1645
+ __publicField2(this, "fieldPaths");
1646
+ __publicField2(this, "isOptional");
1647
+ __publicField2(this, "isConvexValidator");
1624
1648
  this.isOptional = isOptional;
1625
1649
  this.isConvexValidator = true;
1626
1650
  }
@@ -1634,8 +1658,8 @@ var VId = class _VId extends BaseValidator {
1634
1658
  tableName
1635
1659
  }) {
1636
1660
  super({ isOptional });
1637
- __publicField(this, "tableName");
1638
- __publicField(this, "kind", "id");
1661
+ __publicField2(this, "tableName");
1662
+ __publicField2(this, "kind", "id");
1639
1663
  if (typeof tableName !== "string") {
1640
1664
  throw new Error("v.id(tableName) requires a string");
1641
1665
  }
@@ -1660,7 +1684,7 @@ var VId = class _VId extends BaseValidator {
1660
1684
  var VFloat64 = class _VFloat64 extends BaseValidator {
1661
1685
  constructor() {
1662
1686
  super(...arguments);
1663
- __publicField(this, "kind", "float64");
1687
+ __publicField2(this, "kind", "float64");
1664
1688
  }
1665
1689
  /** @internal */
1666
1690
  get json() {
@@ -1680,7 +1704,7 @@ var VFloat64 = class _VFloat64 extends BaseValidator {
1680
1704
  var VInt64 = class _VInt64 extends BaseValidator {
1681
1705
  constructor() {
1682
1706
  super(...arguments);
1683
- __publicField(this, "kind", "int64");
1707
+ __publicField2(this, "kind", "int64");
1684
1708
  }
1685
1709
  /** @internal */
1686
1710
  get json() {
@@ -1698,7 +1722,7 @@ var VInt64 = class _VInt64 extends BaseValidator {
1698
1722
  var VCommitTs = class _VCommitTs extends BaseValidator {
1699
1723
  constructor() {
1700
1724
  super(...arguments);
1701
- __publicField(this, "kind", "commitTs");
1725
+ __publicField2(this, "kind", "commitTs");
1702
1726
  }
1703
1727
  /** @internal */
1704
1728
  get json() {
@@ -1718,7 +1742,7 @@ var VCommitTs = class _VCommitTs extends BaseValidator {
1718
1742
  var VBoolean = class _VBoolean extends BaseValidator {
1719
1743
  constructor() {
1720
1744
  super(...arguments);
1721
- __publicField(this, "kind", "boolean");
1745
+ __publicField2(this, "kind", "boolean");
1722
1746
  }
1723
1747
  /** @internal */
1724
1748
  get json() {
@@ -1738,7 +1762,7 @@ var VBoolean = class _VBoolean extends BaseValidator {
1738
1762
  var VBytes = class _VBytes extends BaseValidator {
1739
1763
  constructor() {
1740
1764
  super(...arguments);
1741
- __publicField(this, "kind", "bytes");
1765
+ __publicField2(this, "kind", "bytes");
1742
1766
  }
1743
1767
  /** @internal */
1744
1768
  get json() {
@@ -1756,7 +1780,7 @@ var VBytes = class _VBytes extends BaseValidator {
1756
1780
  var VString = class _VString extends BaseValidator {
1757
1781
  constructor() {
1758
1782
  super(...arguments);
1759
- __publicField(this, "kind", "string");
1783
+ __publicField2(this, "kind", "string");
1760
1784
  }
1761
1785
  /** @internal */
1762
1786
  get json() {
@@ -1776,7 +1800,7 @@ var VString = class _VString extends BaseValidator {
1776
1800
  var VNull = class _VNull extends BaseValidator {
1777
1801
  constructor() {
1778
1802
  super(...arguments);
1779
- __publicField(this, "kind", "null");
1803
+ __publicField2(this, "kind", "null");
1780
1804
  }
1781
1805
  /** @internal */
1782
1806
  get json() {
@@ -1794,7 +1818,7 @@ var VNull = class _VNull extends BaseValidator {
1794
1818
  var VAny = class _VAny extends BaseValidator {
1795
1819
  constructor() {
1796
1820
  super(...arguments);
1797
- __publicField(this, "kind", "any");
1821
+ __publicField2(this, "kind", "any");
1798
1822
  }
1799
1823
  /** @internal */
1800
1824
  get json() {
@@ -1822,8 +1846,8 @@ var VObject = class _VObject extends BaseValidator {
1822
1846
  fields
1823
1847
  }) {
1824
1848
  super({ isOptional });
1825
- __publicField(this, "fields");
1826
- __publicField(this, "kind", "object");
1849
+ __publicField2(this, "fields");
1850
+ __publicField2(this, "kind", "object");
1827
1851
  globalThis.Object.entries(fields).forEach(([fieldName, validator]) => {
1828
1852
  if (validator === void 0) {
1829
1853
  throwUndefinedValidatorError("v.object()", fieldName);
@@ -1918,8 +1942,8 @@ var VLiteral = class _VLiteral extends BaseValidator {
1918
1942
  */
1919
1943
  constructor({ isOptional, value }) {
1920
1944
  super({ isOptional });
1921
- __publicField(this, "value");
1922
- __publicField(this, "kind", "literal");
1945
+ __publicField2(this, "value");
1946
+ __publicField2(this, "kind", "literal");
1923
1947
  if (typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number" && typeof value !== "bigint") {
1924
1948
  throw new Error("v.literal(value) must be a string, number, or boolean");
1925
1949
  }
@@ -1953,8 +1977,8 @@ var VArray = class _VArray extends BaseValidator {
1953
1977
  element
1954
1978
  }) {
1955
1979
  super({ isOptional });
1956
- __publicField(this, "element");
1957
- __publicField(this, "kind", "array");
1980
+ __publicField2(this, "element");
1981
+ __publicField2(this, "kind", "array");
1958
1982
  if (element === void 0) {
1959
1983
  throwUndefinedValidatorError("v.array()");
1960
1984
  }
@@ -1989,9 +2013,9 @@ var VRecord = class _VRecord extends BaseValidator {
1989
2013
  value
1990
2014
  }) {
1991
2015
  super({ isOptional });
1992
- __publicField(this, "key");
1993
- __publicField(this, "value");
1994
- __publicField(this, "kind", "record");
2016
+ __publicField2(this, "key");
2017
+ __publicField2(this, "value");
2018
+ __publicField2(this, "kind", "record");
1995
2019
  if (key === void 0) {
1996
2020
  throwUndefinedValidatorError("v.record()", "key");
1997
2021
  }
@@ -2041,8 +2065,8 @@ var VUnion = class _VUnion extends BaseValidator {
2041
2065
  */
2042
2066
  constructor({ isOptional, members }) {
2043
2067
  super({ isOptional });
2044
- __publicField(this, "members");
2045
- __publicField(this, "kind", "union");
2068
+ __publicField2(this, "members");
2069
+ __publicField2(this, "kind", "union");
2046
2070
  members.forEach((member, index) => {
2047
2071
  if (member === void 0) {
2048
2072
  throwUndefinedValidatorError("v.union()", `member at index ${index}`);
@@ -2350,17 +2374,17 @@ var v = {
2350
2374
 
2351
2375
  // ../../node_modules/convex/dist/esm/values/errors.js
2352
2376
  var __defProp3 = Object.defineProperty;
2353
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2354
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
2377
+ var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2378
+ var __publicField3 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
2355
2379
  var _a;
2356
2380
  var _b;
2357
2381
  var IDENTIFYING_FIELD = Symbol.for("ConvexError");
2358
2382
  var ConvexError = class extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
2359
2383
  constructor(data) {
2360
2384
  super(typeof data === "string" ? data : stringifyValueForError(data));
2361
- __publicField2(this, "name", "ConvexError");
2362
- __publicField2(this, "data");
2363
- __publicField2(this, _a, true);
2385
+ __publicField3(this, "name", "ConvexError");
2386
+ __publicField3(this, "data");
2387
+ __publicField3(this, _a, true);
2364
2388
  this.data = data;
2365
2389
  }
2366
2390
  };
@@ -2372,8 +2396,8 @@ var bBytes = arr();
2372
2396
 
2373
2397
  // ../../node_modules/convex/dist/esm/browser/logging.js
2374
2398
  var __defProp4 = Object.defineProperty;
2375
- var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2376
- var __publicField3 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
2399
+ var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2400
+ var __publicField4 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
2377
2401
  var INFO_COLOR = "color:rgb(0, 145, 255)";
2378
2402
  function prefix_for_source(source) {
2379
2403
  switch (source) {
@@ -2389,8 +2413,8 @@ function prefix_for_source(source) {
2389
2413
  }
2390
2414
  var DefaultLogger = class {
2391
2415
  constructor(options) {
2392
- __publicField3(this, "_onLogLineFuncs");
2393
- __publicField3(this, "_verbose");
2416
+ __publicField4(this, "_onLogLineFuncs");
2417
+ __publicField4(this, "_verbose");
2394
2418
  this._onLogLineFuncs = {};
2395
2419
  this._verbose = options.verbose;
2396
2420
  }
@@ -2531,20 +2555,20 @@ function serializedQueryTokenIsPaginated(token) {
2531
2555
 
2532
2556
  // ../../node_modules/convex/dist/esm/browser/sync/local_state.js
2533
2557
  var __defProp5 = Object.defineProperty;
2534
- var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2535
- var __publicField4 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
2558
+ var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2559
+ var __publicField5 = (obj, key, value) => __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value);
2536
2560
  var LocalSyncState = class {
2537
2561
  constructor() {
2538
- __publicField4(this, "nextQueryId");
2539
- __publicField4(this, "querySetVersion");
2540
- __publicField4(this, "querySet");
2541
- __publicField4(this, "queryIdToToken");
2542
- __publicField4(this, "identityVersion");
2543
- __publicField4(this, "auth");
2544
- __publicField4(this, "outstandingQueriesOlderThanRestart");
2545
- __publicField4(this, "outstandingAuthOlderThanRestart");
2546
- __publicField4(this, "paused");
2547
- __publicField4(this, "pendingQuerySetModifications");
2562
+ __publicField5(this, "nextQueryId");
2563
+ __publicField5(this, "querySetVersion");
2564
+ __publicField5(this, "querySet");
2565
+ __publicField5(this, "queryIdToToken");
2566
+ __publicField5(this, "identityVersion");
2567
+ __publicField5(this, "auth");
2568
+ __publicField5(this, "outstandingQueriesOlderThanRestart");
2569
+ __publicField5(this, "outstandingAuthOlderThanRestart");
2570
+ __publicField5(this, "paused");
2571
+ __publicField5(this, "pendingQuerySetModifications");
2548
2572
  this.nextQueryId = 0;
2549
2573
  this.querySetVersion = 0;
2550
2574
  this.identityVersion = 0;
@@ -2820,16 +2844,16 @@ var LocalSyncState = class {
2820
2844
 
2821
2845
  // ../../node_modules/convex/dist/esm/browser/sync/request_manager.js
2822
2846
  var __defProp6 = Object.defineProperty;
2823
- var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2824
- var __publicField5 = (obj, key, value) => __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value);
2847
+ var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2848
+ var __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value);
2825
2849
  var RequestManager = class {
2826
2850
  constructor(logger, markConnectionStateDirty) {
2827
2851
  this.logger = logger;
2828
2852
  this.markConnectionStateDirty = markConnectionStateDirty;
2829
- __publicField5(this, "inflightRequests");
2830
- __publicField5(this, "requestsOlderThanRestart");
2831
- __publicField5(this, "inflightMutationsCount", 0);
2832
- __publicField5(this, "inflightActionsCount", 0);
2853
+ __publicField6(this, "inflightRequests");
2854
+ __publicField6(this, "requestsOlderThanRestart");
2855
+ __publicField6(this, "inflightMutationsCount", 0);
2856
+ __publicField6(this, "inflightActionsCount", 0);
2833
2857
  this.inflightRequests = /* @__PURE__ */ new Map();
2834
2858
  this.requestsOlderThanRestart = /* @__PURE__ */ new Set();
2835
2859
  }
@@ -3113,12 +3137,12 @@ var anyApi = createApi();
3113
3137
 
3114
3138
  // ../../node_modules/convex/dist/esm/browser/sync/optimistic_updates_impl.js
3115
3139
  var __defProp7 = Object.defineProperty;
3116
- var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3117
- var __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value);
3140
+ var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3141
+ var __publicField7 = (obj, key, value) => __defNormalProp7(obj, typeof key !== "symbol" ? key + "" : key, value);
3118
3142
  var OptimisticLocalStoreImpl = class _OptimisticLocalStoreImpl {
3119
3143
  constructor(queryResults) {
3120
- __publicField6(this, "queryResults");
3121
- __publicField6(this, "modifiedQueries");
3144
+ __publicField7(this, "queryResults");
3145
+ __publicField7(this, "modifiedQueries");
3122
3146
  this.queryResults = queryResults;
3123
3147
  this.modifiedQueries = [];
3124
3148
  }
@@ -3181,8 +3205,8 @@ var OptimisticLocalStoreImpl = class _OptimisticLocalStoreImpl {
3181
3205
  };
3182
3206
  var OptimisticQueryResults = class {
3183
3207
  constructor() {
3184
- __publicField6(this, "queryResults");
3185
- __publicField6(this, "optimisticUpdates");
3208
+ __publicField7(this, "queryResults");
3209
+ __publicField7(this, "optimisticUpdates");
3186
3210
  this.queryResults = /* @__PURE__ */ new Map();
3187
3211
  this.optimisticUpdates = [];
3188
3212
  }
@@ -3268,13 +3292,13 @@ var OptimisticQueryResults = class {
3268
3292
 
3269
3293
  // ../../node_modules/convex/dist/esm/vendor/long.js
3270
3294
  var __defProp8 = Object.defineProperty;
3271
- var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3272
- var __publicField7 = (obj, key, value) => __defNormalProp7(obj, typeof key !== "symbol" ? key + "" : key, value);
3295
+ var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3296
+ var __publicField8 = (obj, key, value) => __defNormalProp8(obj, typeof key !== "symbol" ? key + "" : key, value);
3273
3297
  var Long = class _Long {
3274
3298
  constructor(low, high) {
3275
- __publicField7(this, "low");
3276
- __publicField7(this, "high");
3277
- __publicField7(this, "__isUnsignedLong__");
3299
+ __publicField8(this, "low");
3300
+ __publicField8(this, "high");
3301
+ __publicField8(this, "__isUnsignedLong__");
3278
3302
  this.low = low | 0;
3279
3303
  this.high = high | 0;
3280
3304
  this.__isUnsignedLong__ = true;
@@ -3345,14 +3369,14 @@ var MAX_UNSIGNED_VALUE = new Long(4294967295 | 0, 4294967295 | 0);
3345
3369
 
3346
3370
  // ../../node_modules/convex/dist/esm/browser/sync/remote_query_set.js
3347
3371
  var __defProp9 = Object.defineProperty;
3348
- var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3349
- var __publicField8 = (obj, key, value) => __defNormalProp8(obj, typeof key !== "symbol" ? key + "" : key, value);
3372
+ var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3373
+ var __publicField9 = (obj, key, value) => __defNormalProp9(obj, typeof key !== "symbol" ? key + "" : key, value);
3350
3374
  var RemoteQuerySet = class {
3351
3375
  constructor(queryPath, logger) {
3352
- __publicField8(this, "version");
3353
- __publicField8(this, "remoteQuerySet");
3354
- __publicField8(this, "queryPath");
3355
- __publicField8(this, "logger");
3376
+ __publicField9(this, "version");
3377
+ __publicField9(this, "remoteQuerySet");
3378
+ __publicField9(this, "queryPath");
3379
+ __publicField9(this, "logger");
3356
3380
  this.version = { querySet: 0, ts: Long.fromNumber(0), identity: 0 };
3357
3381
  this.remoteQuerySet = /* @__PURE__ */ new Map();
3358
3382
  this.queryPath = queryPath;
@@ -3490,8 +3514,8 @@ function encodeClientMessage(message) {
3490
3514
 
3491
3515
  // ../../node_modules/convex/dist/esm/browser/sync/web_socket_manager.js
3492
3516
  var __defProp10 = Object.defineProperty;
3493
- var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp10(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3494
- var __publicField9 = (obj, key, value) => __defNormalProp9(obj, typeof key !== "symbol" ? key + "" : key, value);
3517
+ var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3518
+ var __publicField10 = (obj, key, value) => __defNormalProp10(obj, typeof key !== "symbol" ? key + "" : key, value);
3495
3519
  var CLOSE_NORMAL = 1e3;
3496
3520
  var CLOSE_GOING_AWAY = 1001;
3497
3521
  var CLOSE_NO_STATUS = 1005;
@@ -3544,26 +3568,26 @@ var WebSocketManager = class {
3544
3568
  constructor(uri, callbacks, webSocketConstructor, logger, markConnectionStateDirty, debug) {
3545
3569
  this.markConnectionStateDirty = markConnectionStateDirty;
3546
3570
  this.debug = debug;
3547
- __publicField9(this, "socket");
3548
- __publicField9(this, "connectionCount");
3549
- __publicField9(this, "_hasEverConnected", false);
3550
- __publicField9(this, "lastCloseReason");
3551
- __publicField9(this, "transitionChunkBuffer", null);
3552
- __publicField9(this, "defaultInitialBackoff");
3553
- __publicField9(this, "maxBackoff");
3554
- __publicField9(this, "retries");
3555
- __publicField9(this, "serverInactivityThreshold");
3556
- __publicField9(this, "reconnectDueToServerInactivityTimeout");
3557
- __publicField9(this, "scheduledReconnect", null);
3558
- __publicField9(this, "networkOnlineHandler", null);
3559
- __publicField9(this, "pendingNetworkRecoveryInfo", null);
3560
- __publicField9(this, "uri");
3561
- __publicField9(this, "onOpen");
3562
- __publicField9(this, "onResume");
3563
- __publicField9(this, "onMessage");
3564
- __publicField9(this, "webSocketConstructor");
3565
- __publicField9(this, "logger");
3566
- __publicField9(this, "onServerDisconnectError");
3571
+ __publicField10(this, "socket");
3572
+ __publicField10(this, "connectionCount");
3573
+ __publicField10(this, "_hasEverConnected", false);
3574
+ __publicField10(this, "lastCloseReason");
3575
+ __publicField10(this, "transitionChunkBuffer", null);
3576
+ __publicField10(this, "defaultInitialBackoff");
3577
+ __publicField10(this, "maxBackoff");
3578
+ __publicField10(this, "retries");
3579
+ __publicField10(this, "serverInactivityThreshold");
3580
+ __publicField10(this, "reconnectDueToServerInactivityTimeout");
3581
+ __publicField10(this, "scheduledReconnect", null);
3582
+ __publicField10(this, "networkOnlineHandler", null);
3583
+ __publicField10(this, "pendingNetworkRecoveryInfo", null);
3584
+ __publicField10(this, "uri");
3585
+ __publicField10(this, "onOpen");
3586
+ __publicField10(this, "onResume");
3587
+ __publicField10(this, "onMessage");
3588
+ __publicField10(this, "webSocketConstructor");
3589
+ __publicField10(this, "logger");
3590
+ __publicField10(this, "onServerDisconnectError");
3567
3591
  this.webSocketConstructor = webSocketConstructor;
3568
3592
  this.socket = { state: "disconnected" };
3569
3593
  this.connectionCount = 0;
@@ -4205,26 +4229,26 @@ function jwtDecode(token, options) {
4205
4229
 
4206
4230
  // ../../node_modules/convex/dist/esm/browser/sync/authentication_manager.js
4207
4231
  var __defProp11 = Object.defineProperty;
4208
- var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp11(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4209
- var __publicField10 = (obj, key, value) => __defNormalProp10(obj, typeof key !== "symbol" ? key + "" : key, value);
4232
+ var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4233
+ var __publicField11 = (obj, key, value) => __defNormalProp11(obj, typeof key !== "symbol" ? key + "" : key, value);
4210
4234
  var MAXIMUM_REFRESH_DELAY = 20 * 24 * 60 * 60 * 1e3;
4211
4235
  var MAX_TOKEN_CONFIRMATION_ATTEMPTS = 2;
4212
4236
  var AuthenticationManager = class {
4213
4237
  constructor(syncState, callbacks, config) {
4214
- __publicField10(this, "authState", { state: "noAuth" });
4215
- __publicField10(this, "configVersion", 0);
4216
- __publicField10(this, "syncState");
4217
- __publicField10(this, "authenticate");
4218
- __publicField10(this, "stopSocket");
4219
- __publicField10(this, "tryRestartSocket");
4220
- __publicField10(this, "pauseSocket");
4221
- __publicField10(this, "resumeSocket");
4222
- __publicField10(this, "clearAuth");
4223
- __publicField10(this, "logger");
4224
- __publicField10(this, "refreshTokenLeewaySeconds");
4225
- __publicField10(this, "initialAuthTokenReuse");
4226
- __publicField10(this, "lastRefreshChange");
4227
- __publicField10(this, "tokenConfirmationAttempts", 0);
4238
+ __publicField11(this, "authState", { state: "noAuth" });
4239
+ __publicField11(this, "configVersion", 0);
4240
+ __publicField11(this, "syncState");
4241
+ __publicField11(this, "authenticate");
4242
+ __publicField11(this, "stopSocket");
4243
+ __publicField11(this, "tryRestartSocket");
4244
+ __publicField11(this, "pauseSocket");
4245
+ __publicField11(this, "resumeSocket");
4246
+ __publicField11(this, "clearAuth");
4247
+ __publicField11(this, "logger");
4248
+ __publicField11(this, "refreshTokenLeewaySeconds");
4249
+ __publicField11(this, "initialAuthTokenReuse");
4250
+ __publicField11(this, "lastRefreshChange");
4251
+ __publicField11(this, "tokenConfirmationAttempts", 0);
4228
4252
  this.syncState = syncState;
4229
4253
  this.authenticate = callbacks.authenticate;
4230
4254
  this.stopSocket = callbacks.stopSocket;
@@ -4592,8 +4616,8 @@ function getMarksReport(sessionId) {
4592
4616
 
4593
4617
  // ../../node_modules/convex/dist/esm/browser/sync/client.js
4594
4618
  var __defProp12 = Object.defineProperty;
4595
- var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp12(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4596
- var __publicField11 = (obj, key, value) => __defNormalProp11(obj, typeof key !== "symbol" ? key + "" : key, value);
4619
+ var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4620
+ var __publicField12 = (obj, key, value) => __defNormalProp12(obj, typeof key !== "symbol" ? key + "" : key, value);
4597
4621
  var BaseConvexClient = class {
4598
4622
  /**
4599
4623
  * @param address - The url of your Convex deployment, often provided
@@ -4604,25 +4628,25 @@ var BaseConvexClient = class {
4604
4628
  * @param options - See {@link BaseConvexClientOptions} for a full description.
4605
4629
  */
4606
4630
  constructor(address, onTransition, options) {
4607
- __publicField11(this, "address");
4608
- __publicField11(this, "state");
4609
- __publicField11(this, "requestManager");
4610
- __publicField11(this, "webSocketManager");
4611
- __publicField11(this, "authenticationManager");
4612
- __publicField11(this, "remoteQuerySet");
4613
- __publicField11(this, "optimisticQueryResults");
4614
- __publicField11(this, "_transitionHandlerCounter", 0);
4615
- __publicField11(this, "_nextRequestId");
4616
- __publicField11(this, "_onTransitionFns", /* @__PURE__ */ new Map());
4617
- __publicField11(this, "_sessionId");
4618
- __publicField11(this, "firstMessageReceived", false);
4619
- __publicField11(this, "debug");
4620
- __publicField11(this, "logger");
4621
- __publicField11(this, "maxObservedTimestamp");
4622
- __publicField11(this, "connectionStateSubscribers", /* @__PURE__ */ new Map());
4623
- __publicField11(this, "nextConnectionStateSubscriberId", 0);
4624
- __publicField11(this, "_lastPublishedConnectionState");
4625
- __publicField11(this, "markConnectionStateDirty", () => {
4631
+ __publicField12(this, "address");
4632
+ __publicField12(this, "state");
4633
+ __publicField12(this, "requestManager");
4634
+ __publicField12(this, "webSocketManager");
4635
+ __publicField12(this, "authenticationManager");
4636
+ __publicField12(this, "remoteQuerySet");
4637
+ __publicField12(this, "optimisticQueryResults");
4638
+ __publicField12(this, "_transitionHandlerCounter", 0);
4639
+ __publicField12(this, "_nextRequestId");
4640
+ __publicField12(this, "_onTransitionFns", /* @__PURE__ */ new Map());
4641
+ __publicField12(this, "_sessionId");
4642
+ __publicField12(this, "firstMessageReceived", false);
4643
+ __publicField12(this, "debug");
4644
+ __publicField12(this, "logger");
4645
+ __publicField12(this, "maxObservedTimestamp");
4646
+ __publicField12(this, "connectionStateSubscribers", /* @__PURE__ */ new Map());
4647
+ __publicField12(this, "nextConnectionStateSubscriberId", 0);
4648
+ __publicField12(this, "_lastPublishedConnectionState");
4649
+ __publicField12(this, "markConnectionStateDirty", () => {
4626
4650
  void Promise.resolve().then(() => {
4627
4651
  const curConnectionState = this.connectionState();
4628
4652
  if (JSON.stringify(curConnectionState) !== JSON.stringify(this._lastPublishedConnectionState)) {
@@ -4633,7 +4657,7 @@ var BaseConvexClient = class {
4633
4657
  }
4634
4658
  });
4635
4659
  });
4636
- __publicField11(this, "mark", (name) => {
4660
+ __publicField12(this, "mark", (name) => {
4637
4661
  if (this.debug) {
4638
4662
  mark(name, this.sessionId);
4639
4663
  }
@@ -5310,14 +5334,14 @@ function asPaginationResult(value) {
5310
5334
 
5311
5335
  // ../../node_modules/convex/dist/esm/browser/sync/paginated_query_client.js
5312
5336
  var __defProp13 = Object.defineProperty;
5313
- var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp13(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5314
- var __publicField12 = (obj, key, value) => __defNormalProp12(obj, typeof key !== "symbol" ? key + "" : key, value);
5337
+ var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5338
+ var __publicField13 = (obj, key, value) => __defNormalProp13(obj, typeof key !== "symbol" ? key + "" : key, value);
5315
5339
  var PaginatedQueryClient = class {
5316
5340
  constructor(client, onTransition) {
5317
5341
  this.client = client;
5318
5342
  this.onTransition = onTransition;
5319
- __publicField12(this, "paginatedQuerySet", /* @__PURE__ */ new Map());
5320
- __publicField12(this, "lastTransitionTs");
5343
+ __publicField13(this, "paginatedQuerySet", /* @__PURE__ */ new Map());
5344
+ __publicField13(this, "lastTransitionTs");
5321
5345
  this.lastTransitionTs = Long.fromNumber(0);
5322
5346
  this.client.addOnTransitionHandler(
5323
5347
  (transition) => this.onBaseTransition(transition)
@@ -5677,8 +5701,8 @@ var PaginatedQueryClient = class {
5677
5701
 
5678
5702
  // ../../node_modules/convex/dist/esm/browser/simple_client.js
5679
5703
  var __defProp14 = Object.defineProperty;
5680
- var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp14(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5681
- var __publicField13 = (obj, key, value) => __defNormalProp13(obj, typeof key !== "symbol" ? key + "" : key, value);
5704
+ var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp14(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5705
+ var __publicField14 = (obj, key, value) => __defNormalProp14(obj, typeof key !== "symbol" ? key + "" : key, value);
5682
5706
  var defaultWebSocketConstructor;
5683
5707
  var ConvexClient = class {
5684
5708
  /**
@@ -5687,12 +5711,12 @@ var ConvexClient = class {
5687
5711
  * @public
5688
5712
  */
5689
5713
  constructor(address, options = {}) {
5690
- __publicField13(this, "listeners");
5691
- __publicField13(this, "_client");
5692
- __publicField13(this, "_paginatedClient");
5693
- __publicField13(this, "callNewListenersWithCurrentValuesTimer");
5694
- __publicField13(this, "_closed");
5695
- __publicField13(this, "_disabled");
5714
+ __publicField14(this, "listeners");
5715
+ __publicField14(this, "_client");
5716
+ __publicField14(this, "_paginatedClient");
5717
+ __publicField14(this, "callNewListenersWithCurrentValuesTimer");
5718
+ __publicField14(this, "_closed");
5719
+ __publicField14(this, "_disabled");
5696
5720
  if (options.skipConvexDeploymentUrlCheck !== true) {
5697
5721
  validateDeploymentUrl(address);
5698
5722
  }
@@ -6115,21 +6139,21 @@ var varNames = {
6115
6139
 
6116
6140
  // ../../node_modules/convex/dist/esm/server/schema.js
6117
6141
  var __defProp15 = Object.defineProperty;
6118
- var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp15(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6119
- var __publicField14 = (obj, key, value) => __defNormalProp14(obj, typeof key !== "symbol" ? key + "" : key, value);
6142
+ var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6143
+ var __publicField15 = (obj, key, value) => __defNormalProp15(obj, typeof key !== "symbol" ? key + "" : key, value);
6120
6144
  var TableDefinition = class {
6121
6145
  /**
6122
6146
  * @internal
6123
6147
  */
6124
6148
  constructor(documentType) {
6125
- __publicField14(this, "indexes");
6126
- __publicField14(this, "stagedDbIndexes");
6127
- __publicField14(this, "searchIndexes");
6128
- __publicField14(this, "stagedSearchIndexes");
6129
- __publicField14(this, "vectorIndexes");
6130
- __publicField14(this, "stagedVectorIndexes");
6131
- __publicField14(this, "validator");
6132
- __publicField14(this, "stagedValidator");
6149
+ __publicField15(this, "indexes");
6150
+ __publicField15(this, "stagedDbIndexes");
6151
+ __publicField15(this, "searchIndexes");
6152
+ __publicField15(this, "stagedSearchIndexes");
6153
+ __publicField15(this, "vectorIndexes");
6154
+ __publicField15(this, "stagedVectorIndexes");
6155
+ __publicField15(this, "validator");
6156
+ __publicField15(this, "stagedValidator");
6133
6157
  this.indexes = [];
6134
6158
  this.stagedDbIndexes = [];
6135
6159
  this.searchIndexes = [];
@@ -6322,9 +6346,9 @@ var SchemaDefinition = class {
6322
6346
  * @internal
6323
6347
  */
6324
6348
  constructor(tables, options) {
6325
- __publicField14(this, "tables");
6326
- __publicField14(this, "strictTableNameTypes");
6327
- __publicField14(this, "schemaValidation");
6349
+ __publicField15(this, "tables");
6350
+ __publicField15(this, "strictTableNameTypes");
6351
+ __publicField15(this, "schemaValidation");
6328
6352
  this.tables = tables;
6329
6353
  this.schemaValidation = options?.schemaValidation === void 0 ? true : options.schemaValidation;
6330
6354
  }
@@ -6427,6 +6451,10 @@ function convexBackend(url) {
6427
6451
  const client = new ConvexClient(url, { unsavedChangesWarning: false });
6428
6452
  const queries = api.features.widget.queries;
6429
6453
  const mutations = api.features.widget.mutations;
6454
+ const post = async (path, report) => {
6455
+ const response = await fetch(`${url.replace(/\/$/, "")}/http/widget/${path}`, { method: "POST", body: JSON.stringify(report) });
6456
+ if (!response.ok) throw new Error(`The ${path} report failed: ${response.status}`);
6457
+ };
6430
6458
  return {
6431
6459
  watch: (name, args, onResult, onError) => (
6432
6460
  // One reference per name: the generic index cannot be narrowed further.
@@ -6442,13 +6470,9 @@ function convexBackend(url) {
6442
6470
  });
6443
6471
  },
6444
6472
  // A WebSocket hides the connection from Convex functions: a plain request to an HTTP action, through Cloudflare.
6445
- reportCountry: async (report) => {
6446
- const response = await fetch(`${url.replace(/\/$/, "")}/http/widget/country`, {
6447
- method: "POST",
6448
- body: JSON.stringify(report)
6449
- });
6450
- if (!response.ok) throw new Error(`Country report failed: ${response.status}`);
6451
- },
6473
+ reportCountry: (report) => post("country", report),
6474
+ // Plain too: it still goes when the connection is what broke.
6475
+ reportError: (report) => post("error", report),
6452
6476
  watchConnection: (onChange) => {
6453
6477
  onChange(client.connectionState().isWebSocketConnected);
6454
6478
  return client.subscribeToConnectionState((state) => onChange(state.isWebSocketConnected));
@@ -6462,6 +6486,64 @@ function withCode(error) {
6462
6486
  return Object.assign(error instanceof Error ? error : new Error(String(error)), { code: code2 });
6463
6487
  }
6464
6488
 
6489
+ // ../sdk-core/src/errors.ts
6490
+ var MAX_REPORTS = 5;
6491
+ function isRefusal(error) {
6492
+ return typeof error?.code === "string";
6493
+ }
6494
+ function errorReporter(backend, appKey, source) {
6495
+ const sent = /* @__PURE__ */ new Set();
6496
+ return (where, error) => {
6497
+ if (sent.size >= MAX_REPORTS || isRefusal(error)) return;
6498
+ const failure = error instanceof Error ? error : new Error(String(error));
6499
+ const kind = `${where}:${failure.name}:${failure.message}`;
6500
+ if (sent.has(kind)) return;
6501
+ sent.add(kind);
6502
+ const report = sdkErrorReportOf({
6503
+ appKey,
6504
+ ...source,
6505
+ method: where,
6506
+ name: failure.name || "Error",
6507
+ message: failure.message,
6508
+ stack: failure.stack
6509
+ });
6510
+ if (report) backend.reportError(report).catch(() => {
6511
+ });
6512
+ };
6513
+ }
6514
+ function reportingBackend(backend, report) {
6515
+ const guarded = (where, read) => (value) => {
6516
+ try {
6517
+ read(value);
6518
+ } catch (error) {
6519
+ report(where, error);
6520
+ }
6521
+ };
6522
+ return {
6523
+ ...backend,
6524
+ watch: (name, args, onResult, onError) => backend.watch(name, args, guarded(`watch:${name}`, onResult), onError),
6525
+ watchConnection: (onChange) => backend.watchConnection(guarded("watchConnection", onChange))
6526
+ };
6527
+ }
6528
+ function reportingChat(chat2, report) {
6529
+ const methods = Object.entries(chat2).map(([name, method]) => [
6530
+ name,
6531
+ (...args) => {
6532
+ try {
6533
+ const result = method(...args);
6534
+ return result instanceof Promise ? result.catch((error) => {
6535
+ report(name, error);
6536
+ throw error;
6537
+ }) : result;
6538
+ } catch (error) {
6539
+ report(name, error);
6540
+ throw error;
6541
+ }
6542
+ }
6543
+ ]);
6544
+ return { ...Object.fromEntries(methods), reportError: report };
6545
+ }
6546
+
6465
6547
  // ../sdk-core/src/quotes.ts
6466
6548
  function quoteAuthorOf(quote, you, appName) {
6467
6549
  return quote.from === "contact" ? you : quote.sender?.name ?? appName;
@@ -6476,7 +6558,11 @@ function quoteStepOf(state, replyId) {
6476
6558
 
6477
6559
  // ../sdk-core/src/index.ts
6478
6560
  function createChat(options) {
6479
- return createChatStore(convexBackend(options.backendUrl), options);
6561
+ const backend = convexBackend(options.backendUrl);
6562
+ if (!options.errorSource) return { ...createChatStore(backend, options), reportError: () => {
6563
+ } };
6564
+ const report = errorReporter(backend, options.appKey, options.errorSource);
6565
+ return reportingChat(createChatStore(reportingBackend(backend, report), options), report);
6480
6566
  }
6481
6567
 
6482
6568
  // ../shared/src/utils/app-keys.ts
@@ -6576,6 +6662,8 @@ function hexOf({ l, c, h }) {
6576
6662
  var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
6577
6663
  var MAX_FILE_BYTES = 10 * 1024 * 1024;
6578
6664
  var MAX_ATTACHMENTS = 6;
6665
+ var MAX_EMAIL_FILE_BYTES = 25 * 1024 * 1024;
6666
+ var MAX_EMAIL_SENT_BYTES = 20 * 1024 * 1024;
6579
6667
  var MAX_IMAGE_SIDE = 1600;
6580
6668
  var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
6581
6669
 
@@ -6613,7 +6701,7 @@ function detailsFromUserAgent(userAgent, touchPoints = 0) {
6613
6701
  }
6614
6702
  const android = /Android (\d+(?:\.\d+)?)(?:; ([^;)]+?))?(?: Build\/[^;)]*)?[;)]/.exec(userAgent);
6615
6703
  if (android) {
6616
- const named = android[2]?.trim();
6704
+ const named = android.at(2)?.trim();
6617
6705
  const model = named && !HIDDEN_MODELS.has(named) ? named : void 0;
6618
6706
  const brand = model && brandOf(model);
6619
6707
  return {
@@ -6667,6 +6755,7 @@ function brandOf(model) {
6667
6755
  }
6668
6756
 
6669
6757
  // src/models/sdk.constants.ts
6758
+ var SDK_VERSION = "0.1.18";
6670
6759
  var OFFLINE_NOTICE_MS = 3e3;
6671
6760
  var ANDROID_NAVIGATION_BAR = 48;
6672
6761
  var DEFAULT_MAX_PHOTOS = 4;
@@ -6842,6 +6931,9 @@ function detail(read) {
6842
6931
  function text(value) {
6843
6932
  return typeof value === "string" && value.trim() !== "" && value !== "unknown" ? value : void 0;
6844
6933
  }
6934
+ function errorSource() {
6935
+ return { sdk: "react-native", version: SDK_VERSION, os: import_react_native.Platform.OS };
6936
+ }
6845
6937
  function isDevBuild() {
6846
6938
  return typeof __DEV__ !== "undefined" && __DEV__;
6847
6939
  }
@@ -7038,7 +7130,7 @@ function subscribeChatView(listener) {
7038
7130
  }
7039
7131
 
7040
7132
  // src/components/ChatModal.tsx
7041
- var import_react17 = require("react");
7133
+ var import_react18 = require("react");
7042
7134
  var import_react_native24 = require("react-native");
7043
7135
 
7044
7136
  // src/hooks/use-app-active.ts
@@ -7276,16 +7368,38 @@ var styles = import_react_native4.StyleSheet.create({
7276
7368
  count: { color: "#ffffff", fontSize: 15, fontWeight: "600" }
7277
7369
  });
7278
7370
 
7371
+ // src/components/ChatErrorBoundary.tsx
7372
+ var import_react4 = require("react");
7373
+ var ChatErrorBoundary = class extends import_react4.Component {
7374
+ constructor() {
7375
+ super(...arguments);
7376
+ __publicField(this, "state", { failed: false });
7377
+ }
7378
+ static getDerivedStateFromError() {
7379
+ return { failed: true };
7380
+ }
7381
+ componentDidCatch(error) {
7382
+ this.props.onError(error);
7383
+ }
7384
+ // iOS keeps a closing sheet's screens while it slides away: opened again meanwhile, they draw afresh.
7385
+ componentDidUpdate(previous) {
7386
+ if (this.state.failed && this.props.visible && !previous.visible) this.setState({ failed: false });
7387
+ }
7388
+ render() {
7389
+ return this.state.failed ? null : this.props.children;
7390
+ }
7391
+ };
7392
+
7279
7393
  // src/components/ChatScreen.tsx
7280
- var import_react16 = require("react");
7394
+ var import_react17 = require("react");
7281
7395
  var import_react_native23 = require("react-native");
7282
7396
 
7283
7397
  // src/hooks/use-connection-lost.ts
7284
- var import_react4 = require("react");
7398
+ var import_react5 = require("react");
7285
7399
  function useConnectionLost(connected) {
7286
- const [wasConnected, setWasConnected] = (0, import_react4.useState)(connected);
7287
- const [lost, setLost] = (0, import_react4.useState)(false);
7288
- (0, import_react4.useEffect)(() => {
7400
+ const [wasConnected, setWasConnected] = (0, import_react5.useState)(connected);
7401
+ const [lost, setLost] = (0, import_react5.useState)(false);
7402
+ (0, import_react5.useEffect)(() => {
7289
7403
  if (connected) {
7290
7404
  setWasConnected(true);
7291
7405
  setLost(false);
@@ -7299,11 +7413,11 @@ function useConnectionLost(connected) {
7299
7413
  }
7300
7414
 
7301
7415
  // src/hooks/use-keyboard-overlap.ts
7302
- var import_react5 = require("react");
7416
+ var import_react6 = require("react");
7303
7417
  var import_react_native5 = require("react-native");
7304
7418
  function useKeyboardOverlap(ref) {
7305
- const [overlap, setOverlap] = (0, import_react5.useState)(0);
7306
- (0, import_react5.useEffect)(() => {
7419
+ const [overlap, setOverlap] = (0, import_react6.useState)(0);
7420
+ (0, import_react6.useEffect)(() => {
7307
7421
  if (import_react_native5.Platform.OS === "ios") {
7308
7422
  const frame = import_react_native5.Keyboard.addListener("keyboardWillChangeFrame", (event) => {
7309
7423
  const next = Math.max(0, Math.round(import_react_native5.Dimensions.get("screen").height - event.endCoordinates.screenY));
@@ -7419,7 +7533,7 @@ var styles4 = import_react_native8.StyleSheet.create({
7419
7533
  });
7420
7534
 
7421
7535
  // src/components/ContactCodeCard.tsx
7422
- var import_react6 = require("react");
7536
+ var import_react7 = require("react");
7423
7537
  var import_react_native9 = require("react-native");
7424
7538
 
7425
7539
  // ../shared/src/constants/auth.ts
@@ -7433,9 +7547,9 @@ var MOBILE_AUTH_CODE_TTL_MS = 2 * 6e4;
7433
7547
  var import_jsx_runtime6 = require("react/jsx-runtime");
7434
7548
  function ContactCodeCard({ code: code2, onDismiss }) {
7435
7549
  const { chat: chat2, t, colors } = useChatContext();
7436
- const [value, setValue] = (0, import_react6.useState)("");
7437
- const [error, setError] = (0, import_react6.useState)(null);
7438
- const [busy, setBusy] = (0, import_react6.useState)(false);
7550
+ const [value, setValue] = (0, import_react7.useState)("");
7551
+ const [error, setError] = (0, import_react7.useState)(null);
7552
+ const [busy, setBusy] = (0, import_react7.useState)(false);
7439
7553
  const errorOf = (reason) => reason === "contact_code_invalid" ? t.code_invalid : reason === "contact_code_expired" ? t.code_expired : reason === "rate_limited" ? t.code_rate_limited : t.error;
7440
7554
  const handleSend = async () => {
7441
7555
  setBusy(true);
@@ -7532,11 +7646,11 @@ var styles5 = import_react_native9.StyleSheet.create({
7532
7646
  });
7533
7647
 
7534
7648
  // src/components/Composer.tsx
7535
- var import_react8 = require("react");
7649
+ var import_react9 = require("react");
7536
7650
  var import_react_native11 = require("react-native");
7537
7651
 
7538
7652
  // src/hooks/use-pending-photos.ts
7539
- var import_react7 = require("react");
7653
+ var import_react8 = require("react");
7540
7654
 
7541
7655
  // ../shared/src/utils/files.ts
7542
7656
  function isImage(type) {
@@ -7632,9 +7746,9 @@ var lastId = 0;
7632
7746
  var nextId = () => `photo_${++lastId}`;
7633
7747
  function usePendingPhotos() {
7634
7748
  const { chat: chat2, t, maxPhotos } = useChatContext();
7635
- const [photos, setPhotos] = (0, import_react7.useState)(() => pendingPhotosOfDraft(chat2.draft()?.files ?? [], nextId));
7636
- const [problem, setProblem] = (0, import_react7.useState)(null);
7637
- const [sending, setSending] = (0, import_react7.useState)(false);
7749
+ const [photos, setPhotos] = (0, import_react8.useState)(() => pendingPhotosOfDraft(chat2.draft()?.files ?? [], nextId));
7750
+ const [problem, setProblem] = (0, import_react8.useState)(null);
7751
+ const [sending, setSending] = (0, import_react8.useState)(false);
7638
7752
  const tooMany = maxPhotos === 1 ? t.too_many_one : format(t.too_many, { count: maxPhotos });
7639
7753
  const update = (id, patch) => setPhotos((current) => current.map((photo) => photo.id === id ? { ...photo, ...patch } : photo));
7640
7754
  const upload = async (photo) => {
@@ -7692,7 +7806,7 @@ function usePendingPhotos() {
7692
7806
  setPhotos([]);
7693
7807
  return attachments;
7694
7808
  };
7695
- const draftFiles = (0, import_react7.useMemo)(() => draftFilesOf(photos), [photos]);
7809
+ const draftFiles = (0, import_react8.useMemo)(() => draftFilesOf(photos), [photos]);
7696
7810
  return {
7697
7811
  photos,
7698
7812
  draftFiles,
@@ -7837,22 +7951,22 @@ var styles6 = import_react_native10.StyleSheet.create({
7837
7951
  var import_jsx_runtime8 = require("react/jsx-runtime");
7838
7952
  function Composer() {
7839
7953
  const { chat: chat2, t, colors } = useChatContext();
7840
- const [text2, setText] = (0, import_react8.useState)(() => chat2.draft()?.text ?? "");
7841
- const typed = (0, import_react8.useRef)(text2);
7954
+ const [text2, setText] = (0, import_react9.useState)(() => chat2.draft()?.text ?? "");
7955
+ const typed = (0, import_react9.useRef)(text2);
7842
7956
  const pending = usePendingPhotos();
7843
7957
  const picker = photoPicker();
7844
7958
  const canSend = !pending.sending && (text2.trim().length > 0 || pending.photos.length > 0);
7845
- const draft2 = (0, import_react8.useSyncExternalStore)(subscribeChatView, chatDraft);
7959
+ const draft2 = (0, import_react9.useSyncExternalStore)(subscribeChatView, chatDraft);
7846
7960
  const changeText = (value) => {
7847
7961
  typed.current = value;
7848
7962
  setText(value);
7849
7963
  };
7850
- (0, import_react8.useEffect)(() => {
7964
+ (0, import_react9.useEffect)(() => {
7851
7965
  if (draft2 === null) return;
7852
7966
  changeText(draft2);
7853
7967
  clearDraft();
7854
7968
  }, [draft2]);
7855
- (0, import_react8.useEffect)(() => {
7969
+ (0, import_react9.useEffect)(() => {
7856
7970
  chat2.saveDraft({ text: text2, files: pending.draftFiles });
7857
7971
  }, [chat2, text2, pending.draftFiles]);
7858
7972
  const handleSend = async () => {
@@ -7951,18 +8065,18 @@ var styles7 = import_react_native11.StyleSheet.create({
7951
8065
  });
7952
8066
 
7953
8067
  // src/components/MessageList.tsx
7954
- var import_react15 = require("react");
8068
+ var import_react16 = require("react");
7955
8069
  var import_react_native21 = require("react-native");
7956
8070
 
7957
8071
  // src/components/EmailForm.tsx
7958
- var import_react9 = require("react");
8072
+ var import_react10 = require("react");
7959
8073
  var import_react_native12 = require("react-native");
7960
8074
  var import_jsx_runtime9 = require("react/jsx-runtime");
7961
8075
  function EmailForm({ onSubmit }) {
7962
8076
  const { t, colors } = useChatContext();
7963
- const [email, setEmail] = (0, import_react9.useState)("");
7964
- const [error, setError] = (0, import_react9.useState)(null);
7965
- const [busy, setBusy] = (0, import_react9.useState)(false);
8077
+ const [email, setEmail] = (0, import_react10.useState)("");
8078
+ const [error, setError] = (0, import_react10.useState)(null);
8079
+ const [busy, setBusy] = (0, import_react10.useState)(false);
7966
8080
  const handleSubmit = async () => {
7967
8081
  const address = normaliseEmail(email);
7968
8082
  if (!isEmail(address)) {
@@ -8025,15 +8139,15 @@ var styles8 = import_react_native12.StyleSheet.create({
8025
8139
  });
8026
8140
 
8027
8141
  // src/components/MessageBubble.tsx
8028
- var import_react13 = require("react");
8142
+ var import_react14 = require("react");
8029
8143
  var import_react_native19 = require("react-native");
8030
8144
 
8031
8145
  // src/hooks/use-rise-in.ts
8032
- var import_react10 = require("react");
8146
+ var import_react11 = require("react");
8033
8147
  var import_react_native13 = require("react-native");
8034
8148
  function useRiseIn(fresh) {
8035
- const progress = (0, import_react10.useRef)(new import_react_native13.Animated.Value(fresh ? 0 : 1)).current;
8036
- (0, import_react10.useEffect)(() => {
8149
+ const progress = (0, import_react11.useRef)(new import_react_native13.Animated.Value(fresh ? 0 : 1)).current;
8150
+ (0, import_react11.useEffect)(() => {
8037
8151
  if (!fresh) return;
8038
8152
  import_react_native13.Animated.timing(progress, { toValue: 1, duration: ENTER_MS, useNativeDriver: true }).start();
8039
8153
  }, [fresh, progress]);
@@ -8054,15 +8168,15 @@ function withFileName(url, name) {
8054
8168
  }
8055
8169
 
8056
8170
  // src/hooks/use-attachment-links.ts
8057
- var import_react11 = require("react");
8171
+ var import_react12 = require("react");
8058
8172
  var signed = /* @__PURE__ */ new Map();
8059
8173
  function useAttachmentLinks(chat2, keys, stored) {
8060
- const [links, setLinks] = (0, import_react11.useState)(() => cachedLinks(keys));
8061
- const [attempt, setAttempt] = (0, import_react11.useState)(0);
8062
- const connected = (0, import_react11.useSyncExternalStore)(chat2.subscribe, () => chat2.getState().connected);
8063
- const failed = (0, import_react11.useRef)(false);
8174
+ const [links, setLinks] = (0, import_react12.useState)(() => cachedLinks(keys));
8175
+ const [attempt, setAttempt] = (0, import_react12.useState)(0);
8176
+ const connected = (0, import_react12.useSyncExternalStore)(chat2.subscribe, () => chat2.getState().connected);
8177
+ const failed = (0, import_react12.useRef)(false);
8064
8178
  const wanted = keys.join("|");
8065
- (0, import_react11.useEffect)(() => {
8179
+ (0, import_react12.useEffect)(() => {
8066
8180
  if (!stored) return;
8067
8181
  const list = wanted ? wanted.split("|") : [];
8068
8182
  const missing = list.filter((key) => (signed.get(key)?.until ?? 0) < Date.now());
@@ -8090,7 +8204,7 @@ function useAttachmentLinks(chat2, keys, stored) {
8090
8204
  clearTimeout(retry);
8091
8205
  };
8092
8206
  }, [chat2, wanted, attempt, stored]);
8093
- (0, import_react11.useEffect)(() => {
8207
+ (0, import_react12.useEffect)(() => {
8094
8208
  if (connected && failed.current) setAttempt((current) => current + 1);
8095
8209
  }, [connected]);
8096
8210
  return links;
@@ -8100,13 +8214,13 @@ function cachedLinks(keys) {
8100
8214
  }
8101
8215
 
8102
8216
  // src/components/Skeleton.tsx
8103
- var import_react12 = require("react");
8217
+ var import_react13 = require("react");
8104
8218
  var import_react_native14 = require("react-native");
8105
8219
  var import_jsx_runtime10 = require("react/jsx-runtime");
8106
8220
  function Skeleton({ style }) {
8107
8221
  const { colors } = useChatContext();
8108
- const opacity = (0, import_react12.useRef)(new import_react_native14.Animated.Value(1)).current;
8109
- (0, import_react12.useEffect)(() => {
8222
+ const opacity = (0, import_react13.useRef)(new import_react_native14.Animated.Value(1)).current;
8223
+ (0, import_react13.useEffect)(() => {
8110
8224
  const breathe = import_react_native14.Animated.loop(
8111
8225
  import_react_native14.Animated.sequence([
8112
8226
  import_react_native14.Animated.timing(opacity, { toValue: 0.5, duration: 700, useNativeDriver: true }),
@@ -8357,7 +8471,7 @@ var styles12 = import_react_native18.StyleSheet.create({
8357
8471
 
8358
8472
  // src/components/MessageBubble.tsx
8359
8473
  var import_jsx_runtime15 = require("react/jsx-runtime");
8360
- var MessageBubble = (0, import_react13.memo)(function MessageBubble2({ row, app, onRetry, onQuote, highlighted }) {
8474
+ var MessageBubble = (0, import_react14.memo)(function MessageBubble2({ row, app, onRetry, onQuote, highlighted }) {
8361
8475
  const { chat: chat2, t, locale, colors, openedAt } = useChatContext();
8362
8476
  const { message, startsRun, endsRun, startsDay } = row;
8363
8477
  const own = message.from === "contact";
@@ -8462,14 +8576,14 @@ var styles13 = import_react_native19.StyleSheet.create({
8462
8576
  });
8463
8577
 
8464
8578
  // src/components/TypingBubble.tsx
8465
- var import_react14 = require("react");
8579
+ var import_react15 = require("react");
8466
8580
  var import_react_native20 = require("react-native");
8467
8581
  var import_jsx_runtime16 = require("react/jsx-runtime");
8468
8582
  function TypingBubble({ app, sender }) {
8469
8583
  const { t, colors } = useChatContext();
8470
8584
  const rise = useRiseIn(true);
8471
- const dots = (0, import_react14.useRef)([0, 1, 2].map(() => new import_react_native20.Animated.Value(0))).current;
8472
- (0, import_react14.useEffect)(() => {
8585
+ const dots = (0, import_react15.useRef)([0, 1, 2].map(() => new import_react_native20.Animated.Value(0))).current;
8586
+ (0, import_react15.useEffect)(() => {
8473
8587
  const bounce = import_react_native20.Animated.loop(
8474
8588
  import_react_native20.Animated.stagger(
8475
8589
  150,
@@ -8521,14 +8635,14 @@ var styles14 = import_react_native20.StyleSheet.create({
8521
8635
  var import_jsx_runtime17 = require("react/jsx-runtime");
8522
8636
  function MessageList({ state }) {
8523
8637
  const { chat: chat2, t, colors, openedAt } = useChatContext();
8524
- const listRef = (0, import_react15.useRef)(null);
8525
- const [scrolledUp, setScrolledUp] = (0, import_react15.useState)(false);
8526
- const [highlighted, setHighlighted] = (0, import_react15.useState)(null);
8527
- const [seeking, setSeeking] = (0, import_react15.useState)(null);
8638
+ const listRef = (0, import_react16.useRef)(null);
8639
+ const [scrolledUp, setScrolledUp] = (0, import_react16.useState)(false);
8640
+ const [highlighted, setHighlighted] = (0, import_react16.useState)(null);
8641
+ const [seeking, setSeeking] = (0, import_react16.useState)(null);
8528
8642
  const app = state.app;
8529
8643
  const { messages, seen, atStart } = state;
8530
8644
  const welcomeText = state.texts.welcome;
8531
- const rows = (0, import_react15.useMemo)(() => {
8645
+ const rows = (0, import_react16.useMemo)(() => {
8532
8646
  const welcome = atStart ? {
8533
8647
  id: "welcome",
8534
8648
  from: "team",
@@ -8544,15 +8658,15 @@ function MessageList({ state }) {
8544
8658
  }, [messages, seen, atStart, welcomeText, openedAt]);
8545
8659
  const newest = rows.at(0)?.message;
8546
8660
  const sending = newest?.from === "contact" && newest.status === "sending" ? newest.id : null;
8547
- (0, import_react15.useEffect)(() => {
8661
+ (0, import_react16.useEffect)(() => {
8548
8662
  if (sending) listRef.current?.scrollToOffset({ offset: 0, animated: true });
8549
8663
  }, [sending]);
8550
- (0, import_react15.useEffect)(() => {
8664
+ (0, import_react16.useEffect)(() => {
8551
8665
  if (!highlighted) return;
8552
8666
  const timer = setTimeout(() => setHighlighted(null), QUOTE_HIGHLIGHT_MS);
8553
8667
  return () => clearTimeout(timer);
8554
8668
  }, [highlighted]);
8555
- (0, import_react15.useEffect)(() => {
8669
+ (0, import_react16.useEffect)(() => {
8556
8670
  if (!seeking) return;
8557
8671
  const step = quoteStepOf(state, seeking);
8558
8672
  if (step.kind === "older") chat2.loadOlder();
@@ -8563,9 +8677,9 @@ function MessageList({ state }) {
8563
8677
  listRef.current?.scrollToIndex({ index, animated: true, viewPosition: 0.5 });
8564
8678
  setHighlighted(step.id);
8565
8679
  }, [seeking, state, chat2, rows]);
8566
- const handleQuote = (0, import_react15.useCallback)((replyId) => setSeeking(replyId), []);
8567
- const handleRetry = (0, import_react15.useCallback)((messageId) => chat2.retry(messageId), [chat2]);
8568
- const renderItem = (0, import_react15.useCallback)(
8680
+ const handleQuote = (0, import_react16.useCallback)((replyId) => setSeeking(replyId), []);
8681
+ const handleRetry = (0, import_react16.useCallback)((messageId) => chat2.retry(messageId), [chat2]);
8682
+ const renderItem = (0, import_react16.useCallback)(
8569
8683
  ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageBubble, { row: item, app, onRetry: handleRetry, onQuote: handleQuote, highlighted: highlighted === item.message.id }),
8570
8684
  [app, handleRetry, handleQuote, highlighted]
8571
8685
  );
@@ -8686,7 +8800,7 @@ var styles16 = import_react_native22.StyleSheet.create({
8686
8800
  var import_jsx_runtime19 = require("react/jsx-runtime");
8687
8801
  function ChatScreen({ state, insets, onClose }) {
8688
8802
  const { chat: chat2, t, colors } = useChatContext();
8689
- const rootRef = (0, import_react16.useRef)(null);
8803
+ const rootRef = (0, import_react17.useRef)(null);
8690
8804
  const keyboard = useKeyboardOverlap(rootRef);
8691
8805
  const connectionLost = useConnectionLost(state.connected);
8692
8806
  const app = state.app;
@@ -8714,18 +8828,18 @@ var styles17 = import_react_native23.StyleSheet.create({
8714
8828
  var import_jsx_runtime20 = require("react/jsx-runtime");
8715
8829
  var STRINGS = { fr, en };
8716
8830
  function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
8717
- const state = (0, import_react17.useSyncExternalStore)(chat2.subscribe, chat2.getState);
8718
- const { open: open2 } = (0, import_react17.useSyncExternalStore)(subscribeChatView, chatView);
8831
+ const state = (0, import_react18.useSyncExternalStore)(chat2.subscribe, chat2.getState);
8832
+ const { open: open2 } = (0, import_react18.useSyncExternalStore)(subscribeChatView, chatView);
8719
8833
  const deviceScheme = (0, import_react_native24.useColorScheme)();
8720
8834
  const scheme = colorScheme ?? (deviceScheme === "dark" ? "dark" : "light");
8721
8835
  const active = useAppActive();
8722
8836
  const dimensions = (0, import_react_native24.useWindowDimensions)();
8723
- const [gallery, setGallery] = (0, import_react17.useState)(null);
8724
- const [openedAt, setOpenedAt] = (0, import_react17.useState)(Date.now);
8837
+ const [gallery, setGallery] = (0, import_react18.useState)(null);
8838
+ const [openedAt, setOpenedAt] = (0, import_react18.useState)(Date.now);
8725
8839
  const app = state.app;
8726
8840
  const visible = open2 && app !== null && state.status !== "loading" && state.status !== "hidden";
8727
8841
  const color = app?.color ?? ZEAN_ACCENT_HEX;
8728
- const context = (0, import_react17.useMemo)(
8842
+ const context = (0, import_react18.useMemo)(
8729
8843
  () => ({
8730
8844
  chat: chat2,
8731
8845
  t: STRINGS[state.locale],
@@ -8737,12 +8851,16 @@ function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
8737
8851
  }),
8738
8852
  [chat2, state.locale, color, scheme, openedAt, maxPhotos]
8739
8853
  );
8740
- const insets = (0, import_react17.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
8741
- (0, import_react17.useEffect)(() => chat2.setOpen(open2 && active), [chat2, open2, active]);
8742
- (0, import_react17.useEffect)(() => {
8854
+ const insets = (0, import_react18.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
8855
+ const handleScreenError = (error) => {
8856
+ chat2.reportError("screen", error);
8857
+ zean.close();
8858
+ };
8859
+ (0, import_react18.useEffect)(() => chat2.setOpen(open2 && active), [chat2, open2, active]);
8860
+ (0, import_react18.useEffect)(() => {
8743
8861
  if (visible && active && state.unread > 0) chat2.markRead();
8744
8862
  }, [chat2, visible, active, state.unread]);
8745
- (0, import_react17.useEffect)(() => {
8863
+ (0, import_react18.useEffect)(() => {
8746
8864
  if (visible) setOpenedAt(Date.now());
8747
8865
  else setGallery(null);
8748
8866
  }, [visible]);
@@ -8756,10 +8874,10 @@ function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
8756
8874
  statusBarTranslucent: true,
8757
8875
  navigationBarTranslucent: true,
8758
8876
  onRequestClose: () => import_react_native24.Platform.OS === "android" && gallery ? setGallery(null) : zean.close(),
8759
- children: app && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ChatContext, { value: context, children: [
8877
+ children: app && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChatErrorBoundary, { visible, onError: handleScreenError, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ChatContext, { value: context, children: [
8760
8878
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChatScreen, { state, insets, onClose: zean.close }),
8761
8879
  gallery && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ImageViewer, { gallery, topInset: insets.top, onClose: () => setGallery(null) })
8762
- ] })
8880
+ ] }) })
8763
8881
  }
8764
8882
  );
8765
8883
  }
@@ -8776,12 +8894,12 @@ function ZeanChat({
8776
8894
  maxPhotos,
8777
8895
  backendUrl = backendUrlFor(appKey)
8778
8896
  }) {
8779
- const [chat2, setChat] = (0, import_react18.useState)(null);
8780
- const storageRef = (0, import_react18.useRef)(storage);
8897
+ const [chat2, setChat] = (0, import_react19.useState)(null);
8898
+ const storageRef = (0, import_react19.useRef)(storage);
8781
8899
  const userKey = user ? JSON.stringify(user) : null;
8782
- const identified = (0, import_react18.useRef)(false);
8900
+ const identified = (0, import_react19.useRef)(false);
8783
8901
  const attributesKey = attributes2 ? JSON.stringify(attributes2) : null;
8784
- (0, import_react18.useEffect)(() => {
8902
+ (0, import_react19.useEffect)(() => {
8785
8903
  const started = createChat({
8786
8904
  appKey,
8787
8905
  backendUrl,
@@ -8796,7 +8914,9 @@ function ZeanChat({
8796
8914
  // The Conversation stays on the phone: the next start shows it at once and asks only for newer messages.
8797
8915
  keep: true,
8798
8916
  // A development build: the phone becomes a Test device for App settings > Developers > Webhook.
8799
- dev: isDevBuild()
8917
+ dev: isDevBuild(),
8918
+ // The SDK's own errors go to our Sentry through the backend; the app's own Sentry, if any, is left alone.
8919
+ errorSource: errorSource()
8800
8920
  });
8801
8921
  const detach = attachChat(started);
8802
8922
  setChat(started);
@@ -8805,20 +8925,20 @@ function ZeanChat({
8805
8925
  started.destroy();
8806
8926
  };
8807
8927
  }, [appKey, backendUrl, locale]);
8808
- (0, import_react18.useEffect)(() => {
8928
+ (0, import_react19.useEffect)(() => {
8809
8929
  if (userKey) zean.identify(JSON.parse(userKey));
8810
8930
  else if (identified.current) zean.signOut();
8811
8931
  identified.current = userKey !== null;
8812
8932
  }, [userKey]);
8813
- (0, import_react18.useEffect)(() => {
8933
+ (0, import_react19.useEffect)(() => {
8814
8934
  if (attributesKey) zean.setAttributes(JSON.parse(attributesKey));
8815
8935
  }, [attributesKey, userKey]);
8816
8936
  return chat2 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChatModal, { chat: chat2, colorScheme, maxPhotos }) : null;
8817
8937
  }
8818
8938
 
8819
8939
  // src/hooks/use-zean.ts
8820
- var import_react19 = require("react");
8940
+ var import_react20 = require("react");
8821
8941
  function useZean() {
8822
- const { unread } = (0, import_react19.useSyncExternalStore)(subscribeChatView, chatView);
8942
+ const { unread } = (0, import_react20.useSyncExternalStore)(subscribeChatView, chatView);
8823
8943
  return { ...zean, unreadCount: unread };
8824
8944
  }