@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.mjs CHANGED
@@ -4,12 +4,12 @@ import { create } from 'zustand';
4
4
  import { persist } from 'zustand/middleware';
5
5
  import * as React2 from 'react';
6
6
  import React2__default, { createContext, useMemo, useContext, useState, useCallback, useRef, useEffect, useLayoutEffect, useSyncExternalStore } from 'react';
7
- import { Tooltip as Tooltip$1, Slot, Switch as Switch$1, Avatar as Avatar$1, ScrollArea as ScrollArea$1, Popover as Popover$1, DropdownMenu as DropdownMenu$1, Dialog as Dialog$1, AlertDialog as AlertDialog$1 } from 'radix-ui';
7
+ import { Tooltip as Tooltip$1, Slot, Switch as Switch$1, Dialog as Dialog$1, Avatar as Avatar$1, ScrollArea as ScrollArea$1, Popover as Popover$1, DropdownMenu as DropdownMenu$1, AlertDialog as AlertDialog$1 } from 'radix-ui';
8
8
  import { clsx } from 'clsx';
9
9
  import { twMerge } from 'tailwind-merge';
10
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import { flushSync } from 'react-dom';
12
- import { Sun, Moon, Search, X, Loader2, UserPlus, ChevronDown, ArrowLeft, Users, WifiOff, Wifi, Sparkles, MessageSquareText, ChevronRight, Pin, Star, MoreVertical, Info, UserKey, ShieldUser, Paperclip, Clock, MessageSquareX, Trash2, LogOut, Ban, CheckCheck, Check, Camera, Save, Pencil, Mail, CornerUpLeft, CheckSquare, Smile, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, MessageCircleMore, History, Shield, Send, AlertCircle, ShieldCheck, UserMinus, Settings, MessageCircle, Phone, Video, ExternalLink, Download, ChevronLeft, ZoomOut, ZoomIn, RotateCcw, Music, ArrowRight, MoreHorizontal, PinOff, StarOff, XIcon, ImageIcon, Film, Play, Pause, FileText, FileSpreadsheet, FileIcon, MessageSquare, Eye, Captions } from 'lucide-react';
12
+ import { Sun, Moon, Loader2, Settings, Search, X, UserPlus, ChevronDown, ArrowLeft, Users, WifiOff, Wifi, Sparkles, MessageSquareText, ChevronRight, Pin, Star, MoreVertical, Info, UserKey, ShieldUser, Paperclip, Clock, MessageSquareX, Trash2, LogOut, Ban, CheckCheck, Check, Camera, Save, Pencil, Mail, CornerUpLeft, CheckSquare, Smile, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, MessageCircleMore, History, Shield, Send, AlertCircle, ShieldCheck, UserMinus, MessageCircle, Phone, Video, ExternalLink, Download, ChevronLeft, ZoomOut, ZoomIn, RotateCcw, Music, XIcon, ArrowRight, MoreHorizontal, PinOff, StarOff, ImageIcon, Film, Play, Pause, FileText, FileSpreadsheet, FileIcon, MessageSquare, Eye, Captions } from 'lucide-react';
13
13
  import { cva } from 'class-variance-authority';
14
14
  import EmojiPicker, { Theme } from 'emoji-picker-react';
15
15
  import { getDefaultClassNames, DayPicker } from 'react-day-picker';
@@ -1223,6 +1223,64 @@ var init_query_params = __esm({
1223
1223
  ];
1224
1224
  }
1225
1225
  });
1226
+
1227
+ // src/services/api/api-version.ts
1228
+ var DEFAULT_VERSIONS, apiVersions, normalizeApiVersion, resolveApiRoot, buildVersionedApiUrl, setChatApiVersions, getChatApiVersions, setChatPushApiVersion, syncDefaultApiVersionFromBaseUrl;
1229
+ var init_api_version = __esm({
1230
+ "src/services/api/api-version.ts"() {
1231
+ init_client();
1232
+ DEFAULT_VERSIONS = {
1233
+ default: "v1",
1234
+ push: "v2"
1235
+ };
1236
+ apiVersions = { ...DEFAULT_VERSIONS };
1237
+ normalizeApiVersion = (version) => {
1238
+ const raw = String(version || "v1").trim().replace(/^\/+|\/+$/g, "");
1239
+ if (!raw) return "v1";
1240
+ return /^v\d+$/i.test(raw) ? raw.toLowerCase() : `v${raw}`;
1241
+ };
1242
+ resolveApiRoot = (baseUrl) => {
1243
+ const raw = String(
1244
+ baseUrl || getChatBaseUrl() || apiClient.defaults.baseURL || ""
1245
+ ).trim().replace(/\/$/, "");
1246
+ if (!raw) return "";
1247
+ const withoutVersion = raw.replace(/\/v\d+$/i, "");
1248
+ return withoutVersion || raw;
1249
+ };
1250
+ buildVersionedApiUrl = (path, options) => {
1251
+ const root = resolveApiRoot(options?.baseUrl);
1252
+ const version = normalizeApiVersion(
1253
+ options?.version ?? (options?.service ? apiVersions[options.service] : apiVersions.default)
1254
+ );
1255
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
1256
+ if (!root) {
1257
+ return `/${version}${normalizedPath}`;
1258
+ }
1259
+ return `${root}/${version}${normalizedPath}`;
1260
+ };
1261
+ setChatApiVersions = (config) => {
1262
+ if (!config) return;
1263
+ if (config.default) {
1264
+ apiVersions.default = normalizeApiVersion(config.default);
1265
+ }
1266
+ if (config.push) {
1267
+ apiVersions.push = normalizeApiVersion(config.push);
1268
+ }
1269
+ };
1270
+ getChatApiVersions = () => ({
1271
+ ...apiVersions
1272
+ });
1273
+ setChatPushApiVersion = (version) => {
1274
+ apiVersions.push = normalizeApiVersion(version);
1275
+ };
1276
+ syncDefaultApiVersionFromBaseUrl = (baseUrl) => {
1277
+ const match = String(baseUrl || "").trim().match(/\/(v\d+)\/?$/i);
1278
+ if (match?.[1]) {
1279
+ apiVersions.default = normalizeApiVersion(match[1]);
1280
+ }
1281
+ };
1282
+ }
1283
+ });
1226
1284
  function resolveParamsForRequest(url, method) {
1227
1285
  const apiKey = resolveChatApiKey(url);
1228
1286
  const httpMethod = (method || "get").toLowerCase();
@@ -1239,7 +1297,9 @@ var chatClientId, chatAccessToken, chatBaseUrl, chatSocketUrl, chatQueryParams,
1239
1297
  var init_client = __esm({
1240
1298
  "src/services/api/client.ts"() {
1241
1299
  init_query_params();
1300
+ init_api_version();
1242
1301
  init_query_params();
1302
+ init_api_version();
1243
1303
  chatClientId = "";
1244
1304
  chatAccessToken = "";
1245
1305
  chatBaseUrl = "";
@@ -1257,6 +1317,7 @@ var init_client = __esm({
1257
1317
  setChatBaseURL = (url) => {
1258
1318
  chatBaseUrl = url.trim();
1259
1319
  apiClient.defaults.baseURL = chatBaseUrl;
1320
+ syncDefaultApiVersionFromBaseUrl(chatBaseUrl);
1260
1321
  };
1261
1322
  getChatBaseUrl = () => chatBaseUrl;
1262
1323
  setChatSocketUrl = (url) => {
@@ -3722,7 +3783,7 @@ function resolveApiUrl(apiUrl) {
3722
3783
  function resolveSocketUrl(socketUrl, apiUrl) {
3723
3784
  const explicit = (socketUrl ?? "").trim();
3724
3785
  if (explicit) return explicit;
3725
- return resolveApiUrl(apiUrl).replace(/\/api\/v1\/?$/, "");
3786
+ return resolveApiUrl(apiUrl).replace(/\/api\/v\d+\/?$/i, "");
3726
3787
  }
3727
3788
 
3728
3789
  // src/hooks/chat-sync/useChatSync.ts
@@ -4469,6 +4530,7 @@ var Chat = ({
4469
4530
  queryParams,
4470
4531
  queryParamApis,
4471
4532
  queryParamsByApi,
4533
+ apiVersions: apiVersions2,
4472
4534
  channelsData,
4473
4535
  messagesData,
4474
4536
  onMessageReceived,
@@ -4494,6 +4556,7 @@ var Chat = ({
4494
4556
  const resolvedApiUrl = resolveApiUrl(apiUrl);
4495
4557
  const resolvedSocketUrl = resolveSocketUrl(socketUrl, resolvedApiUrl);
4496
4558
  if (resolvedApiUrl) setChatBaseURL(resolvedApiUrl);
4559
+ setChatApiVersions(apiVersions2);
4497
4560
  if (resolvedSocketUrl) setChatSocketUrl(resolvedSocketUrl);
4498
4561
  let currentToken = accessToken || "";
4499
4562
  let sessionUser = resolveUserFromAccessToken(currentToken, loggedUserDetails);
@@ -5611,6 +5674,18 @@ function formatMemberName(name) {
5611
5674
  function formatLoggedUserName(name) {
5612
5675
  return name ? name.charAt(0).toUpperCase() + name.slice(1) : "User";
5613
5676
  }
5677
+
5678
+ // src/chat/sidebar/build-logged-user-profile.ts
5679
+ var buildLoggedUserProfile = (loggedUserDetails) => ({
5680
+ _id: loggedUserDetails?._id || "1",
5681
+ name: formatLoggedUserName(loggedUserDetails?.name),
5682
+ email: loggedUserDetails?.email || "user@example.com",
5683
+ role: loggedUserDetails?.role || "user",
5684
+ isActive: loggedUserDetails?.isActive ?? true,
5685
+ createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
5686
+ updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
5687
+ image: loggedUserDetails?.image || void 0
5688
+ });
5614
5689
  function Dialog({
5615
5690
  ...props
5616
5691
  }) {
@@ -6545,6 +6620,7 @@ function Switch({
6545
6620
 
6546
6621
  // src/notifications/push.service.ts
6547
6622
  init_client();
6623
+ init_api_version();
6548
6624
  var PUSH_TOKEN_STORAGE_KEY = "realtimex-push-token";
6549
6625
  var SERVICE_WORKER_PATH = "/firebase-messaging-sw.js";
6550
6626
  var PUSH_CHANGED_EVENT = "realtimex:push-changed";
@@ -6556,33 +6632,33 @@ var emitPushChanged = (enabled) => {
6556
6632
  } catch {
6557
6633
  }
6558
6634
  };
6559
- var v2Url = "https://realtimex.softwareco.com/api/v2";
6635
+ var pushApiUrl = (path) => buildVersionedApiUrl(path, { service: "push" });
6560
6636
  var apiGetPushConfig = async () => {
6561
- const { data } = await apiClient.get(`${v2Url}/notifications/push/config`);
6637
+ const { data } = await apiClient.get(pushApiUrl("/notifications/push/config"));
6562
6638
  return data?.data;
6563
6639
  };
6564
6640
  var apiRegisterPushToken = async (token, deviceLabel) => {
6565
- const { data } = await apiClient.post(`${v2Url}/notifications/push/token`, {
6641
+ const { data } = await apiClient.post(pushApiUrl("/notifications/push/token"), {
6566
6642
  token,
6567
6643
  deviceLabel
6568
6644
  });
6569
6645
  return data?.data;
6570
6646
  };
6571
6647
  var apiRemovePushToken = async (token) => {
6572
- const { data } = await apiClient.delete(`${v2Url}/notifications/push/token`, {
6648
+ const { data } = await apiClient.delete(pushApiUrl("/notifications/push/token"), {
6573
6649
  data: { token }
6574
6650
  });
6575
6651
  return data;
6576
6652
  };
6577
6653
  var apiGetPushPreference = async () => {
6578
6654
  const { data } = await apiClient.get(
6579
- `${v2Url}/notifications/push/preference`
6655
+ pushApiUrl("/notifications/push/preference")
6580
6656
  );
6581
6657
  return data?.data;
6582
6658
  };
6583
6659
  var apiUpdatePushPreference = async (enabled) => {
6584
6660
  const { data } = await apiClient.patch(
6585
- `${v2Url}/notifications/push/preference`,
6661
+ pushApiUrl("/notifications/push/preference"),
6586
6662
  { enabled }
6587
6663
  );
6588
6664
  return data?.data;
@@ -6777,13 +6853,15 @@ var usePushNotifications = () => {
6777
6853
  }, [refresh]);
6778
6854
  const setUserEnabled = useCallback(
6779
6855
  async (enabled) => {
6780
- setState((prev) => ({ ...prev, userEnabled: enabled }));
6856
+ setState((prev) => ({ ...prev, loading: true, error: null }));
6781
6857
  try {
6782
6858
  await apiUpdatePushPreference(enabled);
6859
+ setState((prev) => ({ ...prev, userEnabled: enabled, loading: false }));
6783
6860
  } catch (error) {
6784
6861
  setState((prev) => ({
6785
6862
  ...prev,
6786
6863
  userEnabled: !enabled,
6864
+ loading: false,
6787
6865
  error: error instanceof Error ? error.message : "Could not update push preference"
6788
6866
  }));
6789
6867
  }
@@ -6795,36 +6873,66 @@ var usePushNotifications = () => {
6795
6873
  var PushNotificationToggle = ({
6796
6874
  className,
6797
6875
  label = "Push notifications",
6798
- description = "Get notified about new messages on this device"
6876
+ description = "Get notified about new messages on this device",
6877
+ children
6799
6878
  }) => {
6800
6879
  const push = usePushNotifications();
6880
+ const [isToggling, setIsToggling] = useState(false);
6801
6881
  if (!push.supported || !push.allowedByWorkspace || !push.configured) {
6802
6882
  return null;
6803
6883
  }
6804
6884
  const isOn = push.deviceEnabled && push.userEnabled;
6805
6885
  const permissionBlocked = push.permission === "denied";
6886
+ const showLoader = isToggling;
6806
6887
  const handleChange = async (checked) => {
6807
- if (checked) {
6808
- if (!push.userEnabled) await push.setUserEnabled(true);
6809
- if (!push.deviceEnabled) await push.enable();
6810
- } else {
6811
- await push.disable();
6888
+ setIsToggling(true);
6889
+ try {
6890
+ if (checked) {
6891
+ if (!push.userEnabled) await push.setUserEnabled(true);
6892
+ if (!push.deviceEnabled) await push.enable();
6893
+ } else {
6894
+ await push.disable();
6895
+ }
6896
+ } finally {
6897
+ setIsToggling(false);
6812
6898
  }
6813
6899
  };
6900
+ const renderProps = {
6901
+ label,
6902
+ description: permissionBlocked ? "Notifications are blocked in your browser settings" : push.error ?? description,
6903
+ checked: isOn,
6904
+ disabled: showLoader || permissionBlocked || push.loading,
6905
+ loading: showLoader || push.loading,
6906
+ permissionBlocked,
6907
+ error: push.error,
6908
+ onCheckedChange: (checked) => void handleChange(checked)
6909
+ };
6910
+ if (children) {
6911
+ return /* @__PURE__ */ jsx(Fragment, { children: children(renderProps) });
6912
+ }
6814
6913
  return /* @__PURE__ */ jsxs(
6815
6914
  "div",
6816
6915
  {
6817
- className: className ?? "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-surface) px-4 py-3",
6916
+ className: cn(
6917
+ "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-surface) px-4 py-3",
6918
+ className
6919
+ ),
6818
6920
  children: [
6819
6921
  /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
6820
6922
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-(--chat-text)", children: label }),
6821
- /* @__PURE__ */ jsx("p", { className: "text-xs text-(--chat-muted)", children: permissionBlocked ? "Notifications are blocked in your browser settings" : push.error ?? description })
6923
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-(--chat-muted)", children: renderProps.description })
6822
6924
  ] }),
6823
- /* @__PURE__ */ jsx(
6925
+ showLoader ? /* @__PURE__ */ jsx(
6926
+ Loader2,
6927
+ {
6928
+ className: "size-5 shrink-0 animate-spin text-(--chat-theme)",
6929
+ "aria-label": "Updating push notifications"
6930
+ }
6931
+ ) : /* @__PURE__ */ jsx(
6824
6932
  Switch,
6825
6933
  {
6826
6934
  checked: isOn,
6827
- disabled: push.loading || permissionBlocked,
6935
+ disabled: permissionBlocked || push.loading,
6828
6936
  onCheckedChange: (checked) => void handleChange(checked),
6829
6937
  "aria-label": `Toggle ${label}`
6830
6938
  }
@@ -6833,57 +6941,147 @@ var PushNotificationToggle = ({
6833
6941
  }
6834
6942
  );
6835
6943
  };
6836
- var LoggedUserSettingsDialog = ({
6837
- loggedUserDetails
6944
+ var LoggedUserSettingsContent = ({
6945
+ user,
6946
+ title = "Account settings",
6947
+ showProfile = true,
6948
+ showPushToggle = true,
6949
+ className
6838
6950
  }) => {
6839
- const [open, setOpen] = useState(false);
6840
- const user = {
6841
- _id: loggedUserDetails?._id || "1",
6842
- name: formatLoggedUserName(loggedUserDetails?.name),
6843
- email: loggedUserDetails?.email || "user@example.com",
6844
- role: loggedUserDetails?.role || "user",
6845
- isActive: loggedUserDetails?.isActive ?? true,
6846
- createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
6847
- updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
6848
- image: loggedUserDetails?.image || void 0
6849
- };
6850
- return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: setOpen, children: [
6851
- /* @__PURE__ */ jsxs(Tooltip, { children: [
6852
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
6853
- Button,
6854
- {
6855
- type: "button",
6856
- variant: "ghost",
6857
- size: "icon",
6858
- className: sidebarActionBtnClass,
6859
- "aria-label": "Account settings",
6860
- onClick: () => setOpen(true),
6861
- children: /* @__PURE__ */ jsx(Settings, { className: "size-3.5", strokeWidth: 2 })
6862
- }
6863
- ) }),
6864
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: "Settings" })
6865
- ] }),
6866
- /* @__PURE__ */ jsxs(ChatDialogContent, { className: "gap-0 overflow-hidden p-0 sm:max-w-[380px]", children: [
6867
- /* @__PURE__ */ jsx("div", { className: "border-b border-(--chat-border) px-5 py-4", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-left text-base font-semibold text-(--chat-text)", children: "Account settings" }) }),
6868
- /* @__PURE__ */ jsxs("div", { className: "space-y-5 px-5 py-5", children: [
6869
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center text-center", children: [
6870
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
6871
- /* @__PURE__ */ jsxs(Avatar, { className: "size-16 ring-2 ring-(--chat-theme-20)", children: [
6872
- user.image ? /* @__PURE__ */ jsx(AvatarImage, { src: user.image, alt: user.name }) : null,
6873
- /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-lg font-medium text-(--chat-theme)", children: (user.name || "?").charAt(0).toUpperCase() })
6951
+ const { resolveComponent, slotClassName } = useChatCustomization();
6952
+ const PushToggleSlot = resolveComponent(
6953
+ "PushNotificationToggle",
6954
+ PushNotificationToggle
6955
+ );
6956
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
6957
+ /* @__PURE__ */ jsx(
6958
+ "div",
6959
+ {
6960
+ className: cn(
6961
+ "border-b border-(--chat-border) px-5 py-4",
6962
+ slotClassName("loggedUserSettingsHeader")
6963
+ ),
6964
+ children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-left text-base font-semibold text-(--chat-text)", children: title })
6965
+ }
6966
+ ),
6967
+ /* @__PURE__ */ jsxs(
6968
+ "div",
6969
+ {
6970
+ className: cn(
6971
+ "space-y-5 px-5 py-5",
6972
+ slotClassName("loggedUserSettingsContent", className)
6973
+ ),
6974
+ children: [
6975
+ showProfile ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center text-center", children: [
6976
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
6977
+ /* @__PURE__ */ jsxs(
6978
+ Avatar,
6979
+ {
6980
+ className: cn(
6981
+ "size-16 ring-2 ring-(--chat-theme-20)",
6982
+ slotClassName("loggedUserSettingsAvatar")
6983
+ ),
6984
+ children: [
6985
+ user.image ? /* @__PURE__ */ jsx(AvatarImage, { src: user.image, alt: user.name }) : null,
6986
+ /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-lg font-medium text-(--chat-theme)", children: (user.name || "?").charAt(0).toUpperCase() })
6987
+ ]
6988
+ }
6989
+ ),
6990
+ /* @__PURE__ */ jsx("span", { className: "absolute bottom-0.5 right-0.5 size-3 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6874
6991
  ] }),
6875
- /* @__PURE__ */ jsx("span", { className: "absolute bottom-0.5 right-0.5 size-3 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6876
- ] }),
6877
- /* @__PURE__ */ jsx("h3", { className: "mt-3 text-base font-semibold text-(--chat-text)", children: user.name }),
6878
- /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-sm text-(--chat-muted)", children: user.email }),
6879
- /* @__PURE__ */ 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: [
6880
- /* @__PURE__ */ jsx("span", { className: "size-1.5 rounded-full bg-(--chat-online)" }),
6881
- "Online"
6882
- ] })
6883
- ] }),
6884
- /* @__PURE__ */ jsx("div", { className: "border-t border-(--chat-border) pt-4", children: /* @__PURE__ */ jsx(PushNotificationToggle, { className: "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-theme-10) px-4 py-3" }) })
6885
- ] })
6886
- ] })
6992
+ /* @__PURE__ */ jsx("h3", { className: "mt-3 text-base font-semibold text-(--chat-text)", children: user.name }),
6993
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-sm text-(--chat-muted)", children: user.email }),
6994
+ /* @__PURE__ */ 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: [
6995
+ /* @__PURE__ */ jsx("span", { className: "size-1.5 rounded-full bg-(--chat-online)" }),
6996
+ "Online"
6997
+ ] })
6998
+ ] }) : null,
6999
+ showPushToggle ? /* @__PURE__ */ jsx("div", { className: "border-t border-(--chat-border) pt-4", children: /* @__PURE__ */ jsx(
7000
+ PushToggleSlot,
7001
+ {
7002
+ className: cn(
7003
+ "flex items-center justify-between gap-4 rounded-xl border border-(--chat-border) bg-(--chat-theme-10) px-4 py-3",
7004
+ slotClassName("pushNotificationToggle")
7005
+ )
7006
+ }
7007
+ ) }) : null
7008
+ ]
7009
+ }
7010
+ )
7011
+ ] });
7012
+ };
7013
+ var LoggedUserSettingsContent_default = LoggedUserSettingsContent;
7014
+ var LoggedUserSettingsTrigger = ({
7015
+ onClick,
7016
+ className,
7017
+ tooltip = "Settings",
7018
+ ariaLabel = "Account settings"
7019
+ }) => {
7020
+ const { slotClassName } = useChatCustomization();
7021
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
7022
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
7023
+ Button,
7024
+ {
7025
+ type: "button",
7026
+ variant: "ghost",
7027
+ size: "icon",
7028
+ className: cn(
7029
+ sidebarActionBtnClass,
7030
+ slotClassName("loggedUserSettingsTrigger", className)
7031
+ ),
7032
+ "aria-label": ariaLabel,
7033
+ onClick,
7034
+ children: /* @__PURE__ */ jsx(Settings, { className: "size-3.5", strokeWidth: 2 })
7035
+ }
7036
+ ) }),
7037
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: tooltip })
7038
+ ] });
7039
+ };
7040
+ var LoggedUserSettingsTrigger_default = LoggedUserSettingsTrigger;
7041
+ var LoggedUserSettingsDialog = ({
7042
+ loggedUserDetails,
7043
+ open: controlledOpen,
7044
+ onOpenChange: controlledOnOpenChange,
7045
+ title,
7046
+ showProfile = true,
7047
+ showPushToggle = true,
7048
+ className
7049
+ }) => {
7050
+ const { resolveComponent, slotClassName } = useChatCustomization();
7051
+ const [internalOpen, setInternalOpen] = useState(false);
7052
+ const open = controlledOpen ?? internalOpen;
7053
+ const onOpenChange = controlledOnOpenChange ?? setInternalOpen;
7054
+ const TriggerSlot = resolveComponent(
7055
+ "LoggedUserSettingsTrigger",
7056
+ LoggedUserSettingsTrigger_default
7057
+ );
7058
+ const ContentSlot = resolveComponent(
7059
+ "LoggedUserSettingsContent",
7060
+ LoggedUserSettingsContent_default
7061
+ );
7062
+ const user = buildLoggedUserProfile(loggedUserDetails);
7063
+ return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange, children: [
7064
+ /* @__PURE__ */ jsx(TriggerSlot, { onClick: () => onOpenChange(true) }),
7065
+ /* @__PURE__ */ jsx(
7066
+ ChatDialogContent,
7067
+ {
7068
+ className: cn(
7069
+ "gap-0 overflow-hidden p-0 sm:max-w-[380px]",
7070
+ slotClassName("loggedUserSettingsDialog", className)
7071
+ ),
7072
+ children: /* @__PURE__ */ jsx(
7073
+ ContentSlot,
7074
+ {
7075
+ loggedUserDetails,
7076
+ user,
7077
+ onClose: () => onOpenChange(false),
7078
+ title,
7079
+ showProfile,
7080
+ showPushToggle
7081
+ }
7082
+ )
7083
+ }
7084
+ )
6887
7085
  ] });
6888
7086
  };
6889
7087
  var LoggedUserSettingsDialog_default = LoggedUserSettingsDialog;
@@ -6896,16 +7094,12 @@ var LoggedUserDetails = ({
6896
7094
  setSearchQuery
6897
7095
  }) => {
6898
7096
  const { showColorModeToggle } = useChatTheme();
6899
- const user = {
6900
- _id: loggedUserDetails?._id || "1",
6901
- name: formatLoggedUserName(loggedUserDetails?.name),
6902
- email: loggedUserDetails?.email || "user@example.com",
6903
- role: loggedUserDetails?.role || "user",
6904
- isActive: loggedUserDetails?.isActive ?? true,
6905
- createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
6906
- updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
6907
- image: loggedUserDetails?.image || void 0
6908
- };
7097
+ const { resolveComponent } = useChatCustomization();
7098
+ const SettingsDialogSlot = resolveComponent(
7099
+ "LoggedUserSettingsDialog",
7100
+ LoggedUserSettingsDialog_default
7101
+ );
7102
+ const user = buildLoggedUserProfile(loggedUserDetails);
6909
7103
  return /* @__PURE__ */ jsxs("div", { className: "shrink-0 border-b border-(--chat-border) bg-(--chat-surface) px-3 pb-3 pt-3", children: [
6910
7104
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [
6911
7105
  /* @__PURE__ */ jsxs("div", { className: "relative shrink-0", children: [
@@ -6916,14 +7110,11 @@ var LoggedUserDetails = ({
6916
7110
  /* @__PURE__ */ jsx("span", { className: "absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
6917
7111
  ] }),
6918
7112
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
6919
- /* @__PURE__ */ jsxs("h2", { className: "truncate text-xs font-medium leading-tight text-(--chat-text)", children: [
6920
- user.name,
6921
- "123"
6922
- ] }),
7113
+ /* @__PURE__ */ jsx("h2", { className: "truncate text-xs font-medium leading-tight text-(--chat-text)", children: user.name }),
6923
7114
  /* @__PURE__ */ jsx("p", { className: "truncate text-[10px] text-(--chat-muted)", children: user.email })
6924
7115
  ] }),
6925
7116
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [
6926
- /* @__PURE__ */ jsx(LoggedUserSettingsDialog_default, { loggedUserDetails }),
7117
+ /* @__PURE__ */ jsx(SettingsDialogSlot, { loggedUserDetails }),
6927
7118
  showColorModeToggle ? /* @__PURE__ */ jsx(ChatThemeToggle_default, {}) : null
6928
7119
  ] })
6929
7120
  ] }),
@@ -18325,6 +18516,7 @@ var ChatMain = ({
18325
18516
  queryParams,
18326
18517
  queryParamApis,
18327
18518
  queryParamsByApi,
18519
+ apiVersions: apiVersions2,
18328
18520
  themeColor = "#7494ec",
18329
18521
  theme,
18330
18522
  uiConfig,
@@ -18394,6 +18586,7 @@ var ChatMain = ({
18394
18586
  queryParams,
18395
18587
  queryParamApis,
18396
18588
  queryParamsByApi,
18589
+ apiVersions: apiVersions2,
18397
18590
  children: [
18398
18591
  /* @__PURE__ */ jsx(ForegroundPushBridge, {}),
18399
18592
  /* @__PURE__ */ jsx(
@@ -18686,6 +18879,10 @@ var ChannelListItem_default = ChannelListItem2;
18686
18879
  var packageDefaultComponents = {
18687
18880
  ChatLayout: DefaultChatLayout_default,
18688
18881
  LoggedUserDetails: LoggedUserDetails_default,
18882
+ LoggedUserSettingsDialog: LoggedUserSettingsDialog_default,
18883
+ LoggedUserSettingsTrigger: LoggedUserSettingsTrigger_default,
18884
+ LoggedUserSettingsContent: LoggedUserSettingsContent_default,
18885
+ PushNotificationToggle,
18689
18886
  ChannelList: ChannelListView_default,
18690
18887
  ChannelListItem: DefaultChannelListItem,
18691
18888
  ChannelHeader: ChannelHeaderView_default,
@@ -18720,6 +18917,6 @@ var packageDefaultComponents = {
18720
18917
  // src/index.ts
18721
18918
  var index_default = ChatMain_default;
18722
18919
 
18723
- export { CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, ChannelHeaderView_default as ChannelHeader, ChannelListView_default as ChannelList, ChannelListItem_default as ChannelListItem, Chat, ChatAlertsProvider, ChatAvatar_default as ChatAvatar, ChatCustomizationProvider, ChatDateJumpMenu, ChatLayout_default as ChatLayout, ChatLocaleProvider, ChatMain_default as ChatMain, ChatThemeProvider, ChatViewport, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout_default as DefaultChatLayout, ForegroundPushBridge, ForwardModalView as ForwardModal, HeaderCallActions_default as HeaderCallActions, LoggedUserDetails_default as LoggedUserDetails, ChannelMessageBoxView_default as MessageInput, MessageItemView as MessageItem, ActiveChannelMessagesView_default as MessageList, NOTIFICATION_CLICK_SW_TYPE, OPEN_CONVERSATION_EVENT, PUSH_BROADCAST_CHANNEL, PUSH_CHANGED_EVENT, PUSH_DATA_CACHE_NAME, PushNotificationToggle, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, buildChannelFromPushRequest, capitalizeFirst, clampJumpDate, consumePendingOpenConversation, consumePendingOpenFromPushCache, consumePendingOpenRequest, index_default as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, installNotificationClickBridge, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, packageDefaultComponents, peekPendingOpenConversation, peekPendingOpenRequest, requestOpenConversation, resolveApiUrl, resolveChatApiKey, resolveConversationIdFromPushData, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socket_service_default as socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme, usePushNotifications };
18920
+ export { CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, ChannelHeaderView_default as ChannelHeader, ChannelListView_default as ChannelList, ChannelListItem_default as ChannelListItem, Chat, ChatAlertsProvider, ChatAvatar_default as ChatAvatar, ChatCustomizationProvider, ChatDateJumpMenu, ChatLayout_default as ChatLayout, ChatLocaleProvider, ChatMain_default as ChatMain, ChatThemeProvider, ChatViewport, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout_default as DefaultChatLayout, ForegroundPushBridge, ForwardModalView as ForwardModal, HeaderCallActions_default as HeaderCallActions, LoggedUserDetails_default as LoggedUserDetails, LoggedUserSettingsContent_default as LoggedUserSettingsContent, LoggedUserSettingsDialog_default as LoggedUserSettingsDialog, LoggedUserSettingsTrigger_default as LoggedUserSettingsTrigger, ChannelMessageBoxView_default as MessageInput, MessageItemView as MessageItem, ActiveChannelMessagesView_default as MessageList, NOTIFICATION_CLICK_SW_TYPE, OPEN_CONVERSATION_EVENT, PUSH_BROADCAST_CHANNEL, PUSH_CHANGED_EVENT, PUSH_DATA_CACHE_NAME, PushNotificationToggle, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, buildChannelFromPushRequest, buildLoggedUserProfile, buildVersionedApiUrl, capitalizeFirst, clampJumpDate, consumePendingOpenConversation, consumePendingOpenFromPushCache, consumePendingOpenRequest, index_default as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatApiVersions, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, installNotificationClickBridge, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, packageDefaultComponents, peekPendingOpenConversation, peekPendingOpenRequest, requestOpenConversation, resolveApiRoot, resolveApiUrl, resolveChatApiKey, resolveConversationIdFromPushData, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatApiVersions, setChatBaseURL, setChatClientId, setChatPushApiVersion, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socket_service_default as socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme, usePushNotifications };
18724
18921
  //# sourceMappingURL=index.mjs.map
18725
18922
  //# sourceMappingURL=index.mjs.map