@realtimexsco/live-chat 1.4.10 → 1.4.11

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.cjs CHANGED
@@ -1251,6 +1251,64 @@ var init_query_params = __esm({
1251
1251
  ];
1252
1252
  }
1253
1253
  });
1254
+
1255
+ // src/services/api/api-version.ts
1256
+ var DEFAULT_VERSIONS, apiVersions, normalizeApiVersion; exports.resolveApiRoot = void 0; exports.buildVersionedApiUrl = void 0; exports.setChatApiVersions = void 0; exports.getChatApiVersions = void 0; exports.setChatPushApiVersion = void 0; var syncDefaultApiVersionFromBaseUrl;
1257
+ var init_api_version = __esm({
1258
+ "src/services/api/api-version.ts"() {
1259
+ init_client();
1260
+ DEFAULT_VERSIONS = {
1261
+ default: "v1",
1262
+ push: "v2"
1263
+ };
1264
+ apiVersions = { ...DEFAULT_VERSIONS };
1265
+ normalizeApiVersion = (version) => {
1266
+ const raw = String(version || "v1").trim().replace(/^\/+|\/+$/g, "");
1267
+ if (!raw) return "v1";
1268
+ return /^v\d+$/i.test(raw) ? raw.toLowerCase() : `v${raw}`;
1269
+ };
1270
+ exports.resolveApiRoot = (baseUrl) => {
1271
+ const raw = String(
1272
+ baseUrl || exports.getChatBaseUrl() || apiClient.defaults.baseURL || ""
1273
+ ).trim().replace(/\/$/, "");
1274
+ if (!raw) return "";
1275
+ const withoutVersion = raw.replace(/\/v\d+$/i, "");
1276
+ return withoutVersion || raw;
1277
+ };
1278
+ exports.buildVersionedApiUrl = (path, options) => {
1279
+ const root = exports.resolveApiRoot(options?.baseUrl);
1280
+ const version = normalizeApiVersion(
1281
+ options?.version ?? (options?.service ? apiVersions[options.service] : apiVersions.default)
1282
+ );
1283
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
1284
+ if (!root) {
1285
+ return `/${version}${normalizedPath}`;
1286
+ }
1287
+ return `${root}/${version}${normalizedPath}`;
1288
+ };
1289
+ exports.setChatApiVersions = (config) => {
1290
+ if (!config) return;
1291
+ if (config.default) {
1292
+ apiVersions.default = normalizeApiVersion(config.default);
1293
+ }
1294
+ if (config.push) {
1295
+ apiVersions.push = normalizeApiVersion(config.push);
1296
+ }
1297
+ };
1298
+ exports.getChatApiVersions = () => ({
1299
+ ...apiVersions
1300
+ });
1301
+ exports.setChatPushApiVersion = (version) => {
1302
+ apiVersions.push = normalizeApiVersion(version);
1303
+ };
1304
+ syncDefaultApiVersionFromBaseUrl = (baseUrl) => {
1305
+ const match = String(baseUrl || "").trim().match(/\/(v\d+)\/?$/i);
1306
+ if (match?.[1]) {
1307
+ apiVersions.default = normalizeApiVersion(match[1]);
1308
+ }
1309
+ };
1310
+ }
1311
+ });
1254
1312
  function resolveParamsForRequest(url, method) {
1255
1313
  const apiKey = resolveChatApiKey(url);
1256
1314
  const httpMethod = (method || "get").toLowerCase();
@@ -1267,7 +1325,9 @@ var chatClientId, chatAccessToken, chatBaseUrl, chatSocketUrl, chatQueryParams,
1267
1325
  var init_client = __esm({
1268
1326
  "src/services/api/client.ts"() {
1269
1327
  init_query_params();
1328
+ init_api_version();
1270
1329
  init_query_params();
1330
+ init_api_version();
1271
1331
  chatClientId = "";
1272
1332
  chatAccessToken = "";
1273
1333
  chatBaseUrl = "";
@@ -1285,6 +1345,7 @@ var init_client = __esm({
1285
1345
  exports.setChatBaseURL = (url) => {
1286
1346
  chatBaseUrl = url.trim();
1287
1347
  apiClient.defaults.baseURL = chatBaseUrl;
1348
+ syncDefaultApiVersionFromBaseUrl(chatBaseUrl);
1288
1349
  };
1289
1350
  exports.getChatBaseUrl = () => chatBaseUrl;
1290
1351
  exports.setChatSocketUrl = (url) => {
@@ -3750,7 +3811,7 @@ function resolveApiUrl(apiUrl) {
3750
3811
  function resolveSocketUrl(socketUrl, apiUrl) {
3751
3812
  const explicit = (socketUrl ?? "").trim();
3752
3813
  if (explicit) return explicit;
3753
- return resolveApiUrl(apiUrl).replace(/\/api\/v1\/?$/, "");
3814
+ return resolveApiUrl(apiUrl).replace(/\/api\/v\d+\/?$/i, "");
3754
3815
  }
3755
3816
 
3756
3817
  // src/hooks/chat-sync/useChatSync.ts
@@ -4497,6 +4558,7 @@ var Chat = ({
4497
4558
  queryParams,
4498
4559
  queryParamApis,
4499
4560
  queryParamsByApi,
4561
+ apiVersions: apiVersions2,
4500
4562
  channelsData,
4501
4563
  messagesData,
4502
4564
  onMessageReceived,
@@ -4522,6 +4584,7 @@ var Chat = ({
4522
4584
  const resolvedApiUrl = resolveApiUrl(apiUrl);
4523
4585
  const resolvedSocketUrl = resolveSocketUrl(socketUrl, resolvedApiUrl);
4524
4586
  if (resolvedApiUrl) exports.setChatBaseURL(resolvedApiUrl);
4587
+ exports.setChatApiVersions(apiVersions2);
4525
4588
  if (resolvedSocketUrl) exports.setChatSocketUrl(resolvedSocketUrl);
4526
4589
  let currentToken = accessToken || "";
4527
4590
  let sessionUser = resolveUserFromAccessToken(currentToken, loggedUserDetails);
@@ -5639,6 +5702,18 @@ function formatMemberName(name) {
5639
5702
  function formatLoggedUserName(name) {
5640
5703
  return name ? name.charAt(0).toUpperCase() + name.slice(1) : "User";
5641
5704
  }
5705
+
5706
+ // src/chat/sidebar/build-logged-user-profile.ts
5707
+ var buildLoggedUserProfile = (loggedUserDetails) => ({
5708
+ _id: loggedUserDetails?._id || "1",
5709
+ name: formatLoggedUserName(loggedUserDetails?.name),
5710
+ email: loggedUserDetails?.email || "user@example.com",
5711
+ role: loggedUserDetails?.role || "user",
5712
+ isActive: loggedUserDetails?.isActive ?? true,
5713
+ createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
5714
+ updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
5715
+ image: loggedUserDetails?.image || void 0
5716
+ });
5642
5717
  function Dialog({
5643
5718
  ...props
5644
5719
  }) {
@@ -6573,6 +6648,7 @@ function Switch({
6573
6648
 
6574
6649
  // src/notifications/push.service.ts
6575
6650
  init_client();
6651
+ init_api_version();
6576
6652
  var PUSH_TOKEN_STORAGE_KEY = "realtimex-push-token";
6577
6653
  var SERVICE_WORKER_PATH = "/firebase-messaging-sw.js";
6578
6654
  var PUSH_CHANGED_EVENT = "realtimex:push-changed";
@@ -6584,33 +6660,33 @@ var emitPushChanged = (enabled) => {
6584
6660
  } catch {
6585
6661
  }
6586
6662
  };
6587
- var v2Url = "https://realtimex.softwareco.com/api/v2";
6663
+ var pushApiUrl = (path) => exports.buildVersionedApiUrl(path, { service: "push" });
6588
6664
  var apiGetPushConfig = async () => {
6589
- const { data } = await apiClient.get(`${v2Url}/notifications/push/config`);
6665
+ const { data } = await apiClient.get(pushApiUrl("/notifications/push/config"));
6590
6666
  return data?.data;
6591
6667
  };
6592
6668
  var apiRegisterPushToken = async (token, deviceLabel) => {
6593
- const { data } = await apiClient.post(`${v2Url}/notifications/push/token`, {
6669
+ const { data } = await apiClient.post(pushApiUrl("/notifications/push/token"), {
6594
6670
  token,
6595
6671
  deviceLabel
6596
6672
  });
6597
6673
  return data?.data;
6598
6674
  };
6599
6675
  var apiRemovePushToken = async (token) => {
6600
- const { data } = await apiClient.delete(`${v2Url}/notifications/push/token`, {
6676
+ const { data } = await apiClient.delete(pushApiUrl("/notifications/push/token"), {
6601
6677
  data: { token }
6602
6678
  });
6603
6679
  return data;
6604
6680
  };
6605
6681
  var apiGetPushPreference = async () => {
6606
6682
  const { data } = await apiClient.get(
6607
- `${v2Url}/notifications/push/preference`
6683
+ pushApiUrl("/notifications/push/preference")
6608
6684
  );
6609
6685
  return data?.data;
6610
6686
  };
6611
6687
  var apiUpdatePushPreference = async (enabled) => {
6612
6688
  const { data } = await apiClient.patch(
6613
- `${v2Url}/notifications/push/preference`,
6689
+ pushApiUrl("/notifications/push/preference"),
6614
6690
  { enabled }
6615
6691
  );
6616
6692
  return data?.data;
@@ -6805,13 +6881,15 @@ var usePushNotifications = () => {
6805
6881
  }, [refresh]);
6806
6882
  const setUserEnabled = React2.useCallback(
6807
6883
  async (enabled) => {
6808
- setState((prev) => ({ ...prev, userEnabled: enabled }));
6884
+ setState((prev) => ({ ...prev, loading: true, error: null }));
6809
6885
  try {
6810
6886
  await apiUpdatePushPreference(enabled);
6887
+ setState((prev) => ({ ...prev, userEnabled: enabled, loading: false }));
6811
6888
  } catch (error) {
6812
6889
  setState((prev) => ({
6813
6890
  ...prev,
6814
6891
  userEnabled: !enabled,
6892
+ loading: false,
6815
6893
  error: error instanceof Error ? error.message : "Could not update push preference"
6816
6894
  }));
6817
6895
  }
@@ -6823,36 +6901,66 @@ var usePushNotifications = () => {
6823
6901
  var PushNotificationToggle = ({
6824
6902
  className,
6825
6903
  label = "Push notifications",
6826
- description = "Get notified about new messages on this device"
6904
+ description = "Get notified about new messages on this device",
6905
+ children
6827
6906
  }) => {
6828
6907
  const push = usePushNotifications();
6908
+ const [isToggling, setIsToggling] = React2.useState(false);
6829
6909
  if (!push.supported || !push.allowedByWorkspace || !push.configured) {
6830
6910
  return null;
6831
6911
  }
6832
6912
  const isOn = push.deviceEnabled && push.userEnabled;
6833
6913
  const permissionBlocked = push.permission === "denied";
6914
+ const showLoader = isToggling;
6834
6915
  const handleChange = async (checked) => {
6835
- if (checked) {
6836
- if (!push.userEnabled) await push.setUserEnabled(true);
6837
- if (!push.deviceEnabled) await push.enable();
6838
- } else {
6839
- await push.disable();
6916
+ setIsToggling(true);
6917
+ try {
6918
+ if (checked) {
6919
+ if (!push.userEnabled) await push.setUserEnabled(true);
6920
+ if (!push.deviceEnabled) await push.enable();
6921
+ } else {
6922
+ await push.disable();
6923
+ }
6924
+ } finally {
6925
+ setIsToggling(false);
6840
6926
  }
6841
6927
  };
6928
+ const renderProps = {
6929
+ label,
6930
+ description: permissionBlocked ? "Notifications are blocked in your browser settings" : push.error ?? description,
6931
+ checked: isOn,
6932
+ disabled: showLoader || permissionBlocked || push.loading,
6933
+ loading: showLoader || push.loading,
6934
+ permissionBlocked,
6935
+ error: push.error,
6936
+ onCheckedChange: (checked) => void handleChange(checked)
6937
+ };
6938
+ if (children) {
6939
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(renderProps) });
6940
+ }
6842
6941
  return /* @__PURE__ */ jsxRuntime.jsxs(
6843
6942
  "div",
6844
6943
  {
6845
- className: className ?? "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-surface) px-4 py-3",
6944
+ className: cn(
6945
+ "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-surface) px-4 py-3",
6946
+ className
6947
+ ),
6846
6948
  children: [
6847
6949
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
6848
6950
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-(--chat-text)", children: label }),
6849
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-(--chat-muted)", children: permissionBlocked ? "Notifications are blocked in your browser settings" : push.error ?? description })
6951
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-(--chat-muted)", children: renderProps.description })
6850
6952
  ] }),
6851
- /* @__PURE__ */ jsxRuntime.jsx(
6953
+ showLoader ? /* @__PURE__ */ jsxRuntime.jsx(
6954
+ lucideReact.Loader2,
6955
+ {
6956
+ className: "size-5 shrink-0 animate-spin text-(--chat-theme)",
6957
+ "aria-label": "Updating push notifications"
6958
+ }
6959
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
6852
6960
  Switch,
6853
6961
  {
6854
6962
  checked: isOn,
6855
- disabled: push.loading || permissionBlocked,
6963
+ disabled: permissionBlocked || push.loading,
6856
6964
  onCheckedChange: (checked) => void handleChange(checked),
6857
6965
  "aria-label": `Toggle ${label}`
6858
6966
  }
@@ -6861,57 +6969,147 @@ var PushNotificationToggle = ({
6861
6969
  }
6862
6970
  );
6863
6971
  };
6864
- var LoggedUserSettingsDialog = ({
6865
- loggedUserDetails
6972
+ var LoggedUserSettingsContent = ({
6973
+ user,
6974
+ title = "Account settings",
6975
+ showProfile = true,
6976
+ showPushToggle = true,
6977
+ className
6866
6978
  }) => {
6867
- const [open, setOpen] = React2.useState(false);
6868
- const user = {
6869
- _id: loggedUserDetails?._id || "1",
6870
- name: formatLoggedUserName(loggedUserDetails?.name),
6871
- email: loggedUserDetails?.email || "user@example.com",
6872
- role: loggedUserDetails?.role || "user",
6873
- isActive: loggedUserDetails?.isActive ?? true,
6874
- createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
6875
- updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
6876
- image: loggedUserDetails?.image || void 0
6877
- };
6878
- return /* @__PURE__ */ jsxRuntime.jsxs(Dialog, { open, onOpenChange: setOpen, children: [
6879
- /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
6880
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
6881
- Button,
6882
- {
6883
- type: "button",
6884
- variant: "ghost",
6885
- size: "icon",
6886
- className: sidebarActionBtnClass,
6887
- "aria-label": "Account settings",
6888
- onClick: () => setOpen(true),
6889
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-3.5", strokeWidth: 2 })
6890
- }
6891
- ) }),
6892
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: "Settings" })
6893
- ] }),
6894
- /* @__PURE__ */ jsxRuntime.jsxs(ChatDialogContent, { className: "gap-0 overflow-hidden p-0 sm:max-w-[380px]", children: [
6895
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-(--chat-border) px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-left text-base font-semibold text-(--chat-text)", children: "Account settings" }) }),
6896
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5 px-5 py-5", children: [
6897
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center text-center", children: [
6898
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
6899
- /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "size-16 ring-2 ring-(--chat-theme-20)", children: [
6900
- user.image ? /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image, alt: user.name }) : null,
6901
- /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-lg font-medium text-(--chat-theme)", children: (user.name || "?").charAt(0).toUpperCase() })
6979
+ const { resolveComponent, slotClassName } = useChatCustomization();
6980
+ const PushToggleSlot = resolveComponent(
6981
+ "PushNotificationToggle",
6982
+ PushNotificationToggle
6983
+ );
6984
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6985
+ /* @__PURE__ */ jsxRuntime.jsx(
6986
+ "div",
6987
+ {
6988
+ className: cn(
6989
+ "border-b border-(--chat-border) px-5 py-4",
6990
+ slotClassName("loggedUserSettingsHeader")
6991
+ ),
6992
+ children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-left text-base font-semibold text-(--chat-text)", children: title })
6993
+ }
6994
+ ),
6995
+ /* @__PURE__ */ jsxRuntime.jsxs(
6996
+ "div",
6997
+ {
6998
+ className: cn(
6999
+ "space-y-5 px-5 py-5",
7000
+ slotClassName("loggedUserSettingsContent", className)
7001
+ ),
7002
+ children: [
7003
+ showProfile ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center text-center", children: [
7004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
7005
+ /* @__PURE__ */ jsxRuntime.jsxs(
7006
+ Avatar,
7007
+ {
7008
+ className: cn(
7009
+ "size-16 ring-2 ring-(--chat-theme-20)",
7010
+ slotClassName("loggedUserSettingsAvatar")
7011
+ ),
7012
+ children: [
7013
+ user.image ? /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image, alt: user.name }) : null,
7014
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-lg font-medium text-(--chat-theme)", children: (user.name || "?").charAt(0).toUpperCase() })
7015
+ ]
7016
+ }
7017
+ ),
7018
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute bottom-0.5 right-0.5 size-3 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6902
7019
  ] }),
6903
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute bottom-0.5 right-0.5 size-3 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6904
- ] }),
6905
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mt-3 text-base font-semibold text-(--chat-text)", children: user.name }),
6906
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-sm text-(--chat-muted)", children: user.email }),
6907
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-2 inline-flex items-center gap-1.5 rounded-full bg-(--chat-theme-10) px-2.5 py-0.5 text-xs font-medium text-(--chat-theme)", children: [
6908
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-(--chat-online)" }),
6909
- "Online"
6910
- ] })
6911
- ] }),
6912
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-(--chat-border) pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(PushNotificationToggle, { className: "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-theme-10) px-4 py-3" }) })
6913
- ] })
6914
- ] })
7020
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mt-3 text-base font-semibold text-(--chat-text)", children: user.name }),
7021
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-sm text-(--chat-muted)", children: user.email }),
7022
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-2 inline-flex items-center gap-1.5 rounded-full bg-(--chat-theme-10) px-2.5 py-0.5 text-xs font-medium text-(--chat-theme)", children: [
7023
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-(--chat-online)" }),
7024
+ "Online"
7025
+ ] })
7026
+ ] }) : null,
7027
+ showPushToggle ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-(--chat-border) pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(
7028
+ PushToggleSlot,
7029
+ {
7030
+ className: cn(
7031
+ "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-theme-10) px-4 py-3",
7032
+ slotClassName("pushNotificationToggle")
7033
+ )
7034
+ }
7035
+ ) }) : null
7036
+ ]
7037
+ }
7038
+ )
7039
+ ] });
7040
+ };
7041
+ var LoggedUserSettingsContent_default = LoggedUserSettingsContent;
7042
+ var LoggedUserSettingsTrigger = ({
7043
+ onClick,
7044
+ className,
7045
+ tooltip = "Settings",
7046
+ ariaLabel = "Account settings"
7047
+ }) => {
7048
+ const { slotClassName } = useChatCustomization();
7049
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
7050
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
7051
+ Button,
7052
+ {
7053
+ type: "button",
7054
+ variant: "ghost",
7055
+ size: "icon",
7056
+ className: cn(
7057
+ sidebarActionBtnClass,
7058
+ slotClassName("loggedUserSettingsTrigger", className)
7059
+ ),
7060
+ "aria-label": ariaLabel,
7061
+ onClick,
7062
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-3.5", strokeWidth: 2 })
7063
+ }
7064
+ ) }),
7065
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: tooltip })
7066
+ ] });
7067
+ };
7068
+ var LoggedUserSettingsTrigger_default = LoggedUserSettingsTrigger;
7069
+ var LoggedUserSettingsDialog = ({
7070
+ loggedUserDetails,
7071
+ open: controlledOpen,
7072
+ onOpenChange: controlledOnOpenChange,
7073
+ title,
7074
+ showProfile = true,
7075
+ showPushToggle = true,
7076
+ className
7077
+ }) => {
7078
+ const { resolveComponent, slotClassName } = useChatCustomization();
7079
+ const [internalOpen, setInternalOpen] = React2.useState(false);
7080
+ const open = controlledOpen ?? internalOpen;
7081
+ const onOpenChange = controlledOnOpenChange ?? setInternalOpen;
7082
+ const TriggerSlot = resolveComponent(
7083
+ "LoggedUserSettingsTrigger",
7084
+ LoggedUserSettingsTrigger_default
7085
+ );
7086
+ const ContentSlot = resolveComponent(
7087
+ "LoggedUserSettingsContent",
7088
+ LoggedUserSettingsContent_default
7089
+ );
7090
+ const user = buildLoggedUserProfile(loggedUserDetails);
7091
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog, { open, onOpenChange, children: [
7092
+ /* @__PURE__ */ jsxRuntime.jsx(TriggerSlot, { onClick: () => onOpenChange(true) }),
7093
+ /* @__PURE__ */ jsxRuntime.jsx(
7094
+ ChatDialogContent,
7095
+ {
7096
+ className: cn(
7097
+ "gap-0 overflow-hidden p-0 sm:max-w-[380px]",
7098
+ slotClassName("loggedUserSettingsDialog", className)
7099
+ ),
7100
+ children: /* @__PURE__ */ jsxRuntime.jsx(
7101
+ ContentSlot,
7102
+ {
7103
+ loggedUserDetails,
7104
+ user,
7105
+ onClose: () => onOpenChange(false),
7106
+ title,
7107
+ showProfile,
7108
+ showPushToggle
7109
+ }
7110
+ )
7111
+ }
7112
+ )
6915
7113
  ] });
6916
7114
  };
6917
7115
  var LoggedUserSettingsDialog_default = LoggedUserSettingsDialog;
@@ -6924,16 +7122,12 @@ var LoggedUserDetails = ({
6924
7122
  setSearchQuery
6925
7123
  }) => {
6926
7124
  const { showColorModeToggle } = useChatTheme();
6927
- const user = {
6928
- _id: loggedUserDetails?._id || "1",
6929
- name: formatLoggedUserName(loggedUserDetails?.name),
6930
- email: loggedUserDetails?.email || "user@example.com",
6931
- role: loggedUserDetails?.role || "user",
6932
- isActive: loggedUserDetails?.isActive ?? true,
6933
- createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
6934
- updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
6935
- image: loggedUserDetails?.image || void 0
6936
- };
7125
+ const { resolveComponent } = useChatCustomization();
7126
+ const SettingsDialogSlot = resolveComponent(
7127
+ "LoggedUserSettingsDialog",
7128
+ LoggedUserSettingsDialog_default
7129
+ );
7130
+ const user = buildLoggedUserProfile(loggedUserDetails);
6937
7131
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 border-b border-(--chat-border) bg-(--chat-surface) px-3 pb-3 pt-3", children: [
6938
7132
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [
6939
7133
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [
@@ -6944,14 +7138,11 @@ var LoggedUserDetails = ({
6944
7138
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6945
7139
  ] }),
6946
7140
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
6947
- /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "truncate text-xs font-medium leading-tight text-(--chat-text)", children: [
6948
- user.name,
6949
- "123"
6950
- ] }),
7141
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "truncate text-xs font-medium leading-tight text-(--chat-text)", children: user.name }),
6951
7142
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-[10px] text-(--chat-muted)", children: user.email })
6952
7143
  ] }),
6953
7144
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [
6954
- /* @__PURE__ */ jsxRuntime.jsx(LoggedUserSettingsDialog_default, { loggedUserDetails }),
7145
+ /* @__PURE__ */ jsxRuntime.jsx(SettingsDialogSlot, { loggedUserDetails }),
6955
7146
  showColorModeToggle ? /* @__PURE__ */ jsxRuntime.jsx(ChatThemeToggle_default, {}) : null
6956
7147
  ] })
6957
7148
  ] }),
@@ -18353,6 +18544,7 @@ var ChatMain = ({
18353
18544
  queryParams,
18354
18545
  queryParamApis,
18355
18546
  queryParamsByApi,
18547
+ apiVersions: apiVersions2,
18356
18548
  themeColor = "#7494ec",
18357
18549
  theme,
18358
18550
  uiConfig,
@@ -18422,6 +18614,7 @@ var ChatMain = ({
18422
18614
  queryParams,
18423
18615
  queryParamApis,
18424
18616
  queryParamsByApi,
18617
+ apiVersions: apiVersions2,
18425
18618
  children: [
18426
18619
  /* @__PURE__ */ jsxRuntime.jsx(ForegroundPushBridge, {}),
18427
18620
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -18714,6 +18907,10 @@ var ChannelListItem_default = ChannelListItem2;
18714
18907
  var packageDefaultComponents = {
18715
18908
  ChatLayout: DefaultChatLayout_default,
18716
18909
  LoggedUserDetails: LoggedUserDetails_default,
18910
+ LoggedUserSettingsDialog: LoggedUserSettingsDialog_default,
18911
+ LoggedUserSettingsTrigger: LoggedUserSettingsTrigger_default,
18912
+ LoggedUserSettingsContent: LoggedUserSettingsContent_default,
18913
+ PushNotificationToggle,
18717
18914
  ChannelList: ChannelListView_default,
18718
18915
  ChannelListItem: DefaultChannelListItem,
18719
18916
  ChannelHeader: ChannelHeaderView_default,
@@ -18771,6 +18968,9 @@ exports.ForegroundPushBridge = ForegroundPushBridge;
18771
18968
  exports.ForwardModal = ForwardModalView;
18772
18969
  exports.HeaderCallActions = HeaderCallActions_default;
18773
18970
  exports.LoggedUserDetails = LoggedUserDetails_default;
18971
+ exports.LoggedUserSettingsContent = LoggedUserSettingsContent_default;
18972
+ exports.LoggedUserSettingsDialog = LoggedUserSettingsDialog_default;
18973
+ exports.LoggedUserSettingsTrigger = LoggedUserSettingsTrigger_default;
18774
18974
  exports.MessageInput = ChannelMessageBoxView_default;
18775
18975
  exports.MessageItem = MessageItemView;
18776
18976
  exports.MessageList = ActiveChannelMessagesView_default;
@@ -18786,6 +18986,7 @@ exports.apiRegisterPushToken = apiRegisterPushToken;
18786
18986
  exports.apiRemovePushToken = apiRemovePushToken;
18787
18987
  exports.apiUpdatePushPreference = apiUpdatePushPreference;
18788
18988
  exports.buildChannelFromPushRequest = buildChannelFromPushRequest;
18989
+ exports.buildLoggedUserProfile = buildLoggedUserProfile;
18789
18990
  exports.capitalizeFirst = capitalizeFirst;
18790
18991
  exports.clampJumpDate = clampJumpDate;
18791
18992
  exports.consumePendingOpenConversation = consumePendingOpenConversation;