@sendbird/ai-agent-messenger-react-native 1.3.0 → 1.3.1

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.d.ts CHANGED
@@ -895,7 +895,7 @@ declare type CSATSubmitParams = {
895
895
  resolutionScore?: number;
896
896
  };
897
897
 
898
- declare interface CustomMessageTemplateData {
898
+ export declare interface CustomMessageTemplateData {
899
899
  id: string;
900
900
  response: {
901
901
  status: number;
@@ -929,7 +929,7 @@ declare type ExpoImagePickerModule = typeof ExpoImagePicker;
929
929
  /**
930
930
  * For better understanding: https://sendbird.atlassian.net/wiki/spaces/AA/pages/3075014695/Extended+Message+Payload+Spec
931
931
  */
932
- declare interface ExtendedMessagePayload {
932
+ export declare interface ExtendedMessagePayload {
933
933
  is_thinking: boolean;
934
934
  cta_button: {
935
935
  label: string;
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ var wr = Object.defineProperty;
2
2
  var xr = (e, t, n) => t in e ? wr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var U = (e, t, n) => xr(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import * as s from "react";
5
- import { createContext as Gt, useContext as Ne, useLayoutEffect as Ce, useState as S, useEffect as M, useRef as F, useCallback as w, useMemo as K, forwardRef as st, useImperativeHandle as Ir, useId as qt, useReducer as Tr, memo as Ue, isValidElement as kr, Fragment as Mr, Children as Lr } from "react";
6
- import { StyleSheet as J, View as we, Animated as R, Image as We, Modal as Pr, I18nManager as Fe, Text as xt, TouchableOpacity as Dr, Pressable as jt, PanResponder as Rr, Easing as pe, FlatList as Or, Linking as ye, useWindowDimensions as Br, ScrollView as Un, KeyboardAvoidingView as Wn, TextInput as Yt, Platform as re, Alert as ke, Keyboard as ot, BackHandler as Nr } from "react-native";
5
+ import { createContext as Gt, useContext as Ne, useLayoutEffect as Ee, useState as S, useEffect as M, useRef as F, useCallback as w, useMemo as K, forwardRef as st, useImperativeHandle as Ir, useId as qt, useReducer as Tr, memo as Ue, isValidElement as kr, Fragment as Mr, Children as Lr } from "react";
6
+ import { StyleSheet as J, View as we, Animated as R, Image as We, Modal as Pr, I18nManager as Fe, Text as xt, TouchableOpacity as Dr, Pressable as jt, PanResponder as Rr, Easing as pe, FlatList as Or, Linking as ye, useWindowDimensions as Br, ScrollView as Un, KeyboardAvoidingView as Wn, TextInput as Yt, Platform as re, Alert as Te, Keyboard as ot, BackHandler as Nr } from "react-native";
7
7
  import { useSafeAreaInsets as at, SafeAreaProvider as Hr, SafeAreaInsetsContext as Vn } from "react-native-safe-area-context";
8
8
  import zr, { SendbirdChatOptions as Fr, SendbirdProduct as $r, DeviceOsPlatform as He, SendbirdPlatform as Gn, SessionHandler as Ur, ConnectionHandler as it, SendbirdError as Wr, LogLevel as Vr } from "@sendbird/chat";
9
9
  import { ConversationStatus as ee, AIAgentModule as Gr, AIAgentMessageFeedbackRating as bn } from "@sendbird/chat/aiAgent";
@@ -55,7 +55,7 @@ function ue(e) {
55
55
  }
56
56
  function r({ template: a, children: i }) {
57
57
  const { updateTemplate: l } = Ne(t);
58
- return Ce(() => {
58
+ return Ee(() => {
59
59
  a && l(a);
60
60
  }, [a]), /* @__PURE__ */ s.createElement(s.Fragment, null, i);
61
61
  }
@@ -67,7 +67,7 @@ function ue(e) {
67
67
  component: l
68
68
  }) {
69
69
  const { updateComponent: c } = Ne(t);
70
- return Ce(() => {
70
+ return Ee(() => {
71
71
  l && c(a, l);
72
72
  }, [l]), null;
73
73
  };
@@ -85,7 +85,7 @@ const xe = (e) => {
85
85
  var t, n;
86
86
  return !!(e != null && e.isAIAgent && ((t = e == null ? void 0 : e.conversation) == null ? void 0 : t.status) === ee.OPEN || e != null && e.isDesk && ((n = e == null ? void 0 : e.helpdeskInfo) == null ? void 0 : n.ticketStatus) === "open");
87
87
  };
88
- function Le(e) {
88
+ function Me(e) {
89
89
  var n, r, o;
90
90
  return typeof (((n = e == null ? void 0 : e.conversation) == null ? void 0 : n.handedOverAt) ?? ((o = (r = e == null ? void 0 : e.conversation) == null ? void 0 : r.handoff) == null ? void 0 : o.timestamp)) == "number";
91
91
  }
@@ -155,7 +155,7 @@ function Co(e, t, n) {
155
155
  const r = /* @__PURE__ */ new Date(), o = new Date(((i = e.lastMessage) == null ? void 0 : i.createdAt) || e.createdAt), a = jr(r, o);
156
156
  return a < 1 ? n.justNow : a < 60 ? n.minutesAgo(a) : Yr(o) ? n.hoursAgo(Kr(r, o)) : t(o, n.dateShortFormat);
157
157
  }
158
- const Te = "sb-agent", Kn = "KEY_IMG_ASPECT_RATIO", Xn = "*/*", k = {
158
+ const Ie = "sb-agent", Kn = "KEY_IMG_ASPECT_RATIO", Xn = "*/*", k = {
159
159
  BODY_MAX_WIDTH: 244,
160
160
  AVATAR_SIZE: 26,
161
161
  BODY_TIME_GAP: 4,
@@ -271,7 +271,7 @@ const Sn = (e) => {
271
271
  var t;
272
272
  return !!((t = e.extendedMessagePayload) != null && t.feedback);
273
273
  }
274
- }, ut = `@${Te}`, An = ({ appId: e, aiAgentId: t, storage: n }) => {
274
+ }, ut = `@${Ie}`, An = ({ appId: e, aiAgentId: t, storage: n }) => {
275
275
  const r = {
276
276
  templateBase: `${ut}-template`,
277
277
  template: (o) => `${r.templateBase}/templates/${o}`,
@@ -372,19 +372,19 @@ class Qn {
372
372
  this.level = t;
373
373
  }
374
374
  verbose(...t) {
375
- this.level <= 0 && console.log(`[${Te}/verbose]`, ...t);
375
+ this.level <= 0 && console.log(`[${Ie}/verbose]`, ...t);
376
376
  }
377
377
  debug(...t) {
378
- this.level <= 1 && console.log(`[${Te}/debug]`, ...t);
378
+ this.level <= 1 && console.log(`[${Ie}/debug]`, ...t);
379
379
  }
380
380
  info(...t) {
381
- this.level <= 2 && console.log(`[${Te}/info]`, ...t);
381
+ this.level <= 2 && console.log(`[${Ie}/info]`, ...t);
382
382
  }
383
383
  warn(...t) {
384
- this.level <= 3 && console.warn(`[${Te}/warn]`, ...t);
384
+ this.level <= 3 && console.warn(`[${Ie}/warn]`, ...t);
385
385
  }
386
386
  error(...t) {
387
- this.level <= 4 && console.error(`[${Te}/error]`, ...t);
387
+ this.level <= 4 && console.error(`[${Ie}/error]`, ...t);
388
388
  }
389
389
  }
390
390
  function wn(e, t, n, r) {
@@ -407,7 +407,7 @@ function Bo(e) {
407
407
  };
408
408
  typeof e.groupChannel != "object" && t("GroupChannelModule"), typeof e.aiAgent != "object" && t("AIAgentModule");
409
409
  }
410
- const ve = {
410
+ const be = {
411
411
  conversation: {
412
412
  isTalkToAgentViewEnabled: !0,
413
413
  scrollMode: "auto",
@@ -432,33 +432,33 @@ const ve = {
432
432
  }, No = (e) => {
433
433
  var t, n, r, o, a, i, l, c, u, m, g, d, p, _;
434
434
  return e ? {
435
- ...ve,
435
+ ...be,
436
436
  ...e,
437
437
  conversation: {
438
- ...ve.conversation,
438
+ ...be.conversation,
439
439
  ...e == null ? void 0 : e.conversation,
440
440
  header: {
441
- ...(t = ve.conversation) == null ? void 0 : t.header,
441
+ ...(t = be.conversation) == null ? void 0 : t.header,
442
442
  ...(n = e == null ? void 0 : e.conversation) == null ? void 0 : n.header
443
443
  },
444
444
  input: {
445
- ...(r = ve.conversation) == null ? void 0 : r.input,
445
+ ...(r = be.conversation) == null ? void 0 : r.input,
446
446
  ...(o = e == null ? void 0 : e.conversation) == null ? void 0 : o.input,
447
447
  camera: {
448
- ...(i = (a = ve.conversation) == null ? void 0 : a.input) == null ? void 0 : i.camera,
448
+ ...(i = (a = be.conversation) == null ? void 0 : a.input) == null ? void 0 : i.camera,
449
449
  ...(c = (l = e == null ? void 0 : e.conversation) == null ? void 0 : l.input) == null ? void 0 : c.camera
450
450
  },
451
451
  gallery: {
452
- ...(m = (u = ve.conversation) == null ? void 0 : u.input) == null ? void 0 : m.gallery,
452
+ ...(m = (u = be.conversation) == null ? void 0 : u.input) == null ? void 0 : m.gallery,
453
453
  ...(d = (g = e == null ? void 0 : e.conversation) == null ? void 0 : g.input) == null ? void 0 : d.gallery
454
454
  }
455
455
  },
456
456
  fileViewer: {
457
- ...(p = ve.conversation) == null ? void 0 : p.fileViewer,
457
+ ...(p = be.conversation) == null ? void 0 : p.fileViewer,
458
458
  ...(_ = e == null ? void 0 : e.conversation) == null ? void 0 : _.fileViewer
459
459
  }
460
460
  }
461
- } : ve;
461
+ } : be;
462
462
  }, {
463
463
  Provider: Ho,
464
464
  useContext: Z
@@ -842,7 +842,7 @@ const Tn = 25 * 1024 * 1024, ts = {
842
842
  });
843
843
  }, []), r = w(
844
844
  (o) => {
845
- const { channel: a, uploadSizeLimit: i = Tn } = o, l = (u = !0) => a != null && a.isAIAgent ? u ? Le(a) : !1 : !0, c = (u) => {
845
+ const { channel: a, uploadSizeLimit: i = Tn } = o, l = (u = !0) => a != null && a.isAIAgent ? u ? Me(a) : !1 : !0, c = (u) => {
846
846
  if (l())
847
847
  return e.defaultUploadSizeLimit ?? i;
848
848
  const m = e.defaultUploadSizeLimit ?? i, g = e.uploadSizeLimitPerType.get(u) ?? m;
@@ -859,7 +859,7 @@ const Tn = 25 * 1024 * 1024, ts = {
859
859
  case "always":
860
860
  return !0;
861
861
  case "handed_off_only":
862
- return Le(a);
862
+ return Me(a);
863
863
  default:
864
864
  return !0;
865
865
  }
@@ -1259,7 +1259,7 @@ const us = (e) => JSON.parse(e), ds = () => {
1259
1259
  aiAgentUserId: (r == null ? void 0 : r.userId) ?? "",
1260
1260
  isStreamAnimating: n
1261
1261
  }), l = Es({
1262
- shouldApply: !!(e != null && e.isAIAgent) && !Le(e),
1262
+ shouldApply: !!(e != null && e.isAIAgent) && !Me(e),
1263
1263
  isDisabledWhileAIResponding: i,
1264
1264
  lastMessage: Cn(t, [tt.PENDING, tt.SUCCEEDED]),
1265
1265
  currentUserId: (o == null ? void 0 : o.userId) ?? ""
@@ -1867,7 +1867,7 @@ const Rs = "remove_powered_by", Zt = (e, t) => {
1867
1867
  return { fallbackIcon: a, url: e == null ? void 0 : e.coverUrl, title: (e == null ? void 0 : e.name) ?? "" };
1868
1868
  }
1869
1869
  };
1870
- return e.isAIAgent ? Le(e) ? o.human("agent") : o.ai("delight") : e.isDesk ? o.human("agent") : o.channel("user");
1870
+ return e.isAIAgent ? Me(e) ? o.human("agent") : o.ai("delight") : e.isDesk ? o.human("agent") : o.channel("user");
1871
1871
  }, Pt = (e) => Tr((t, n) => ({ ...t, ...n }), e);
1872
1872
  var fe = /* @__PURE__ */ ((e) => (e.AI_AGENT_CSAT_5 = "AI_AGENT_CSAT_5", e.AI_AGENT_CSAT_5_WITH_CRE = "AI_AGENT_CSAT_5_WITH_CRE", e.HELPDESK_CSAT_5 = "HELPDESK_CSAT_5", e))(fe || {});
1873
1873
  const Os = /* @__PURE__ */ new Set(["free_text", "single_choice"]), Bs = ({ csatPayload: e, type: t, initialCsat: n, initialCsatReason: r, initialIsResolved: o }) => {
@@ -1929,9 +1929,9 @@ const Os = /* @__PURE__ */ new Set(["free_text", "single_choice"]), Bs = ({ csat
1929
1929
  textLength: t.length,
1930
1930
  enabled: n
1931
1931
  }).current, p = n, _ = i < t.length, v = d.initialEnabled && (p || _);
1932
- return Ce(() => {
1932
+ return Ee(() => {
1933
1933
  m.onStart = r, m.onProgress = o, m.onComplete = a, d.textLength = t.length, d.enabled = n;
1934
- }), Ce(() => {
1934
+ }), Ee(() => {
1935
1935
  var h;
1936
1936
  d.initialEnabled && (g.startCalled || (g.startCalled = !0, (h = m.onStart) == null || h.call(m)), l((y) => t.length < y ? t.length : y));
1937
1937
  }, [t]), M(() => {
@@ -3246,7 +3246,7 @@ const D = {
3246
3246
  top: "paddingTop",
3247
3247
  bottom: "paddingBottom"
3248
3248
  }
3249
- }, De = (e, t = Fe.isRTL ? "rtl" : "ltr") => {
3249
+ }, Pe = (e, t = Fe.isRTL ? "rtl" : "ltr") => {
3250
3250
  const n = at();
3251
3251
  return e.reduce(
3252
3252
  (r, o) => {
@@ -3437,7 +3437,7 @@ const Ya = ({
3437
3437
  const o = ur.use(), { themedColor: a } = V();
3438
3438
  return /* @__PURE__ */ s.createElement(O, { onPress: r, style: o.actionItem, activeOpacity: 0.75 }, e && /* @__PURE__ */ s.createElement(B, { type: e, size: 24, color: a.primary }), /* @__PURE__ */ s.createElement(T, { variant: "body3", color: n ? a.error : a.textHighEmphasis, numberOfLines: 1 }, t));
3439
3439
  }, Ka = ({ onClose: e, children: t }) => {
3440
- const n = ur.use(), { translateY: r, panHandlers: o, wrapWithAnimation: a } = cr(), i = De(["left", "right"]);
3440
+ const n = ur.use(), { translateY: r, panHandlers: o, wrapWithAnimation: a } = cr(), i = Pe(["left", "right"]);
3441
3441
  return /* @__PURE__ */ s.createElement(O, { onPress: a(e), style: n.overlay }, /* @__PURE__ */ s.createElement(f.Animated, { style: [n.container, i, { transform: [{ translateY: r }] }], ...o }, t));
3442
3442
  }, nn = ue({
3443
3443
  template: Ka,
@@ -3578,7 +3578,7 @@ const ur = D.create(({ theme: e, edgeInsets: t }) => ({
3578
3578
  NoChannels: oi,
3579
3579
  NoMessages: si
3580
3580
  }
3581
- }), Me = (e) => {
3581
+ }), ke = (e) => {
3582
3582
  const { Template: t } = on.useContext();
3583
3583
  return /* @__PURE__ */ s.createElement(t, { ...e });
3584
3584
  }, ii = ({ style: e, onPress: t }) => {
@@ -3671,13 +3671,13 @@ const ur = D.create(({ theme: e, edgeInsets: t }) => ({
3671
3671
  type: Kt(e.name, e.type),
3672
3672
  onPress: n ? () => n == null ? void 0 : n(e) : void 0
3673
3673
  }
3674
- ), t), Pe = ({ style: e, ...t }) => /* @__PURE__ */ s.createElement(We, { style: [e, t], ...t }), mi = ({
3674
+ ), t), Le = ({ style: e, ...t }) => /* @__PURE__ */ s.createElement(We, { style: [e, t], ...t }), mi = ({
3675
3675
  file: e,
3676
3676
  onClickMedia: t = ({ url: r }) => ye.openURL(r),
3677
3677
  children: n
3678
3678
  }) => {
3679
3679
  const r = gi.use();
3680
- return /* @__PURE__ */ s.createElement(f, { gap: k.GAP_GROUPED }, /* @__PURE__ */ s.createElement(O, { style: r.mediaContainer, onPress: () => t == null ? void 0 : t(e) }, /* @__PURE__ */ s.createElement(Pe, { source: { uri: e.url }, style: r.media, resizeMode: "cover" })), n);
3680
+ return /* @__PURE__ */ s.createElement(f, { gap: k.GAP_GROUPED }, /* @__PURE__ */ s.createElement(O, { style: r.mediaContainer, onPress: () => t == null ? void 0 : t(e) }, /* @__PURE__ */ s.createElement(Le, { source: { uri: e.url }, style: r.media, resizeMode: "cover" })), n);
3681
3681
  }, gi = D.create(({ select: e, theme: t }) => ({
3682
3682
  mediaContainer: {
3683
3683
  width: k.BODY_MAX_WIDTH,
@@ -3740,7 +3740,7 @@ const ur = D.create(({ theme: e, edgeInsets: t }) => ({
3740
3740
  }
3741
3741
  }), hr = Ue(({ src: e, onPress: t }) => {
3742
3742
  const [n, r] = S("1/1"), [o, a] = S(!1), i = hi.use();
3743
- return Ce(() => {
3743
+ return Ee(() => {
3744
3744
  e && ar(e).then(({ width: l, height: c }) => r(`${l}/${c}`));
3745
3745
  }, [e]), /* @__PURE__ */ s.createElement(jt, { style: { marginTop: 8 }, onPress: t }, /* @__PURE__ */ s.createElement(f, { style: [i.container, { aspectRatio: n }] }, o ? /* @__PURE__ */ s.createElement(B, { size: 28, type: "thumbnail-none", color: (l) => l.textHighEmphasisInverse }) : /* @__PURE__ */ s.createElement(We, { source: { uri: e }, style: J.absoluteFillObject, onError: () => a(!0) })));
3746
3746
  }), hi = D.create(({ themedColor: e }) => ({
@@ -4582,7 +4582,7 @@ const Ui = ({
4582
4582
  return () => r(e);
4583
4583
  })();
4584
4584
  return /* @__PURE__ */ s.createElement(f, { flexDirection: "column", alignItems: "flex-end", gap: k.GAP_GROUPED }, /* @__PURE__ */ s.createElement(O, { onPress: g, style: [a.imageContainer, { aspectRatio: i }], activeOpacity: 0.75 }, !u && /* @__PURE__ */ s.createElement(f, { alignItems: "center", justifyContent: "center" }, /* @__PURE__ */ s.createElement(_r, { size: 26 }, /* @__PURE__ */ s.createElement(B, { type: "spinner", color: (d) => d.textLowEmphasis, size: 26 }))), /* @__PURE__ */ s.createElement(
4585
- Pe,
4585
+ Le,
4586
4586
  {
4587
4587
  source: { uri: c },
4588
4588
  style: [a.image, { opacity: u ? 1 : 0 }],
@@ -4919,7 +4919,7 @@ const Ui = ({
4919
4919
  }) => {
4920
4920
  const [o, a] = S(!1), i = br.use();
4921
4921
  return o ? /* @__PURE__ */ s.createElement(al, { value: e, selected: r, label: n }) : /* @__PURE__ */ s.createElement(
4922
- Pe,
4922
+ Le,
4923
4923
  {
4924
4924
  source: { uri: t },
4925
4925
  style: i.emojiImage(r),
@@ -5007,28 +5007,30 @@ const Ui = ({
5007
5007
  }, ml = (e) => {
5008
5008
  if (e.messageType !== "admin.csat")
5009
5009
  throw new Error("Invalid message type");
5010
- const { extendedMessagePayload: t, onSubmitCSAT: n } = e, { csat: r, csatReason: o, csatExpireAt: a, isResolvedWhenDeterminedByUser: i } = e, [, l] = S(0), c = ul(t == null ? void 0 : t.csat), u = gl.use();
5010
+ const { extendedMessagePayload: t, onSubmitCSAT: n } = e, { csat: r, csatReason: o, csatExpireAt: a, isResolvedWhenDeterminedByUser: i } = e, [, l] = S(0), c = ul(t == null ? void 0 : t.csat), u = F(!1), m = gl.use();
5011
5011
  if (!c || !c.visibility || !fe[c.type]) return null;
5012
- const m = c.type === fe.AI_AGENT_CSAT_5 || c.type === fe.AI_AGENT_CSAT_5_WITH_CRE || c.type === fe.HELPDESK_CSAT_5 ? At : () => null;
5013
- return /* @__PURE__ */ s.createElement(f, { style: u.container }, !r && vn(a) ? /* @__PURE__ */ s.createElement(dl, null) : /* @__PURE__ */ s.createElement(
5014
- m,
5012
+ const g = c.type === fe.AI_AGENT_CSAT_5 || c.type === fe.AI_AGENT_CSAT_5_WITH_CRE || c.type === fe.HELPDESK_CSAT_5 ? At : () => null;
5013
+ return /* @__PURE__ */ s.createElement(f, { style: m.container }, !r && vn(a) ? /* @__PURE__ */ s.createElement(dl, null) : /* @__PURE__ */ s.createElement(
5014
+ g,
5015
5015
  {
5016
5016
  csatPayload: c,
5017
5017
  type: c.type,
5018
5018
  initialCsat: r,
5019
5019
  initialCsatReason: o,
5020
5020
  initialIsResolved: i,
5021
- renderSubmitButton: ({ state: g, params: d, validateParams: p }) => /* @__PURE__ */ s.createElement(
5021
+ renderSubmitButton: ({ state: d, params: p, validateParams: _ }) => /* @__PURE__ */ s.createElement(
5022
5022
  O,
5023
5023
  {
5024
5024
  activeOpacity: 0.75,
5025
- disabled: g === "submitted",
5025
+ disabled: d === "submitted",
5026
5026
  onPress: async () => {
5027
- !vn(a) && p() ? await n(d) : l((_) => _ + 1);
5027
+ u.current || (!vn(a) && _() ? (u.current = !0, await n(p).finally(() => {
5028
+ u.current = !1;
5029
+ })) : l((v) => v + 1));
5028
5030
  },
5029
- style: u.submitButton(g)
5031
+ style: m.submitButton(d)
5030
5032
  },
5031
- /* @__PURE__ */ s.createElement(T, { variant: "button", style: u.submitButtonText(g) }, g === "submitted" ? c.csat_submitted_label : c.csat_submit_label)
5033
+ /* @__PURE__ */ s.createElement(T, { variant: "button", style: m.submitButtonText(d) }, d === "submitted" ? c.csat_submitted_label : c.csat_submit_label)
5032
5034
  )
5033
5035
  }
5034
5036
  ));
@@ -5114,7 +5116,7 @@ const Ui = ({
5114
5116
  channelSource: p,
5115
5117
  scrollSource: _,
5116
5118
  state: { input: v, streamAnimation: h }
5117
- } = me(), y = bl(), E = Cl.use(), b = De(["left", "right"]), { state: C, props: I } = _;
5119
+ } = me(), y = bl(), E = Cl.use(), b = Pe(["left", "right"]), { state: C, props: I } = _;
5118
5120
  M(() => {
5119
5121
  C.isAwayFromBottom || d.resetNewMessages();
5120
5122
  }, [C.isAwayFromBottom]);
@@ -5161,31 +5163,31 @@ const Ui = ({
5161
5163
  ...x,
5162
5164
  messageType: "admin.csat",
5163
5165
  isResolvedWhenDeterminedByUser: yo(x),
5164
- onSubmitCSAT: async ({ csat: be, ...Ie }) => {
5165
- var Ee;
5166
- be && await ((Ee = p.channel) == null ? void 0 : Ee.submitCSAT({ csat: be, ...Ie }));
5166
+ onSubmitCSAT: async (ve) => {
5167
+ var Ce;
5168
+ await ((Ce = p.channel) == null ? void 0 : Ce.submitCSAT(ve));
5167
5169
  }
5168
5170
  }
5169
5171
  ) : null : /* @__PURE__ */ s.createElement(r, { ...qe, messageType: "admin" });
5170
5172
  if (je.isOutgoing(A, (m == null ? void 0 : m.userId) ?? "")) {
5171
- const be = {
5173
+ const ve = {
5172
5174
  ...qe,
5173
5175
  sender: N(A),
5174
5176
  sendingStatus: A.sendingStatus,
5175
5177
  onClickFailedMessage: H(A)
5176
5178
  };
5177
5179
  if (A.isUserMessage())
5178
- return /* @__PURE__ */ s.createElement(n, { ...be, messageType: "user" });
5180
+ return /* @__PURE__ */ s.createElement(n, { ...ve, messageType: "user" });
5179
5181
  if (A.isFileMessage()) {
5180
- const [Ie, Ee] = ((fn = A.metaArrays.find((Y) => Y.key === Kn)) == null ? void 0 : fn.value) ?? [];
5182
+ const [Ce, Re] = ((fn = A.metaArrays.find((Y) => Y.key === Kn)) == null ? void 0 : fn.value) ?? [];
5181
5183
  return /* @__PURE__ */ s.createElement(
5182
5184
  n,
5183
5185
  {
5184
- ...be,
5186
+ ...ve,
5185
5187
  messageType: "file",
5186
5188
  file: A,
5187
5189
  metadata: {
5188
- aspectRatio: Ie && Ee ? `${Ie}/${Ee}` : "1/1",
5190
+ aspectRatio: Ce && Re ? `${Ce}/${Re}` : "1/1",
5189
5191
  localFile: (_n = A.messageParams) == null ? void 0 : _n.file
5190
5192
  }
5191
5193
  }
@@ -5193,13 +5195,13 @@ const Ui = ({
5193
5195
  }
5194
5196
  }
5195
5197
  if (je.isIncoming(A, (m == null ? void 0 : m.userId) ?? "")) {
5196
- const be = A.sender.userId === (u == null ? void 0 : u.userId), Ie = G === 0, Ee = {
5198
+ const ve = A.sender.userId === (u == null ? void 0 : u.userId), Ce = G === 0, Re = {
5197
5199
  ...qe,
5198
- sender: N(A, be),
5199
- suggestedRepliesVisible: Ie,
5200
- isBotMessage: be,
5200
+ sender: N(A, ve),
5201
+ suggestedRepliesVisible: Ce,
5202
+ isBotMessage: ve,
5201
5203
  isStreaming: nt.isStreaming(A),
5202
- isHandedOff: Le(p.channel),
5204
+ isHandedOff: Me(p.channel),
5203
5205
  isConversationClosed: xe(p.channel),
5204
5206
  isFeedbackEnabled: u == null ? void 0 : u.isUserFeedbackEnabled,
5205
5207
  isFeedbackCommentEnabled: u == null ? void 0 : u.isUserFeedbackCommentOptionEnabled,
@@ -5250,9 +5252,9 @@ const Ui = ({
5250
5252
  }
5251
5253
  };
5252
5254
  if (A.isUserMessage())
5253
- return /* @__PURE__ */ s.createElement(t, { ...Ee, messageType: "user" });
5255
+ return /* @__PURE__ */ s.createElement(t, { ...Re, messageType: "user" });
5254
5256
  if (A.isFileMessage())
5255
- return /* @__PURE__ */ s.createElement(t, { ...Ee, messageType: "file", file: A });
5257
+ return /* @__PURE__ */ s.createElement(t, { ...Re, messageType: "file", file: A });
5256
5258
  }
5257
5259
  return null;
5258
5260
  })(), z = El(A, ie) && /* @__PURE__ */ s.createElement(Xa, { date: A.createdAt, style: E.dateSeparator });
@@ -5288,10 +5290,10 @@ const Ui = ({
5288
5290
  renderItem: L,
5289
5291
  loading: !d.initialized,
5290
5292
  error: !!(g || p.error),
5291
- LoadingComponent: /* @__PURE__ */ s.createElement(Me, { type: "loading" }),
5292
- EmptyComponent: /* @__PURE__ */ s.createElement(Me, { type: "noMessages", label: a.common.placeholder_no_messages }),
5293
+ LoadingComponent: /* @__PURE__ */ s.createElement(ke, { type: "loading" }),
5294
+ EmptyComponent: /* @__PURE__ */ s.createElement(ke, { type: "noMessages", label: a.common.placeholder_no_messages }),
5293
5295
  ErrorComponent: /* @__PURE__ */ s.createElement(
5294
- Me,
5296
+ ke,
5295
5297
  {
5296
5298
  type: "error",
5297
5299
  label: (g == null ? void 0 : g.message) ?? ((ae = p.error) == null ? void 0 : ae.message),
@@ -5555,7 +5557,7 @@ const Bl = ({ onPressAddAttachment: e, disabled: t }) => /* @__PURE__ */ s.creat
5555
5557
  }
5556
5558
  }), Hl = ({ name: e, type: t, url: n, onRemove: r }) => {
5557
5559
  const o = zl.use();
5558
- return /* @__PURE__ */ s.createElement(f, { style: o.wrapper }, wo(t) ? /* @__PURE__ */ s.createElement(Pe, { source: { uri: n }, style: o.image, resizeMode: "cover" }) : /* @__PURE__ */ s.createElement(sn, { name: e, type: Kt(e, t) }), r && /* @__PURE__ */ s.createElement(O, { onPress: r, style: o.removeButton }, /* @__PURE__ */ s.createElement(B, { type: "remove", size: 20, color: o.removeIcon.tintColor })));
5560
+ return /* @__PURE__ */ s.createElement(f, { style: o.wrapper }, wo(t) ? /* @__PURE__ */ s.createElement(Le, { source: { uri: n }, style: o.image, resizeMode: "cover" }) : /* @__PURE__ */ s.createElement(sn, { name: e, type: Kt(e, t) }), r && /* @__PURE__ */ s.createElement(O, { onPress: r, style: o.removeButton }, /* @__PURE__ */ s.createElement(B, { type: "remove", size: 20, color: o.removeIcon.tintColor })));
5559
5561
  }, Je = 7, zl = D.create(({ themedColor: e }) => ({
5560
5562
  wrapper: {
5561
5563
  marginTop: Je,
@@ -5663,16 +5665,16 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5663
5665
  }), m = (h, y) => {
5664
5666
  const E = y.filter((x) => u.isSupportedMimeType(x.type));
5665
5667
  if (E.length === 0 && y.length > 0)
5666
- return ke.alert("", t.conversation.file_upload_not_supported_file), h;
5668
+ return Te.alert("", t.conversation.file_upload_not_supported_file), h;
5667
5669
  const b = (x) => {
5668
5670
  const N = u.getUploadSizeLimit(x.type);
5669
5671
  return x.size && x.size > N;
5670
5672
  }, C = E.find((x) => b(x));
5671
5673
  if (C) {
5672
5674
  const x = u.getUploadSizeLimitInMB(C.type);
5673
- return ke.alert("", t.conversation.file_upload_notification_size_limit(x)), h;
5675
+ return Te.alert("", t.conversation.file_upload_notification_size_limit(x)), h;
5674
5676
  }
5675
- return h.length + E.length > u.maxAttachmentCount ? (ke.alert("", t.conversation.file_upload_notification_count_limit(u.maxAttachmentCount)), h) : [...h, ...E];
5677
+ return h.length + E.length > u.maxAttachmentCount ? (Te.alert("", t.conversation.file_upload_notification_count_limit(u.maxAttachmentCount)), h) : [...h, ...E];
5676
5678
  }, g = (h) => {
5677
5679
  c((y) => m(y, h));
5678
5680
  }, d = (h) => {
@@ -5716,7 +5718,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5716
5718
  maxAttachmentCount: u.maxAttachmentCount
5717
5719
  };
5718
5720
  }, Yl = () => {
5719
- const { config: e } = Z(), t = Dl(), { strings: n } = W(), { messageSource: r } = me(), { openModal: o } = Qt(), a = De(["left", "right", "bottom"]), i = Kl.use(), {
5721
+ const { config: e } = Z(), t = Dl(), { strings: n } = W(), { messageSource: r } = me(), { openModal: o } = Qt(), a = Pe(["left", "right", "bottom"]), i = Kl.use(), {
5720
5722
  maxAttachmentCount: l,
5721
5723
  sendButtonVisible: c,
5722
5724
  addAttachmentButtonVisible: u,
@@ -5737,7 +5739,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5737
5739
  label: n.conversation.attachment_camera,
5738
5740
  onPress: async () => {
5739
5741
  if (!d())
5740
- return ke.alert("", n.conversation.file_upload_no_supported_files), b(null);
5742
+ return Te.alert("", n.conversation.file_upload_no_supported_files), b(null);
5741
5743
  const te = await t.captureCamera();
5742
5744
  b(te);
5743
5745
  }
@@ -5749,7 +5751,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5749
5751
  label: n.conversation.attachment_photo,
5750
5752
  onPress: async () => {
5751
5753
  if (!d())
5752
- return ke.alert("", n.conversation.file_upload_no_supported_files), b(null);
5754
+ return Te.alert("", n.conversation.file_upload_no_supported_files), b(null);
5753
5755
  const te = await t.selectFromGallery({
5754
5756
  selectionLimit: l - _.files.length
5755
5757
  });
@@ -5763,7 +5765,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5763
5765
  label: n.conversation.attachment_document,
5764
5766
  onPress: async () => {
5765
5767
  if (!p())
5766
- return ke.alert("", n.conversation.file_upload_no_supported_files), b(null);
5768
+ return Te.alert("", n.conversation.file_upload_no_supported_files), b(null);
5767
5769
  const te = await t.selectFile({
5768
5770
  selectionLimit: l - _.files.length,
5769
5771
  mimeTypes: g
@@ -5813,7 +5815,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5813
5815
  backgroundColor: e.colors.base.background
5814
5816
  })
5815
5817
  })), Er = ({ start: e, title: t, titleAlign: n = "start", end: r }) => {
5816
- const o = De(["left", "right", "top"]), [a, i] = S(0), [l, c] = S(0), u = (d) => {
5818
+ const o = Pe(["left", "right", "top"]), [a, i] = S(0), [l, c] = S(0), u = (d) => {
5817
5819
  i(d.nativeEvent.layout.width);
5818
5820
  }, m = (d) => {
5819
5821
  c(d.nativeEvent.layout.width);
@@ -5871,7 +5873,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5871
5873
  }, Jl = () => {
5872
5874
  const { themedColor: e } = V(), {
5873
5875
  channelSource: { channel: t }
5874
- } = me(), n = Zt("handoff-button", t), r = !Yn(t) || Le(t);
5876
+ } = me(), n = Zt("handoff-button", t), r = !Yn(t) || Me(t);
5875
5877
  return n ? /* @__PURE__ */ s.createElement(
5876
5878
  O,
5877
5879
  {
@@ -5923,7 +5925,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5923
5925
  } = me(), { userSession: t, aiAgentInfo: n } = oe(), { config: r } = Z(), o = sr({ channel: e, userSession: t, aiAgentInfo: n }), a = (l = (i = r == null ? void 0 : r.conversation) == null ? void 0 : i.header) == null ? void 0 : l.avatarEnabled;
5924
5926
  return /* @__PURE__ */ s.createElement(f, { gap: 6, flexDirection: "row", alignItems: "center", maxWidth: "100%" }, a && /* @__PURE__ */ s.createElement(vr, { channel: e, size: 34 }), /* @__PURE__ */ s.createElement(f, { flexShrink: 1 }, /* @__PURE__ */ s.createElement(T, { numberOfLines: 1, variant: "h1" }, o.title)));
5925
5927
  }, tc = (e) => {
5926
- const { components: t } = Re.useContext();
5928
+ const { components: t } = De.useContext();
5927
5929
  return /* @__PURE__ */ s.createElement(
5928
5930
  Er,
5929
5931
  {
@@ -5934,15 +5936,15 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5934
5936
  }
5935
5937
  );
5936
5938
  }, nc = () => {
5937
- const { components: e } = Re.useContext();
5939
+ const { components: e } = De.useContext();
5938
5940
  return /* @__PURE__ */ s.createElement(e.MenuButton, null);
5939
5941
  }, rc = () => {
5940
- const { components: e } = Re.useContext();
5942
+ const { components: e } = De.useContext();
5941
5943
  return /* @__PURE__ */ s.createElement(e.Title, null);
5942
5944
  }, oc = () => {
5943
- const { components: e } = Re.useContext();
5945
+ const { components: e } = De.useContext();
5944
5946
  return /* @__PURE__ */ s.createElement(f, { flexDirection: "row", alignItems: "center", gap: 10 }, /* @__PURE__ */ s.createElement(e.HandoffButton, null), /* @__PURE__ */ s.createElement(e.CloseButton, null));
5945
- }, Re = ue({
5947
+ }, De = ue({
5946
5948
  template: tc,
5947
5949
  components: {
5948
5950
  StartArea: nc,
@@ -5954,7 +5956,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
5954
5956
  CloseButton: Zl
5955
5957
  }
5956
5958
  }), sc = () => {
5957
- const { Template: e } = Re.useContext();
5959
+ const { Template: e } = De.useContext();
5958
5960
  return /* @__PURE__ */ s.createElement(e, { titleAlign: "start" });
5959
5961
  }, ac = (e) => {
5960
5962
  const { components: t } = dn.useContext();
@@ -6034,7 +6036,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6034
6036
  }
6035
6037
  })), gc = () => {
6036
6038
  var l;
6037
- const { Template: e } = dc.useContext(), { strings: t } = W(), { connectionError: n } = oe(), { listSource: r, onNavigateToConversation: o } = mn(), a = De(["left", "right"]), i = hc.use();
6039
+ const { Template: e } = dc.useContext(), { strings: t } = W(), { connectionError: n } = oe(), { listSource: r, onNavigateToConversation: o } = mn(), a = Pe(["left", "right"]), i = hc.use();
6038
6040
  return /* @__PURE__ */ s.createElement(
6039
6041
  mr,
6040
6042
  {
@@ -6055,9 +6057,9 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6055
6057
  ),
6056
6058
  loading: !r.initialized,
6057
6059
  error: !!(n || r.error),
6058
- LoadingComponent: /* @__PURE__ */ s.createElement(Me, { type: "loading" }),
6059
- EmptyComponent: /* @__PURE__ */ s.createElement(Me, { type: "noChannels", label: t.common.placeholder_no_conversations }),
6060
- ErrorComponent: /* @__PURE__ */ s.createElement(Me, { type: "error", label: (n == null ? void 0 : n.message) ?? ((l = r.error) == null ? void 0 : l.message) })
6060
+ LoadingComponent: /* @__PURE__ */ s.createElement(ke, { type: "loading" }),
6061
+ EmptyComponent: /* @__PURE__ */ s.createElement(ke, { type: "noChannels", label: t.common.placeholder_no_conversations }),
6062
+ ErrorComponent: /* @__PURE__ */ s.createElement(ke, { type: "error", label: (n == null ? void 0 : n.message) ?? ((l = r.error) == null ? void 0 : l.message) })
6061
6063
  }
6062
6064
  );
6063
6065
  }, hc = D.create(({ theme: e }) => ({
@@ -6069,7 +6071,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6069
6071
  backgroundColor: e.colors.base.background
6070
6072
  }
6071
6073
  })), pc = () => {
6072
- const { strings: e } = W(), { language: t, countryCode: n, context: r } = Z(), { aiAgentInfo: o, refreshActiveChannel: a, createConversation: i, setActiveChannel: l, sdkUser: c } = oe(), { onNavigateToConversation: u } = mn(), m = De(["left", "right", "bottom"]), g = fc.use();
6074
+ const { strings: e } = W(), { language: t, countryCode: n, context: r } = Z(), { aiAgentInfo: o, refreshActiveChannel: a, createConversation: i, setActiveChannel: l, sdkUser: c } = oe(), { onNavigateToConversation: u } = mn(), m = Pe(["left", "right", "bottom"]), g = fc.use();
6073
6075
  return /* @__PURE__ */ s.createElement(
6074
6076
  O,
6075
6077
  {
@@ -6157,7 +6159,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6157
6159
  }), xc = ({ children: e, ...t }) => {
6158
6160
  const { Template: n } = gn.useContext();
6159
6161
  return /* @__PURE__ */ s.createElement(cc, { ...t }, /* @__PURE__ */ s.createElement(n, null), e);
6160
- }, Ic = "1.3.0", Tc = Ic, Bu = st(
6162
+ }, Ic = "1.3.1", Tc = Ic, Bu = st(
6161
6163
  function({
6162
6164
  logLevel: t = Vr.WARN,
6163
6165
  language: n = ct,
@@ -6196,7 +6198,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6196
6198
  }
6197
6199
  ), kc = _o(
6198
6200
  dn,
6199
- Re,
6201
+ De,
6200
6202
  gn,
6201
6203
  Ge,
6202
6204
  on,
@@ -6283,7 +6285,7 @@ const Wl = ({ onPressSend: e }) => /* @__PURE__ */ s.createElement(O, { style: V
6283
6285
  isDefaultIcon: t,
6284
6286
  size: n,
6285
6287
  fillColor: r
6286
- }) => e ? t ? /* @__PURE__ */ s.createElement(Pe, { source: { uri: e }, width: n, height: n, tintColor: r, resizeMode: "contain" }) : /* @__PURE__ */ s.createElement(Pe, { source: { uri: e }, width: n, height: n, resizeMode: "cover" }) : /* @__PURE__ */ s.createElement(B, { type: "delight", size: n, color: r }), Nc = ({ size: e, fillColor: t }) => /* @__PURE__ */ s.createElement(B, { type: "chevron-down", size: e, color: t }), Hc = D.create(() => ({
6288
+ }) => e ? t ? /* @__PURE__ */ s.createElement(Le, { source: { uri: e }, width: n, height: n, tintColor: r, resizeMode: "contain" }) : /* @__PURE__ */ s.createElement(Le, { source: { uri: e }, width: n, height: n, resizeMode: "cover" }) : /* @__PURE__ */ s.createElement(B, { type: "delight", size: n, color: r }), Nc = ({ size: e, fillColor: t }) => /* @__PURE__ */ s.createElement(B, { type: "chevron-down", size: e, color: t }), Hc = D.create(() => ({
6287
6289
  container: (e) => ({
6288
6290
  position: "relative",
6289
6291
  width: e.size,
@@ -6655,7 +6657,7 @@ const {
6655
6657
  }, su = (e) => {
6656
6658
  var a, i, l, c;
6657
6659
  const { setPosition: t, setMargin: n, setLauncherSize: r, setSpacing: o } = hn();
6658
- return Ce(() => {
6660
+ return Ee(() => {
6659
6661
  e.position && t(e.position), e.margin && n(e.margin), e.launcherSize !== void 0 && r(e.launcherSize), e.spacing !== void 0 && o(e.spacing);
6660
6662
  }, [
6661
6663
  e.position,
@@ -6668,10 +6670,10 @@ const {
6668
6670
  ]), null;
6669
6671
  }, au = ({ children: e }) => {
6670
6672
  const { setConversationChildren: t } = pn();
6671
- return Ce(() => (t(e), () => t(null)), [e]), null;
6673
+ return Ee(() => (t(e), () => t(null)), [e]), null;
6672
6674
  }, iu = ({ children: e }) => {
6673
6675
  const { setConversationListChildren: t } = pn();
6674
- return Ce(() => (t(e), () => t(null)), [e]), null;
6676
+ return Ee(() => (t(e), () => t(null)), [e]), null;
6675
6677
  }, lu = ({
6676
6678
  entryPoint: e = "Conversation",
6677
6679
  edgeToEdgeEnabled: t = !0,
@@ -6720,7 +6722,7 @@ export {
6720
6722
  ic as Conversation,
6721
6723
  Ru as ConversationContext,
6722
6724
  aa as ConversationContextProvider,
6723
- Re as ConversationHeaderLayout,
6725
+ De as ConversationHeaderLayout,
6724
6726
  dn as ConversationLayout,
6725
6727
  xc as ConversationList,
6726
6728
  Ou as ConversationListContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendbird/ai-agent-messenger-react-native",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Delight AI Agent Messenger for React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@react-native-documents/picker": "^10.1.7",
53
53
  "@react-native/babel-preset": "0.81.1",
54
- "@sendbird/chat": "^4.20.4",
54
+ "@sendbird/chat": "^4.20.6",
55
55
  "@types/jest": "^29.5.14",
56
56
  "@types/react": "19.2.2",
57
57
  "@types/react-syntax-highlighter": "^15.5.13",
@@ -67,7 +67,7 @@
67
67
  "react-native-safe-area-context": "^5.6.1",
68
68
  "typescript": "^5.9.2",
69
69
  "vite-plugin-static-copy": "^3.1.4",
70
- "@sendbird/ai-agent-core": "1.13.0",
70
+ "@sendbird/ai-agent-core": "1.13.1",
71
71
  "@sendbird/vite-tools": "0.0.1"
72
72
  },
73
73
  "dependencies": {
@@ -79,7 +79,7 @@
79
79
  "peerDependencies": {
80
80
  "@react-native-clipboard/clipboard": ">=1.0.0",
81
81
  "@react-native-documents/picker": ">=10.0.0",
82
- "@sendbird/chat": "^4.20.4",
82
+ "@sendbird/chat": "^4.20.6",
83
83
  "date-fns": ">=4.0.0",
84
84
  "expo-document-picker": ">=14.0.0",
85
85
  "expo-image-picker": ">=17.0.0",