@zean-chat/react-native 0.1.4 → 0.1.7

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
@@ -26,10 +26,11 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/components/ZeanChat.tsx
29
- var import_react14 = require("react");
29
+ var import_react17 = require("react");
30
30
 
31
31
  // ../shared/src/constants/app.ts
32
32
  var APP_NAME = "Zean";
33
+ var APP_URL = "https://zean.chat";
33
34
  var PRODUCTION_BACKEND_URL = "https://api.zean.chat";
34
35
  var STAGING_APP_KEY_PREFIX = "app_stg_";
35
36
  var STAGING_BACKEND_URL = "https://api-stg.zean.chat";
@@ -37,6 +38,8 @@ var SUPPORTED_LOCALES = ["fr", "en"];
37
38
  var DEFAULT_LOCALE = "fr";
38
39
 
39
40
  // ../shared/src/constants/conversations.ts
41
+ var INBOX_FILTERS = ["all", "mine", "unassigned"];
42
+ var INBOX_VIEWS = [...INBOX_FILTERS, "unread"];
40
43
  var CONTACT_ID_MAX_LENGTH = 200;
41
44
  var CONTACT_NAME_MAX_LENGTH = 120;
42
45
  var CONTACT_PHONE_MAX_LENGTH = 32;
@@ -198,12 +201,19 @@ function minutesOf(clock) {
198
201
  // ../sdk-core/src/chat.ts
199
202
  var CLOCK_MS = 3e4;
200
203
  var TYPING_SIGNAL_MS = 2e3;
204
+ var EMAIL_ASK_TYPING_MS = 1200;
201
205
  var SECRET_BYTES = 32;
202
206
  var SECRET_RETRY_MS = 2e3;
207
+ var KEPT_MESSAGES = 100;
208
+ var KEPT_VERSION = 1;
209
+ var LIVE_AFTER_CLOSE_MS = 2 * 6e4;
210
+ var ADVANCE_AFTER = WIDGET_PAGE_SIZE / 2;
203
211
  function createChatStore(backend, options) {
204
212
  const secretKey = `zean:${options.appKey}:device`;
205
213
  const outboxKey = `zean:${options.appKey}:outbox`;
206
214
  const attributesKey = `zean:${options.appKey}:attributes`;
215
+ const keptKey = `zean:${options.appKey}:conversation`;
216
+ const keep = options.keep === true;
207
217
  const listeners2 = /* @__PURE__ */ new Set();
208
218
  const stops = [];
209
219
  let deviceSecret = null;
@@ -214,6 +224,14 @@ function createChatStore(backend, options) {
214
224
  let limit = WIDGET_PAGE_SIZE;
215
225
  let loadingOlder = false;
216
226
  let stopMessages = null;
227
+ let stopTyping = null;
228
+ let kept = [];
229
+ let keptHasOlder = false;
230
+ let keptHistory = null;
231
+ let askedAfter;
232
+ let windowed = false;
233
+ let open2 = false;
234
+ let liveTimer = null;
217
235
  let typing = null;
218
236
  let typingTimer = null;
219
237
  let lastTypingSignal = 0;
@@ -224,6 +242,10 @@ function createChatStore(backend, options) {
224
242
  let reported = false;
225
243
  let user = null;
226
244
  let contactCode = null;
245
+ let emailGiven = false;
246
+ let wroteHere = false;
247
+ let emailAskWanted = false;
248
+ let emailAskTimer = null;
227
249
  let generation = 0;
228
250
  let identifying = null;
229
251
  let identified = false;
@@ -232,10 +254,11 @@ function createChatStore(backend, options) {
232
254
  let destroyed = false;
233
255
  let state = derive();
234
256
  const emit2 = () => {
257
+ holdEmailAsk();
235
258
  state = derive();
236
259
  for (const listener of listeners2) listener();
237
260
  };
238
- const args = () => ({ appKey: options.appKey, deviceSecret, host: options.host });
261
+ const args = () => ({ appKey: options.appKey, deviceSecret, host: options.host, bundle: options.bundle });
239
262
  const deviceLanguage = options.deviceLanguage ?? options.languages[0];
240
263
  const device = () => ({
241
264
  locale: state.locale,
@@ -255,6 +278,7 @@ function createChatStore(backend, options) {
255
278
  useSecret(secret);
256
279
  outbox = await loadOutbox();
257
280
  heldAttributes = { ...await loadAttributes(), ...heldAttributes };
281
+ if (keep) await loadKept();
258
282
  if (destroyed) return;
259
283
  emit2();
260
284
  stops.push(
@@ -273,11 +297,50 @@ function createChatStore(backend, options) {
273
297
  backend.watch("session", args(), handleSession, () => {
274
298
  failedToLoad = true;
275
299
  emit2();
276
- }),
277
- backend.watch("typing", args(), handleTyping, () => {
278
300
  })
279
301
  ];
302
+ if (!keep || open2) watchLive();
303
+ }
304
+ function watchLive() {
280
305
  watchMessages();
306
+ stopTyping?.();
307
+ stopTyping = backend.watch("typing", args(), handleTyping, () => {
308
+ });
309
+ }
310
+ function stopLive() {
311
+ if (keep && stopMessages) {
312
+ const hasOlder = serverHasOlder();
313
+ kept = serverMessages();
314
+ keptHasOlder = hasOlder;
315
+ page = { messages: [], hasOlder: false, seen: page.seen };
316
+ windowed = false;
317
+ }
318
+ stopMessages?.();
319
+ stopMessages = null;
320
+ stopTyping?.();
321
+ stopTyping = null;
322
+ typing = null;
323
+ }
324
+ function stopLiveLater() {
325
+ keepLive();
326
+ liveTimer = setTimeout(() => {
327
+ liveTimer = null;
328
+ stopLive();
329
+ emit2();
330
+ }, LIVE_AFTER_CLOSE_MS);
331
+ }
332
+ function keepLive() {
333
+ if (liveTimer) clearTimeout(liveTimer);
334
+ liveTimer = null;
335
+ }
336
+ function serverMessages() {
337
+ if (kept.length === 0) return page.messages;
338
+ if (page.messages.length === 0) return kept;
339
+ const keptIds = new Set(kept.map((message) => message.id));
340
+ return [...kept, ...page.messages.filter((message) => !keptIds.has(message.id))];
341
+ }
342
+ function serverHasOlder() {
343
+ return kept.length > 0 ? keptHasOlder : page.hasOlder;
281
344
  }
282
345
  function sendIdentity() {
283
346
  const person = user;
@@ -307,11 +370,11 @@ function createChatStore(backend, options) {
307
370
  if (session?.state !== result.state && result.state === "not_found")
308
371
  console.warn(`${APP_NAME}: no App has the key "${options.appKey}". Check the install snippet.`);
309
372
  if (session?.state !== result.state && result.state === "domain_not_allowed")
310
- console.warn(
311
- `${APP_NAME}: ${options.host ?? "this page"} is not on the App's allowed domains. Add it in the App settings.`
312
- );
373
+ console.warn(`${APP_NAME}: ${options.host ?? "this page"} is not the App's Domain. Set it in the App settings.`);
374
+ if (session?.state !== result.state && result.state === "bundle_id_not_allowed") console.warn(bundleWarning(options.bundle));
313
375
  session = result;
314
376
  failedToLoad = false;
377
+ if (keep) checkKept(result);
315
378
  emit2();
316
379
  if ("report" in result && result.report && !reported) {
317
380
  reported = true;
@@ -352,10 +415,17 @@ function createChatStore(backend, options) {
352
415
  }
353
416
  function watchMessages() {
354
417
  stopMessages?.();
418
+ const after = !windowed && kept.length > 0 ? kept.at(-1).createdAt : void 0;
419
+ askedAfter = after;
355
420
  stopMessages = backend.watch(
356
421
  "messages",
357
- { ...args(), limit },
422
+ { ...args(), limit: after === void 0 ? limit : WIDGET_PAGE_SIZE, ...after === void 0 ? {} : { after } },
358
423
  (result) => {
424
+ if (after !== void 0 && result.hasOlder) windowed = true;
425
+ if (after === void 0 || windowed) {
426
+ kept = [];
427
+ keptHasOlder = false;
428
+ }
359
429
  page = result;
360
430
  pageLoaded = true;
361
431
  loadingOlder = false;
@@ -364,6 +434,12 @@ function createChatStore(backend, options) {
364
434
  outbox = outbox.filter((entry) => !stored.has(entry.clientId));
365
435
  saveOutbox();
366
436
  }
437
+ if (after !== void 0 && !windowed && result.messages.length >= ADVANCE_AFTER) {
438
+ kept = serverMessages();
439
+ page = { messages: [], hasOlder: false, seen: result.seen };
440
+ watchMessages();
441
+ }
442
+ saveKept();
367
443
  emit2();
368
444
  startOnce();
369
445
  },
@@ -395,37 +471,124 @@ function createChatStore(backend, options) {
395
471
  }
396
472
  );
397
473
  }
474
+ function statusOf() {
475
+ if (failedToLoad || session && hidesChat(session)) return "hidden";
476
+ const noConversation = keep && session !== null && "contact" in session && !session.contact?.historyKey;
477
+ return session && (pageLoaded || noConversation) ? session.state : "loading";
478
+ }
479
+ function wantsEmail() {
480
+ const app = session && "app" in session ? session.app : null;
481
+ const contact = session && "contact" in session ? session.contact : null;
482
+ return statusOf() === "ready" && !!contact && contact.email === null && !emailGiven && (app?.askEmail ?? false);
483
+ }
484
+ function holdEmailAsk() {
485
+ const wanted = wantsEmail();
486
+ if (wanted && !emailAskWanted && wroteHere) {
487
+ emailAskTimer = setTimeout(() => {
488
+ emailAskTimer = null;
489
+ emit2();
490
+ }, EMAIL_ASK_TYPING_MS);
491
+ } else if (!wanted && emailAskTimer) {
492
+ clearTimeout(emailAskTimer);
493
+ emailAskTimer = null;
494
+ }
495
+ emailAskWanted = wanted;
496
+ }
398
497
  function derive() {
399
- const status = failedToLoad || session?.state === "not_found" || session?.state === "domain_not_allowed" ? "hidden" : session && pageLoaded ? session.state : "loading";
498
+ const status = statusOf();
400
499
  const app = session && "app" in session ? session.app : null;
401
500
  const contact = session && "contact" in session ? session.contact : null;
402
501
  const locale = localeOf(options.languages, app?.defaultLocale ?? DEFAULT_LOCALE);
403
502
  const fallback = DEFAULT_WIDGET_TEXTS;
404
503
  const textOf = (key) => pickText(app?.texts[key], locale, app?.defaultLocale ?? DEFAULT_LOCALE, { fr: fallback.fr[key], en: fallback.en[key] });
405
504
  const verified = session !== null && "identity" in session && session.identity === "verified";
406
- const stored = new Set(page.messages.map((message) => message.clientId));
505
+ const shown = serverMessages();
506
+ const hasOlder = serverHasOlder();
507
+ const stored = new Set(shown.map((message) => message.clientId));
407
508
  const pending = outbox.filter((entry) => !stored.has(entry.clientId)).map(fromOutbox);
408
509
  return {
409
510
  status,
410
- app: app ? { name: app.name, color: app.color, logoUrl: app.logoUrl, launcher: app.launcher, showBadge: app.showBadge } : null,
511
+ app: app ? {
512
+ name: app.name,
513
+ color: app.color,
514
+ logoUrl: app.logoUrl,
515
+ launcher: app.launcher,
516
+ showBadge: app.showBadge,
517
+ hiddenPages: app.hiddenPages
518
+ } : null,
411
519
  locale,
412
520
  texts: { header: textOf("header"), welcome: textOf("welcome"), away: textOf("away") },
413
521
  online: app ? app.teamOnline && isWithinBusinessHours(app.hours, /* @__PURE__ */ new Date()) : false,
414
- messages: [...page.messages.map(fromServer), ...pending],
522
+ messages: [...shown.map(fromServer), ...pending],
415
523
  // Past the most the widget holds, older messages stay in the dashboard.
416
- hasOlder: page.hasOlder && limit < WIDGET_MAX_MESSAGES,
417
- atStart: !page.hasOlder,
524
+ hasOlder: hasOlder && Math.max(limit, shown.length) < WIDGET_MAX_MESSAGES,
525
+ atStart: !hasOlder,
418
526
  loadingOlder,
419
527
  seen: page.seen,
420
528
  unread: contact?.unread ?? 0,
421
- teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : null,
529
+ teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : emailAskTimer ? { sender: null } : null,
422
530
  email: contact?.email ?? null,
423
531
  known: contact !== null,
532
+ askEmail: emailAskWanted && !emailAskTimer,
533
+ emailGiven,
424
534
  verified,
425
535
  contactCode: verified ? null : contactCode,
426
536
  connected
427
537
  };
428
538
  }
539
+ function checkKept(result) {
540
+ const history = "contact" in result ? result.contact?.historyKey ?? null : null;
541
+ if (history !== keptHistory) {
542
+ keptHistory = history;
543
+ dropKept();
544
+ }
545
+ if (hidesChat(result)) forgetKept();
546
+ else if (history !== null && !stopMessages && serverMessages().length === 0 && deviceSecret) {
547
+ watchLive();
548
+ if (!open2) stopLiveLater();
549
+ } else saveKept();
550
+ }
551
+ async function loadKept() {
552
+ try {
553
+ const saved = JSON.parse(await options.storage.getItem(keptKey) || "null");
554
+ if (saved?.version !== KEPT_VERSION || !Array.isArray(saved.messages) || !("app" in saved.session)) return;
555
+ session = saved.session;
556
+ kept = saved.messages;
557
+ keptHasOlder = saved.hasOlder;
558
+ keptHistory = saved.session.contact?.historyKey ?? null;
559
+ page = { messages: [], hasOlder: false, seen: saved.seen };
560
+ pageLoaded = kept.length > 0 || !saved.session.contact?.historyKey;
561
+ } catch {
562
+ }
563
+ }
564
+ function saveKept() {
565
+ if (!keep || !session || hidesChat(session)) return;
566
+ const current = session;
567
+ const shown = serverMessages();
568
+ const value = {
569
+ version: KEPT_VERSION,
570
+ // Told once per load, by the backend: never from what was kept.
571
+ session: { ...current, report: false },
572
+ messages: shown.slice(-KEPT_MESSAGES),
573
+ hasOlder: shown.length > KEPT_MESSAGES || serverHasOlder(),
574
+ seen: page.seen
575
+ };
576
+ quietly(() => options.storage.setItem(keptKey, JSON.stringify(value)));
577
+ }
578
+ function dropKept() {
579
+ kept = [];
580
+ keptHasOlder = false;
581
+ windowed = false;
582
+ if (stopMessages && askedAfter !== void 0) {
583
+ page = { messages: [], hasOlder: false, seen: false };
584
+ watchMessages();
585
+ }
586
+ }
587
+ function forgetKept() {
588
+ dropKept();
589
+ keptHistory = null;
590
+ if (keep) quietly(() => options.storage.setItem(keptKey, ""));
591
+ }
429
592
  async function untilDone(task) {
430
593
  for (; ; ) {
431
594
  try {
@@ -489,6 +652,7 @@ function createChatStore(backend, options) {
489
652
  };
490
653
  outbox = [...outbox, entry];
491
654
  saveOutbox();
655
+ wroteHere = true;
492
656
  emit2();
493
657
  if (started) deliver(entry);
494
658
  },
@@ -511,11 +675,21 @@ function createChatStore(backend, options) {
511
675
  },
512
676
  loadOlder() {
513
677
  if (!state.hasOlder || loadingOlder || !deviceSecret) return;
514
- limit = Math.min(limit + WIDGET_PAGE_SIZE, WIDGET_MAX_MESSAGES);
678
+ const shown = !windowed && kept.length > 0 ? serverMessages().length : limit;
679
+ limit = Math.min(shown + WIDGET_PAGE_SIZE, WIDGET_MAX_MESSAGES);
680
+ windowed = true;
515
681
  loadingOlder = true;
516
682
  emit2();
517
683
  watchMessages();
518
684
  },
685
+ setOpen(value) {
686
+ if (open2 === value) return;
687
+ open2 = value;
688
+ if (!keep) return;
689
+ keepLive();
690
+ if (!value) stopLiveLater();
691
+ else if (!stopMessages && deviceSecret) watchLive();
692
+ },
519
693
  markRead() {
520
694
  if (state.unread === 0 || !deviceSecret) return;
521
695
  backend.call("markRead", args()).catch(() => {
@@ -532,6 +706,8 @@ function createChatStore(backend, options) {
532
706
  if (!deviceSecret) return { ok: false, code: "not_found" };
533
707
  try {
534
708
  await backend.call("setEmail", { ...args(), email });
709
+ emailGiven = true;
710
+ emit2();
535
711
  return { ok: true };
536
712
  } catch (error) {
537
713
  return { ok: false, code: codeOf(error) };
@@ -563,10 +739,13 @@ function createChatStore(backend, options) {
563
739
  saveOutbox();
564
740
  heldAttributes = {};
565
741
  saveAttributes();
742
+ forgetKept();
743
+ emit2();
566
744
  }
567
745
  if (user?.id !== person.id) {
568
746
  generation += 1;
569
747
  contactCode = null;
748
+ emailGiven = false;
570
749
  }
571
750
  user = person;
572
751
  identified = false;
@@ -607,14 +786,16 @@ function createChatStore(backend, options) {
607
786
  user = null;
608
787
  identified = false;
609
788
  contactCode = null;
789
+ emailGiven = false;
610
790
  identifying = null;
611
791
  identifiedKnown = false;
612
792
  if (deviceSecret) backend.call("signOut", args()).catch(() => {
613
793
  });
614
794
  for (const stop of watchers) stop();
615
795
  watchers = [];
616
- stopMessages?.();
617
- stopMessages = null;
796
+ stopLive();
797
+ forgetKept();
798
+ keepLive();
618
799
  deviceSecret = null;
619
800
  outbox = [];
620
801
  saveOutbox();
@@ -633,13 +814,23 @@ function createChatStore(backend, options) {
633
814
  emit2();
634
815
  watchAll();
635
816
  },
817
+ async joinWithPass(pass) {
818
+ await starting;
819
+ await deviceKnown();
820
+ if (destroyed || !deviceSecret) return;
821
+ await backend.call("joinWithPass", { ...args(), pass }).catch(() => {
822
+ });
823
+ },
636
824
  destroy() {
637
825
  destroyed = true;
638
826
  for (const resolve of deviceWaiters.splice(0)) resolve();
639
827
  stopMessages?.();
828
+ stopTyping?.();
640
829
  for (const stop of watchers) stop();
641
830
  for (const stop of stops) stop();
642
831
  if (typingTimer) clearTimeout(typingTimer);
832
+ keepLive();
833
+ if (emailAskTimer) clearTimeout(emailAskTimer);
643
834
  listeners2.clear();
644
835
  backend.close();
645
836
  }
@@ -668,6 +859,22 @@ function fromOutbox(entry) {
668
859
  error: entry.error
669
860
  };
670
861
  }
862
+ function bundleWarning(bundle) {
863
+ if (!bundle)
864
+ return `${APP_NAME}: the chat could not read this app's Bundle ID or Package name. Install expo-application (Expo) or react-native-device-info.`;
865
+ const field = bundle.os === "ios" ? "Bundle ID" : "Package name";
866
+ return `${APP_NAME}: ${bundle.id} is not the App's ${field}. Set it in the App settings.`;
867
+ }
868
+ function hidesChat(result) {
869
+ return result.state === "not_found" || result.state === "domain_not_allowed" || result.state === "bundle_id_not_allowed";
870
+ }
871
+ function quietly(write) {
872
+ try {
873
+ void Promise.resolve(write()).catch(() => {
874
+ });
875
+ } catch {
876
+ }
877
+ }
671
878
  function codeOf(error) {
672
879
  const code2 = error?.code;
673
880
  return typeof code2 === "string" ? code2 : "unknown";
@@ -6165,46 +6372,70 @@ function hexOf({ l, c, h }) {
6165
6372
  }).join("")}`;
6166
6373
  }
6167
6374
 
6375
+ // ../shared/src/constants/uploads.ts
6376
+ var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
6377
+ var MAX_FILE_BYTES = 10 * 1024 * 1024;
6378
+ var MAX_ATTACHMENTS = 6;
6379
+ var MAX_IMAGE_SIDE = 1600;
6380
+ var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
6381
+
6168
6382
  // src/models/sdk.constants.ts
6169
6383
  var OFFLINE_NOTICE_MS = 3e3;
6170
6384
  var ANDROID_NAVIGATION_BAR = 48;
6385
+ var DEFAULT_MAX_PHOTOS = 4;
6386
+ var CHAT_STORAGE_ID = "zean-chat";
6171
6387
  var LINK_RETRY_MS = 1500;
6172
6388
  var LINK_RETRIES = 5;
6173
6389
  var LINK_LIFETIME_MS = 50 * 60 * 1e3;
6174
6390
  var NEUTRAL_COLORS = {
6175
6391
  light: {
6176
- background: "#ffffff",
6177
- surface: "#f4f4f5",
6178
- text: "#09090b",
6179
- muted: "#71717a",
6180
- border: "#e4e4e7",
6181
- danger: "#dc2626",
6182
- online: "#22c55e"
6392
+ background: "#f2f2f7",
6393
+ surface: "#ffffff",
6394
+ text: "#000000",
6395
+ muted: "#6c6c70",
6396
+ border: "#dee1e7",
6397
+ danger: "#ff3b30",
6398
+ online: "#22c55e",
6399
+ skeleton: "rgba(120,120,128,0.16)"
6183
6400
  },
6184
6401
  dark: {
6185
- background: "#18181b",
6186
- surface: "#27272a",
6187
- text: "#fafafa",
6188
- muted: "#a1a1aa",
6189
- border: "#3f3f46",
6190
- danger: "#f87171",
6191
- online: "#22c55e"
6402
+ background: "#000000",
6403
+ surface: "#1c1c1e",
6404
+ text: "#ffffff",
6405
+ muted: "#98989f",
6406
+ border: "#38383a",
6407
+ danger: "#ff453a",
6408
+ online: "#22c55e",
6409
+ skeleton: "rgba(120,120,128,0.32)"
6192
6410
  }
6193
6411
  };
6412
+ var RADII = { inner: 4, pill: 14, group: 20, composer: 28 };
6413
+ var COMPOSER_BUTTON = 40;
6414
+ var RUN_GAP_MS = 5 * 60 * 1e3;
6415
+ var NEWEST_BUTTON_OFFSET = 120;
6416
+ var IMAGE_SIDE = 240;
6417
+ var ENTER_MS = 180;
6194
6418
  var ICONS = {
6195
6419
  close: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACH0lEQVR4nOzZPUoDURTF8esH1mKvNm5AwdK9qER7K8EFuIQ0iYI7ELV3IboCC0HBQlD0HpKBCJl34ryvKc4PLqIjMvmb94wvyyZByyZBCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkSsWho704/P1g/J7if2GbTkM/R5ms5w+rVakt/PisW59Dmb+XzfZ9Pn3srDL3vsc2p/7weP8dE6iqm77vPa8jOufQY+P1YG4ox8judc+7LJvX5YBzF70Jq1B25utESkUBzAY+y8UmL2oBefm8B13PDI8htbexy48nm3jmL3oFufbZ/dlut7NtmT7iwPLOWjwHXEGViE2ECADRkRQpG2LO3G3WzIoWcO4p1YpBSBsMc8WDjSrqX768b2HEj2RyJFICgVqWgcSBUIckcqHgdSBoJckarEgdSBIHWkanEgRyBIFalqHMgVCGIjVY8DOQNB10i9iAO5A8F/I/UmDpQ+u2H/GuA6Ah0GvgevoKNfIS+qdKBFnh0hpY9RiiyxWYsstzbF40DpQNAlUpU4UCMQ4IHiCCR0VNLAnhN1ZBGjVqAGOypJcmQRo3ag0HKrtqxm1Q4EzXLDseiBz6fPuc+F9UDN97Dm2fD59nmznuhboN7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inT032GxxsI4JYGsSONaQHPiRlZJIAvSuMYlNmfs8pUGCiEtfom5DgC+Lj7UHT8ivSWA4Od0PU8397u097/S4I+xQaDS81ytaUGgJpoIFI5ASgRSIpASgZQIpEQgJQIpEUiJQEoEUiKQEoGUCKREICUCZdwIWP3e+hba3bgRcJcN9lo6rLnBXkv7FjbYGWOMMcYYYwx6fxA4satIP8/dAAAAAElFTkSuQmCC",
6197
6421
  photo: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAFJklEQVR4nOybaaiVRRjH/3kro0UroTLoQ1QUtlEUthiFoiVEBBkttkFBfQmLqA9BfWgxKPriZ/GDiruIO64gKiKuuIILiiBccUFBxF2fv3NG7z3O8s575z0z7+X84A/3zpnznnP+Z2be55l5Th+0cdIHbZy0DfLQmw16SDRR1NnQxEZbELeg9zJV9HFT2zTRJwigNxt0UtS/qe2U6F4EEDrFnhP9IpoNNWyvVKhNok9Rnv4F25yEjKB/RT+j9Twj2olwrljag2ZNkRH0lGg70phD3kJCbvU8fodogegxpCPpOukzaCzSmkNWICGuKfam6Eekg4s0b9O7kRCXQd9Z2nn3+lI0EGr4V6WXRNMt76FrEGi7C9qw9TcGk675vaHxJpv5SDQDaTEFgbHoFky6DGJQ1c/Qfo/oNNJiCgJj0S2YdC3S/Sztqc1pKXVNVhejOrpd23ebzxXeXS+IRogeRByOiJZCpVLXca1BMUJ15m7viAaLXm+0rRGth/qmdqA6oqQaVRl0u+gv0U+wT+PLUPnd71CjITbZGsTcbSZUklkE5nmjRHsQlywNYu7GaROanuwXDRKdRzxals2H8A/K5W58zlhkSMwR9BrUAlw2++brvSFaizhkN4K+t7x419xtYOPvTkM/PvdbxONUwTYnMQ163NI+BjefLowJvEYZFhdscxJzip0Q3WdoN+VuA0THDH2Pih5AHJiVM4wY0fhfB4GdIReJGUmfs7T3RfH87RLiQSO+QA+JOcW2WNqHGtqGWfpuRGbEHEFbRSMN7eOgIutlog7RcKihb8JmcjJir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h5j/HjHeUCInKYQaZ9eLyWH1jip8h4EKvtwx0s5D6Kf1rwTftwamWPU86jGAE8TdmPdvCF8jqE+5vFQb/Y9taQHb/VUHBBCi5IwQUpuCCFdQAAAP//SGoJjgAAAAZJREFUAwCco5s+yR6YMQAAAABJRU5ErkJggg==",
6200
6424
  remove: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACi0lEQVR4nOybSUosQRCG4/keby3udeUFFFx6Gael4Epwr0dw44Q3cNp7BA+gJ3AhKLgQnOLHahzoyqiqjIxIIT74cSjozvo6MysrsnqCgiQTFCQJQQIhSCAECYQggRAkEIIEQpBACBIIQQIhSCAECYQggX+kw2zz84bqQK09uT3oD2eXc91kt/mfF+rt+Ut57HA2vvy9wJnmnJM9+LD3OWv0vT04x0saSI7dSc5dy2scclY4b2QD5OxxlsYce6aPtj7SAHLmoP/ULnjUUAtJKTkA5zh4pOTMQbec48RxNHiPyrNP7XLAAeeBBpI7B53Rx5wz13J8njNDZeak0ZyTkoOhvkoZ5ArC8LmgtKQ50p+4pWEFVObBXEFE9pLM5AANQcBKkqkcoCUIlJZkLgdoCgKlJLnIAdqCgLYkNzmghCCgJclVDiglCORKcpcDSgoCQyVVIQeUFgT6SqpGDtAqmEm80ueSv+3El1p+/4lppcC6uNWld6SwLqOYDLGvdBlubZjLAdaCwBBJLnKAhyDQR5KbHBDbPgJePajPZF2intQZD0FDrmRukqwF5VzmXSRZCuq6Qr4i2/JtEquVdJ/bh9HiVVpxm1zZLHpQ33srr42AsZQWNPTGsxpJJQXl3pVXIamUIK2ShbukEoK06zmukrQFlSp2uUnSFFS6EugiSUuQVZnUXJKGIOsasqmkXEFeBXYzSbmCtjnrieMli11dJVX5jCKwqgRKvbjKZxQty6TSllJ1zygecJbJtob82rznEY1vj9sziifNmy9ynjibnC3y41S7PVobh1OcF8491YFaezy/NvAriG0fgRAkEIIEQpBACBIIQQIhSCAECYQggRAkEIIEQpBACBJ4BwAA///VLe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+mwYjYssKLX4kH7QnJyJmFSkxt7XDz5blZNb0qM9wdfuXC3LQULEY4sP6QdNy1mbJN/ZZGhBTmqSQoqP6QdNy4lNUsx1SEo6Tf+LQzw/qPQNdpPJmeP0WiXn/eyQJJlOzhZPRJYkVSWnJEcAbwBuKuam7+/HyR9eALzqKyGEEEIIIYQQQghBEj+c/mnM4jHRJgAAAABJRU5ErkJggg==",
6428
+ down: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABCUlEQVR4nO3ZQQqDMBBG4f8EeqmCFqS9/yHstnRlSYlQimK0monJ+yDgzuE5LkQJAAAAAAAAAAAA+Kgldf64a2tJzXOR9JA0+OOuG8N5mol53IwmKkn91zDjefmnF1vn7/07T+9nje4+MYxVpLk443GzJhVoiBhpKY5ZoGrmFYsZKSSO2SvmXAMGPCpSSJyXn9FUK+kZMOiea34NvOdNiWgjRjpdnJiRThsnRqTTxzkyUjZxjoiUXZw9I2UbZ49I2cf5J1IxcbZEKi7O2k8Dq0+X02zSUNrmbNmk4jbn300qYnO2blJRm7N2k4rcnNBIxFn4XWP5+yhJdUo//AAAAAAAAAAAAKCcvAFtUXbojKVOAwAAAABJRU5ErkJggg=="
6202
6429
  };
6203
6430
 
6204
6431
  // src/models/sdk.utils.ts
6205
6432
  function format(template, values) {
6206
6433
  return template.replace(/\{(\w+)\}/g, (match, key) => key in values ? String(values[key]) : match);
6207
6434
  }
6435
+ function photoLimit(chosen) {
6436
+ if (chosen === void 0 || !Number.isFinite(chosen)) return DEFAULT_MAX_PHOTOS;
6437
+ return Math.min(MAX_ATTACHMENTS, Math.max(1, Math.floor(chosen)));
6438
+ }
6208
6439
  function chatColors(color, scheme) {
6209
6440
  return { ...accentColors(color, scheme), ...NEUTRAL_COLORS[scheme] };
6210
6441
  }
@@ -6219,6 +6450,92 @@ function deviceLanguages() {
6219
6450
  return [];
6220
6451
  }
6221
6452
  }
6453
+ function appBundle() {
6454
+ if (import_react_native.Platform.OS !== "ios" && import_react_native.Platform.OS !== "android") return void 0;
6455
+ const id = expoApplicationId() ?? deviceInfoBundleId();
6456
+ return id ? { os: import_react_native.Platform.OS, id } : void 0;
6457
+ }
6458
+ function chatStorage(storage) {
6459
+ const found2 = storage ? keyValue(storage) : installedStorage();
6460
+ if (!found2) {
6461
+ console.warn(
6462
+ `${APP_NAME}: no storage found, so the conversation is forgotten when the app closes. Install react-native-mmkv, @react-native-async-storage/async-storage or expo-sqlite, then build the app again.`
6463
+ );
6464
+ }
6465
+ const memory = /* @__PURE__ */ new Map();
6466
+ return {
6467
+ getItem: async (key) => {
6468
+ try {
6469
+ if (found2) return await found2.getItem(key);
6470
+ } catch {
6471
+ }
6472
+ return memory.get(key) ?? null;
6473
+ },
6474
+ setItem: async (key, value) => {
6475
+ memory.set(key, value);
6476
+ try {
6477
+ await found2?.setItem(key, value);
6478
+ } catch {
6479
+ }
6480
+ }
6481
+ };
6482
+ }
6483
+ function keyValue(storage) {
6484
+ if ("getItem" in storage) return storage;
6485
+ return { getItem: (key) => storage.getString(key) ?? null, setItem: (key, value) => storage.set(key, value) };
6486
+ }
6487
+ function installedStorage() {
6488
+ return mmkvStorage() ?? moduleStorage("async-storage") ?? moduleStorage("kv-store") ?? browserStorage();
6489
+ }
6490
+ function mmkvStorage() {
6491
+ try {
6492
+ const module2 = require("react-native-mmkv");
6493
+ const config = { id: CHAT_STORAGE_ID };
6494
+ if (typeof module2?.createMMKV === "function") return keyValue(module2.createMMKV(config));
6495
+ if (typeof module2?.MMKV === "function") return keyValue(new module2.MMKV(config));
6496
+ return null;
6497
+ } catch {
6498
+ return null;
6499
+ }
6500
+ }
6501
+ function moduleStorage(name) {
6502
+ try {
6503
+ const module2 = name === "async-storage" ? require("@react-native-async-storage/async-storage") : require("expo-sqlite/kv-store");
6504
+ return [module2, module2.default, module2.Storage].find(isKeyValue) ?? null;
6505
+ } catch {
6506
+ return null;
6507
+ }
6508
+ }
6509
+ function browserStorage() {
6510
+ try {
6511
+ const storage = globalThis.localStorage;
6512
+ return isKeyValue(storage) ? storage : null;
6513
+ } catch {
6514
+ return null;
6515
+ }
6516
+ }
6517
+ function isKeyValue(value) {
6518
+ if (typeof value !== "object" || value === null) return false;
6519
+ const { getItem, setItem } = value;
6520
+ return typeof getItem === "function" && typeof setItem === "function";
6521
+ }
6522
+ function expoApplicationId() {
6523
+ try {
6524
+ const expo = require("expo-application");
6525
+ return typeof expo?.applicationId === "string" ? expo.applicationId : null;
6526
+ } catch {
6527
+ return null;
6528
+ }
6529
+ }
6530
+ function deviceInfoBundleId() {
6531
+ try {
6532
+ const module2 = require("react-native-device-info");
6533
+ const getBundleId = module2?.getBundleId ?? module2?.default?.getBundleId;
6534
+ return typeof getBundleId === "function" ? getBundleId() : null;
6535
+ } catch {
6536
+ return null;
6537
+ }
6538
+ }
6222
6539
  function deviceOs() {
6223
6540
  if (import_react_native.Platform.OS === "ios") return `iOS ${import_react_native.Platform.Version}`;
6224
6541
  if (import_react_native.Platform.OS === "android") return `Android ${import_react_native.Platform.constants.Release}`;
@@ -6255,8 +6572,8 @@ function hideKeyboard() {
6255
6572
  }
6256
6573
 
6257
6574
  // src/components/ChatModal.tsx
6258
- var import_react13 = require("react");
6259
- var import_react_native19 = require("react-native");
6575
+ var import_react16 = require("react");
6576
+ var import_react_native23 = require("react-native");
6260
6577
 
6261
6578
  // src/hooks/use-app-active.ts
6262
6579
  var import_react = require("react");
@@ -6321,9 +6638,14 @@ var en = {
6321
6638
  photo_type: "This photo cannot be sent. Send a JPEG, PNG or WebP photo.",
6322
6639
  photo_size: "{name} is too large. Send a smaller photo.",
6323
6640
  too_many: "At most {count} photos per message.",
6641
+ too_many_one: "One photo per message.",
6324
6642
  open_image: "Open the image",
6325
6643
  close_image: "Close the image",
6326
- open_file: "Open {name}"
6644
+ open_file: "Open {name}",
6645
+ today: "Today",
6646
+ yesterday: "Yesterday",
6647
+ newest: "Go to the latest messages",
6648
+ image_count: "{index} of {count}"
6327
6649
  };
6328
6650
 
6329
6651
  // src/i18n/fr.ts
@@ -6368,33 +6690,122 @@ var fr = {
6368
6690
  photo_type: "Cette photo ne peut pas \xEAtre envoy\xE9e. Envoyez une photo JPEG, PNG ou WebP.",
6369
6691
  photo_size: "{name} est trop volumineuse. Envoyez une photo plus l\xE9g\xE8re.",
6370
6692
  too_many: "Au plus {count} photos par message.",
6693
+ too_many_one: "Une seule photo par message.",
6371
6694
  open_image: "Ouvrir l'image",
6372
6695
  close_image: "Fermer l'image",
6373
- open_file: "Ouvrir {name}"
6696
+ open_file: "Ouvrir {name}",
6697
+ today: "Aujourd'hui",
6698
+ yesterday: "Hier",
6699
+ newest: "Aller aux derniers messages",
6700
+ image_count: "{index} sur {count}"
6374
6701
  };
6375
6702
 
6376
6703
  // src/components/ImageViewer.tsx
6704
+ var import_react3 = require("react");
6705
+ var import_react_native4 = require("react-native");
6706
+
6707
+ // src/components/Icon.tsx
6377
6708
  var import_react_native3 = require("react-native");
6378
6709
  var import_jsx_runtime = require("react/jsx-runtime");
6379
- function ImageViewer({ image, onClose }) {
6710
+ function Icon({ name, color, size }) {
6711
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
6712
+ import_react_native3.Image,
6713
+ {
6714
+ source: { uri: ICONS[name] },
6715
+ style: { width: size, height: size, tintColor: color },
6716
+ accessibilityElementsHidden: true,
6717
+ importantForAccessibility: "no"
6718
+ }
6719
+ );
6720
+ }
6721
+
6722
+ // src/components/ImageViewer.tsx
6723
+ var import_jsx_runtime2 = require("react/jsx-runtime");
6724
+ function ImageViewer({ gallery, topInset, onClose }) {
6380
6725
  const { t } = useChatContext();
6381
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native3.Pressable, { onPress: onClose, accessibilityRole: "button", accessibilityLabel: t.close_image, style: styles.viewer, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native3.Image, { source: { uri: image.url }, style: styles.image, resizeMode: "contain", accessibilityLabel: image.name }) });
6726
+ const window2 = (0, import_react_native4.useWindowDimensions)();
6727
+ const [size, setSize] = (0, import_react3.useState)({ width: window2.width, height: window2.height });
6728
+ const [index, setIndex] = (0, import_react3.useState)(gallery.index);
6729
+ const count = gallery.images.length;
6730
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
6731
+ import_react_native4.View,
6732
+ {
6733
+ testID: "zean-viewer",
6734
+ style: styles.viewer,
6735
+ accessibilityViewIsModal: true,
6736
+ onLayout: (event) => setSize({ width: event.nativeEvent.layout.width, height: event.nativeEvent.layout.height }),
6737
+ children: [
6738
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
6739
+ import_react_native4.FlatList,
6740
+ {
6741
+ testID: "zean-images",
6742
+ horizontal: true,
6743
+ pagingEnabled: true,
6744
+ data: gallery.images,
6745
+ initialScrollIndex: gallery.index,
6746
+ getItemLayout: (_data, item) => ({ length: size.width, offset: size.width * item, index: item }),
6747
+ keyExtractor: (image, item) => `${item}:${image.url}`,
6748
+ showsHorizontalScrollIndicator: false,
6749
+ onMomentumScrollEnd: (event) => setIndex(Math.round(event.nativeEvent.contentOffset.x / size.width)),
6750
+ renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
6751
+ import_react_native4.ScrollView,
6752
+ {
6753
+ style: size,
6754
+ contentContainerStyle: styles.page,
6755
+ maximumZoomScale: 4,
6756
+ minimumZoomScale: 1,
6757
+ centerContent: true,
6758
+ showsHorizontalScrollIndicator: false,
6759
+ showsVerticalScrollIndicator: false,
6760
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Image, { source: { uri: item.url }, style: size, resizeMode: "contain", accessibilityLabel: item.name })
6761
+ }
6762
+ )
6763
+ }
6764
+ ),
6765
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native4.View, { style: [styles.bar, { top: topInset + 12 }], children: [
6766
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
6767
+ import_react_native4.Pressable,
6768
+ {
6769
+ onPress: onClose,
6770
+ accessibilityRole: "button",
6771
+ accessibilityLabel: t.close_image,
6772
+ hitSlop: 8,
6773
+ style: ({ pressed }) => [styles.close, pressed && styles.pressed],
6774
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", color: "#ffffff", size: 18 })
6775
+ }
6776
+ ),
6777
+ count > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Text, { style: styles.count, children: format(t.image_count, { index: index + 1, count }) })
6778
+ ] })
6779
+ ]
6780
+ }
6781
+ );
6382
6782
  }
6383
- var styles = import_react_native3.StyleSheet.create({
6384
- viewer: { ...import_react_native3.StyleSheet.absoluteFill, backgroundColor: "rgba(0,0,0,0.9)", padding: 16 },
6385
- image: { flex: 1 }
6783
+ var styles = import_react_native4.StyleSheet.create({
6784
+ viewer: { ...import_react_native4.StyleSheet.absoluteFill, backgroundColor: "#000000" },
6785
+ page: { flexGrow: 1, alignItems: "center", justifyContent: "center" },
6786
+ bar: { position: "absolute", left: 16, right: 16, flexDirection: "row", alignItems: "center", gap: 12 },
6787
+ close: {
6788
+ width: 36,
6789
+ height: 36,
6790
+ borderRadius: 18,
6791
+ alignItems: "center",
6792
+ justifyContent: "center",
6793
+ backgroundColor: "rgba(255,255,255,0.18)"
6794
+ },
6795
+ pressed: { opacity: 0.6 },
6796
+ count: { color: "#ffffff", fontSize: 15, fontWeight: "600" }
6386
6797
  });
6387
6798
 
6388
6799
  // src/components/ChatScreen.tsx
6389
- var import_react12 = require("react");
6390
- var import_react_native18 = require("react-native");
6800
+ var import_react15 = require("react");
6801
+ var import_react_native22 = require("react-native");
6391
6802
 
6392
6803
  // src/hooks/use-connection-lost.ts
6393
- var import_react3 = require("react");
6804
+ var import_react4 = require("react");
6394
6805
  function useConnectionLost(connected) {
6395
- const [wasConnected, setWasConnected] = (0, import_react3.useState)(connected);
6396
- const [lost, setLost] = (0, import_react3.useState)(false);
6397
- (0, import_react3.useEffect)(() => {
6806
+ const [wasConnected, setWasConnected] = (0, import_react4.useState)(connected);
6807
+ const [lost, setLost] = (0, import_react4.useState)(false);
6808
+ (0, import_react4.useEffect)(() => {
6398
6809
  if (connected) {
6399
6810
  setWasConnected(true);
6400
6811
  setLost(false);
@@ -6408,31 +6819,24 @@ function useConnectionLost(connected) {
6408
6819
  }
6409
6820
 
6410
6821
  // src/hooks/use-keyboard-overlap.ts
6411
- var import_react4 = require("react");
6412
- var import_react_native4 = require("react-native");
6822
+ var import_react5 = require("react");
6823
+ var import_react_native5 = require("react-native");
6413
6824
  function useKeyboardOverlap(ref) {
6414
- const [overlap, setOverlap] = (0, import_react4.useState)(0);
6415
- (0, import_react4.useEffect)(() => {
6416
- if (import_react_native4.Platform.OS === "ios") {
6417
- const animate = (duration) => import_react_native4.LayoutAnimation.configureNext(import_react_native4.LayoutAnimation.create(duration || 250, "keyboard", "opacity"));
6418
- const show2 = import_react_native4.Keyboard.addListener("keyboardWillShow", (event) => {
6419
- animate(event.duration);
6420
- setOverlap(Math.round(event.endCoordinates.height));
6421
- });
6422
- const hide2 = import_react_native4.Keyboard.addListener("keyboardWillHide", (event) => {
6423
- animate(event.duration);
6424
- setOverlap(0);
6825
+ const [overlap, setOverlap] = (0, import_react5.useState)(0);
6826
+ (0, import_react5.useEffect)(() => {
6827
+ if (import_react_native5.Platform.OS === "ios") {
6828
+ const frame = import_react_native5.Keyboard.addListener("keyboardWillChangeFrame", (event) => {
6829
+ const next = Math.max(0, Math.round(import_react_native5.Dimensions.get("screen").height - event.endCoordinates.screenY));
6830
+ if (event.duration > 0) import_react_native5.LayoutAnimation.configureNext(import_react_native5.LayoutAnimation.create(event.duration, "keyboard"));
6831
+ setOverlap(next);
6425
6832
  });
6426
- return () => {
6427
- show2.remove();
6428
- hide2.remove();
6429
- };
6833
+ return () => frame.remove();
6430
6834
  }
6431
- const show = import_react_native4.Keyboard.addListener("keyboardDidShow", (event) => {
6835
+ const show = import_react_native5.Keyboard.addListener("keyboardDidShow", (event) => {
6432
6836
  const keyboardTop = event.endCoordinates.screenY;
6433
6837
  ref.current?.measureInWindow((_x, y, _width, height) => setOverlap(Math.max(0, Math.round(y + height - keyboardTop))));
6434
6838
  });
6435
- const hide = import_react_native4.Keyboard.addListener("keyboardDidHide", () => setOverlap(0));
6839
+ const hide = import_react_native5.Keyboard.addListener("keyboardDidHide", () => setOverlap(0));
6436
6840
  return () => {
6437
6841
  show.remove();
6438
6842
  hide.remove();
@@ -6445,74 +6849,72 @@ function useKeyboardOverlap(ref) {
6445
6849
  var import_react_native7 = require("react-native");
6446
6850
 
6447
6851
  // src/components/AppMark.tsx
6448
- var import_react_native5 = require("react-native");
6449
- var import_jsx_runtime2 = require("react/jsx-runtime");
6852
+ var import_react_native6 = require("react-native");
6853
+ var import_jsx_runtime3 = require("react/jsx-runtime");
6450
6854
  function AppMark({ app }) {
6451
6855
  const { colors } = useChatContext();
6452
- if (app.logoUrl) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native5.Image, { source: { uri: app.logoUrl }, style: styles2.mark, accessibilityIgnoresInvertColors: true });
6453
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native5.View, { style: [styles2.mark, styles2.bubble], children: [0, 1, 2].map((dot) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native5.View, { style: [styles2.dot, { backgroundColor: colors.primary }] }, dot)) });
6856
+ if (app.logoUrl) {
6857
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
6858
+ import_react_native6.Image,
6859
+ {
6860
+ source: { uri: app.logoUrl },
6861
+ style: [styles2.mark, styles2.logo, { borderColor: colors.border }],
6862
+ accessibilityIgnoresInvertColors: true
6863
+ }
6864
+ );
6865
+ }
6866
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.mark, styles2.bubble], children: [0, 1, 2].map((dot) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.dot, { backgroundColor: colors.primary }] }, dot)) });
6454
6867
  }
6455
- var styles2 = import_react_native5.StyleSheet.create({
6456
- mark: { width: 34, height: 34, borderRadius: 12, backgroundColor: "#ffffff" },
6457
- bubble: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, borderBottomLeftRadius: 3 },
6458
- dot: { width: 4, height: 4, borderRadius: 2 }
6868
+ var styles2 = import_react_native6.StyleSheet.create({
6869
+ mark: { width: 40, height: 40, borderRadius: 12, borderWidth: 1, borderColor: "transparent", backgroundColor: "#ffffff" },
6870
+ logo: { borderRadius: 20 },
6871
+ bubble: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, borderBottomLeftRadius: 4 },
6872
+ dot: { width: 5, height: 5, borderRadius: 2.5 }
6459
6873
  });
6460
6874
 
6461
- // src/components/Icon.tsx
6462
- var import_react_native6 = require("react-native");
6463
- var import_jsx_runtime3 = require("react/jsx-runtime");
6464
- function Icon({ name, color, size = 20 }) {
6465
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
6466
- import_react_native6.Image,
6467
- {
6468
- source: { uri: ICONS[name] },
6469
- style: { width: size, height: size, tintColor: color },
6470
- accessibilityElementsHidden: true,
6471
- importantForAccessibility: "no"
6472
- }
6473
- );
6474
- }
6475
-
6476
6875
  // src/components/ChatHeader.tsx
6477
6876
  var import_jsx_runtime4 = require("react/jsx-runtime");
6478
- function ChatHeader({ app, online, greeting, topInset, onClose }) {
6877
+ function ChatHeader({ app, online, topInset, onClose }) {
6479
6878
  const { t, colors } = useChatContext();
6480
6879
  const onPrimary = { color: colors.primaryForeground };
6481
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: [styles3.header, { backgroundColor: colors.primary, paddingTop: topInset + 16 }], children: [
6482
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.row, children: [
6483
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { children: [
6484
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AppMark, { app }),
6485
- online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
6486
- ] }),
6487
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
6488
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
6489
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], children: online ? t.online : t.away })
6490
- ] }),
6491
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
6492
- import_react_native7.Pressable,
6493
- {
6494
- onPress: onClose,
6495
- accessibilityRole: "button",
6496
- accessibilityLabel: t.close_chat,
6497
- hitSlop: 8,
6498
- style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
6499
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground })
6500
- }
6501
- )
6880
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.header, { backgroundColor: colors.primary, paddingTop: topInset + 16 }], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.row, children: [
6881
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { children: [
6882
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AppMark, { app }),
6883
+ online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
6502
6884
  ] }),
6503
- greeting && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.greeting, onPrimary], children: greeting })
6504
- ] });
6885
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
6886
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
6887
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], numberOfLines: 1, children: online ? t.online : t.away })
6888
+ ] }),
6889
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
6890
+ import_react_native7.Pressable,
6891
+ {
6892
+ onPress: onClose,
6893
+ accessibilityRole: "button",
6894
+ accessibilityLabel: t.close_chat,
6895
+ hitSlop: 8,
6896
+ style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
6897
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground, size: 18 })
6898
+ }
6899
+ )
6900
+ ] }) });
6505
6901
  }
6506
6902
  var styles3 = import_react_native7.StyleSheet.create({
6507
- header: { gap: 12, paddingHorizontal: 16, paddingBottom: 18 },
6508
- row: { flexDirection: "row", alignItems: "center", gap: 10 },
6509
- online: { position: "absolute", right: -2, bottom: -2, width: 10, height: 10, borderRadius: 5, borderWidth: 2 },
6510
- titles: { flex: 1, minWidth: 0 },
6511
- name: { fontSize: 16, fontWeight: "600" },
6512
- status: { fontSize: 12, opacity: 0.9 },
6513
- close: { width: 34, height: 34, alignItems: "center", justifyContent: "center", borderRadius: 8 },
6514
- pressed: { backgroundColor: "rgba(255,255,255,0.15)" },
6515
- greeting: { fontSize: 18, lineHeight: 24, fontWeight: "600", letterSpacing: -0.3 }
6903
+ header: { paddingHorizontal: 16, paddingBottom: 20 },
6904
+ row: { flexDirection: "row", alignItems: "center", gap: 12 },
6905
+ online: { position: "absolute", right: -3, bottom: -3, width: 14, height: 14, borderRadius: 7, borderWidth: 2 },
6906
+ titles: { flex: 1, minWidth: 0, gap: 1 },
6907
+ name: { fontSize: 18, fontWeight: "700", letterSpacing: -0.3 },
6908
+ status: { fontSize: 14, fontWeight: "500", opacity: 0.85 },
6909
+ close: {
6910
+ width: 34,
6911
+ height: 34,
6912
+ alignItems: "center",
6913
+ justifyContent: "center",
6914
+ borderRadius: 17,
6915
+ backgroundColor: "rgba(255,255,255,0.18)"
6916
+ },
6917
+ pressed: { opacity: 0.6 }
6516
6918
  });
6517
6919
 
6518
6920
  // src/components/ChatNotice.tsx
@@ -6523,24 +6925,36 @@ function ChatNotice({ children }) {
6523
6925
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native8.Text, { accessibilityLiveRegion: "polite", style: [styles4.notice, { backgroundColor: colors.surface, color: colors.muted }], children });
6524
6926
  }
6525
6927
  var styles4 = import_react_native8.StyleSheet.create({
6526
- notice: { borderRadius: 8, paddingHorizontal: 12, paddingVertical: 8, textAlign: "center", fontSize: 14, overflow: "hidden" }
6928
+ notice: {
6929
+ alignSelf: "center",
6930
+ maxWidth: 640,
6931
+ borderRadius: 20,
6932
+ paddingHorizontal: 16,
6933
+ paddingVertical: 12,
6934
+ textAlign: "center",
6935
+ fontSize: 14,
6936
+ lineHeight: 20,
6937
+ overflow: "hidden"
6938
+ }
6527
6939
  });
6528
6940
 
6529
6941
  // src/components/ContactCodeCard.tsx
6530
- var import_react5 = require("react");
6942
+ var import_react6 = require("react");
6531
6943
  var import_react_native9 = require("react-native");
6532
6944
 
6533
6945
  // ../shared/src/constants/auth.ts
6534
6946
  var CODE_LENGTH = 6;
6535
6947
  var CODE_MAX_AGE_SECONDS = 15 * 60;
6948
+ var TEST_EMAIL_DOMAIN = "zean-test.local";
6949
+ var DEV_OPERATOR_EMAIL = `operator@${TEST_EMAIL_DOMAIN}`;
6536
6950
 
6537
6951
  // src/components/ContactCodeCard.tsx
6538
6952
  var import_jsx_runtime6 = require("react/jsx-runtime");
6539
6953
  function ContactCodeCard({ code: code2, onDismiss }) {
6540
6954
  const { chat: chat2, t, colors } = useChatContext();
6541
- const [value, setValue] = (0, import_react5.useState)("");
6542
- const [error, setError] = (0, import_react5.useState)(null);
6543
- const [busy, setBusy] = (0, import_react5.useState)(false);
6955
+ const [value, setValue] = (0, import_react6.useState)("");
6956
+ const [error, setError] = (0, import_react6.useState)(null);
6957
+ const [busy, setBusy] = (0, import_react6.useState)(false);
6544
6958
  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;
6545
6959
  const handleSend = async () => {
6546
6960
  setBusy(true);
@@ -6563,7 +6977,7 @@ function ContactCodeCard({ code: code2, onDismiss }) {
6563
6977
  if (!result.ok) setError(errorOf(result.code));
6564
6978
  };
6565
6979
  const label = format(code2.sent ? t.code_label : t.code_prompt, { email: code2.email });
6566
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, { borderColor: colors.border }], children: [
6980
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, { backgroundColor: colors.surface }], children: [
6567
6981
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.prompt, { color: colors.text }], children: label }),
6568
6982
  code2.sent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.row, children: [
6569
6983
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -6580,7 +6994,10 @@ function ContactCodeCard({ code: code2, onDismiss }) {
6580
6994
  autoComplete: "one-time-code",
6581
6995
  textContentType: "oneTimeCode",
6582
6996
  returnKeyType: "done",
6583
- style: [styles5.input, { borderColor: error ? colors.danger : colors.border, color: colors.text }]
6997
+ style: [
6998
+ styles5.input,
6999
+ { backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
7000
+ ]
6584
7001
  }
6585
7002
  ),
6586
7003
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -6589,8 +7006,8 @@ function ContactCodeCard({ code: code2, onDismiss }) {
6589
7006
  onPress: () => void handleSubmit(),
6590
7007
  disabled: busy,
6591
7008
  accessibilityRole: "button",
6592
- style: [styles5.submit, { backgroundColor: colors.primary }, busy && styles5.busy],
6593
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.submitText, { color: colors.primaryForeground }], children: t.code_submit })
7009
+ style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
7010
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_submit })
6594
7011
  }
6595
7012
  )
6596
7013
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.actions, children: [
@@ -6600,52 +7017,44 @@ function ContactCodeCard({ code: code2, onDismiss }) {
6600
7017
  onPress: () => void handleSend(),
6601
7018
  disabled: busy,
6602
7019
  accessibilityRole: "button",
6603
- style: [styles5.send, { backgroundColor: colors.primary }, busy && styles5.busy],
6604
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.submitText, { color: colors.primaryForeground }], children: t.code_send })
7020
+ style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
7021
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_send })
6605
7022
  }
6606
7023
  ),
6607
7024
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: onDismiss, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }], children: t.code_dismiss }) })
6608
7025
  ] }),
6609
7026
  error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { accessibilityLiveRegion: "polite", style: [styles5.error, { color: colors.danger }], children: error }),
6610
- code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }, busy && styles5.busy], children: t.code_resend }) })
7027
+ code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.primaryText }, busy && styles5.dim], children: t.code_resend }) })
6611
7028
  ] });
6612
7029
  }
6613
7030
  var styles5 = import_react_native9.StyleSheet.create({
6614
- card: { gap: 8, padding: 12, borderRadius: 12, borderWidth: import_react_native9.StyleSheet.hairlineWidth },
6615
- prompt: { fontSize: 14, lineHeight: 20 },
7031
+ card: { gap: 10, padding: 16, borderRadius: RADII.group },
7032
+ prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
6616
7033
  row: { flexDirection: "row", gap: 8 },
6617
- actions: { flexDirection: "row", alignItems: "center", gap: 12 },
7034
+ actions: { flexDirection: "row", alignItems: "center", gap: 16 },
6618
7035
  input: {
6619
7036
  flex: 1,
6620
7037
  minWidth: 0,
7038
+ height: 44,
6621
7039
  borderWidth: 1,
6622
- borderRadius: 8,
6623
- paddingHorizontal: 12,
6624
- paddingVertical: 8,
6625
- fontSize: 16,
6626
- letterSpacing: 4
7040
+ borderRadius: RADII.pill,
7041
+ paddingHorizontal: 14,
7042
+ fontSize: 18,
7043
+ letterSpacing: 6
6627
7044
  },
6628
- submit: { justifyContent: "center", paddingHorizontal: 12, borderRadius: 8 },
6629
- send: { paddingHorizontal: 12, paddingVertical: 8, borderRadius: 8 },
6630
- busy: { opacity: 0.6 },
6631
- submitText: { fontSize: 14, fontWeight: "500" },
6632
- link: { fontSize: 12, fontWeight: "500" },
6633
- error: { fontSize: 12 }
7045
+ button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
7046
+ buttonText: { fontSize: 15, fontWeight: "600" },
7047
+ dim: { opacity: 0.6 },
7048
+ link: { fontSize: 13, fontWeight: "600" },
7049
+ error: { fontSize: 13 }
6634
7050
  });
6635
7051
 
6636
7052
  // src/components/Composer.tsx
6637
- var import_react7 = require("react");
6638
- var import_react_native10 = require("react-native");
6639
-
6640
- // ../shared/src/constants/uploads.ts
6641
- var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
6642
- var MAX_FILE_BYTES = 10 * 1024 * 1024;
6643
- var MAX_ATTACHMENTS = 6;
6644
- var MAX_IMAGE_SIDE = 1600;
6645
- var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
7053
+ var import_react8 = require("react");
7054
+ var import_react_native11 = require("react-native");
6646
7055
 
6647
7056
  // src/hooks/use-pending-photos.ts
6648
- var import_react6 = require("react");
7057
+ var import_react7 = require("react");
6649
7058
 
6650
7059
  // ../shared/src/utils/files.ts
6651
7060
  function isImage(type) {
@@ -6655,37 +7064,43 @@ function isImage(type) {
6655
7064
  // src/hooks/use-pending-photos.ts
6656
7065
  var lastId = 0;
6657
7066
  function usePendingPhotos() {
6658
- const { chat: chat2, t } = useChatContext();
6659
- const [photos, setPhotos] = (0, import_react6.useState)([]);
6660
- const [problem, setProblem] = (0, import_react6.useState)(null);
7067
+ const { chat: chat2, t, maxPhotos } = useChatContext();
7068
+ const [photos, setPhotos] = (0, import_react7.useState)([]);
7069
+ const [problem, setProblem] = (0, import_react7.useState)(null);
7070
+ const [sending, setSending] = (0, import_react7.useState)(false);
7071
+ const tooMany = maxPhotos === 1 ? t.too_many_one : format(t.too_many, { count: maxPhotos });
6661
7072
  const update = (id, patch) => setPhotos((current) => current.map((photo) => photo.id === id ? { ...photo, ...patch } : photo));
6662
- const upload = async (id, photo, type) => {
7073
+ const upload = async (photo) => {
7074
+ update(photo.id, { status: "uploading" });
6663
7075
  try {
6664
7076
  const file = await (await fetch(photo.uri)).blob();
6665
7077
  if (file.size > MAX_FILE_BYTES) {
6666
7078
  setProblem(format(t.photo_size, { name: photo.name }));
6667
- update(id, { status: "failed" });
6668
- return;
7079
+ update(photo.id, { status: "failed" });
7080
+ return null;
6669
7081
  }
6670
- const { key, url } = await chat2.uploadLink(type, file.size);
6671
- const response = await fetch(url, { method: "PUT", headers: { "Content-Type": type }, body: file });
7082
+ const { key, url } = await chat2.uploadLink(photo.type, file.size);
7083
+ const response = await fetch(url, { method: "PUT", headers: { "Content-Type": photo.type }, body: file });
6672
7084
  if (!response.ok) throw new Error(`Upload failed: ${response.status}`);
6673
7085
  const attachment = {
6674
7086
  key,
6675
7087
  name: photo.name,
6676
- type,
7088
+ type: photo.type,
6677
7089
  size: file.size,
6678
7090
  ...photo.width && photo.height ? { width: photo.width, height: photo.height } : {}
6679
7091
  };
6680
- update(id, { status: "ready", attachment });
7092
+ update(photo.id, { status: "ready", attachment });
7093
+ return attachment;
6681
7094
  } catch {
6682
- update(id, { status: "failed" });
7095
+ update(photo.id, { status: "failed" });
7096
+ return null;
6683
7097
  }
6684
7098
  };
6685
7099
  const add = (picked) => {
6686
7100
  setProblem(null);
6687
- const room = MAX_ATTACHMENTS - photos.length;
6688
- if (picked.length > room) setProblem(format(t.too_many, { count: MAX_ATTACHMENTS }));
7101
+ const room = maxPhotos - photos.length;
7102
+ if (picked.length > room) setProblem(tooMany);
7103
+ const added = [];
6689
7104
  for (const photo of picked.slice(0, Math.max(0, room))) {
6690
7105
  if (!photo.type || !isImage(photo.type)) {
6691
7106
  setProblem(t.photo_type);
@@ -6696,29 +7111,33 @@ function usePendingPhotos() {
6696
7111
  continue;
6697
7112
  }
6698
7113
  lastId += 1;
6699
- const id = `photo_${lastId}`;
6700
- setPhotos((current) => [...current, { id, name: photo.name, uri: photo.uri, status: "uploading", attachment: null }]);
6701
- void upload(id, photo, photo.type);
7114
+ const { uri, name, type, width, height } = photo;
7115
+ added.push({ id: `photo_${lastId}`, uri, name, type, width, height, status: "picked", attachment: null });
6702
7116
  }
7117
+ setPhotos((current) => [...current, ...added]);
6703
7118
  };
6704
7119
  const remove = (id) => setPhotos((current) => current.filter((photo) => photo.id !== id));
6705
- const take = () => {
6706
- const ready = photos.flatMap((photo) => photo.status === "ready" && photo.attachment ? [photo.attachment] : []);
6707
- setPhotos([]);
7120
+ const send = async () => {
6708
7121
  setProblem(null);
6709
- return ready;
7122
+ setSending(true);
7123
+ const attachments = await Promise.all(photos.map((photo) => photo.attachment ?? upload(photo)));
7124
+ setSending(false);
7125
+ if (attachments.includes(null)) return null;
7126
+ setPhotos([]);
7127
+ return attachments;
6710
7128
  };
6711
7129
  return {
6712
7130
  photos,
6713
7131
  problem,
6714
7132
  /** Photos that still fit in the message. */
6715
- room: MAX_ATTACHMENTS - photos.length,
7133
+ room: maxPhotos - photos.length,
7134
+ /** Why no more photos fit. */
7135
+ tooMany,
6716
7136
  add,
6717
7137
  remove,
6718
- take,
6719
- showProblem: setProblem,
6720
- uploading: photos.some((photo) => photo.status === "uploading"),
6721
- ready: photos.some((photo) => photo.status === "ready")
7138
+ send,
7139
+ sending,
7140
+ showProblem: setProblem
6722
7141
  };
6723
7142
  }
6724
7143
 
@@ -6783,7 +7202,7 @@ function imagePicker(module2) {
6783
7202
  }
6784
7203
  function photoOf({ uri, fileName, type, width, height, fileSize }) {
6785
7204
  const name = fileName || uri.split("/").pop() || "photo.jpg";
6786
- const extension = name.split(".").pop()?.toLowerCase() ?? "";
7205
+ const extension = name.split(".").pop().toLowerCase();
6787
7206
  return {
6788
7207
  uri,
6789
7208
  name,
@@ -6793,24 +7212,81 @@ function photoOf({ uri, fileName, type, width, height, fileSize }) {
6793
7212
  };
6794
7213
  }
6795
7214
 
6796
- // src/components/Composer.tsx
7215
+ // src/components/PendingPhotos.tsx
7216
+ var import_react_native10 = require("react-native");
6797
7217
  var import_jsx_runtime7 = require("react/jsx-runtime");
7218
+ function PendingPhotos({ photos, locked, onRemove }) {
7219
+ const { t, colors } = useChatContext();
7220
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles6.photos, children: photos.map((photo) => {
7221
+ const failed = photo.status === "failed";
7222
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
7223
+ import_react_native10.View,
7224
+ {
7225
+ accessible: true,
7226
+ accessibilityLabel: `${photo.name}, ${photo.status === "uploading" ? t.uploading : failed ? t.not_sent : t.ready}`,
7227
+ style: [styles6.photo, { borderColor: failed ? colors.danger : colors.border }],
7228
+ children: [
7229
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Image, { source: { uri: photo.uri }, style: styles6.preview }),
7230
+ photo.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ActivityIndicator, { color: "#ffffff" }) }),
7231
+ failed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: styles6.failed, children: "!" }) }),
7232
+ !locked && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
7233
+ import_react_native10.Pressable,
7234
+ {
7235
+ onPress: () => onRemove(photo.id),
7236
+ accessibilityRole: "button",
7237
+ accessibilityLabel: format(t.remove_photo, { name: photo.name }),
7238
+ hitSlop: 8,
7239
+ style: styles6.remove,
7240
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: "#ffffff", size: 12 })
7241
+ }
7242
+ )
7243
+ ]
7244
+ },
7245
+ photo.id
7246
+ );
7247
+ }) });
7248
+ }
7249
+ var styles6 = import_react_native10.StyleSheet.create({
7250
+ photos: { gap: 8, paddingTop: 6, paddingRight: 6 },
7251
+ photo: { width: 64, height: 64, borderRadius: 14, borderWidth: 1, overflow: "hidden" },
7252
+ preview: { width: "100%", height: "100%" },
7253
+ cover: { ...import_react_native10.StyleSheet.absoluteFill, alignItems: "center", justifyContent: "center", backgroundColor: "rgba(0,0,0,0.35)" },
7254
+ failed: { color: "#ffffff", fontSize: 20, fontWeight: "700" },
7255
+ remove: {
7256
+ position: "absolute",
7257
+ top: 4,
7258
+ right: 4,
7259
+ width: 20,
7260
+ height: 20,
7261
+ borderRadius: 10,
7262
+ alignItems: "center",
7263
+ justifyContent: "center",
7264
+ backgroundColor: "rgba(0,0,0,0.6)"
7265
+ }
7266
+ });
7267
+
7268
+ // src/components/Composer.tsx
7269
+ var import_jsx_runtime8 = require("react/jsx-runtime");
6798
7270
  function Composer() {
6799
7271
  const { chat: chat2, t, colors } = useChatContext();
6800
- const [text, setText] = (0, import_react7.useState)("");
6801
- const [focused, setFocused] = (0, import_react7.useState)(false);
7272
+ const [text, setText] = (0, import_react8.useState)("");
7273
+ const typed = (0, import_react8.useRef)("");
6802
7274
  const pending = usePendingPhotos();
6803
7275
  const picker = photoPicker();
6804
- const canSend = !pending.uploading && (text.trim().length > 0 || pending.ready);
6805
- const handleSend = () => {
6806
- if (!canSend) return;
6807
- chat2.send(text.trim(), pending.take());
6808
- setText("");
7276
+ const canSend = !pending.sending && (text.trim().length > 0 || pending.photos.length > 0);
7277
+ const changeText = (value) => {
7278
+ typed.current = value;
7279
+ setText(value);
7280
+ };
7281
+ const handleSend = async () => {
7282
+ const attachments = pending.photos.length > 0 ? await pending.send() : [];
7283
+ if (!attachments) return;
7284
+ chat2.send(typed.current.trim(), attachments);
7285
+ changeText("");
6809
7286
  };
6810
7287
  const handlePick = async () => {
6811
- if (!picker) return;
6812
7288
  if (pending.room <= 0) {
6813
- pending.showProblem(format(t.too_many, { count: MAX_ATTACHMENTS }));
7289
+ pending.showProblem(pending.tooMany);
6814
7290
  return;
6815
7291
  }
6816
7292
  try {
@@ -6820,119 +7296,166 @@ function Composer() {
6820
7296
  pending.showProblem(t.error);
6821
7297
  }
6822
7298
  };
6823
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: styles6.composer, children: [
6824
- pending.photos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles6.photos, children: pending.photos.map((photo) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
6825
- import_react_native10.View,
6826
- {
6827
- style: [
6828
- styles6.photo,
6829
- { borderColor: photo.status === "failed" ? colors.danger : colors.border, backgroundColor: colors.background }
6830
- ],
6831
- children: [
6832
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Image, { source: { uri: photo.uri }, style: styles6.preview }),
6833
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: [styles6.photoStatus, { color: photo.status === "failed" ? colors.danger : colors.muted }], children: photo.status === "uploading" ? t.uploading : photo.status === "failed" ? t.not_sent : t.ready }),
6834
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6835
- import_react_native10.Pressable,
6836
- {
6837
- onPress: () => pending.remove(photo.id),
6838
- accessibilityRole: "button",
6839
- accessibilityLabel: format(t.remove_photo, { name: photo.name }),
6840
- hitSlop: 8,
6841
- style: styles6.remove,
6842
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: colors.muted, size: 14 })
6843
- }
6844
- )
6845
- ]
6846
- },
6847
- photo.id
6848
- )) }),
6849
- pending.problem && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { accessibilityLiveRegion: "polite", style: [styles6.problem, { color: colors.danger }], children: pending.problem }),
6850
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: [styles6.field, { backgroundColor: colors.background, borderColor: focused ? colors.primary : colors.border }], children: [
6851
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6852
- import_react_native10.TextInput,
7299
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: styles7.composer, children: [
7300
+ pending.photos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PendingPhotos, { photos: pending.photos, locked: pending.sending, onRemove: pending.remove }),
7301
+ pending.problem && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { accessibilityLiveRegion: "polite", style: [styles7.problem, { color: colors.danger }], children: pending.problem }),
7302
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: [styles7.pill, { backgroundColor: colors.surface }], children: [
7303
+ picker && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
7304
+ import_react_native11.Pressable,
7305
+ {
7306
+ onPress: () => void handlePick(),
7307
+ disabled: pending.sending,
7308
+ accessibilityRole: "button",
7309
+ accessibilityLabel: t.attach,
7310
+ accessibilityState: { disabled: pending.sending },
7311
+ style: ({ pressed }) => [styles7.button, pressed && { backgroundColor: colors.background }],
7312
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "photo", color: colors.muted, size: 22 })
7313
+ }
7314
+ ),
7315
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
7316
+ import_react_native11.TextInput,
6853
7317
  {
6854
7318
  value: text,
6855
7319
  onChangeText: (value) => {
6856
- setText(value);
7320
+ changeText(value);
6857
7321
  chat2.typing();
6858
7322
  },
6859
- onFocus: () => setFocused(true),
6860
- onBlur: () => setFocused(false),
6861
7323
  multiline: true,
6862
7324
  maxLength: MAX_MESSAGE_LENGTH,
6863
7325
  placeholder: t.placeholder,
6864
7326
  placeholderTextColor: colors.muted,
6865
7327
  accessibilityLabel: t.placeholder,
6866
- style: [styles6.input, { color: colors.text }]
7328
+ style: [styles7.input, { color: colors.text }, !picker && styles7.inputAlone]
6867
7329
  }
6868
7330
  ),
6869
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: styles6.tools, children: [
6870
- picker && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6871
- import_react_native10.Pressable,
6872
- {
6873
- onPress: () => void handlePick(),
6874
- accessibilityRole: "button",
6875
- accessibilityLabel: t.attach,
6876
- hitSlop: 6,
6877
- style: styles6.tool,
6878
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "photo", color: colors.muted })
6879
- }
6880
- ),
6881
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6882
- import_react_native10.Pressable,
6883
- {
6884
- onPress: handleSend,
6885
- disabled: !canSend,
6886
- accessibilityRole: "button",
6887
- accessibilityLabel: t.send,
6888
- accessibilityState: { disabled: !canSend },
6889
- hitSlop: 6,
6890
- style: ({ pressed }) => [styles6.send, pressed && styles6.pressed],
6891
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "send", color: canSend ? colors.primary : colors.border, size: 22 })
6892
- }
6893
- )
6894
- ] })
7331
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
7332
+ import_react_native11.Pressable,
7333
+ {
7334
+ onPress: () => void handleSend(),
7335
+ disabled: !canSend,
7336
+ accessibilityRole: "button",
7337
+ accessibilityLabel: t.send,
7338
+ accessibilityState: { disabled: !canSend },
7339
+ style: ({ pressed }) => [
7340
+ styles7.button,
7341
+ { backgroundColor: canSend ? colors.primary : colors.skeleton },
7342
+ pressed && styles7.pressed
7343
+ ],
7344
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "send", color: canSend ? colors.primaryForeground : colors.muted, size: 20 })
7345
+ }
7346
+ )
6895
7347
  ] })
6896
7348
  ] });
6897
7349
  }
6898
- var styles6 = import_react_native10.StyleSheet.create({
7350
+ var styles7 = import_react_native11.StyleSheet.create({
6899
7351
  composer: { gap: 8 },
6900
- photos: { gap: 6 },
6901
- photo: {
6902
- flexDirection: "row",
7352
+ problem: { fontSize: 12, paddingHorizontal: 8 },
7353
+ pill: { flexDirection: "row", alignItems: "flex-end", gap: 4, padding: 4, borderRadius: RADII.composer },
7354
+ button: {
7355
+ width: COMPOSER_BUTTON,
7356
+ height: COMPOSER_BUTTON,
7357
+ borderRadius: COMPOSER_BUTTON / 2,
6903
7358
  alignItems: "center",
6904
- gap: 8,
6905
- height: 44,
6906
- paddingLeft: 4,
6907
- paddingRight: 28,
6908
- borderRadius: 8,
6909
- borderWidth: 1
7359
+ justifyContent: "center"
6910
7360
  },
6911
- preview: { width: 32, height: 32, borderRadius: 6 },
6912
- photoStatus: { fontSize: 12 },
6913
- remove: { position: "absolute", top: 4, right: 4, width: 20, height: 20, alignItems: "center", justifyContent: "center" },
6914
- problem: { fontSize: 12 },
6915
- field: { gap: 4, paddingHorizontal: 8, paddingTop: 8, paddingBottom: 6, borderRadius: 12, borderWidth: 1 },
6916
- input: { maxHeight: 128, minHeight: 28, paddingHorizontal: 6, paddingVertical: 2, fontSize: 16, lineHeight: 22 },
6917
- tools: { flexDirection: "row", alignItems: "center" },
6918
- tool: { width: 28, height: 28, alignItems: "center", justifyContent: "center", borderRadius: 8 },
6919
- send: { marginLeft: "auto", width: 32, height: 32, alignItems: "center", justifyContent: "center", borderRadius: 8 },
6920
- pressed: { transform: [{ scale: 0.9 }] }
7361
+ // Five lines of 22 points, and the room around them.
7362
+ input: {
7363
+ flex: 1,
7364
+ minHeight: COMPOSER_BUTTON,
7365
+ maxHeight: 5 * 22 + 18,
7366
+ paddingHorizontal: 4,
7367
+ paddingTop: 9,
7368
+ paddingBottom: 9,
7369
+ fontSize: 16,
7370
+ lineHeight: 22
7371
+ },
7372
+ inputAlone: { paddingLeft: 12 },
7373
+ pressed: { transform: [{ scale: 0.92 }] }
6921
7374
  });
6922
7375
 
6923
7376
  // src/components/MessageList.tsx
6924
- var import_react11 = require("react");
6925
- var import_react_native16 = require("react-native");
7377
+ var import_react14 = require("react");
7378
+ var import_react_native20 = require("react-native");
7379
+
7380
+ // src/models/conversation.utils.ts
7381
+ function authorOf(message) {
7382
+ if (message.from === "contact") return "contact";
7383
+ return `team:${message.sender?.name ?? ""}:${message.sender?.image ?? ""}`;
7384
+ }
7385
+ function startOfDay(timestamp) {
7386
+ const day = new Date(timestamp);
7387
+ day.setHours(0, 0, 0, 0);
7388
+ return day.getTime();
7389
+ }
7390
+ function sameDay(left, right) {
7391
+ return startOfDay(left) === startOfDay(right);
7392
+ }
7393
+ function joins(older, newer) {
7394
+ return older.status !== "failed" && authorOf(older) === authorOf(newer) && newer.createdAt - older.createdAt < RUN_GAP_MS && sameDay(older.createdAt, newer.createdAt);
7395
+ }
7396
+ function conversationRows(messages, seen, welcome) {
7397
+ const all = welcome ? [welcome, ...messages] : [...messages];
7398
+ const lastReply = all.findLastIndex((message) => message.from === "team" && message.sender !== null);
7399
+ return all.map((message, index) => {
7400
+ const older = all[index - 1];
7401
+ const newer = all[index + 1];
7402
+ const isWelcome = message === welcome;
7403
+ return {
7404
+ message,
7405
+ startsRun: !older || !joins(older, message),
7406
+ endsRun: !newer || !joins(message, newer),
7407
+ // Alone, the welcome has no day: there is nothing to date.
7408
+ startsDay: isWelcome ? messages.length > 0 : !older || !sameDay(older.createdAt, message.createdAt),
7409
+ receipt: receiptOf(message, seen || index < lastReply),
7410
+ welcome: isWelcome
7411
+ };
7412
+ });
7413
+ }
7414
+ function receiptOf(message, seen) {
7415
+ if (message.from === "team" || message.status === "failed") return null;
7416
+ if (message.status === "sending") return "sending";
7417
+ return seen ? "seen" : "sent";
7418
+ }
7419
+ var DATE_STYLES = {
7420
+ time: { hour: "2-digit", minute: "2-digit" },
7421
+ weekday: { weekday: "long" },
7422
+ day: { day: "numeric", month: "short" },
7423
+ dayYear: { day: "numeric", month: "short", year: "numeric" }
7424
+ };
7425
+ var formats = /* @__PURE__ */ new Map();
7426
+ function formatDate(timestamp, locale, style) {
7427
+ const key = `${locale}:${style}`;
7428
+ let format2 = formats.get(key);
7429
+ if (!format2) {
7430
+ format2 = new Intl.DateTimeFormat(locale, DATE_STYLES[style]);
7431
+ formats.set(key, format2);
7432
+ }
7433
+ return format2.format(timestamp);
7434
+ }
7435
+ function messageTime(timestamp, locale) {
7436
+ return formatDate(timestamp, locale, "time");
7437
+ }
7438
+ function dayLabel(timestamp, now, locale, t) {
7439
+ const today = startOfDay(now);
7440
+ const day = startOfDay(timestamp);
7441
+ if (day === today) return t.today;
7442
+ if (day === startOfDay(today - 1)) return t.yesterday;
7443
+ const weekAgo = new Date(today);
7444
+ weekAgo.setDate(weekAgo.getDate() - 6);
7445
+ if (day >= weekAgo.getTime()) return formatDate(timestamp, locale, "weekday");
7446
+ const sameYear = new Date(timestamp).getFullYear() === new Date(now).getFullYear();
7447
+ return formatDate(timestamp, locale, sameYear ? "day" : "dayYear");
7448
+ }
6926
7449
 
6927
7450
  // src/components/EmailForm.tsx
6928
- var import_react8 = require("react");
6929
- var import_react_native11 = require("react-native");
6930
- var import_jsx_runtime8 = require("react/jsx-runtime");
7451
+ var import_react9 = require("react");
7452
+ var import_react_native12 = require("react-native");
7453
+ var import_jsx_runtime9 = require("react/jsx-runtime");
6931
7454
  function EmailForm({ onSubmit }) {
6932
7455
  const { t, colors } = useChatContext();
6933
- const [email, setEmail] = (0, import_react8.useState)("");
6934
- const [error, setError] = (0, import_react8.useState)(null);
6935
- const [busy, setBusy] = (0, import_react8.useState)(false);
7456
+ const [email, setEmail] = (0, import_react9.useState)("");
7457
+ const [error, setError] = (0, import_react9.useState)(null);
7458
+ const [busy, setBusy] = (0, import_react9.useState)(false);
6936
7459
  const handleSubmit = async () => {
6937
7460
  const address = normaliseEmail(email);
6938
7461
  if (!isEmail(address)) {
@@ -6945,11 +7468,11 @@ function EmailForm({ onSubmit }) {
6945
7468
  setBusy(false);
6946
7469
  if (!result.ok) setError(result.code === "invalid_email" ? t.email_invalid : t.error);
6947
7470
  };
6948
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: [styles7.form, { borderColor: colors.border }], children: [
6949
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { style: [styles7.prompt, { color: colors.text }], children: t.email_prompt }),
6950
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: styles7.row, children: [
6951
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
6952
- import_react_native11.TextInput,
7471
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: [styles8.card, { backgroundColor: colors.surface }], children: [
7472
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.prompt, { color: colors.text }], children: t.email_prompt }),
7473
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: styles8.row, children: [
7474
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
7475
+ import_react_native12.TextInput,
6953
7476
  {
6954
7477
  value: email,
6955
7478
  onChangeText: setEmail,
@@ -6963,39 +7486,54 @@ function EmailForm({ onSubmit }) {
6963
7486
  autoComplete: "email",
6964
7487
  textContentType: "emailAddress",
6965
7488
  returnKeyType: "send",
6966
- style: [styles7.input, { borderColor: error ? colors.danger : colors.border, color: colors.text }]
7489
+ style: [
7490
+ styles8.input,
7491
+ { backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
7492
+ ]
6967
7493
  }
6968
7494
  ),
6969
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
6970
- import_react_native11.Pressable,
7495
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
7496
+ import_react_native12.Pressable,
6971
7497
  {
6972
7498
  onPress: () => void handleSubmit(),
6973
7499
  disabled: busy,
6974
7500
  accessibilityRole: "button",
6975
- style: [styles7.submit, { backgroundColor: colors.primary }, busy && styles7.busy],
6976
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { style: [styles7.submitText, { color: colors.primaryForeground }], children: t.email_submit })
7501
+ style: ({ pressed }) => [styles8.button, { backgroundColor: colors.primary }, (busy || pressed) && styles8.dim],
7502
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.buttonText, { color: colors.primaryForeground }], children: t.email_submit })
6977
7503
  }
6978
7504
  )
6979
7505
  ] }),
6980
- error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { accessibilityLiveRegion: "polite", style: [styles7.error, { color: colors.danger }], children: error })
7506
+ error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { accessibilityLiveRegion: "polite", style: [styles8.error, { color: colors.danger }], children: error })
6981
7507
  ] });
6982
7508
  }
6983
- var styles7 = import_react_native11.StyleSheet.create({
6984
- form: { gap: 8, padding: 12, borderRadius: 12, borderWidth: import_react_native11.StyleSheet.hairlineWidth },
6985
- prompt: { fontSize: 14, lineHeight: 20 },
7509
+ var styles8 = import_react_native12.StyleSheet.create({
7510
+ card: { gap: 10, marginHorizontal: 12, marginTop: 14, padding: 16, borderRadius: RADII.group },
7511
+ prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
6986
7512
  row: { flexDirection: "row", gap: 8 },
6987
- input: { flex: 1, minWidth: 0, borderWidth: 1, borderRadius: 8, paddingHorizontal: 12, paddingVertical: 8, fontSize: 16 },
6988
- submit: { justifyContent: "center", paddingHorizontal: 12, borderRadius: 8 },
6989
- busy: { opacity: 0.6 },
6990
- submitText: { fontSize: 14, fontWeight: "500" },
6991
- error: { fontSize: 12 }
7513
+ input: { flex: 1, minWidth: 0, height: 44, borderWidth: 1, borderRadius: RADII.pill, paddingHorizontal: 14, fontSize: 16 },
7514
+ button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
7515
+ buttonText: { fontSize: 15, fontWeight: "600" },
7516
+ dim: { opacity: 0.6 },
7517
+ error: { fontSize: 13 }
6992
7518
  });
6993
7519
 
6994
7520
  // src/components/MessageBubble.tsx
6995
- var import_react_native14 = require("react-native");
7521
+ var import_react_native18 = require("react-native");
7522
+
7523
+ // src/hooks/use-rise-in.ts
7524
+ var import_react10 = require("react");
7525
+ var import_react_native13 = require("react-native");
7526
+ function useRiseIn(fresh) {
7527
+ const progress = (0, import_react10.useRef)(new import_react_native13.Animated.Value(fresh ? 0 : 1)).current;
7528
+ (0, import_react10.useEffect)(() => {
7529
+ if (!fresh) return;
7530
+ import_react_native13.Animated.timing(progress, { toValue: 1, duration: ENTER_MS, useNativeDriver: true }).start();
7531
+ }, [fresh, progress]);
7532
+ return { opacity: progress, transform: [{ translateY: progress.interpolate({ inputRange: [0, 1], outputRange: [8, 0] }) }] };
7533
+ }
6996
7534
 
6997
7535
  // src/components/MessageFiles.tsx
6998
- var import_react_native12 = require("react-native");
7536
+ var import_react_native15 = require("react-native");
6999
7537
 
7000
7538
  // ../shared/src/utils/file-links.ts
7001
7539
  var encoder = new TextEncoder();
@@ -7008,13 +7546,13 @@ function withFileName(url, name) {
7008
7546
  }
7009
7547
 
7010
7548
  // src/hooks/use-attachment-links.ts
7011
- var import_react9 = require("react");
7549
+ var import_react11 = require("react");
7012
7550
  var signed = /* @__PURE__ */ new Map();
7013
7551
  function useAttachmentLinks(chat2, keys, stored) {
7014
- const [links, setLinks] = (0, import_react9.useState)(() => cachedLinks(keys));
7015
- const [attempt, setAttempt] = (0, import_react9.useState)(0);
7552
+ const [links, setLinks] = (0, import_react11.useState)(() => cachedLinks(keys));
7553
+ const [attempt, setAttempt] = (0, import_react11.useState)(0);
7016
7554
  const wanted = keys.join("|");
7017
- (0, import_react9.useEffect)(() => {
7555
+ (0, import_react11.useEffect)(() => {
7018
7556
  if (!stored) return;
7019
7557
  const list = wanted ? wanted.split("|") : [];
7020
7558
  const missing = list.filter((key) => (signed.get(key)?.until ?? 0) < Date.now());
@@ -7043,51 +7581,79 @@ function cachedLinks(keys) {
7043
7581
  return new Map(keys.flatMap((key) => signed.has(key) ? [[key, signed.get(key).url]] : []));
7044
7582
  }
7045
7583
 
7584
+ // src/components/Skeleton.tsx
7585
+ var import_react12 = require("react");
7586
+ var import_react_native14 = require("react-native");
7587
+ var import_jsx_runtime10 = require("react/jsx-runtime");
7588
+ function Skeleton({ style }) {
7589
+ const { colors } = useChatContext();
7590
+ const opacity = (0, import_react12.useRef)(new import_react_native14.Animated.Value(1)).current;
7591
+ (0, import_react12.useEffect)(() => {
7592
+ const breathe = import_react_native14.Animated.loop(
7593
+ import_react_native14.Animated.sequence([
7594
+ import_react_native14.Animated.timing(opacity, { toValue: 0.5, duration: 700, useNativeDriver: true }),
7595
+ import_react_native14.Animated.timing(opacity, { toValue: 1, duration: 700, useNativeDriver: true })
7596
+ ])
7597
+ );
7598
+ breathe.start();
7599
+ return () => breathe.stop();
7600
+ }, [opacity]);
7601
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
7602
+ import_react_native14.Animated.View,
7603
+ {
7604
+ style: [{ backgroundColor: colors.skeleton, opacity }, style],
7605
+ accessibilityElementsHidden: true,
7606
+ importantForAccessibility: "no-hide-descendants"
7607
+ }
7608
+ );
7609
+ }
7610
+
7046
7611
  // src/components/MessageFiles.tsx
7047
- var import_jsx_runtime9 = require("react/jsx-runtime");
7048
- var IMAGE_SIDE = 224;
7612
+ var import_jsx_runtime11 = require("react/jsx-runtime");
7049
7613
  function MessageFiles({ attachments, own, stored }) {
7050
- const { chat: chat2, t, colors, openImage } = useChatContext();
7614
+ const { chat: chat2, t, colors, openImages } = useChatContext();
7051
7615
  const links = useAttachmentLinks(
7052
7616
  chat2,
7053
7617
  attachments.map((attachment) => attachment.key),
7054
7618
  stored
7055
7619
  );
7056
7620
  if (attachments.length === 0) return null;
7057
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.View, { style: [styles8.files, { alignItems: own ? "flex-end" : "flex-start" }], children: attachments.map((attachment) => {
7621
+ const gallery = attachments.flatMap((attachment) => {
7622
+ const url = links.get(attachment.key);
7623
+ return url && isImage(attachment.type) ? [{ url, name: attachment.name }] : [];
7624
+ });
7625
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.files, { alignItems: own ? "flex-end" : "flex-start" }], children: attachments.map((attachment) => {
7058
7626
  const url = links.get(attachment.key);
7059
7627
  if (isImage(attachment.type)) {
7060
7628
  const size = imageSize(attachment);
7061
- return url ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
7062
- import_react_native12.Pressable,
7629
+ return url ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
7630
+ import_react_native15.Pressable,
7063
7631
  {
7064
- onPress: () => openImage({ url, name: attachment.name }),
7632
+ onPress: () => openImages({ images: gallery, index: gallery.findIndex((image) => image.url === url) }),
7065
7633
  accessibilityRole: "imagebutton",
7066
7634
  accessibilityLabel: t.open_image,
7067
- style: [styles8.image, { borderColor: colors.border }],
7068
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Image, { source: { uri: url }, style: size, resizeMode: "cover", accessibilityLabel: attachment.name })
7069
- },
7070
- attachment.key
7071
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
7072
- import_react_native12.View,
7073
- {
7074
- style: [styles8.image, size, { backgroundColor: colors.surface, borderColor: colors.border }]
7635
+ style: ({ pressed }) => [styles9.image, { borderColor: colors.border }, pressed && styles9.pressed],
7636
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Image, { source: { uri: url }, style: size, resizeMode: "cover", accessibilityLabel: attachment.name })
7075
7637
  },
7076
7638
  attachment.key
7077
- );
7639
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Skeleton, { style: [styles9.image, size, { borderColor: colors.border }] }, attachment.key);
7078
7640
  }
7079
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
7080
- import_react_native12.Pressable,
7641
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
7642
+ import_react_native15.Pressable,
7081
7643
  {
7082
7644
  disabled: !url,
7083
- onPress: () => url && void import_react_native12.Linking.openURL(withFileName(url, attachment.name)),
7645
+ onPress: () => void import_react_native15.Linking.openURL(withFileName(url, attachment.name)),
7084
7646
  accessibilityRole: "link",
7085
7647
  accessibilityLabel: format(t.open_file, { name: attachment.name }),
7086
- style: [styles8.file, { borderColor: colors.border, backgroundColor: colors.background }],
7648
+ style: ({ pressed }) => [
7649
+ styles9.file,
7650
+ { borderColor: colors.border, backgroundColor: colors.surface },
7651
+ pressed && styles9.pressed
7652
+ ],
7087
7653
  children: [
7088
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file", color: colors.muted, size: 16 }),
7089
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.fileName, { color: colors.text }], numberOfLines: 1, children: attachment.name }),
7090
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "download", color: colors.muted, size: 16 })
7654
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.fileIcon, { backgroundColor: colors.primaryTint }], children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "file", color: colors.primaryText, size: 16 }) }),
7655
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Text, { style: [styles9.fileName, { color: colors.text }], numberOfLines: 1, children: attachment.name }),
7656
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "download", color: colors.muted, size: 16 })
7091
7657
  ]
7092
7658
  },
7093
7659
  attachment.key
@@ -7095,318 +7661,456 @@ function MessageFiles({ attachments, own, stored }) {
7095
7661
  }) });
7096
7662
  }
7097
7663
  function imageSize({ width, height }) {
7098
- if (!width || !height) return { width: 160, height: 160 };
7664
+ if (!width || !height) return { width: 180, height: 180 };
7099
7665
  const scale = IMAGE_SIDE / Math.max(width, height);
7100
- return { width: Math.max(80, Math.round(width * scale)), height: Math.max(80, Math.round(height * scale)) };
7666
+ return { width: Math.max(96, Math.round(width * scale)), height: Math.max(96, Math.round(height * scale)) };
7101
7667
  }
7102
- var styles8 = import_react_native12.StyleSheet.create({
7103
- files: { gap: 6 },
7104
- image: { overflow: "hidden", borderRadius: 12, borderWidth: import_react_native12.StyleSheet.hairlineWidth },
7668
+ var styles9 = import_react_native15.StyleSheet.create({
7669
+ files: { gap: 4 },
7670
+ image: { overflow: "hidden", borderRadius: RADII.group, borderWidth: 1 },
7671
+ pressed: { opacity: 0.8 },
7105
7672
  file: {
7106
7673
  flexDirection: "row",
7107
7674
  alignItems: "center",
7108
7675
  gap: 10,
7109
- width: 208,
7110
- padding: 8,
7111
- borderRadius: 12,
7112
- borderWidth: import_react_native12.StyleSheet.hairlineWidth
7676
+ width: 232,
7677
+ padding: 10,
7678
+ borderRadius: RADII.group,
7679
+ borderWidth: 1
7113
7680
  },
7114
- fileName: { flex: 1, fontSize: 14 }
7681
+ fileIcon: { width: 32, height: 32, borderRadius: 16, alignItems: "center", justifyContent: "center" },
7682
+ fileName: { flex: 1, fontSize: 14, fontWeight: "500" }
7683
+ });
7684
+
7685
+ // src/components/MessageMeta.tsx
7686
+ var import_react_native16 = require("react-native");
7687
+ var import_jsx_runtime12 = require("react/jsx-runtime");
7688
+ function MessageMeta({ row, onRetry }) {
7689
+ const { t, locale, colors } = useChatContext();
7690
+ const { message, receipt } = row;
7691
+ if (message.status === "failed") {
7692
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native16.View, { style: [styles10.meta, styles10.own], accessibilityLiveRegion: "polite", children: [
7693
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.danger }], children: message.error === "rate_limited" ? t.rate_limited : t.not_sent }),
7694
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Pressable, { onPress: onRetry, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, styles10.retry, { color: colors.danger }], children: t.retry }) })
7695
+ ] });
7696
+ }
7697
+ if (receipt === "sending") {
7698
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.View, { style: [styles10.meta, styles10.own], children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: t.sending }) });
7699
+ }
7700
+ const time = messageTime(message.createdAt, locale);
7701
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
7702
+ import_react_native16.View,
7703
+ {
7704
+ style: [styles10.meta, receipt ? styles10.own : styles10.team],
7705
+ accessible: true,
7706
+ accessibilityLabel: receipt ? `${time}, ${receipt === "seen" ? t.seen : t.sent}` : time,
7707
+ children: [
7708
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: time }),
7709
+ receipt && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7710
+ Icon,
7711
+ {
7712
+ name: receipt === "seen" ? "seen" : "check",
7713
+ color: receipt === "seen" ? colors.primaryText : colors.muted,
7714
+ size: 14
7715
+ }
7716
+ )
7717
+ ]
7718
+ }
7719
+ );
7720
+ }
7721
+ var styles10 = import_react_native16.StyleSheet.create({
7722
+ meta: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 4, marginTop: 4, paddingHorizontal: 4 },
7723
+ own: { alignSelf: "flex-end", justifyContent: "flex-end" },
7724
+ team: { alignSelf: "flex-start" },
7725
+ text: { fontSize: 12 },
7726
+ retry: { fontWeight: "600", textDecorationLine: "underline" }
7115
7727
  });
7116
7728
 
7117
7729
  // src/components/TeamAvatar.tsx
7118
- var import_react_native13 = require("react-native");
7119
- var import_jsx_runtime10 = require("react/jsx-runtime");
7730
+ var import_react_native17 = require("react-native");
7731
+ var import_jsx_runtime13 = require("react/jsx-runtime");
7120
7732
  function TeamAvatar({ app, sender }) {
7121
7733
  const { colors } = useChatContext();
7122
7734
  const image = sender ? sender.image : app.logoUrl;
7123
- if (image) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native13.Image, { source: { uri: image }, style: styles9.avatar, accessibilityIgnoresInvertColors: true });
7124
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
7125
- import_react_native13.View,
7735
+ if (image) {
7736
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Image, { source: { uri: image }, style: [styles11.avatar, { borderColor: colors.border }], accessibilityIgnoresInvertColors: true });
7737
+ }
7738
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
7739
+ import_react_native17.View,
7126
7740
  {
7127
- style: [styles9.avatar, { backgroundColor: sender ? colors.primaryTint : colors.primary }],
7741
+ style: [styles11.avatar, { backgroundColor: sender ? colors.primaryTint : colors.primary }],
7128
7742
  accessibilityElementsHidden: true,
7129
7743
  importantForAccessibility: "no-hide-descendants",
7130
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native13.Text, { style: [styles9.initials, { color: sender ? colors.primaryText : colors.primaryForeground }], children: initialsOf(sender?.name ?? app.name) })
7744
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Text, { style: [styles11.initials, { color: sender ? colors.primaryText : colors.primaryForeground }], children: initialsOf(sender?.name ?? app.name) })
7131
7745
  }
7132
7746
  );
7133
7747
  }
7134
- var styles9 = import_react_native13.StyleSheet.create({
7135
- avatar: { width: 26, height: 26, borderRadius: 13, alignItems: "center", justifyContent: "center" },
7136
- initials: { fontSize: 10, fontWeight: "600" }
7748
+ var styles11 = import_react_native17.StyleSheet.create({
7749
+ avatar: {
7750
+ width: 28,
7751
+ height: 28,
7752
+ borderRadius: 14,
7753
+ borderWidth: 1,
7754
+ borderColor: "transparent",
7755
+ alignItems: "center",
7756
+ justifyContent: "center",
7757
+ overflow: "hidden"
7758
+ },
7759
+ initials: { fontSize: 11, fontWeight: "700" }
7137
7760
  });
7138
7761
 
7139
7762
  // src/components/MessageBubble.tsx
7140
- var import_jsx_runtime11 = require("react/jsx-runtime");
7141
- function MessageBubble({ message, app, showName, status, onRetry }) {
7142
- const { t, colors } = useChatContext();
7143
- if (message.from === "contact") {
7144
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native14.View, { style: styles10.own, children: [
7145
- message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
7146
- import_react_native14.Text,
7763
+ var import_jsx_runtime14 = require("react/jsx-runtime");
7764
+ function MessageBubble({ row, app, onRetry }) {
7765
+ const { t, locale, colors, openedAt } = useChatContext();
7766
+ const { message, startsRun, endsRun, startsDay } = row;
7767
+ const own = message.from === "contact";
7768
+ const rise = useRiseIn(message.createdAt > openedAt && (!own || message.status === "sending"));
7769
+ const corner = startsRun ? RADII.group : RADII.inner;
7770
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.Animated.View, { style: [styles12.row, { paddingTop: startsRun ? 14 : 3 }, rise], children: [
7771
+ startsDay && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.day, { backgroundColor: colors.surface, color: colors.muted }], accessibilityRole: "header", children: dayLabel(message.createdAt, openedAt, locale, t) }),
7772
+ own ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.own, children: [
7773
+ message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7774
+ import_react_native18.Text,
7147
7775
  {
7148
7776
  selectable: true,
7149
7777
  style: [
7150
- styles10.bubble,
7151
- styles10.ownBubble,
7152
- { backgroundColor: colors.primary, color: colors.primaryForeground },
7153
- message.status === "sending" && styles10.sending
7778
+ styles12.bubble,
7779
+ { borderTopRightRadius: corner, borderBottomRightRadius: RADII.inner },
7780
+ { backgroundColor: colors.primary, color: colors.primaryForeground }
7154
7781
  ],
7155
7782
  children: message.body
7156
7783
  }
7157
7784
  ),
7158
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MessageFiles, { attachments: message.attachments, own: true, stored: message.status === "sent" }),
7159
- message.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native14.View, { style: styles10.failed, children: [
7160
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Text, { style: [styles10.meta, { color: colors.danger }], children: message.error === "rate_limited" ? t.rate_limited : t.not_sent }),
7161
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Pressable, { onPress: onRetry, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Text, { style: [styles10.meta, styles10.retry, { color: colors.danger }], children: t.retry }) })
7162
- ] }) : status && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Text, { style: [styles10.meta, { color: colors.muted }], children: status })
7163
- ] });
7164
- }
7165
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native14.View, { style: styles10.team, children: [
7166
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TeamAvatar, { app, sender: message.sender }),
7167
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native14.View, { style: styles10.teamColumn, children: [
7168
- showName && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Text, { style: [styles10.meta, styles10.name, { color: colors.muted }], children: message.sender?.name ?? app.name }),
7169
- message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native14.Text, { selectable: true, style: [styles10.bubble, styles10.teamBubble, { backgroundColor: colors.surface, color: colors.text }], children: message.body }),
7170
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MessageFiles, { attachments: message.attachments, own: false, stored: true })
7785
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: true, stored: message.status === "sent" }),
7786
+ endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry })
7787
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.team, children: [
7788
+ startsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.name, { color: colors.muted }], numberOfLines: 1, children: message.sender?.name ?? app.name }),
7789
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamRow, children: [
7790
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.avatar, children: endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TeamAvatar, { app, sender: message.sender }) }),
7791
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamColumn, children: [
7792
+ message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7793
+ import_react_native18.Text,
7794
+ {
7795
+ selectable: true,
7796
+ style: [
7797
+ styles12.bubble,
7798
+ { borderTopLeftRadius: corner, borderBottomLeftRadius: RADII.inner },
7799
+ { backgroundColor: colors.surface, color: colors.text }
7800
+ ],
7801
+ children: message.body
7802
+ }
7803
+ ),
7804
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: false, stored: true })
7805
+ ] })
7806
+ ] }),
7807
+ endsRun && !row.welcome && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.teamMeta, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry }) })
7171
7808
  ] })
7172
7809
  ] });
7173
7810
  }
7174
- var styles10 = import_react_native14.StyleSheet.create({
7811
+ var AVATAR = 28;
7812
+ var styles12 = import_react_native18.StyleSheet.create({
7813
+ row: { paddingHorizontal: 12 },
7814
+ day: {
7815
+ alignSelf: "center",
7816
+ marginBottom: 14,
7817
+ paddingHorizontal: 12,
7818
+ paddingVertical: 4,
7819
+ borderRadius: RADII.pill,
7820
+ overflow: "hidden",
7821
+ fontSize: 12,
7822
+ fontWeight: "700",
7823
+ letterSpacing: 1,
7824
+ textTransform: "uppercase"
7825
+ },
7175
7826
  own: { alignSelf: "flex-end", alignItems: "flex-end", maxWidth: "80%", gap: 4 },
7176
- team: { flexDirection: "row", alignItems: "flex-start", gap: 8, maxWidth: "88%" },
7177
- teamColumn: { flexShrink: 1, gap: 4 },
7178
- bubble: { borderRadius: 12, paddingHorizontal: 12, paddingVertical: 8, fontSize: 14, lineHeight: 22, overflow: "hidden" },
7179
- ownBubble: { borderTopRightRadius: 3 },
7180
- teamBubble: { borderTopLeftRadius: 3 },
7181
- sending: { opacity: 0.7 },
7182
- meta: { fontSize: 12 },
7183
- name: { fontWeight: "500" },
7184
- failed: { flexDirection: "row", flexWrap: "wrap", justifyContent: "flex-end", gap: 4 },
7185
- retry: { fontWeight: "500", textDecorationLine: "underline" }
7827
+ team: { alignSelf: "flex-start", maxWidth: "85%" },
7828
+ name: { marginBottom: 4, marginLeft: AVATAR + 12, fontSize: 12, fontWeight: "600" },
7829
+ teamRow: { flexDirection: "row", alignItems: "flex-end", gap: 8 },
7830
+ avatar: { width: AVATAR },
7831
+ teamColumn: { flexShrink: 1, alignItems: "flex-start", gap: 4 },
7832
+ teamMeta: { marginLeft: AVATAR + 8 },
7833
+ bubble: {
7834
+ borderRadius: RADII.group,
7835
+ paddingHorizontal: 14,
7836
+ paddingVertical: 10,
7837
+ fontSize: 16,
7838
+ lineHeight: 22,
7839
+ overflow: "hidden"
7840
+ }
7186
7841
  });
7187
7842
 
7188
7843
  // src/components/TypingBubble.tsx
7189
- var import_react10 = require("react");
7190
- var import_react_native15 = require("react-native");
7191
- var import_jsx_runtime12 = require("react/jsx-runtime");
7844
+ var import_react13 = require("react");
7845
+ var import_react_native19 = require("react-native");
7846
+ var import_jsx_runtime15 = require("react/jsx-runtime");
7192
7847
  function TypingBubble({ app, sender }) {
7193
7848
  const { t, colors } = useChatContext();
7194
- const dots = (0, import_react10.useRef)([0, 1, 2].map(() => new import_react_native15.Animated.Value(0.3))).current;
7195
- (0, import_react10.useEffect)(() => {
7196
- const pulse = import_react_native15.Animated.loop(
7197
- import_react_native15.Animated.stagger(
7849
+ const rise = useRiseIn(true);
7850
+ const dots = (0, import_react13.useRef)([0, 1, 2].map(() => new import_react_native19.Animated.Value(0))).current;
7851
+ (0, import_react13.useEffect)(() => {
7852
+ const bounce = import_react_native19.Animated.loop(
7853
+ import_react_native19.Animated.stagger(
7198
7854
  150,
7199
7855
  dots.map(
7200
- (dot) => import_react_native15.Animated.sequence([
7201
- import_react_native15.Animated.timing(dot, { toValue: 1, duration: 300, useNativeDriver: true }),
7202
- import_react_native15.Animated.timing(dot, { toValue: 0.3, duration: 300, useNativeDriver: true }),
7203
- import_react_native15.Animated.delay(300)
7856
+ (dot) => import_react_native19.Animated.sequence([
7857
+ import_react_native19.Animated.timing(dot, { toValue: 1, duration: 300, useNativeDriver: true }),
7858
+ import_react_native19.Animated.timing(dot, { toValue: 0, duration: 300, useNativeDriver: true }),
7859
+ import_react_native19.Animated.delay(300)
7204
7860
  ])
7205
7861
  )
7206
7862
  )
7207
7863
  );
7208
- pulse.start();
7209
- return () => pulse.stop();
7864
+ bounce.start();
7865
+ return () => bounce.stop();
7210
7866
  }, [dots]);
7211
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native15.View, { style: styles11.row, accessible: true, accessibilityLabel: format(t.typing, { name: sender?.name ?? t.team }), children: [
7212
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TeamAvatar, { app, sender }),
7213
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native15.View, { style: [styles11.bubble, { backgroundColor: colors.surface }], children: dots.map((opacity, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native15.Animated.View, { style: [styles11.dot, { backgroundColor: colors.muted, opacity }] }, index)) })
7867
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native19.Animated.View, { style: [styles13.row, rise], accessible: true, accessibilityLabel: format(t.typing, { name: sender?.name ?? t.team }), children: [
7868
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TeamAvatar, { app, sender }),
7869
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native19.View, { style: [styles13.bubble, { backgroundColor: colors.surface }], children: dots.map((dot, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7870
+ import_react_native19.Animated.View,
7871
+ {
7872
+ style: [
7873
+ styles13.dot,
7874
+ {
7875
+ backgroundColor: colors.muted,
7876
+ opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
7877
+ transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -3] }) }]
7878
+ }
7879
+ ]
7880
+ },
7881
+ index
7882
+ )) })
7214
7883
  ] });
7215
7884
  }
7216
- var styles11 = import_react_native15.StyleSheet.create({
7217
- row: { flexDirection: "row", alignItems: "center", gap: 8 },
7885
+ var styles13 = import_react_native19.StyleSheet.create({
7886
+ row: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 14 },
7218
7887
  bubble: {
7219
7888
  flexDirection: "row",
7220
7889
  alignItems: "center",
7221
- gap: 4,
7222
- height: 32,
7223
- paddingHorizontal: 12,
7224
- borderRadius: 12,
7225
- borderTopLeftRadius: 3
7890
+ gap: 5,
7891
+ height: 42,
7892
+ paddingHorizontal: 16,
7893
+ borderRadius: RADII.group,
7894
+ borderBottomLeftRadius: RADII.inner
7226
7895
  },
7227
- dot: { width: 6, height: 6, borderRadius: 3 }
7896
+ dot: { width: 7, height: 7, borderRadius: 3.5 }
7228
7897
  });
7229
7898
 
7230
7899
  // src/components/MessageList.tsx
7231
- var import_jsx_runtime13 = require("react/jsx-runtime");
7900
+ var import_jsx_runtime16 = require("react/jsx-runtime");
7232
7901
  function MessageList({ state }) {
7233
- const { chat: chat2, t, colors } = useChatContext();
7902
+ const { chat: chat2, t, colors, openedAt } = useChatContext();
7903
+ const listRef = (0, import_react14.useRef)(null);
7904
+ const [scrolledUp, setScrolledUp] = (0, import_react14.useState)(false);
7234
7905
  const app = state.app;
7235
- const { messages } = state;
7236
- const newestFirst = (0, import_react11.useMemo)(() => [...messages].reverse(), [messages]);
7237
- const lastContactIndex = messages.findLastIndex((message) => message.from === "contact");
7238
- const latest = lastContactIndex >= 0 ? messages[lastContactIndex] : void 0;
7239
- const status = latest?.status === "sending" ? t.sending : latest?.status === "sent" ? state.seen ? t.seen : t.sent : null;
7240
- const askEmail = state.status === "ready" && !state.online && state.known && !state.email;
7241
- const welcome = {
7242
- id: "welcome",
7243
- from: "team",
7244
- sender: null,
7245
- body: state.texts.welcome,
7246
- attachments: [],
7247
- createdAt: 0,
7248
- status: "sent",
7249
- error: null
7250
- };
7251
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
7252
- import_react_native16.FlatList,
7253
- {
7254
- inverted: true,
7255
- data: newestFirst,
7256
- keyExtractor: (message) => message.id,
7257
- extraData: status,
7258
- renderItem: ({ item, index }) => {
7259
- const position = messages.length - 1 - index;
7260
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
7261
- MessageBubble,
7262
- {
7263
- message: item,
7264
- app,
7265
- showName: item.from === "team" && (position === 0 || messages[position - 1].from !== "team"),
7266
- status: position === lastContactIndex ? status : null,
7267
- onRetry: () => chat2.retry(item.id)
7268
- }
7269
- );
7270
- },
7271
- ItemSeparatorComponent: Gap,
7272
- ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.below, children: [
7273
- state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
7274
- askEmail && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
7275
- state.email && !state.online && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native16.Text, { style: [styles12.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
7276
- ] }),
7277
- ListFooterComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.above, children: [
7278
- state.hasOlder && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
7279
- import_react_native16.Pressable,
7906
+ const { messages, seen, atStart } = state;
7907
+ const welcomeText = state.texts.welcome;
7908
+ const rows = (0, import_react14.useMemo)(() => {
7909
+ const welcome = atStart ? {
7910
+ id: "welcome",
7911
+ from: "team",
7912
+ sender: null,
7913
+ body: welcomeText,
7914
+ attachments: [],
7915
+ createdAt: messages[0]?.createdAt ?? openedAt,
7916
+ status: "sent",
7917
+ error: null
7918
+ } : null;
7919
+ return conversationRows(messages, seen, welcome).reverse();
7920
+ }, [messages, seen, atStart, welcomeText, openedAt]);
7921
+ const newest = rows.at(0)?.message;
7922
+ const sending = newest?.from === "contact" && newest.status === "sending" ? newest.id : null;
7923
+ (0, import_react14.useEffect)(() => {
7924
+ if (sending) listRef.current?.scrollToOffset({ offset: 0, animated: true });
7925
+ }, [sending]);
7926
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.list, children: [
7927
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
7928
+ import_react_native20.FlatList,
7929
+ {
7930
+ ref: listRef,
7931
+ testID: "zean-conversation",
7932
+ inverted: true,
7933
+ data: rows,
7934
+ keyExtractor: (row) => row.message.id,
7935
+ renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MessageBubble, { row: item, app, onRetry: () => chat2.retry(item.message.id) }),
7936
+ ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.below, children: [
7937
+ state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
7938
+ state.askEmail && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
7939
+ state.email && (!state.online || state.emailGiven) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
7940
+ ] }),
7941
+ ListFooterComponent: state.hasOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.View, { style: styles14.above, children: state.loadingOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Skeleton, { style: [styles14.bone, styles14.olderBone] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
7942
+ import_react_native20.Pressable,
7280
7943
  {
7281
7944
  onPress: chat2.loadOlder,
7282
- disabled: state.loadingOlder,
7283
7945
  accessibilityRole: "button",
7284
- style: [styles12.earlier, state.loadingOlder && styles12.loading],
7285
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native16.Text, { style: [styles12.earlierText, { color: colors.muted }], children: t.earlier })
7946
+ style: ({ pressed }) => [styles14.earlier, { backgroundColor: colors.surface }, pressed && styles14.pressed],
7947
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.earlierText, { color: colors.muted }], children: t.earlier })
7286
7948
  }
7287
- ),
7288
- state.atStart && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MessageBubble, { message: welcome, app, showName: true, status: null, onRetry: () => {
7289
- } })
7290
- ] }),
7291
- contentContainerStyle: styles12.content,
7292
- keyboardShouldPersistTaps: "handled",
7293
- keyboardDismissMode: "interactive",
7294
- style: styles12.list
7295
- }
7296
- );
7297
- }
7298
- function Gap() {
7299
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native16.View, { style: styles12.gap });
7949
+ ) }) : void 0,
7950
+ onScroll: (event) => setScrolledUp(event.nativeEvent.contentOffset.y > NEWEST_BUTTON_OFFSET),
7951
+ scrollEventThrottle: 64,
7952
+ maintainVisibleContentPosition: scrolledUp ? { minIndexForVisible: 0 } : void 0,
7953
+ contentContainerStyle: styles14.content,
7954
+ keyboardShouldPersistTaps: "handled",
7955
+ keyboardDismissMode: "on-drag",
7956
+ style: styles14.list
7957
+ }
7958
+ ),
7959
+ scrolledUp && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
7960
+ import_react_native20.Pressable,
7961
+ {
7962
+ onPress: () => listRef.current?.scrollToOffset({ offset: 0, animated: true }),
7963
+ accessibilityRole: "button",
7964
+ accessibilityLabel: t.newest,
7965
+ style: ({ pressed }) => [
7966
+ styles14.newest,
7967
+ { backgroundColor: colors.surface, borderColor: colors.border },
7968
+ pressed && styles14.pressed
7969
+ ],
7970
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "down", color: colors.text, size: 20 })
7971
+ }
7972
+ )
7973
+ ] });
7300
7974
  }
7301
- var styles12 = import_react_native16.StyleSheet.create({
7975
+ var styles14 = import_react_native20.StyleSheet.create({
7302
7976
  list: { flex: 1 },
7303
7977
  // Inverted, `flex-end` is the top: a short Conversation starts under the header, as in the web widget.
7304
- content: { flexGrow: 1, justifyContent: "flex-end", padding: 14 },
7305
- gap: { height: 10 },
7306
- below: { gap: 10, paddingTop: 10 },
7307
- above: { gap: 10, paddingBottom: 10 },
7308
- saved: { fontSize: 12, textAlign: "center" },
7309
- earlier: { alignSelf: "center", paddingHorizontal: 12, paddingVertical: 4, borderRadius: 999 },
7310
- loading: { opacity: 0.6 },
7311
- earlierText: { fontSize: 12, fontWeight: "500" }
7978
+ content: { flexGrow: 1, justifyContent: "flex-end", paddingBottom: 12, paddingTop: 4 },
7979
+ below: { gap: 10 },
7980
+ above: { alignItems: "center", paddingTop: 8 },
7981
+ saved: { paddingTop: 10, paddingHorizontal: 16, fontSize: 12, textAlign: "center" },
7982
+ earlier: { paddingHorizontal: 14, paddingVertical: 6, borderRadius: RADII.pill },
7983
+ earlierText: { fontSize: 12, fontWeight: "600" },
7984
+ pressed: { opacity: 0.6 },
7985
+ bone: { height: 44, borderRadius: RADII.group },
7986
+ olderBone: { width: "50%", alignSelf: "flex-start", marginHorizontal: 12 },
7987
+ newest: {
7988
+ position: "absolute",
7989
+ right: 16,
7990
+ bottom: 12,
7991
+ width: COMPOSER_BUTTON,
7992
+ height: COMPOSER_BUTTON,
7993
+ borderRadius: COMPOSER_BUTTON / 2,
7994
+ borderWidth: import_react_native20.StyleSheet.hairlineWidth,
7995
+ alignItems: "center",
7996
+ justifyContent: "center",
7997
+ shadowColor: "#000000",
7998
+ shadowOpacity: 0.12,
7999
+ shadowRadius: 8,
8000
+ shadowOffset: { width: 0, height: 2 },
8001
+ elevation: 3
8002
+ }
7312
8003
  });
7313
8004
 
7314
8005
  // src/components/PoweredBy.tsx
7315
- var import_react_native17 = require("react-native");
7316
- var import_jsx_runtime14 = require("react/jsx-runtime");
8006
+ var import_react_native21 = require("react-native");
8007
+ var import_jsx_runtime17 = require("react/jsx-runtime");
7317
8008
  function PoweredBy() {
7318
8009
  const { t, colors } = useChatContext();
7319
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native17.View, { style: styles13.row, accessible: true, accessibilityLabel: `${t.powered_by} ${APP_NAME}`, children: [
7320
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native17.Text, { style: [styles13.text, { color: colors.muted }], children: t.powered_by }),
7321
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "mark", color: ZEAN_ACCENT_HEX, size: 14 }),
7322
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native17.Text, { style: [styles13.text, styles13.name, { color: colors.muted }], children: APP_NAME })
7323
- ] });
8010
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
8011
+ import_react_native21.Pressable,
8012
+ {
8013
+ style: ({ pressed }) => [styles15.row, pressed && styles15.pressed],
8014
+ accessibilityRole: "link",
8015
+ accessibilityLabel: `${t.powered_by} ${APP_NAME}`,
8016
+ onPress: () => void import_react_native21.Linking.openURL(APP_URL),
8017
+ children: [
8018
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, { color: colors.muted }], children: t.powered_by }),
8019
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon, { name: "mark", color: ZEAN_ACCENT_HEX, size: 14 }),
8020
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, styles15.name, { color: colors.muted }], children: APP_NAME })
8021
+ ]
8022
+ }
8023
+ );
7324
8024
  }
7325
- var styles13 = import_react_native17.StyleSheet.create({
7326
- row: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4 },
8025
+ var styles15 = import_react_native21.StyleSheet.create({
8026
+ row: { flexDirection: "row", alignItems: "center", justifyContent: "center", alignSelf: "center", gap: 4 },
8027
+ pressed: { opacity: 0.6 },
7327
8028
  text: { fontSize: 12 },
7328
8029
  name: { fontWeight: "600" }
7329
8030
  });
7330
8031
 
7331
8032
  // src/components/ChatScreen.tsx
7332
- var import_jsx_runtime15 = require("react/jsx-runtime");
8033
+ var import_jsx_runtime18 = require("react/jsx-runtime");
7333
8034
  function ChatScreen({ state, insets, onClose }) {
7334
8035
  const { t, colors } = useChatContext();
7335
- const rootRef = (0, import_react12.useRef)(null);
8036
+ const rootRef = (0, import_react15.useRef)(null);
7336
8037
  const keyboard = useKeyboardOverlap(rootRef);
7337
8038
  const connectionLost = useConnectionLost(state.connected);
7338
- const [codeDismissed, setCodeDismissed] = (0, import_react12.useState)(false);
8039
+ const [codeDismissed, setCodeDismissed] = (0, import_react15.useState)(false);
7339
8040
  const app = state.app;
7340
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native18.View, { ref: rootRef, style: [styles14.screen, { backgroundColor: colors.background, paddingBottom: keyboard }], children: [
7341
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7342
- ChatHeader,
7343
- {
7344
- app,
7345
- online: state.online,
7346
- greeting: state.messages.length === 0 ? state.texts.header : null,
7347
- topInset: insets.top,
7348
- onClose
7349
- }
7350
- ),
7351
- connectionLost && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native18.View, { style: styles14.notice, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.reconnecting }) }),
7352
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MessageList, { state }),
7353
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native18.View, { style: [styles14.footer, { borderTopColor: colors.border, paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
7354
- state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
7355
- state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Composer, {}),
7356
- app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PoweredBy, {})
8041
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { ref: rootRef, style: [styles16.screen, { backgroundColor: colors.background, paddingBottom: keyboard }], children: [
8042
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatHeader, { app, online: state.online, topInset: insets.top, onClose }),
8043
+ connectionLost && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native22.View, { style: styles16.notice, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.reconnecting }) }),
8044
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessageList, { state }),
8045
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { style: [styles16.footer, { paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
8046
+ state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
8047
+ state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Composer, {}),
8048
+ app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PoweredBy, {})
7357
8049
  ] })
7358
8050
  ] });
7359
8051
  }
7360
- var styles14 = import_react_native18.StyleSheet.create({
8052
+ var styles16 = import_react_native22.StyleSheet.create({
7361
8053
  screen: { flex: 1 },
7362
- notice: { paddingHorizontal: 14, paddingTop: 12 },
7363
- footer: { gap: 8, paddingHorizontal: 12, paddingTop: 10, borderTopWidth: import_react_native18.StyleSheet.hairlineWidth }
8054
+ notice: { paddingHorizontal: 12, paddingTop: 12 },
8055
+ footer: { gap: 8, paddingHorizontal: 10, paddingTop: 6 }
7364
8056
  });
7365
8057
 
7366
8058
  // src/components/ChatModal.tsx
7367
- var import_jsx_runtime16 = require("react/jsx-runtime");
8059
+ var import_jsx_runtime19 = require("react/jsx-runtime");
7368
8060
  var STRINGS = { fr, en };
7369
- function ChatModal({ chat: chat2, colorScheme }) {
7370
- const state = (0, import_react13.useSyncExternalStore)(chat2.subscribe, chat2.getState);
7371
- const { open: open2 } = (0, import_react13.useSyncExternalStore)(subscribeChatView, chatView);
7372
- const deviceScheme = (0, import_react_native19.useColorScheme)();
8061
+ function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
8062
+ const state = (0, import_react16.useSyncExternalStore)(chat2.subscribe, chat2.getState);
8063
+ const { open: open2 } = (0, import_react16.useSyncExternalStore)(subscribeChatView, chatView);
8064
+ const deviceScheme = (0, import_react_native23.useColorScheme)();
7373
8065
  const scheme = colorScheme ?? (deviceScheme === "dark" ? "dark" : "light");
7374
8066
  const active = useAppActive();
7375
- const dimensions = (0, import_react_native19.useWindowDimensions)();
7376
- const [image, setImage] = (0, import_react13.useState)(null);
8067
+ const dimensions = (0, import_react_native23.useWindowDimensions)();
8068
+ const [gallery, setGallery] = (0, import_react16.useState)(null);
8069
+ const [openedAt, setOpenedAt] = (0, import_react16.useState)(Date.now);
7377
8070
  const app = state.app;
7378
8071
  const visible = open2 && app !== null && state.status !== "loading" && state.status !== "hidden";
7379
8072
  const color = app?.color ?? ZEAN_ACCENT_HEX;
7380
- const context = (0, import_react13.useMemo)(
7381
- () => ({ chat: chat2, t: STRINGS[state.locale], colors: chatColors(color, scheme), openImage: setImage }),
7382
- [chat2, state.locale, color, scheme]
8073
+ const context = (0, import_react16.useMemo)(
8074
+ () => ({
8075
+ chat: chat2,
8076
+ t: STRINGS[state.locale],
8077
+ locale: state.locale,
8078
+ colors: chatColors(color, scheme),
8079
+ openedAt,
8080
+ openImages: setGallery,
8081
+ maxPhotos: photoLimit(maxPhotos)
8082
+ }),
8083
+ [chat2, state.locale, color, scheme, openedAt, maxPhotos]
7383
8084
  );
7384
- const insets = (0, import_react13.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
7385
- (0, import_react13.useEffect)(() => {
8085
+ const insets = (0, import_react16.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
8086
+ (0, import_react16.useEffect)(() => chat2.setOpen(open2 && active), [chat2, open2, active]);
8087
+ (0, import_react16.useEffect)(() => {
7386
8088
  if (visible && active && state.unread > 0) chat2.markRead();
7387
8089
  }, [chat2, visible, active, state.unread]);
7388
- (0, import_react13.useEffect)(() => {
7389
- if (!visible) setImage(null);
8090
+ (0, import_react16.useEffect)(() => {
8091
+ if (visible) setOpenedAt(Date.now());
8092
+ else setGallery(null);
7390
8093
  }, [visible]);
7391
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
7392
- import_react_native19.Modal,
8094
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8095
+ import_react_native23.Modal,
7393
8096
  {
8097
+ testID: "zean-chat",
7394
8098
  visible,
7395
8099
  animationType: "slide",
7396
- presentationStyle: import_react_native19.Platform.OS === "ios" && !import_react_native19.Platform.isPad ? "pageSheet" : "fullScreen",
8100
+ presentationStyle: import_react_native23.Platform.OS === "ios" && !import_react_native23.Platform.isPad ? "pageSheet" : "fullScreen",
7397
8101
  statusBarTranslucent: true,
7398
8102
  navigationBarTranslucent: true,
7399
- onRequestClose: () => import_react_native19.Platform.OS === "android" && image ? setImage(null) : zean.close(),
7400
- children: app && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ChatContext, { value: context, children: [
7401
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChatScreen, { state, insets, onClose: zean.close }),
7402
- image && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ImageViewer, { image, onClose: () => setImage(null) })
8103
+ onRequestClose: () => import_react_native23.Platform.OS === "android" && gallery ? setGallery(null) : zean.close(),
8104
+ children: app && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ChatContext, { value: context, children: [
8105
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatScreen, { state, insets, onClose: zean.close }),
8106
+ gallery && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ImageViewer, { gallery, topInset: insets.top, onClose: () => setGallery(null) })
7403
8107
  ] })
7404
8108
  }
7405
8109
  );
7406
8110
  }
7407
8111
 
7408
8112
  // src/components/ZeanChat.tsx
7409
- var import_jsx_runtime17 = require("react/jsx-runtime");
8113
+ var import_jsx_runtime20 = require("react/jsx-runtime");
7410
8114
  function ZeanChat({
7411
8115
  appKey,
7412
8116
  storage,
@@ -7414,22 +8118,27 @@ function ZeanChat({
7414
8118
  attributes: attributes2,
7415
8119
  locale,
7416
8120
  colorScheme,
8121
+ maxPhotos,
7417
8122
  backendUrl = backendUrlFor(appKey)
7418
8123
  }) {
7419
- const [chat2, setChat] = (0, import_react14.useState)(null);
7420
- const storageRef = (0, import_react14.useRef)(storage);
8124
+ const [chat2, setChat] = (0, import_react17.useState)(null);
8125
+ const storageRef = (0, import_react17.useRef)(storage);
7421
8126
  const userKey = user ? JSON.stringify(user) : null;
7422
- const identified = (0, import_react14.useRef)(false);
8127
+ const identified = (0, import_react17.useRef)(false);
7423
8128
  const attributesKey = attributes2 ? JSON.stringify(attributes2) : null;
7424
- (0, import_react14.useEffect)(() => {
8129
+ (0, import_react17.useEffect)(() => {
7425
8130
  const started = createChat({
7426
8131
  appKey,
7427
8132
  backendUrl,
7428
- storage: storageRef.current,
8133
+ storage: chatStorage(storageRef.current),
7429
8134
  // A chosen language goes first: the chat takes the first one it speaks.
7430
8135
  languages: locale ? [locale] : deviceLanguages(),
7431
8136
  deviceLanguage: deviceLanguages()[0],
7432
- os: deviceOs()
8137
+ os: deviceOs(),
8138
+ // Checked against the App's Bundle ID or Package name: another app with the same key shows no chat.
8139
+ bundle: appBundle(),
8140
+ // The Conversation stays on the phone: the next start shows it at once and asks only for newer messages.
8141
+ keep: true
7433
8142
  });
7434
8143
  const detach = attachChat(started);
7435
8144
  setChat(started);
@@ -7438,20 +8147,20 @@ function ZeanChat({
7438
8147
  started.destroy();
7439
8148
  };
7440
8149
  }, [appKey, backendUrl, locale]);
7441
- (0, import_react14.useEffect)(() => {
8150
+ (0, import_react17.useEffect)(() => {
7442
8151
  if (userKey) zean.identify(JSON.parse(userKey));
7443
8152
  else if (identified.current) zean.signOut();
7444
8153
  identified.current = userKey !== null;
7445
8154
  }, [userKey]);
7446
- (0, import_react14.useEffect)(() => {
8155
+ (0, import_react17.useEffect)(() => {
7447
8156
  if (attributesKey) zean.setAttributes(JSON.parse(attributesKey));
7448
8157
  }, [attributesKey]);
7449
- return chat2 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatModal, { chat: chat2, colorScheme }) : null;
8158
+ return chat2 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChatModal, { chat: chat2, colorScheme, maxPhotos }) : null;
7450
8159
  }
7451
8160
 
7452
8161
  // src/hooks/use-zean.ts
7453
- var import_react15 = require("react");
8162
+ var import_react18 = require("react");
7454
8163
  function useZean() {
7455
- const { unread } = (0, import_react15.useSyncExternalStore)(subscribeChatView, chatView);
8164
+ const { unread } = (0, import_react18.useSyncExternalStore)(subscribeChatView, chatView);
7456
8165
  return { ...zean, unreadCount: unread };
7457
8166
  }